// Yorum satırlarında her bir dosyanın başlangıcını ve
// sonunu ayrı ayrı belinttim. Bunları buradan kopyalayıp
// ayrı ayrı dosyalara yapıştırdıktan sonra derleyebilirsiniz.
// NOT: Borland Derleyicileri ile test edilmiştir.
//----------------------------------------------------------//
// dosya adı: assert.h
#define BOCEK
#ifdef BOCEK
void Guvence(char*, unsigned); /* Prototip */
#define ASSERT(f) \
if (f) \
{ } \
else \
Guvence(__FILE__, __LINE__)
#else
#define ASSERT(f)
#endif
// ---- dosya bitti- assert.h
//----------------------------------------------------------//
//----------------------------------------------------------//
// dosya adı: assert.cpp
#include "./assert.h"
#include "tmstd16c.h"
#ifdef BOCEK
void cdecl Guvence(char* strFile, unsigned uLine)
{
char bb[(57 - 24) * (17 - 10) * 2 + 200];
char* sece[] = { "Abort",
"Retry"};
CEkran kk;
gettext(25, 11, 57, 17, bb);
do {
kk.cerceve(25, 11, 55, 16, 0, 4, 1);
kk.renk(0, 4);
gotoxy(26, 12); cprintf("Guvence Uyarisi");
gotoxy(26, 13); cprintf("Dosya : %s", strFile);
gotoxy(26, 14); cprintf("Satir : %d", uLine);
if(1 == kk.ymenu(*sece, 33, 15, 7, 4, 2, 5))
{
kk.renk(7, 0);
kk.sil();
fflush(NULL);
cerr << "Assertion failed in: " << strFile
<< ", line: " << uLine << endl;
fflush(stderr);
fcloseall();
_setcursortype(_NORMALCURSOR);
abort();
}
puttext(25, 11, 57, 17, bb);
} while (TRUE);
}
#endif
// ---- dosya bitti- assert.cpp
//----------------------------------------------------------//
//----------------------------------------------------------//
// dosya adı: tmstd16c.h
#include <ctype.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <dos.h>
#include "./assert.h"
#define FALSE 0
#define TRUE 1
#define MB_OK 1
#define MB_YESNO 2
struct TARIH
{
unsigned char gun, ay;
unsigned int yil;
};
struct TEL
{
unsigned int kod,
n1,
n2;
};
class CEkran
{
private:
void buyukHarf(char*);
public:
int keyread(void);
void hyaz(int, int, unsigned char, int, int);
void sil(void)
{
clrscr();
};
void renk(int r1, int r2)
{
textcolor(r1);
textbackground(r2);
};
int sifre(char*, int, int, int, int, int);
void cerceve(int, int, int, int, int, int, unsigned char);
void yaz(const char*, int, int, int, int); // katar ifade
void yaz(const char*, int, int, int, int, int); // katar ifade
void yaz(unsigned long, int, int, int, int); // parasal de§er
void yaz(unsigned long, int, int, int, int, int); // saysal de§er
int giris(char*, int, int, int, int, int); // katar ifade
int giris(unsigned long*, int, int, int, int); // parasal de§er
int giris(unsigned long*, int, int, int, int, int); // saysal de§er
int giris(TARIH*, int, int, int, int); // tarih giriŸi
int giris(TEL*, int, int, int, int); // telefon giriŸi
int menu(const char*, int, int, int, int, int, int);
int kmenu(const char*, int, int, int, int, int, int, int);
int ymenu(const char*, int, int, int, int, int, int);
int iletiKutusu(const char*, const char*, int);
};
// ---- dosya bitti- tmstd16c.h
//----------------------------------------------------------//
//----------------------------------------------------------//
// dosya adı: tmstd16c.cpp
#include "tmstd16c.h"
void CEkran::cerceve(int x1, int y1, int x2, int y2,
int r1, int r2, unsigned char golge)
{
/*012345*/
char s[] = "»ÈºÍɼ";
int i, j;
ASSERT(x1 > 0 && y1 > 0 && x1 < 81 && y1 < 26);
ASSERT(x2 > 0 && y2 > 0 && x2 < 81 && y2 < 26);
#ifdef BOCEK
if (golge == 1)
{
if (x2 > 78)
Guvence(__FILE__, __LINE__);
if (y2 == 25)
Guvence(__FILE__, __LINE__);
}
#endif
hyaz(x1, y1, s[4], r1, r2);
hyaz(x2, y2, s[5], r1, r2);
hyaz(x2, y1, s[0], r1, r2);
hyaz(x1, y2, s[1], r1, r2);
for (i = 1; i <= (x2 - x1 - 1); i++)
{
hyaz(x1 + i, y1, s[3], r1, r2);
hyaz(x1 + i, y2, s[3], r1, r2);
}
for (i = 1; i <= (y2 - y1 - 1); i++)
{
hyaz(x1, y1 + i, s[2], r1, r2);
hyaz(x2, y1 + i, s[2], r1, r2);
for (j = x1 + 1; j < x1 + (x2 - x1); j++)
hyaz(j, y1 + i, 32, r1, r2);
}
if (golge == 1)
{
unsigned char* ekran;
unsigned char* segment = (unsigned char*) 0x449L;
if (*segment == 7)
ekran = (unsigned char*) 0xb0000000L;
else
ekran = (unsigned char*) 0xb8000000L;
for (i = 2; i <= (x2 - x1 +2); i++)
*(ekran + (i + x1 - 1) * 2 + y2 * 160 + 1) = 8;
for (i = 1; i <= (y2 - y1 + 1); i++)
{
*(ekran + x2 * 2 + (y1 + i - 1) * 160 + 1) = 8;
*(ekran + (x2 + 1) * 2 + (y1 + i - 1) * 160 + 1) = 8;
}
}
} // cerceve()
// katar veri giriŸi
int CEkran::giris(char* str, int x, int y, int r1, int r2, int len)
{
int p = 0, i, key, j, ret = -256, insert = 1;
#ifdef BOCEK
ASSERT(strlen(str) <= len);
#endif
CEkran::renk(15, 4);
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(str != NULL);
gotoxy(x, y);
while(1)
{
buyukHarf(str);
_setcursortype(_NOCURSOR);
gotoxy(x, y); cprintf("%s", str);
for (i = 0; i < (len - strlen(str) ); ++i)
cprintf(" ");
gotoxy(x + p, y);
(!insert) ? _setcursortype(_SOLIDCURSOR) : _setcursortype(_NORMALCURSOR);
switch(key = keyread())
{
case 9:
case 13: ret = 0; break;
case 27: ret = -1; break;
case -77:
if (p < strlen(str))
p++;
break;
case -75: p--; break;
case -83:
if (p < strlen(str))
for (i = p; i < len; i++)
str[i] = str[i+1];
break;
case 8:
if (p > 0)
{
for (i = p-1 ; i < strlen(str); i++)
str[i] = str[i+1];
p--;
}
break;
case -71: p = 0; break;
case -79: p = strlen(str); break;
case -82: insert = !insert; break;
default:
if (key < 32)
{
ret = key;
break;
}
j = strlen(str);
if (insert)
{
if (j < len)
{
for (i = j + 1; i > p; i--)
str[i] = str[i-1];
str[p] = (char) key;
p++;
str[j+1] = '\0';
}
}
else
{
if (p < len)
{
str[p] = (char) key;
p++;
str[j+1] = '\0';
}
}
break;
} /* switch */
if (p < 0) p = 0;
if (p > len) p = len;
if (ret != -256)
{
renk(r1, r2);
gotoxy(x, y);
for(i = 0; i <= len; i++)
cprintf(" ");
gotoxy(x, y);
cprintf("%s",str);
_setcursortype(_NOCURSOR);
return ret;
}
}
} // katar veri giriŸi
void CEkran::hyaz(int x, int y, unsigned char c, int r1, int r2)
{
char* ekran;
char* aaa = (char*) 0x449L;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
if (*aaa == 7)
ekran = (char*) 0xb0000000L;
else
ekran = (char*) 0xb8000000L;
*(ekran + (x - 1) * 2 + (y - 1) * 160 + 1) = r2 * 0x10 + r1;
*(ekran + (x - 1) * 2 + (y - 1) * 160) = c;
} // hyaz()
int CEkran::keyread(void)
{
int key;
char strtime[11];
tm *aa = new tm;
ASSERT(aa != NULL);
time_t t;
do
{
t = time(NULL);
aa = localtime(&t);
sprintf(strtime, "[%02d:%02d:%02d]",
aa->tm_hour, aa->tm_min, aa->tm_sec);
*(strtime + 10) = 0;
yaz(strtime, 70, 1, 0, 2);
if (kbhit())
{
key = getch();
if (key == 0 && kbhit())
key = (-1) * getch();
break;
}
} while(1);
delete aa;
return key;
} // keyread()
int CEkran::menu(const char *sece, int x, int y,
int r1, int r2, int secsay, int secboy)
{
int i, a = 1;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT((x + secboy) <= 80 && (y + secsay) <= 25);
ASSERT(sece != NULL);
_setcursortype(_NOCURSOR);
do
{
for (i = 1; i <= secsay; i++)
{
if (i == a)
renk(r2, r1);
else
renk(r1, r2);
gotoxy(x, y + i - 1);
cprintf("%s", (sece + (i - 1) * (secboy + 1)));
}
switch(keyread())
{
case 9:
case -80: a++; break;
case -15:
case -72: a--; break;
case 13: return a;
case 27: return -1;
}
if (a == 0) a = secsay;
if (a == secsay + 1) a = 1;
} while(1);
} // menu()
int CEkran::iletiKutusu(const char* msg, const char* ttl, int stl)
{
ASSERT(msg != NULL && ttl != NULL);
ASSERT(stl == MB_OK || stl == MB_YESNO);
#ifdef BOCEK
ASSERT(strlen(msg) > 10);
#endif
int x = 40 - (strlen(msg) + 3) / 2, y = 10, key, ret;
char ekran[80 * 25 * 2 + 200];
gettext(x, y, x + strlen(msg) + 5, y + 6, ekran);
cerceve(x, y, x + strlen(msg) + 3, y + 5, 15, 6, 1);
yaz(msg, 40 - strlen(msg) / 2, y + 2, 15, 6);
yaz(ttl, 40 - strlen(ttl) / 2, y, 15, 6);
_setcursortype(_NOCURSOR);
switch(stl)
{
case MB_OK:
renk(6, 15);
gotoxy(40 - strlen(" <Tamam> ") / 2, y + 4);
cprintf("%s", " <Tamam> ");
do
{
key = keyread();
if (key == 13 || key == 27)
break;
} while(1);
break;
case MB_YESNO:
char* pp[] = {"<Evet> ",
"<Hayr>"};
ret = ymenu(*pp, 33, 14, 15, 6, 2, 7);
break;
}
puttext(x, y, x + strlen(msg) + 5, y + 6, ekran);
return ret;
} // msgbox()
// parasal de§er giriŸi...
int CEkran::giris(unsigned long* para, int x, int y, int r1, int r2)
{
char aaa[30];
int key, ret = -256;
unsigned int p;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(para != NULL);
_setcursortype(_NORMALCURSOR);
do
{
ultoa(*para,aaa,10);
p = strlen(aaa);
ASSERT(p <= 9);
yaz(*para, x, y, 15, 4);
switch(key = keyread())
{
case 13:
case 9: ret = 0; break;
case 27: ret = -1; break;
case 8:
if (p > 0)
(*para) /= 10;
break;
default:
if (key < 0)
ret = key;
if (key < '0' || key > '9')
break;
if (key == '0' && (*para) == 0)
break;
if (p < 9)
{
(*para) *= 10;
(*para) += (key - '0');
}
}
if (ret != -256)
{
yaz(*para, x, y, r1, r2);
_setcursortype(_NOCURSOR);
return ret;
}
} while(1);
} // parasal de§er giriŸi...
// katar ifade
void CEkran::yaz(const char* str, int x, int y, int r1, int r2)
{
#ifdef BOCEK
ASSERT(strlen(str) <= 80);
#endif
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
for (int i = 0; i < strlen(str); i++)
hyaz(i + x, y, *(str + i), r1, r2);
} // katar ifade
// parasal de§er
void CEkran::yaz(unsigned long para, int x, int y, int r1, int r2)
{
char strpara[10];
char aa[12];
int i, j;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
strcpy(aa, " ");
ultoa(para, strpara, 10);
for (i = strlen(strpara), j = 11; i >= 0; j--, i--)
{
if (j == 3 || j == 7)
aa[j--] = ',';
aa[j] = strpara[i];
}
aa[11] = 0;
renk(r1, r2);
gotoxy(x, y);
cprintf("%s,000\b", aa);
} // parayaz...
// saysal de§er...
void CEkran::yaz(unsigned long para, int x, int y, int r1, int r2, int len)
{
char* strpara = new char[len + 1];
char* str = new char[len + 2];
#ifdef BOCEK
ASSERT(strlen(ultoa(para, NULL, 10)) <= len);
#endif
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ultoa(para, strpara, 10);
renk(r1, r2);
gotoxy(x, y);
sprintf(str, "%%%ds\b", len);
cprintf(str, strpara);
delete str;
delete strpara;
} // sayiyaz()
// saysal de§er giriŸi...
int CEkran::giris(unsigned long* para, int x, int y, int r1, int r2, int len)
{
char aaa[30];
int key, ret = -256;
unsigned int p;
#ifdef BOCEK
unsigned int dbgdenden = strlen(ultoa(*para, NULL, 10));
ASSERT(dbgdenden < len);
#endif
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(para != NULL);
_setcursortype(_NORMALCURSOR);
do
{
yaz(*para, x, y, 15, 4, len);
ultoa(*para, aaa, 10);
p = strlen(aaa);
switch(key = keyread())
{
case 13:
case 9: ret = 0; break;
case 27: ret = -1; break;
case 8:
if (p > 0)
(*para) /= 10;
break;
default:
if (key < 0)
ret = key;
if (key < '0' || key > '9')
break;
if (key == '0' && *para == 0)
break;
if (p < len)
{
(*para) *= 10;
(*para) += (key - '0');
}
}
if (ret != -256)
{
yaz(*para, x, y, r1, r2, len);
_setcursortype(_NOCURSOR);
return ret;
}
} while(1);
} // saysal de§er giriŸi...
int CEkran::sifre(char* str, int x, int y, int r1, int r2, int len)
{
int i, key, ret = -256, p = strlen(str);
#ifdef BOCEK
ASSERT(strlen(str) <= len);
#endif
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(str != NULL);
renk(15, 4);
gotoxy(x, y);
for(i = 0; i < len; i++)
cprintf(" ");
gotoxy(x, y);
for(i = 0; i < strlen(str); i++)
cprintf("*");
_setcursortype(_NORMALCURSOR);
do
{
buyukHarf(str);
switch(key = keyread())
{
case 13:
case 9: ret = 0; break;
case 8: if (strlen(str) > 0)
{
str[strlen(str) - 1] = '\0';
cprintf("\b \b");
p--;
}
break;
case 27: ret = -1; break;
default:
if (key < 32)
ret = key;
else
if (strlen(str) < len)
{
str[p] = key;
p++;
str[p] = '\0';
cprintf("*");
}
}
if (ret != -256)
{
renk(r1, r2);
gotoxy(x, y);
for(i = 0; i <= len; i++)
cprintf(" ");
gotoxy(x, y);
for(i = 0; i < strlen(str); i++)
cprintf("*");
_setcursortype(_NOCURSOR);
return ret;
}
} while (1);
} // sifre()
// tarihsel de§er giriŸi...
int CEkran::giris(TARIH* tar, int x, int y, int r1, int r2)
{
char str[11];
char gun[3], ay[3], yil[5];
int p = 0, key, ret = -256;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(tar != NULL);
_setcursortype(_NORMALCURSOR);
CEkran::renk(15, 4);
itoa(tar->gun, gun, 10);
itoa(tar->ay, ay, 10);
itoa(tar->yil, yil, 10);
sprintf(str, "%02d/%02d/%04d", tar->gun, tar->ay, tar->yil);
do
{
gotoxy(x, y);
cprintf("%s", str);
gotoxy(x + p, y);
switch (key = keyread())
{
case 13:
case 9: ret = 0; break;
case 27: ret = -1; break;
case -83: break;
case -75:
if (p >= 0)
p--;
if (p == 2 || p == 5)
p--;
break;
case -77:
if (p < 10)
p++;
if (p == 2 || p == 5)
p++;
break;
case -71: p = 0; break;
case -79: p = 10; break;
case 8:
if (p >= 0)
{
p--;
if (p == 2 || p == 5)
p--;
str[p] = ' ';
}
break;
default:
if (key < 0)
ret = key;
if (key < '0' || key > '9')
break;
if (p < 10)
{
str[p] = key;
p++;
if (p == 2 || p == 5)
p++;
}
}
if (p < 0)
p = 0;
if (ret != -256)
{
gotoxy(x, y);
renk(r1, r2);
cprintf("%s", str);
gun[0] = str[0];
gun[1] = str[1];
gun[2] = '\0';
ay[0] = str[3];
ay[1] = str[4];
ay[2] = '\0';
yil[0] = str[6];
yil[1] = str[7];
yil[2] = str[8];
yil[3] = str[9];
yil[4] = '\0';
tar->gun = atoi(gun);
tar->ay = atoi(ay);
tar->yil = atoi(yil);
_setcursortype(_NOCURSOR);
return ret;
}
} while(1);
} // tarihsel de§er giriŸi...
int CEkran::ymenu(const char *sece, int x, int y,
int r1, int r2, int secsay, int secboy)
{
int i, a = 0;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(sece != NULL);
ASSERT((x + secboy * secsay) <= 80);
_setcursortype(_NOCURSOR);
do
{
for (i = 0; i < secsay; i++)
{
if (i == a)
renk(r2, r1);
else
renk(r1, r2);
gotoxy(x + i * (secboy + 2), y);
cprintf(" %s ", (sece + i * (secboy + 1)));
}
switch(keyread())
{
case 9: case -77: a++; break;
case -15: case -75: a--; break;
case 13: return (a + 1);
case 27: return -1;
}
if (a == -1) a = secsay - 1;
if (a == secsay) a = 0;
} while(1);
} // ymenu()
// telefon de§er giriŸi...
int CEkran::giris(TEL* tel, int x, int y, int r1, int r2)
{
char str[15];
char kod[4], n1[4], n2[5];
int p = 1, key, ret = -256;
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
ASSERT(tel != NULL);
_setcursortype(_NORMALCURSOR);
renk(15, 4);
itoa(tel->kod, kod, 10);
itoa(tel->n1, n1, 10);
itoa(tel->n2, n2, 10);
sprintf(str, "(%03d)-%03d-%04d", tel->kod, tel->n1, tel->n2);
do
{
gotoxy(x, y);
cprintf("%s", str);
gotoxy(x + p, y);
switch (key = keyread())
{
case 13:
case 9: ret = 0; break;
case 27: ret = -1; break;
case -83: break;
case -75:
if (p >= 1)
p--;
if (p == 9)
p--;
if (p == 5)
p -= 2;
break;
case -77:
if (p < 14)
p++;
if (p == 9)
p++;
if (p == 4)
p += 2;
break;
case -71: p = 0; break;
case -79: p = 14; break;
case 8:
if (p > 1)
{
p--;
if (p == 9)
p--;
if (p == 5)
p -= 2;
str[p] = ' ';
}
break;
default:
if (key < 0)
ret = key;
if (key < '0' || key > '9')
break;
if (p < 14)
{
str[p] = key;
p++;
if (p == 9)
p++;
if (p == 4)
p += 2;
}
}
if (p < 1)
p = 1;
if (ret != -256)
{
gotoxy(x, y);
renk(r1, r2);
cprintf("%s", str);
kod[0] = str[1];
kod[1] = str[2];
kod[2] = str[3];
kod[3] = 0;
n1[0] = str[6];
n1[1] = str[7];
n1[2] = str[8];
n1[3] = 0;
n2[0] = str[10];
n2[1] = str[11];
n2[2] = str[12];
n2[3] = str[13];
n2[4] = 0;
tel->kod = atoi(kod);
tel->n1 = atoi(n1);
tel->n2 = atoi(n2);
_setcursortype(_NOCURSOR);
return ret;
}
} while(1);
} // telefon de§er giriŸi...
int CEkran::kmenu(const char* sece, int x, int y, int r1, int r2,
int secsay, int gsecsay, int secboy)
{
int baslama = 0, secili = 0, i;
int scr = 0;
double _scr;
ASSERT(sece != NULL);
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
#ifdef BOCEK
ASSERT((x + secboy) <= 80 && (y + secsay) <= 25);
#endif
_setcursortype(_NOCURSOR);
if (gsecsay < secsay) secsay = gsecsay;
while (1)
{
for (i = 0; i <= secsay - 1; i++)
{
if (gsecsay > secsay)
if (i == scr)
hyaz(x + secboy, y + i, 219, 15, r2);
else
hyaz(x + secboy, y + i, 176, r1, r2);
if (i == secili)
yaz((sece + (baslama + i) * (secboy + 1)), x, y + i, r2, r1, secboy);
else
yaz((sece + (baslama + i) * (secboy + 1)), x, y + i, r1, r2, secboy);
}
switch (keyread())
{
case -71: baslama = 0; secili = 0; break;
case -79: baslama = gsecsay - secsay; secili = secsay; break;
case -81: baslama += secsay; break;
case -73: baslama -= secsay; break;
case -80: secili++; break;
case -72: secili--; break;
case 27: return -1;
case 13:
return (baslama + secili);
}
if (secili == secsay)
{
baslama++;
secili--;
}
if (secili == -1)
{
baslama--;
secili++;
}
if (baslama < 0) baslama = 0;
if (baslama >= gsecsay - (secsay - 1)) baslama = gsecsay - secsay;
_scr = (double) (baslama + secili + 1) / gsecsay * secsay;
scr = _scr;
if (scr >= secsay)
scr = secsay - 1;
}
}
// katar ifade
void CEkran::yaz(const char* str, int x, int y, int r1, int r2, int boy)
{
#ifdef BOCEK
ASSERT(strlen(str) <= boy);
#endif
ASSERT(str != NULL);
ASSERT(x > 0 && y > 0 && x < 81 && y < 26);
for (int i = 0; i < boy; i++)
hyaz(i + x, y, *(str + i), r1, r2);
} // katar ifade
void CEkran::buyukHarf(char* str)
{
ASSERT(str != NULL);
for (int i = 0; i < strlen(str); i++)
{
switch (str[i])
{
case '': str[i] = 'š'; break;
case 'i': str[i] = '˜'; break;
case '': str[i] = 'I'; break;
case '”': str[i] = '™'; break;
case '‡': str[i] = '€'; break;
case 'Ÿ': str[i] = ''; break;
case '§': str[i] = '¦'; break;
case 'š': break;
case '˜': break;
case 'I': break;
case '™': break;
case '€': break;
case '': break;
case '¦': break;
default: str[i] = toupper(str[i]);
}
}
}
// dosya bitti- tmstd16c.cpp
//----------------------------------------------------------//