home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
677
/
TSRTOOLS
/
TSRLIB.DOC
< prev
next >
Wrap
Text File
|
1993-10-07
|
65KB
|
863 lines
------------------------------------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| T S R L I B |
| |
| Version 1.5 |
| |
| Copyright (C) 1993, Geoff Friesen B.Sc. |
| All rights reserved. |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
------------------------------------------------------------------------
| |
| Introduction |
| ------------ |
| |
| A TSR application built with TSR TOOLKIT starts out as a C file with |
| a main () function. Source code for all functions referenced inside |
| this file must be included as TSR TOOLKIT takes a source code only |
| approach to building TSR applications. There exists no mechanism to |
| link object modules. |
| |
| TSRLIB is a source library of useful C functions that you can access |
| from within your TSR applications. Function categories include file |
| and directory, string, video, keyboard, conversion, date and time. |
| I refer to the mechanism for including these functions in the main C |
| file as "source linking". |
| |
| Each source file making up TSRLIB begins with a C #define directive. |
| This is followed by a symbol beginning with INCL_ and followed by |
| the name of the source file. Any source file that depends upon the |
| presence of this source file uses the C #if, #include, and #endif |
| directives to ensure that the file is included during compilation. |
| |
| Consider the following example. Your main C file will need to call |
| the v_border (), v_cputs (), and v_gotoxy () functions. VBORDER.C |
| contains the v_border () function source code, VCPUTS.C contains the |
| v_cputs () function source code, and VGOTOXY.C contains the |
| v_gotoxy () function source code. You would probably place the fol- |
| lowing directives at the end of the main C file. |
| |
| #ifndef INCL_VBORDER |
| #include "vborder.C" |
| #endif |
| |
| #ifndef INCL_VCPUTS |
| #include "vcputs.C" |
| #endif |
| |
| #ifndef INCL_VGOTOXY |
| #include "vgotoxy.C" |
| #endif |
| |
| If INCL_VBORDER is defined then v_border () source code has already |
| been included. Therefore, it will not be included again. The same |
| holds true for INCL_VCPUTS and INCL_VGOTOXY. The directive checking |
| INCL_VGOTOXY is not really necessary because vborder.C contains the |
| same directives to include vgotoxy.C since v_border () accesses the |
| v_gotoxy () function. However, you can duplicate the #include since |
| it ensures that vgotoxy.C is included only once. |
| |
| |
------------------------------------------------------------------------
- 2 -
------------------------------------------------------------------------
| |
| TSRLIB is composed of a single include file TSRLIB.H and many source |
| files. TSRLIB.H contains #include directives to the various BORLAND |
| header files, constants, and function prototypes for those functions |
| not prototyped in the BORLAND headers. You will notice that I have |
| included protoypes for various API functions. These functions exist |
| in either the TSR kernel or the main C file. I do not consider them |
| part of TSRLIB so I have not documented them in TSRLIB.DOC. Consult |
| TSR.DOC for information on these functions. |
| |
| The next section itemizes each source file. The name of the file is |
| specified. This is followed by the export define (the INCL_ define |
| which the main C file or another library source file tests to see if |
| the source file has already been included). Following, is a list of |
| import defines. These are INCL_ directives which a source file uses |
| to ensure that source files which it requires are included. A glo- |
| bals section follows which lists global variables and functions that |
| normally would be private to the source file (unfortunately, this is |
| not possible with a source-only approach). Finally, a list of func- |
| tion prototypes for each "visible" function in the source file is |
| presented. |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 3 -
------------------------------------------------------------------------
| |
| TSRLIB Source Files |
| ------------------- |
| |
| |
| * ATOI.C |
| |
| EXPORT: INCL_ATOI |
| |
| IMPORT: INCL_ISDIGIT |
| INCL_ISSPACE |
| |
| PROTO : int atoi (const char *s); |
| |
| |
| * ATOL.C |
| |
| EXPORT: INCL_ATOL |
| |
| IMPORT: INCL_ISDIGIT |
| INCL_ISSPACE |
| |
| PROTO : long atol (const char *s); |
| |
| |
| * ATTRIB.C |
| |
| EXPORT: INCL_ATTRIB |
| |
| GLOBAL: int attribute; |
| |
| |
| * CHDIR.C |
| |
| EXPORT: INCL_CHDIR |
| |
| PROTO : int chdir (const char *path); |
| |
| |
| * CHMOD.C |
| |
| EXPORT: INCL_CHMOD |
| |
| PROTO : int _chmod (const char *path, int func, int attrib); |
| |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 4 -
------------------------------------------------------------------------
| |
| * CLOSE.C |
| |
| EXPORT: INCL_CLOSE |
| |
| PROTO : int _close (int handle); |
| |
| |
| * CREAT.C |
| |
| EXPORT: INCL_CREAT |
| |
| PROTO : int _creat (const char *path, int attrib); |
| |
| |
| * FILELENG.C |
| |
| EXPORT: INCL_FILELENGTH |
| |
| IMPORT: INCL_LSEEK |
| INCL_TELL |
| |
| PROTO : long filelength (int handle); |
| |
| |
| * FIND.C |
| |
| EXPORT: INCL_FIND |
| |
| PROTO : int findfirst (const char *pathname, struct ffblk *ffblk, |
| int attrib); |
| int findnext (struct ffblk *ffblk); |
| |
| |
| * FORMAT.C |
| |
| EXPORT: INCL_FORMAT |
| |
| GLOBAL: void _prt10 (unsigned num, char *str); |
| void _prt16 (unsigned num, char *str, int hexcase); |
| void _prtl10 (unsigned long num, char *str); |
| void _prtl16 (unsigned long num, char *str, int hexcase); |
| |
| PROTO : int pascal format (void (*func) (int), const char *fmt, |
| void *ap); |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 5 -
------------------------------------------------------------------------
| |
| * GETCURDI.C |
| |
| EXPORT: INCL_GETCURDIR |
| |
| PROTO : int getcurdir (int drive, char *directory); |
| |
| |
| * GETDATE.C |
| |
| EXPORT: INCL_GETDATE |
| |
| PROTO : void getdate (struct date *datep); |
| |
| |
| * GETDISK.C |
| |
| EXPORT: INCL_GETDISK |
| |
| PROTO : int getdisk (void); |
| |
| |
| * GETSTR.C |
| |
| EXPORT: INCL_GETSTR |
| |
| IMPORT: INCL_KFETCH |
| INCL_STRLEN |
| INCL_VCPUTS |
| INCL_VGETMODE |
| INCL_VGETSHAPE |
| INCL_VGOTOXY |
| INCL_VPUTCH |
| INCL_VSCREEN |
| INCL_VSETSHAPE |
| INCL_VWHEREX |
| INCL_VWHEREY |
| |
| PROTO : int getstr (char *buffer, unsigned char maxlen); |
| |
| |
| * GETTIME.C |
| |
| EXPORT: INCL_GETTIME |
| |
| PROTO : void gettime (struct time *timep); |
| |
| |
| |
| |
------------------------------------------------------------------------
- 6 -
------------------------------------------------------------------------
| |
| * GETVECT.C |
| |
| EXPORT: INCL_GETVECT |
| |
| PROTO : void interrupt (*getvect (int interruptno)) (); |
| |
| |
| * ISALNUM.C |
| |
| EXPORT: INCL_ISALNUM |
| |
| IMPORT: INCL_ISALPHA |
| INCL_ISDIGIT |
| |
| PROTO : int isalnum (int c); |
| |
| |
| * ISALPHA.C |
| |
| EXPORT: INCL_ISALPHA |
| |
| IMPORT: INCL_ISLOWER |
| INCL_ISUPPER |
| |
| PROTO : int isalpha (int c); |
| |
| |
| * ISDIGIT.C |
| |
| EXPORT: INCL_ISDIGIT |
| |
| PROTO : int isdigit (int c); |
| |
| |
| * ISLEAP.C |
| |
| EXPORT: INCL_ISLEAP |
| |
| PROTO : int isleap (int year); |
| |
| |
| * ISLOWER.C |
| |
| EXPORT: INCL_ISLOWER |
| |
| PROTO : int islower (int c); |
| |
| |
| |
------------------------------------------------------------------------
- 7 -
------------------------------------------------------------------------
| |
| * ISSPACE.C |
| |
| EXPORT: INCL_ISSPACE |
| |
| PROTO : int isspace (int c); |
| |
| |
| * ISUPPER.C |
| |
| EXPORT: INCL_ISUPPER |
| |
| PROTO : int isupper (int c); |
| |
| |
| * ISXDIGIT.C |
| |
| EXPORT: INCL_ISXDIGIT |
| |
| IMPORT: INCL_ISALNUM |
| INCL_TOUPPER |
| |
| PROTO : int isxdigit (int c); |
| |
| |
| * ITOA.C |
| |
| EXPORT: INCL_ITOA |
| |
| IMPORT: INCL_STRREV |
| |
| PROTO : char *_itoa (int value, char *string); |
| |
| |
| * KFETCH.C |
| |
| EXPORT: INCL_KFETCH |
| |
| PROTO : int k_fetch (void); |
| |
| |
| * KISKEY.C |
| |
| EXPORT: INCL_KISKEY |
| |
| PROTO : int k_iskey (void); |
| |
| |
| |
| |
------------------------------------------------------------------------
- 8 -
------------------------------------------------------------------------
| |
| * LSEEK.C |
| |
| EXPORT: INCL_LSEEK |
| |
| PROTO : long lseek (int handle, long offset, int fromwhere); |
| |
| |
| * LTOA.C |
| |
| EXPORT: INCL_LTOA |
| |
| IMPORT: INCL_STRREV |
| |
| PROTO : char *_ltoa (long value, char *string); |
| |
| |
| * MEMSWAP.C |
| |
| EXPORT: INCL_MEMSWAP |
| |
| PROTO : void memswap (void *addr1, void *addr2, size_t n); |
| |
| |
| * MKDIR.C |
| |
| EXPORT: INCL_MKDIR |
| |
| PROTO : int mkdir (const char *path); |
| |
| |
| * OPEN.C |
| |
| EXPORT: INCL_OPEN |
| |
| PROTO : int _open (const char *filename, int oflags); |
| |
| |
| * READ.C |
| |
| EXPORT: INCL_READ |
| |
| PROTO : int _read (int handle, void *buf, unsigned len); |
| |
| |
| * RENAME.C |
| |
| EXPORT: INCL_RENAME |
| |
| PROTO : int rename (const char *oldname, const char *newname); |
------------------------------------------------------------------------
- 9 -
------------------------------------------------------------------------
| |
| * RMDIR.C |
| |
| EXPORT: INCL_RMDIR |
| |
| PROTO : int rmdir (const char *path); |
| |
| |
| * SETDATE.C |
| |
| EXPORT: INCL_SETDATE |
| |
| PROTO : void setdate (struct date *datep); |
| |
| |
| * SETDISK.C |
| |
| EXPORT: INCL_SETDISK |
| |
| PROTO : int setdisk (int drive); |
| |
| |
| * SETTIME.C |
| |
| EXPORT: INCL_SETTIME |
| |
| PROTO : void settime (struct time *timep); |
| |
| |
| * SETVECT.C |
| |
| EXPORT: INCL_SETVECT |
| |
| PROTO : void setvect (int interruptno, void interrupt (*isr) ()); |
| |
| |
| * SPRINTF.C |
| |
| EXPORT: INCL_SPRINTF |
| |
| IMPORT: INCL_FORMAT |
| |
| GLOBAL: char *sprintf_buffer; |
| void sprintf_putc (int c); |
| |
| PROTO : int sprintf (char *buffer, const char *fmt, ...); |
| |
| |
| |
| |
------------------------------------------------------------------------
- 10 -
------------------------------------------------------------------------
| |
| * STRCMP.C |
| |
| EXPORT: INCL_STRCMP |
| |
| PROTO : int strcmp (const char *s1, const char *s2); |
| |
| |
| * STRCPY.C |
| |
| EXPORT: INCL_STRCPY |
| |
| PROTO : char *strcpy (char *dest, const char *src); |
| |
| |
| * STRICMP.C |
| |
| EXPORT: INCL_STRICMP |
| |
| IMPORT: INCL_TOUPPER |
| |
| PROTO : int stricmp (const char *s1, const char *s2); |
| |
| |
| * STRLEN.C |
| |
| EXPORT: INCL_STRLEN |
| |
| PROTO : size_t strlen (const char *s); |
| |
| |
| * STRLWR.C |
| |
| EXPORT: INCL_STRLWR |
| |
| IMPORT: INCL_TOLOWER |
| |
| PROTO : char *strlwr (char *s); |
| |
| |
| * STRNCMP.C |
| |
| EXPORT: INCL_STRNCMP |
| |
| PROTO : int strncmp (const char *s1, const char *s2, size_t maxlen); |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 11 -
------------------------------------------------------------------------
| |
| * STRNCPY.C |
| |
| EXPORT: INCL_STRNCPY |
| |
| PROTO : char *strncpy (char *dest, const char *src, size_t maxlen); |
| |
| |
| * STRNICMP.C |
| |
| EXPORT: INCL_STRNICMP |
| |
| IMPORT: INCL_TOUPPER |
| |
| PROTO : int strnicmp (const char *s1, const char *s2, |
| size_t maxlen); |
| |
| |
| * STRREV.C |
| |
| EXPORT: INCL_STRREV |
| |
| IMPORT: INCL_STRLEN |
| |
| PROTO : char *strrev (char *s); |
| |
| |
| * STRUPR.C |
| |
| EXPORT: INCL_STRUPR |
| |
| IMPORT: INCL_TOUPPER |
| |
| PROTO : char *strupr (char *s); |
| |
| |
| * TELL.C |
| |
| EXPORT: INCL_TELL |
| |
| IMPORT: INCL_LSEEK |
| |
| PROTO : long tell (int handle); |
| |
| |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 12 -
------------------------------------------------------------------------
| |
| * TOLOWER.C |
| |
| EXPORT: INCL_TOLOWER |
| |
| IMPORT: INCL_ISUPPER |
| |
| PROTO : int tolower (int ch); |
| |
| |
| * TOUPPER.C |
| |
| EXPORT: INCL_TOUPPER |
| |
| IMPORT: INCL_ISLOWER |
| |
| PROTO : int toupper (int ch); |
| |
| |
| * UCURSOR.C |
| |
| EXPORT: INCL_UCURSOR |
| |
| GLOBAL: void update_cursor (void); |
| |
| |
| * UNLINK.C |
| |
| EXPORT: INCL_UNLINK |
| |
| PROTO : int unlink (const char *filename); |
| |
| |
| * VAA.C |
| |
| EXPORT: INCL_VAA |
| |
| PROTO : int v_aa (void); |
| |
| |
| * VBORDER.C |
| |
| EXPORT: INCL_VBORDER |
| |
| IMPORT: INCL_VGOTOXY |
| INCL_VPUTCH |
| |
| PROTO : void v_border (int style, int x, int y, int nx, int ny); |
| |
| |
------------------------------------------------------------------------
- 13 -
------------------------------------------------------------------------
| |
| * VCPRINTF.C |
| |
| EXPORT: INCL_VCPRINTF |
| |
| IMPORT: INCL_FORMAT |
| INCL_VPUTCH |
| |
| GLOBAL: void v_cprintf_putc (int c); |
| |
| PROTO : int v_cprintf (const char *fmt, ...); |
| |
| |
| * VCPUTS.C |
| |
| EXPORT: INCL_VCPUTS |
| |
| IMPORT: INCL_ATTRIB |
| INCL_UCURSOR |
| |
| PROTO : int v_cputs (const char *str); |
| |
| |
| * VGETATTR.C |
| |
| EXPORT: INCL_VGETATTR |
| |
| IMPORT: INCL_ATTRIB |
| |
| PROTO : int v_getattr (void); |
| |
| |
| * VGETMODE.C |
| |
| EXPORT: INCL_VGETMODE |
| |
| PROTO : int v_getmode (void); |
| |
| |
| * VGETSHAP.C |
| |
| EXPORT: INCL_VGETSHAPE |
| |
| PROTO : int v_getshape (void); |
| |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 14 -
------------------------------------------------------------------------
| |
| * VGOTOXY.C |
| |
| EXPORT: INCL_VGOTOXY |
| |
| PROTO : void v_gotoxy (int x, int y) |
| |
| |
| * VPAINT.C |
| |
| EXPORT: INCL_VPAINT |
| |
| IMPORT: INCL_VGOTOXY |
| INCL_VPUTCH |
| |
| PROTO : void v_paint (int c, int x, int y, int nx, int ny); |
| |
| |
| * VPUTCH.C |
| |
| EXPORT: INCL_VPUTCH |
| |
| IMPORT: INCL_ATTRIB |
| INCL_UCURSOR |
| |
| PROTO : int v_putch (int c, int count); |
| |
| |
| * VSCREEN.C |
| |
| EXPORT: INCL_VSCREEN |
| |
| PROTO : void v_screen (int cmd, int x, int y, int nx, int ny, |
| void *buffer); |
| |
| |
| * VSCROLL.C |
| |
| EXPORT: INCL_VSCROLL |
| |
| PROTO : void v_scroll (int x, int y, int nx, int ny, int dir, |
| int nblines, int attr); |
| |
| |
| |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 15 -
------------------------------------------------------------------------
| |
| * VSETATTR.C |
| |
| EXPORT: INCL_VSETATTR |
| |
| IMPORT: INCL_ATTRIB |
| |
| PROTO : void v_setattr (int attr); |
| |
| |
| * VSETSHAP.C |
| |
| EXPORT: INCL_VSETSHAPE |
| |
| PROTO : void v_setshape (int shape); |
| |
| |
| * VSHADOW.C |
| |
| EXPORT: INCL_VSHADOW |
| |
| IMPORT: INCL_VSCREEN |
| |
| PROTO : void v_shadow (int x1, int y1, int nx, int ny); |
| |
| |
| * VWHEREX.C |
| |
| EXPORT: INCL_VWHEREX |
| |
| PROTO : int v_wherex (void); |
| |
| |
| * VWHEREY.C |
| |
| EXPORT: INCL_VWHEREY |
| |
| PROTO : int v_wherey (void); |
| |
| |
| * WRITE.C |
| |
| EXPORT: INCL_WRITE |
| |
| PROTO : int _write (int handle, void *buf, unsigned len); |
| |
| |
| |
| |
| |
------------------------------------------------------------------------
- 16 -