home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 1990 MetaWare Incorporated; All Rights Reserved */
-
- /**** name=difftime ****/
- #define main TEST_difftime
-
- /*
- Find elapsed time between start of program and entry of a string.
- */
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
-
- void main() {
- time_t time1, time2;
- char name[20];
-
- puts("Please enter your name.");
- time(&time1);
- gets(name);
- time(&time2);
- printf("It took you %f seconds to "
- "enter your name, %s\n",
- difftime(time2, time1), name);
- }
- /* End difftime */
- #undef main
- /**** name=div ****/
- #define main TEST_div
-
- #include <stdlib.h>
- #include <stdio.h>
-
- void main (){
- div_t result;
- int i = 20, j = 3;
- result = div(i, j);
- printf("Numerator = %d\n"
- "Denominator = %d\n", i, j);
- printf("Result: Quotient = %d\n"
- " Remainder = %d\n",
- result.quot, result.rem);
- }
- /* End div */
- #undef main
- /**** name=_dos_allocmem ****/
- #define main TEST__dos_allocmem
-
- /*
- This program allocates and frees 10 paragraphs of memory.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- unsigned seg_address;
-
- void main() {
- if (_dos_allocmem(10, &seg_address) != 0)
- perror("_dos_allocmem failed.");
- else {
- printf("_dos_allocmem successful.\n");
- if (_dos_freemem (seg_address) != 0)
- perror("_dos_freemem failed.");
- else
- printf("_dos_freemem successful.\n");
- }
- }
-
- /* End _dos_allocmem */
- #undef main
- /**** name=_dos_close ****/
- #define main TEST__dos_close
-
- /*
- This program creates a dummy file and then closes it using the
- _dos_close function.
- */
- #include <io.h>
- #include <dos.h>
- #include <fcntl.h>
- #include <sys\stat.h>
- #include <stdio.h>
-
- void main() {
- int pan, bad;
-
- puts("Testing _dos_close...\n");
- pan = open("dsclose.tmp",
- O_CREAT | O_BINARY| O_TRUNC,
- S_IREAD | S_IWRITE);
-
- if (pan == -1)
- printf("Cannot truncate file dsclose.tmp,"
- " error code=%d.\n",pan);
- else
- printf("File dsclose.tmp has been truncated,"
- " handle=%d.\n",pan);
- bad = _dos_close(pan);
- if (bad)
- puts("dsclose.tmp is not closed.");
- else
- puts("dsclose.tmp is closed.");
- }
-
- /* End _dos_close */
- #undef main
- /**** name=_dos_creatX ****/
- #define main TEST__dos_creatX
-
- /*
- This program opens a data file with _dos_creat and attempts to open it
- again with _dos_creatnew, which fails because the file already exists.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- int handle1, handle2;
-
- if (_dos_creat("doscreat.tmp",
- _A_NORMAL, &handle1) != 0)
- printf("_dos_creat - no data file created.");
- else
- printf("_dos_creat - created data file"
- " doscreat.tmp.\n");
- _dos_close(handle1);
- printf("_dos_creatnew should now fail, because"
- " the file already exists!\n");
- if (_dos_creatnew("doscreat.tmp",
- _A_RDONLY, &handle2) != 0)
- printf("_dos_creatnew - no data file created.");
- else {
- printf("_dos_creatnew - created data"
- " file doscreat.tmp.\n");
- _dos_close(handle2);
- }
- }
- /* End _dos_creat* */
- #undef main
- /**** name=_dosexterr ****/
- #define main TEST__dosexterr
-
-
- /*
- This program tries to open a file and, if the open fails, displays the
- DOS extended error information.
- */
-
- #include <dos.h>
- #include <fcntl.h>
- #include <io.h>
- #include <stdio.h>
-
- void main() {
- struct DOSERROR err;
- int handle;
-
- if ((handle = open("1junkfile", O_RDWR)) == -1) {
- _dosexterr(&err);
- printf("error = %d\nclass = %d"
- "\naction = %d\nlocus = %d\n",
- err.exterror, err.class,
- err.action, err.locus);
- }
- else
- printf("Extended information printed"
- " only if open fails.",close(handle));
- }
- /* End _dosexterr */
- #undef main
- /**** name=_dos_findX ****/
- #define main TEST__dos_findX
-
- /*
- This program repeatedly prompts the user for a file specification and
- prints all matching file names in the current directory.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
-
- void main() {
- struct find_t c_file;
- char *filespec = "*.*";
-
- if (_dos_findfirst(filespec, _A_NORMAL,
- & c_file) == 0) {
- printf ("\nListing of files "
- "w/ filespec %s\n\n", filespec);
- printf ("%12s is %6lu bytes "
- "long\n", c_file.name, c_file.size);
- while (_dos_findnext(&c_file) == 0)
- printf("%12s is %6lu bytes long\n",
- c_file.name, c_file.size);
- }
- else perror("error in findfirst");
- }
- /* End _dos_find* */
- #undef main
- /**** name=_dos_freemem ****/
- #define main TEST__dos_freemem
- /* End _dos_freemem */
- #undef main
- /**** name=_dos_getdate ****/
- #define main TEST__dos_getdate
-
- /*
- This program displays the current system date and time.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- char *day[] =
- {"Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday"};
- struct dosdate_t date;
- struct dostime_t time;
-
- _dos_getdate (&date);
- _dos_gettime (&time);
- printf("The date is: %s, %d-%d-%d\n",
- day[date.dayofweek],
- date.month, date.day, date.year);
- printf("The time is: %d:%d:%d.%d\n",
- time.hour, time.minute,
- time.second, time.hsecond);
- }
-
- /* End _dos_getdate */
- #undef main
- /**** name=_dos_getdiskfree ****/
- #define main TEST__dos_getdiskfree
-
- /*
- This program computes the total capacity and remaining free space of the
- default drive.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- struct diskfree_t drive;
- unsigned tc, ac, spc, bps;
-
- /* Get info on default drive. */
- _dos_getdiskfree (0, &drive);
- tc = drive.total_clusters;
- ac = drive.avail_clusters;
- spc = drive.sectors_per_cluster;
- bps = drive.bytes_per_sector;
-
- printf("The current drive has a capacity of %lu "
- "bytes.\n", (unsigned long)tc*spc*bps);
- printf("The current drive has %lu bytes free.\n",
- (unsigned long)ac*spc*bps);
- }
-
- /* End _dos_getdiskfree */
- #undef main
- /**** name=_dos_getdrive ****/
- #define main TEST__dos_getdrive
-
- /*
- This program will get disk drive information for a user-specified drive.
- */
-
- #include <stdio.h>
- #include <dos.h>
- #include <bios.h>
- #include <ctype.h>
-
- void main() {
- unsigned drive, savedrive;
- unsigned logicaldrives, ok;
- int choice;
- struct diskfree_t dinfo;
-
- /* Save the current default drive. */
- _dos_getdrive( &savedrive);
-
- /* Get choice from user. */
- do {
- printf("\nFor which drive would you"
- " like info (a-z)?: ");
- choice = _bios_keybrd(_KEYBRD_READ);
- printf("%c\n\n", (char) choice);
- if ((ok = isalpha((char) choice)) == 0)
- printf("Enter a drive letter.\n");
- } while (!ok);
-
- /* Change drive to selected. */
- drive = (unsigned)(tolower(choice) - 'a' + 1);
- _dos_setdrive(drive, &logicaldrives);
-
- /* Get drive info and print it. */
- _dos_getdiskfree(drive, &dinfo);
- printf("Info for drive %c\n",
- toupper((char)choice));
- printf(" total clusters : %d\n",
- dinfo.total_clusters);
- printf(" available clusters: %d\n",
- dinfo.avail_clusters);
- printf(" sectors/cluster : %d\n",
- dinfo.sectors_per_cluster);
- printf(" bytes/sector : %d\n",
- dinfo.bytes_per_sector);
-
- /* Change drive back. */
- _dos_setdrive(savedrive, &logicaldrives);
- }
-
- /* End _dos_getdrive */
- #undef main
- /**** name=_dos_getfileattr ****/
- #define main TEST__dos_getfileattr
-
- /*
- Create a file and read its attributes.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- unsigned attribute;
- int handle;
- /*
- Create file getattr.tmp only if it does not
- already exist.
- */
- if (_dos_creatnew("getattr.tmp",
- _A_RDONLY, &handle) != 0)
- perror("_dos_creatnew");
- else {
-
- _dos_close(handle);
- printf("Created file getattr.tmp.\n");
- /* Get file attributes of newly created file. */
- _dos_getfileattr("getattr.tmp", &attribute);
- if ((attribute & _A_RDONLY) != 0)
- printf("getattr.tmp read only.\n");
- else
- printf("getattr.tmp not read only.\n");
- /* Reset file attributes. */
- _dos_setfileattr("getattr.tmp", _A_NORMAL);
- /* Get file attributes again. */
- _dos_getfileattr("getattr.tmp",&attribute);
- if ((attribute & _A_RDONLY) != 0)
- printf("getattr.tmp now read only.\n");
- else
- printf("getattr.tmp not read only.\n");
- }
- }
- /* End _dos_getfileattr */
- #undef main
- /**** name=_dos_getftime ****/
- #define main TEST__dos_getftime
-
- /*
- This program creates a file and displays its date stamp.
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <dos.h>
-
- void main() {
- unsigned date, time, day, month, year;
- int handle;
-
- /* Create a new file. */
- if (_dos_creatnew("getftime.tmp",
- _A_NORMAL, &handle) != 0)
- perror("_dos_creatnew error");
- else {
- /* Get date stamp on file. */
- _dos_getftime(handle, &date, &time);
-
- /* Compute and display statistics. */
- day = date & 0x1f;
- month = date >> 5 & 0xf;
- year = (date >> 9 & 0x7f) + 1980;
- printf("The file getftime.tmp is stamped:\n");
- printf("\tday : %u\n", day);
- printf("\tmonth: %u\n", month);
-
- printf("\tyear : %u\n", year);
- }
- }
-
- /* End _dos_getftime */
- #undef main
- /**** name=_dos_gettime ****/
- #define main TEST__dos_gettime
- /* End _dos_gettime */
- #undef main
- /**** name=_dos_open ****/
- #define main TEST__dos_open
- /* End _dos_open */
- #undef main
- /**** name=_dos_read ****/
- #define main TEST__dos_read
-
- /*
- The program opens, reads from, and closes a file.
- */
- #include <stdio.h>
- #include <dos.h>
- #include <fcntl.h>
- #define BLOCK 1024
-
- void main() {
- int handle;
- _Far char buffer[BLOCK];
- unsigned bytes;
-
- /* Open file in read-only mode. */
- if (_dos_open("test.dat",
- O_RDONLY, &handle) != 0)
- perror("_dos_open failed to open file.");
- else {
- printf("_dos_open opened file.\n");
- /* Read from file into buffer. */
- if (_dos_read(handle,buffer,BLOCK,&bytes) != 0)
- perror("_dos_read failed to read file.");
- else
- printf("\nBuffer contents:\n%s", buffer);
- if (_dos_close(handle) != 0)
- perror("Close failed.\n");
- else
- printf("File successfully closed.\n");
- }
- }
-
- /* End _dos_read */
- #undef main
- #undef BLOCK
- /**** name=_dos_setblock ****/
- #define main TEST__dos_setblock
-
- /*
- This program allocates a block of memory, increases the allocation, and
- releases the memory.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- unsigned segment;
- unsigned maxavail;
-
- void main() {
- /* Allocate five paragraphs of memory. */
- if (_dos_allocmem(5, &segment) != 0)
- perror("_dos_allocmem error");
- else {
- printf("Five paragraphs allocated.\n");
-
- /* Increase allocation to ten paragraphs. */
- if (_dos_setblock(10,segment,&maxavail) != 0)
- perror("_dos_setblock error.");
- else
- printf("Allocation increased to "
- "ten paragraphs.\n");
-
- /* Free allocated memory. */
- if (_dos_freemem(segment) != 0)
- perror("_dos_freemem error.");
- else
- printf("Memory freed.\n");
- }
- }
-
- /* End _dos_setblock */
- #undef main
- /**** name=_dos_setdate ****/
- #define main TEST__dos_setdate
-
- /*
- This program sets the new date and time for the system.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- char *day[] = {"Sunday", "Monday", "Tuesday",
- "Wednesday", "Thursday",
- "Friday", "Saturday"};
- struct dosdate_t date, date2;
- struct dostime_t time, time2;
-
- _dos_getdate(&date2);
- _dos_gettime(&time2);
-
- date.dayofweek = 0; /* Sunday */
- date.month = 12;
- date.day = 25;
- date.year = 2000;
- _dos_setdate (&date); /* Set the above date. */
-
- time.hour = 0;
- time.minute = 0;
- time.second = 0;
- time.hsecond = 0;
- _dos_settime(&time); /* Set the above time. */
-
- printf("The date is: %s, %d-%d-%d\n",
- day[date.dayofweek],
- date.month, date.day, date.year);
- printf("The time is: %d:%d:%d.%d\n",
- time.hour, time.minute,
- time.second, time.hsecond);
- _dos_setdate(&date2);
- _dos_settime(&time2);
- }
- /* End _dos_setdate */
- #undef main
- /**** name=_dos_setdrive ****/
- #define main TEST__dos_setdrive
-
- /*
- This program lists all currently installed logical drives.
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- unsigned drive;
- unsigned logical_drives;
- unsigned savedrive;
- int i;
-
- /* Save current drive. */
- _dos_getdrive(&savedrive);
-
- /* List all currently installed drives. */
- for (i = 1; i <= 26; i++) {
- _dos_setdrive(i, &logical_drives);
- _dos_getdrive(&drive);
- if (i == drive)
- printf("drive %c: is installed\n",
- 'a' + i - 1);
- else
- printf("drive %c: is not installed\n",
- 'a' + i - 1);
- }
- printf("\nThere are %d logical drives\n",
- logical_drives);
-
- /* Restore to original drive. */
- _dos_setdrive(savedrive, &logical_drives);
- }
-
- /* End _dos_setdrive */
- #undef main
- /**** name=_dos_setfileattr ****/
- #define main TEST__dos_setfileattr
-
- #include <stdio.h>
- #include <dos.h>
-
- void main() {
- unsigned attribute;
- int handle;
-
- /*
- Create file setattr.tmp only if it does not already exist.
- */
-
- if (_dos_creatnew("setattr.tmp", _A_NORMAL,
- &handle) != 0)
- perror("_dos_creatnew");
- else {
- printf("Created file setattr.tmp.\n");
- /* Get file attributes of newly created file. */
- _dos_getfileattr("setattr.tmp", &attribute);
- if ((attribute & _A_RDONLY) != 0)
- printf("setattr.tmp read only.\n");
- else
- printf("setattr.tmp not read only.\n");
-
- /* Reset file attributes. */
- _dos_setfileattr("setattr.tmp", _A_RDONLY);
-
- /* Get file attributes again. */
- _dos_getfileattr("setattr.tmp",&attribute);
- if ((attribute & _A_RDONLY) != 0)
- printf("setattr.tmp now read only.\n");
- else
- printf("setattr.tmp now not read only.\n");
- }
- }
- /* End _dos_setfileattr */
- #undef main
- /**** name=_dos_setftime ****/
- #define main TEST__dos_setftime
-
- /*
- This program creates a file and alters its date/time stamp.
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <dos.h>
-
- void main() {
- unsigned date, time, day, month, year;
- int handle;
-
- /* Create a new file. */
- if (_dos_creatnew("setftime.tmp", _A_NORMAL,
- &handle) != 0)
- perror("_dos_creatnew error");
- else {
- /* Set date and time stamp on file. */
- date = 0x0;
- time = 0x0;
- _dos_setftime(handle, date, time);
-
- /* Compute and display new statistics. */
- _dos_getftime(handle, &date, &time);
- day = date & 0x1f;
- month = date >> 5 & 0xf;
- year = (date >> 9 & 0x7f) + 1980;
-
- printf("The file setftime.tmp is now stamped:\n");
- printf("\tday : %u\n", day);
- printf("\tmonth: %u\n", month);
- printf("\tyear : %u\n", year);
- }
- }
-
- /* End _dos_setftime */
- #undef main
- /**** name=_dos_settime ****/
- #define main TEST__dos_settime
-
- /*
- This program alters then restores the current system date and time.
-
- CAUTION: YOUR SYSTEM TIME AND DATE WILL BE SLIGHTLY ALTERED!!
- */
-
- #include <stdio.h>
- #include <dos.h>
-
- char *days[] ={"Sunday", "Monday", "Tuesday",
- "Wednesday", "Thursday", "Friday", "Saturday"};
-
- void main() {
- struct dosdate_t date;
- struct dostime_t time;
- unsigned char day;
- unsigned int year;
- unsigned char hour;
-
- /* Print the current system date and time. */
- _dos_getdate (&date);
- _dos_gettime (&time);
- printf("The date is: %s, %d-%d-%d\n",
- days[date.dayofweek], date.month,
- date.day, date.year);
- printf("The time is: %d:%d:%d.%d\n", time.hour,
- time.minute, time.second, time.hsecond);
-
- /* Save then alter the date and time. */
- year = date.year, date.year = 1999;
- day = date.day, date.day = 0;
- hour = time.hour, time.hour = 11;
-
- /* Print the new date and time. */
- _dos_setdate(&date);
- _dos_settime(&time);
- printf("The new date is: %s, %d-%d-%d\n",
- days[date.dayofweek], date.month,
- date.day, date.year);
-
- printf("The new time is: %d:%d:%d.%d\n",
- time.hour, time.minute, time.second,
- time.hsecond);
-
-
- /* Restore correct date and time. */
- date.year = year;
- date.day = day;
- time.hour = hour;
- _dos_setdate(&date);
- _dos_settime(&time);
- printf("The restored date is: %s,"
- " %d-%d-%d\n", days[date.dayofweek],
- date.month, date.day, date.year);
- printf("The restored time is: %d:%d:%d.%d\n",
- time.hour, time.minute,
- time.second, time.hsecond);
- }
-
- /* End _dos_settime */
- #undef main
- /**** name=_dos_write ****/
- #define main TEST__dos_write
-
- /*
- This program opens, writes to, and closes a file.
- */
- #include <stdio.h>
- #include <fcntl.h>
- #include <string.h>
- #include <dos.h>
-
- void main() {
- int handle;
- void *buffer =
- "This line to go into file doswrite.tmp.";
- unsigned length = 40, bytes;
-
- /* Open file in read/write mode. */
- if (_dos_creat("doswrite.tmp",_A_NORMAL,&handle) != 0)
- perror("_dos_open could not open file"
- " doswrite.tmp.");
- else {
- printf("_dos_open opened file doswrite.tmp.\n");
- /* Copy buffer to file. */
- if (_dos_write(handle, (_Far void *) buffer,
- length, &bytes) != 0) {
- perror("_dos_write failed to write buffer to"
- " doswrite.tmp.");
- printf("%d bytes actually written\n", bytes);
- }
- else printf("_dos_write wrote buffer"
-
- " to file doswrite.tmp.\n");
- /* Close file. */
- if (_dos_close(handle) != 0)
- perror("_dos_close failed to close file"
- " doswrite.tmp.");
- else
- printf("_dos_close closed file"
- " doswrite.tmp.\n");
- }
- }
- /* End _dos_write */
- #undef main
- /**** name=_dupX ****/
- #define main TEST__dupX
-
- #include <io.h>
- #include <fcntl.h>
- #include <sys\stat.h>
- #include <stdio.h>
- #include <conio.h>
- #define STDOUT 1
-
- int pan, fry;
- char c;
- extern void f1();
- extern void f2();
-
- void main() {
- printf("\nEXAMPLE 1:\n");
- f1();
- printf("\nEXAMPLE 2:\n");
- f2();
- }
-
- void f1() {
- pan = open("test.dat",O_RDONLY | O_BINARY);
-
- if (pan != -1) {
- printf("File test.dat exists, handle=%d.\n",pan);
- fry = _dup(pan);
- while(read(pan, &c, 1), putch(c), (c != '='));
- close(pan); /* Close the first file handle. */
- /* Continue reading dup. */
- while(read(fry, &c, 1) > 0)
-
- putch(c); /* File handle. */
- }
- else
- printf("File test.dat cannot be opened,"
- " error code = %d.\n",pan);
- close(pan);
- }
-
- void f2() {
- pan = open("dup2test.tmp",
- _O_CREAT|_O_BINARY|_O_TRUNC,_S_IWRITE);
-
- if (pan != -1) {
- printf("Created dup2test.tmp, handle=%d\n", pan);
- fry=_dup(STDOUT);
- printf("This message should show"
- " on the screen.\n");
- _dup2(pan, STDOUT);
- printf("This message must not show"
- " on the screen!!!\n");
- _dup2(fry,STDOUT);
- printf("And this is the last screen message.\n");
- }
- else
- printf("file dup2test.tmp cannot be opened,"
- " error code=%d\n", pan);
- close(pan);
- }
- /* End _dup* */
- #undef main
- #undef STDOUT
- /**** name=_eof ****/
- #define main TEST__eof
-
- #include <io.h>
- #include <conio.h>
- #include <fcntl.h>
- #include <stdio.h>
-
- void main() {
- int pan;
- char c;
-
- pan = _open("test.dat", _O_RDONLY|_O_BINARY);
- if (pan != -1) {
- printf("File test.dat exists,"
- " handle=%d.\n", pan);
- while (!_eof(pan)) {
- _read(pan, &c, 1);
- _putch(c);
- }
- }
- else
- printf("File test.dat cannot be opened,"
- " error code = %d.\n", pan);
- }
- /* End _eof */
- #undef main
- /**** name=_execX ****/
- #define main TEST__execX
-
- #include <errno.h>
- #include <stdio.h>
- #include <process.h>
- #include <string.h>
-
- void main() {
- char path[120], *args[10];
- int i;
-
- printf("Enter name of program to execute"
- " (with arguments): ");
- gets(path);
- args[0] = strtok(path, " ");
- i = 1;
- while ((args[i] = strtok(NULL, " ")) != NULL)
- i++;
- printf("\nexec-ing subprocess %s...\n", path);
- /*
- If _exec() was successful, the following statements should not be
- seen.
- */
- printf("\nI should not be seeing this message:\t"
- "return code is: %d", _execv(path, args));
- printf(", errno is: %d\n",errno);
- }
- /* End _exec* */
- #undef main
- /**** name=exit ****/
- #define main TEST_exit
-
- #include <stdlib.h>
- #include <stdio.h>
-
- void main() {
- int day;
- printf("Enter the week day desired: ");
- scanf("%d", &day);
- if ((day >= 1) && (day <= 7)) {
- printf("\nCorrect day entry."
- " Exiting Program.\n");
- exit(0); /* Returns correct status. */
- }
- else {
- printf("\nIncorrect! Exiting Program!\n");
- exit(1); /* Returns bad status. */
- }
- }
-
- /* End exit */
- #undef main
- /**** name=exp ****/
- #define main TEST_exp
-
- /*
- This program tests the function exp().
- */
- #include <math.h>
- #include <stdio.h>
-
- void main() {
- double x;
-
- x = exp(2.0);
- printf("e-squared is equal to %f.\n", x);
- }
- /* End exp */
- #undef main
-
- /*****names*****/
-
- char * names[]={
- "difftime",
- "div",
- "_dos_allocmem",
- "_dos_close",
- "_dos_creatX",
- "_dosexterr",
- "_dos_findX",
- "_dos_getdate",
- "_dos_getdiskfree",
- "_dos_getdrive",
- "_dos_getfileattr",
- "_dos_getftime",
- "_dos_read",
- "_dos_setblock",
- "_dos_setdate",
- "_dos_setdrive",
- "_dos_setfileattr",
- "_dos_setftime",
- "_dos_settime",
- "_dos_write",
- "_dupX",
- "_eof",
- "_execX",
- "exit",
- "exp",
- "",""};
- int nextfunum;
- void main() {
- char ans[90];
- for (;;) {
- for (int j=0;j< 25;j++)
- if (j%3==2) printf("%4d %-21s\n",j+1,names[j]);
- else printf("%4d %-21s",j+1,names[j]);
- printf("\n\nPlease enter a number from the above list (enter=%d, exit=0): ",++nextfunum);
- gets(ans);
- if (ans[0] != 0) nextfunum=atoi(ans);
- printf("\n\n\n");
- switch(nextfunum) {
- case 0:exit(0);
- case 1:TEST_difftime();break;
- case 2:TEST_div();break;
- case 3:TEST__dos_allocmem();break;
- case 4:TEST__dos_close();break;
- case 5:TEST__dos_creatX();break;
- case 6:TEST__dosexterr();break;
- case 7:TEST__dos_findX();break;
- case 8:TEST__dos_getdate();break;
- case 9:TEST__dos_getdiskfree();break;
- case 10:TEST__dos_getdrive();break;
- case 11:TEST__dos_getfileattr();break;
- case 12:TEST__dos_getftime();break;
- case 13:TEST__dos_read();break;
- case 14:TEST__dos_setblock();break;
- case 15:TEST__dos_setdate();break;
- case 16:TEST__dos_setdrive();break;
- case 17:TEST__dos_setfileattr();break;
- case 18:TEST__dos_setftime();break;
- case 19:TEST__dos_settime();break;
- case 20:TEST__dos_write();break;
- case 21:TEST__dupX();break;
- case 22:TEST__eof();break;
- case 23:TEST__execX();break;
- case 24:TEST_exit();break;
- case 25:TEST_exp();break;
- default:printf("I don't recognize that answer\n");nextfunum=-1;break;
- }
- printf("\n\npress enter to select another function\n");
- gets(ans);
- }
- }
-