/* Copyright (C) Magna Carta Software, Inc. 1987-1990. All Rights Reserved. C WINDOWS TOOLKIT & C COMMUNICATIONS TOOLKIT Compatibility: TURBOC v1.5+, MSC 5.0/5.1/QC, Power C v1.2.0+, Watcom C v7.0+. */ #include #if 0 #if defined(MSC) /* MSC V5.0 ONLY! (function required due to bug that invalidates macro) MK_FP -- An equivalent to the Turbo C macro of the same name, rewritten here as a function because MSC 5.0 bit shifting routines appear to have a bug. Under MSC5.0, call this function rather than the macro. */ void far *MK_FP(unsigned pseg, unsigned poff) { unsigned long fptr; FP_SEG(fptr) = pseg; /* convert to long */ FP_OFF(fptr) = poff; /* make ls 16 bits the offset */ return (fptr); } #endif #endif #if defined(MSC) || defined(_INTELC32_) || defined(__WATCOMC__) || defined(__NDPC__) #if (!defined(CTC) && !defined(CTF)) #if defined(__NDPC__) #include #else #include #include #endif #include unsigned long memavail(void) { unsigned hsize = UINT_MAX; void *h; while ((h = memcalloc(hsize, sizeof(char))) == NULL) hsize-=1024; memfree(h); return ((unsigned long) hsize); } #endif #endif #if (defined(__WATCOMC__) && defined(VERSION70)) #include #include typedef unsigned short WORD; /* WATCOM C does not access the DOS file system in a fashion similar to the other compilers so we write our own "findfirst()" function. WATCOM C uses a function called opendir(), which could be used instead. */ int findfirst(const char *pathname, struct ffblk *ffblk, int attrib) { union REGS regs; struct SREGS sregs; segread(&sregs); regs.h.ah = 0X1A; /* DOS set DTA function */ #if defined(__SMALL__) || defined(__MEDIUM__) regs.x.dx = (WORD) ffblk; /* address of new DTA */ #else regs.x.dx = (WORD) FP_OFF(ffblk); /* address of new DTA */ sregs.ds = (WORD) FP_SEG(ffblk); /* address of new DTA */ #endif intdosx(®s, ®s, &sregs); /* this reads the registers... */ regs.h.ah = 0X4E; /* DOS find first matching file */ regs.x.cx = attrib; /* search attribute */ #if defined(__SMALL__) || defined(__MEDIUM__) regs.x.dx = (WORD) pathname; /* address of new DTA */ #else regs.x.dx = (WORD) FP_OFF(pathname);/* DS:DX is address of pathname */ sregs.ds = (WORD) FP_SEG(pathname); #endif intdosx(®s, ®s, &sregs); return ((regs.x.cflag) ? regs.x.ax : 0); } int findnext(struct ffblk *ffblk) { union REGS regs; struct SREGS sregs; /* SET THE DTA TO ffblk */ segread(&sregs); regs.h.ah = 0X1A; /* DOS set DTA function */ #if defined(__SMALL__) || defined(__MEDIUM__) regs.x.dx = (WORD) ffblk; /* address of new DTA */ #else regs.x.dx = (WORD) FP_OFF(ffblk); /* address of new DTA */ sregs.ds = (WORD) FP_SEG(ffblk); /* address of new DTA */ #endif intdosx(®s, ®s, &sregs); /* this reads the registers... */ regs.h.ah = 0X4F; /* DOS find next matching file */ intdosx(®s, ®s, &sregs); return ((regs.x.cflag) ? regs.x.ax : 0); } unsigned short _bios_keybrd(unsigned service) { union REGS r; r.x.ax = service; int86(0X16, &r, &r); return (r.x.ax); } #endif