Category : C Source Code
Archive   : QCDEMO.ZIP
Filename : STDLIB.QC

 
Output of file : STDLIB.QC contained in archive : QCDEMO.ZIP
/*
/* QC Interpreter Standard Library
/**/

#define NULL 0
#define EOF -1
#define FILE int
#define stdin 1
#define stdout 2
#define stderr 3
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
#define O_APPEND 8
#define O_CREAT 0x0100
#define O_TRUNC 0x0200
#define O_EXCL 0x0400

/* ------- System functions -------- */

exit()
{
sys(0);
}

system(s)
{
return sys(s,5);
}

execl(s,a,b,c,d,e,f,g,h,i)
{
return sys(s,a,b,c,d,e,f,g,h,i,6);
}

dirscan(p,f)
{
return sys(p,f,7);
}

bdos(a,b)
{
return sys(a,b,8);
}

inp(p)
{
return sys(p, 9);
}

outp(p,v)
{
return sys(p,v,10);
}

/* ---------- File I/O functions ----------- */

fopen(f,m)
{
return sys(f,m,20);
}

fclose(u)
{
return sys(u,21);
}

fgetc(u)
{
return sys(u,22);
}

getchar()
{
int c;
c = sys(1,22);
c = c == '\r' ? '\n' : c;
if (isatty(1))
sys(c,3,23);
return(c == 26 ? -1 : c);
}

ungetc(c,u)
{
return sys(c,u,31);
}

ungetch(c)
{
return sys(c,1,31);
}

fputc(c,u)
{
return sys(c,u,23);
}

putchar(c)
{
return sys(c,2,23);
}

fgets(b,n,u)
{
return sys(b,n,u,24);
}

gets(b)
{
return sys(b,80,1,24);
}

fputs(b,u)
{
return sys(b,u,25);
}

puts(b)
{
int i;
i = sys(b,2,25);
sys('\n',2,23);
return i;
}

fread(s,l,u)
{
return sys(s,l,u,26);
}

fwrite(s,l,u)
{
return sys(s,l,u,27);
}

ftell(u)
{
return sys(u,28);
}

fseek(u,o,w)
long o;
{
return sys(u,o,w,29);
}

open(f,m)
char *f;
{
return sys(f,m+0x8000,34);
}

close(f)
{
return sys(f,35);
}

read(f,b,l)
{
return sys(f,b,l,36);
}

write(f,b,l)
{
return sys(f,b,l,37);
}

creat(f, m)
{
return sys(f,0x600,38);
}

lseek(f,o,w)
long o;
{
return sys(f,o,w,39);
}

fileno(u)
{
return u;
}

isatty(u)
{
return sys(u,30);
}

rewind(u)
{
fseek(u,0L,0);
}

unlink(s)
{
return sys(s,32);
}

rename(o,n)
{
return sys(o,n,33);
}

tell(u)
{
return sys(u,19);
}

/* -------- String and memory allocation functions --------- */

strcmp(s,t)
{
return sys(s,t,40);
}

strncmp(s,t,n)
{
return sys(s,t,n,40);
}

strcpy(s,t)
{
return sys(s,t,41);
}

strncpy(s,t,n)
{
return sys(s,t,n,41);
}

strlen(s)
{
return sys(s,42);
}

strcat(d,s)
char *d,*s;
{
strcpy(d+strlen(d)-1,s);
}

malloc(n)
{
return sys(n,47);
}

free(p)
{
return sys(p,48);
}

/* ----------- Format conversion functions --------- */

sscanf(s,a,b,c,d,e,f,g,h,i)
char *s,*a,*b,*c,*d,*e,*f,*g,*h,*i;
{
sys(s,a,b,c,d,e,f,g,h,i,60);
}

scanf(a,b,c,d,e,f,g,h,i)
char *a,*b,*c,*d,*e,*f,*g,*h,*i;
{
char s[128];
gets(s);
sys(s,a,b,c,d,e,f,g,h,i,60);
}

sprintf(s,a,b,c,d,e,f,g,h,i,j)
char *s, *a;
float b,c,d,e,f,g,h,i,j;
{
return sys(s,a,b,c,d,e,f,g,h,i,j,61);
}

printf(a,b,c,d,e,f,g,h,i,j)
char *a;
float b,c,d,e,f,g,h,i,j;
{
fprintf(2,a,b,c,d,e,f,g,h,i,j);
}

fprintf(u,a,b,c,d,e,f,g,h,i,j)
char *a;
float b,c,d,e,f,g,h,i,j;
{
char s[128];
sys(s,a,b,c,d,e,f,g,h,i,j,61);
sys(s,u,25);
}

atoi(b)
{
int i;
sys(b,"%d",&i,60);
return i;
}

atol(b)
{
long l;
sys(b,"%ld",&l,60);
return l;
}

atof(b)
{
float f;
sys(b,"%lf",&f,60);
return f;
}

/* -------- Miscellaneous ---------- */

isdigit(c)
{
return '0'<=c && c<='9';
}

isupper(c)
{
return c >= 'A' && c <= 'Z';
}

islower(c)
{
return c >= 'a' && c <= 'z';
}

isalpha(c)
{
return isupper(c) || islower(c);
}

isprint(c)
{
return c >= 32 && c < 128;
}

isascii(c)
{
return c < 128;
}

isalnum(c)
{
return isalpha(c) || isdigit(c);
}

isspace(c)
{
return c == 32 || (8 < c && c < 14);
}

toupper(c)
{
if(islower(c))
return c-32;
return c;
}

tolower(c)
{
if(isupper(c))
return c+32;
return c;
}

toascii(c)
{
return c & 127;
}

/* ------------ Math functions ------------- */

abs(n)
{
return n < 0 ? -n : n;
}

acos(x)
double x;
{
return sys(x, 70);
}

asin(x)
double x;
{
return sys(x, 71);
}

atan(x)
double x;
{
return sys(x, 72);
}

ceil(x)
double x;
{
return sys(x, 73);
}

cos(x)
double x;
{
return sys(x, 74);
}

cosh(x)
double x;
{
return sys(x, 75);
}

exp(x)
double x;
{
return sys(x, 76);
}

fabs(x)
double x;
{
return sys(x, 77);
}

floor(x)
double x;
{
return sys(x, 78);
}

sin(x)
double x;
{
return sys(x, 79);
}

sinh(x)
double x;
{
return sys(x, 80);
}

sqrt(x)
double x;
{
return sys(x, 81);
}

tan(x)
double x;
{
return sys(x, 82);
}

tanh(x)
double x;
{
return sys(x, 83);
}

log(x)
double x;
{
return sys(x, 84);
}

log10(x)
double x;
{
return sys(x, 85);
}

pow(x, y)
double x, y;
{
return sys(y, x, 86);
}

atan2(x, y)
double x, y;
{
return sys(y, x, 87);
}



  3 Responses to “Category : C Source Code
Archive   : QCDEMO.ZIP
Filename : STDLIB.QC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/