![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-16 11:56 |
47,813 topics / 349,903 posts / today 0 new / 48,258 members |
| DOS疑难解答 & 问题讨论 (解答室) » What language are library functions in C written in? |
| Printable Version 932 / 11 |
| Floor1 dosgui | Posted 2004-02-26 00:00 |
| 初级用户 Posts 3 Credits 118 | |
|
Question!!!!!!!!!!!!!!!!
|
|
| Floor2 Kinglion | Posted 2004-02-27 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
Of course they are written in C, and some are also written in assembly language.
|
|
| Floor3 Kinglion | Posted 2004-02-27 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
Turbo C 2.0 Complete Chinese Explanation of Functions
Classification functions, in the library ctype.h int isalpha(int ch) returns a nonzero value if ch is a letter ('A'-'Z','a'-'z' , otherwise returns 0 int isalnum(int ch) returns a nonzero value if ch is a letter ('A'-'Z','a'-'z' or digit ('0'-'9' , otherwise returns 0 int isascii(int ch) returns a nonzero value if ch is a character (0-127 in the ASCII code), otherwise returns 0 int iscntrl(int ch) returns a nonzero value if ch is a delete character (0x7F) or ordinary control character (0x00-0x1F), otherwise returns 0 int isdigit(int ch) returns a nonzero value if ch is a digit ('0'-'9' , otherwise returns 0 int isgraph(int ch) returns a nonzero value if ch is a printable character (excluding space) (0x21-0x7E), otherwise returns 0 int islower(int ch) returns a nonzero value if ch is a lowercase letter ('a'-'z' , otherwise returns 0 int isprint(int ch) returns a nonzero value if ch is a printable character (including space) (0x20-0x7E), otherwise returns 0 int ispunct(int ch) returns a nonzero value if ch is a punctuation character (0x00-0x1F), otherwise returns 0 int isspace(int ch) returns a nonzero value if ch is a space (' ' , horizontal tab ('\t' , carriage return ('\r' , form feed ('\f' , vertical tab ('\v' , or newline ('\n' , otherwise returns 0 int isupper(int ch) returns a nonzero value if ch is an uppercase letter ('A'-'Z' , otherwise returns 0 int isxdigit(int ch) returns a nonzero value if ch is a hexadecimal digit ('0'-'9','A'-'F','a'-'f' , otherwise returns 0 int tolower(int ch) returns the corresponding lowercase letter ('a'-'z' if ch is an uppercase letter ('A'-'Z' int toupper(int ch) returns the corresponding uppercase letter ('A'-'Z' if ch is a lowercase letter ('a'-'z'![]() Math functions, in the libraries math.h、stdlib.h、string.h、float.h int abs(int i) returns the absolute value of integer parameter i double cabs(struct complex znum) returns the absolute value of complex number znum double fabs(double x) returns the absolute value of double-precision parameter x long labs(long n) returns the absolute value of long integer parameter n double exp(double x) returns the value of the exponential function ex double frexp(double value,int *eptr) returns the value of x in value=x*2n, with n stored in eptr double ldexp(double value,int exp); returns the value of value*2exp double log(double x) returns the value of logex double log10(double x) returns the value of log10x double pow(double x,double y) returns the value of xy double pow10(int p) returns the value of 10p double sqrt(double x) returns the square root of x double acos(double x) returns the inverse cosine cos-1(x) of x, with x in radians double asin(double x) returns the inverse sine sin-1(x) of x, with x in radians double atan(double x) returns the inverse tangent tan-1(x) of x, with x in radians double atan2(double y,double x) returns the inverse tangent tan-1(x) of y/x, y's x in radians double cos(double x) returns the cosine cos(x) of x, with x in radians double sin(double x) returns the sine sin(x) of x, with x in radians double tan(double x) returns the tangent tan(x) of x, with x in radians double cosh(double x) returns the hyperbolic cosine cosh(x) of x, with x in radians double sinh(double x) returns the hyperbolic sine sinh(x) of x, with x in radians double tanh(double x) returns the hyperbolic tangent tanh(x) of x, with x in radians double hypot(double x,double y) returns the length of the hypotenuse (z) of a right triangle, where x and y are the lengths of the legs, z2=x2+y2 double ceil(double x) returns the smallest integer not less than x double floor(double x) returns the largest integer not greater than x void srand(unsigned seed) initializes the random number generator int rand() generates a random number and returns it double poly(double x,int n,double c) generates a polynomial from the parameters double modf(double value,double *iptr) splits double-precision number value into mantissa and exponent double fmod(double x,double y) returns the remainder of x/y double frexp(double value,int *eptr) splits double-precision number value into mantissa and exponent double atof(char *nptr) converts string nptr to a floating-point number and returns it double atoi(char *nptr) converts string nptr to an integer and returns it double atol(char *nptr) converts string nptr to a long integer and returns it char *ecvt(double value,int ndigit,int *decpt,int *sign) converts floating-point number value to a string and returns that string char *fcvt(double value,int ndigit,int *decpt,int *sign) converts floating-point number value to a string and returns that string char *gcvt(double value,int ndigit,char *buf) converts number value to a string, stores it in buf, and returns the pointer to buf char *ultoa(unsigned long value,char *string,int radix) converts unsigned integer value to a string and returns that string, radix is the base used in conversion char *ltoa(long value,char *string,int radix) converts long integer value to a string and returns that string, radix is the base used in conversion char *itoa(int value,char *string,int radix) converts integer value to a string, stores it in string, radix is the base used in conversion double atof(char *nptr) converts string nptr to a double-precision number and returns it, returns 0 on error int atoi(char *nptr) converts string nptr to an integer and returns it, returns 0 on error long atol(char *nptr) converts string nptr to a long integer and returns it, returns 0 on error double strtod(char *str,char **endptr)converts string str to a double-precision number and returns it, long strtol(char *str,char **endptr,int base)converts string str to a long integer and returns it, int matherr(struct exception *e) user function to modify math error return information (not necessary to use) double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval) user function to modify math error return information (not necessary to use) unsigned int _clear87() clears the floating-point status word and returns the original floating-point status void _fpreset() reinitializes the floating-point math package unsigned int _status87() returns the floating-point status word Directory functions, in the libraries dir.h、dos.h int chdir(char *path) makes the specified directory path (for example:"C:\\WPS" the current working directory, returns 0 on success int findfirst(char *pathname,struct ffblk *ffblk,int attrib) searches for the specified file, returns 0 on success pathname is the specified directory name and file name, such as "C:\\WPS\\TXT" ffblk is a structure specified to save file information, defined as follows: ┏━━━━━━━━━━━━━━━━━━┓ ┃struct ffblk ┃ ┃{ ┃ ┃ char ff_reserved; /*DOS reserved word*/┃ ┃ char ff_attrib; /*file attribute*/ ┃ ┃ int ff_ftime; /*file time*/ ┃ ┃ int ff_fdate; /*file date*/ ┃ ┃ long ff_fsize; /*file length*/ ┃ ┃ char ff_name; /*file name*/ ┃ ┃} ┃ ┗━━━━━━━━━━━━━━━━━━┛ attrib is the file attribute, represented by the following characters ┏━━━━━━━━━┳━━━━━━━━┓ ┃FA_RDONLY read-only file┃FA_LABEL volume label┃ ┃FA_HIDDEN hidden file┃FA_DIREC directory ┃ ┃FA_SYSTEM system file┃FA_ARCH archive ┃ ┗━━━━━━━━━┻━━━━━━━━┛ Example: struct ffblk ff; findfirst("*.wps",&ff,FA_RDONLY); int findnext(struct ffblk *ffblk) gets the file matching finddirst, returns 0 on success void fumerge(char *path,char *drive,char *dir,char *name,char *ext) this function composes a filename into path from drive(C:、A: etc.), path dir(\TC、\BC\LIB etc.), filename name(TC、WPS etc.), and extension ext(.EXE、.COM etc.). int fnsplit(char *path,char *drive,char *dir,char *name,char *ext) this function splits filename path into drive(C:、A: etc.), path dir(\TC、\BC\LIB etc.), filename name(TC、WPS etc.), and extension ext(.EXE、.COM etc.), and stores them separately in the corresponding variables. int getcurdir(int drive,char *direc) this function returns the current working directory name of the specified drive. Returns 0 on success drive specified drive (0=current,1=A,2=B,3=C etc.) direc variable used to store the current working path of the specified drive char *getcwd(char *buf,iint n) this function gets the current working directory and stores it in buf, up to n bytes long. Returns NULL on error int getdisk() gets the drive currently in use, returns an integer (0=A,1=B,2=C etc.) int setdisk(int drive) sets the drive to use drive(0=A,1=B,2=C etc.), returns the total number of available drives int mkdir(char *pathname) creates a new directory pathname, returns 0 on success int rmdir(char *pathname) deletes a directory pathname, returns 0 on success char *mktemp(char *template) constructs a filename that does not exist in the current directory and stores it in template char *searchpath(char *pathname) uses MSDOS to find the path where file filename is located, this function uses DOS's PATH variable, returns NULL if the file is not found Process functions, in the libraries stdlib.h、process.h void abort() this function writes a termination message to stderr by calling _exit with exit code 3, and abnormally terminates the program. No return value int exec…loads and runs other programs int execl(char *pathname,char *arg0,char *arg1,…,char *argn,NULL) int execle(char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp) int execlp(char *pathname,char *arg0,char *arg1,…,NULL) int execlpe(char *pathname,char *arg0,char *arg1,…,NULL,char *envp) int execv(char *pathname,char *argv) int execve(char *pathname,char *argv,char *envp) int execvp(char *pathname,char *argv) int execvpe(char *pathname,char *argv,char *envp) The exec function family loads and runs program pathname, and passes parameters arg0(arg1,arg2,argv,envp) to the subprogram, returning -1 on error. In the exec function family, when the suffixes l、v、p、e are added after exec, the specified function has a certain capability. With suffix p, the function can use DOS's PATH variable to find the subprogram file. l, the number of parameters passed to the function is fixed. v, the number of parameters passed to the function is not fixed. e, the function passes the specified parameter envp, allowing the child process environment to be changed, Without suffix e, the child process uses the current program's environment. void _exit(int status) terminates the current program, but does not clean up void exit(int status) terminates the current program, closes all files, writes the output in the buffer (waits for output), and calls any registered "exit functions", no return value |
|
| Floor4 Kinglion | Posted 2004-02-27 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
int spawn…runs a subprogram
int spawnl(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL) int spawnle(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp) int spawnlp(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL) int spawnlpe(int mode,char *pathname,char *arg0,char *arg1,…, char *argn,NULL,char *envp) int spawnv(int mode,char *pathname,char *argv) int spawnve(int mode,char *pathname,char *argv,char *envp) int spawnvp(int mode,char *pathname,char *argv) int spawnvpe(int mode,char *pathname,char *argv,char *envp) The spawn function family runs the subprogram pathname in mode mode, and passes the parameters arg0(arg1,arg2,argv,envp) to the subprogram. Returns -1 on error mode is the run mode: mode is P_WAIT means return to this program after the subprogram finishes running P_NOWAIT means run this program at the same time while the subprogram is running (not usable) P_OVERLAY means run the subprogram after this program exits In the spawn function family, when the suffixes l、v、p、e are added after spawn, the specified function will have a certain capability With suffix p, the function uses DOS's PATH to find the subprogram file l, the number of parameters passed to the function is fixed. v, the number of parameters passed to the function is not fixed. e, the specified parameter envp can be passed to the subprogram, allowing the subprogram runtime environment to be changed. Without suffix e, the subprogram uses this program's environment. int system(char *command) passes the MSDOS command command to DOS for execution and conversion subprogram, libraries are math.h、stdlib.h、ctype.h、float.h char *ecvt(double value,int ndigit,int *decpt,int *sign) converts floating-point number value to a string and returns that string char *fcvt(double value,int ndigit,int *decpt,int *sign) converts floating-point number value to a string and returns that string char *gcvt(double value,int ndigit,char *buf) converts number value to a string, stores it in buf, and returns the pointer to buf char *ultoa(unsigned long value,char *string,int radix) converts unsigned integer value to a string and returns that string, radix is the base used in conversion char *ltoa(long value,char *string,int radix) converts long integer value to a string and returns that string, radix is the base used in conversion char *itoa(int value,char *string,int radix) converts integer value to a string and stores it in string, radix is the base used in conversion double atof(char *nptr) converts string nptr to a double-precision number and returns it, returns 0 on error int atoi(char *nptr) converts string nptr to an integer and returns it, returns 0 on error long atol(char *nptr) converts string nptr to a long integer and returns it, returns 0 on error double strtod(char *str,char **endptr) converts string str to a double-precision number and returns it, long strtol(char *str,char **endptr,int base) converts string str to a long integer and returns it, int toascii(int c) returns the ASCII corresponding to c int tolower(int ch) if ch is an uppercase letter ('A'-'Z' returns the corresponding lowercase letter ('a'- 'z' int _tolower(int ch) returns the corresponding lowercase letter ('a'-'z' for ch int toupper(int ch) if ch is a lowercase letter ('a'-'z' returns the corresponding uppercase letter ('A'- 'Z' int _toupper(int ch) returns the corresponding uppercase letter ('A'-'Z' for ch Diagnostic functions, in the libraries assert.h、math.h void assert(int test) a macro expanded like an if statement, if test fails, it displays a message and abnormally terminates the program, no return value void perror(char *string) this function displays the most recent error message, in the format: string string:error message char *strerror(char *str) this function returns the most recent error message, in the format: string str:error message int matherr(struct exception *e) user function to modify math error return information (not necessary to use) double _matherr(_mexcep why,char *fun,double *arg1p, double *arg2p,double retval) user function to modify math error return information (not necessary to use) Input/output subroutines, libraries are io.h、conio.h、stat.h、dos.h、stdio.h、signal.h int kbhit() this function returns the most recently pressed key int fgetchar() reads a character from the console (keyboard) and displays it on the screen int getch() reads a character from the console (keyboard) without displaying it on the screen int putch() writes a character to the console (keyboard) int getchar() reads a character from the console (keyboard) and displays it on the screen int putchar() writes a character to the console (keyboard) int getche() reads a character from the console (keyboard) and displays it on the screen int ungetch(int c) returns character c to the console (keyboard) char *cgets(char *string) reads a string from the console (keyboard) and stores it in string int scanf(char *format) reads a string from the console, assigns values to each parameter respectively, and uses BIOS for output int vscanf(char *format,Valist param) reads a string from the console, assigns values to each parameter respectively, and uses BIOS for output, parameters are taken from Valist param int cscanf(char *format) reads a string from the console, assigns values to each parameter respectively, and operates directly on the console, for example the display writes characters directly to video memory int sscanf(char *string,char *format) assigns values to each parameter respectively through string string int vsscanf(char *string,char *format,Vlist param) assigns values to each parameter respectively through string string, parameters are taken from Vlist param int puts(char *string) sends a string string to the console (display), using BIOS for output void cputs(char *string) sends a string string to the console (display), operating directly on the console, for example the display uses direct video-memory writing int printf(char *format) sends formatted string output to the console (display), using BIOS for output int vprintf(char *format,Valist param) sends formatted string output to the console (display), using BIOS for output, parameters are taken from Valist param int cprintf(char *format) sends formatted string output to the console (display), operating directly on the console, for example the display uses direct video-memory writing int vcprintf(char *format,Valist param) sends formatted string output to the console (display), operating directly on the console, for example the display uses direct video-memory writing, parameters are taken from Valist param int sprintf(char *string,char *format) rewrites the contents of string string as a formatted string int vsprintf(char *string,char *format,Valist param) rewrites the contents of string string as a formatted string, parameters are taken from Valist param int rename(char *oldname,char *newname)changes the name of file oldname to newname int ioctl(int handle,int cmd) this function is used to control input/output devices, see the table below: ┌───┬────────────────────────────┐ │cmd value │function │ ├───┼────────────────────────────┤ │ 0 │get device information │ │ 1 │set device information │ │ 2 │read argcx bytes into the address pointed to by argdx │ │ 3 │write argcx bytes to the address pointed to by argdx │ │ 4 │same as cmd=2 except handle is treated as a device number (0=current,1=A, etc.) │ │ 5 │same as cmd=3 except handle is treated as a device number (0=current,1=A, etc.) │ │ 6 │get input status │ │ 7 │get output status │ │ 8 │test removability; DOS 3.x only │ │ 11 │set share-conflict retry count; DOS 3.x only │ └───┴────────────────────────────┘ int (*ssignal(int sig,int(*action)())() executes a software signal (not necessary to use) int gsignal(int sig) executes a software signal (not necessary to use) int _open(char *pathname,int access)opens a file for reading or writing, then determines whether to read or write according to access, see the table below for access values ┌──────┬────────────────────┐ │access value │meaning │ ├──────┼────────────────────┤ │O_RDONLY │read file │ │O_WRONLY │write file │ │O_RDWR │both read and write │ │O_NOINHERIT │if the file is not passed to the subprogram, it is included │ │O_DENYALL │only the current process is allowed to access the file │ │O_DENYWRITE │only reading from any other open file is allowed │ │O_DENYREAD │only writing from any other open file is allowed │ │O_DENYNONE │allows other shared opens of the file │ └──────┴────────────────────┘ int open(char *pathname,int access)opens a file for reading or writing, then determines whether to read or write according to access, see the table below for access values ┌────┬────────────────────┐ │access value│meaning │ ├────┼────────────────────┤ │O_RDONLY│read file │ │O_WRONLY│write file │ │O_RDWR │both read and write │ │O_NDELAY│unused; for UNIX system compatibility │ │O_APPEND│both read and write, but each write always appends to the end of the file │ │O_CREAT │if the file exists, this flag is useless; if it does not exist, create a new file │ │O_TRUNC │if the file exists, its length is truncated to 0 and attributes remain unchanged │ │O_EXCL │unused; for UNIX system compatibility │ │O_BINARY│this flag can explicitly specify opening the file in binary mode │ │O_TEXT │this flag can be used to explicitly specify opening the file in text mode│ └────┴────────────────────┘ permiss is the file attribute, it can be the following values: S_IWRITE allows write S_IREAD allows read S_IREAD|S_IWRITE allows read and write int creat(char *filename,int permiss) creates a new file filename, and sets its read/write properties. permiss is the file read/write property, it can be the following values S_IWRITE allows write S_IREAD allows read S_IREAD|S_IWRITE allows read and write int _creat(char *filename,int attrib) creates a new file filename, and sets file attributes. attrib is the file attribute, it can be the following values FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system int creatnew(char *filenamt,int attrib) creates a new file filename, and sets file attributes. attrib is the file attribute, it can be the following values FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system int creattemp(char *filenamt,int attrib) creates a new file filename, and sets file attributes. attrib is the file attribute, it can be the following values FA_RDONLY read-only FA_HIDDEN hidden FA_SYSTEM system int read(int handle,void *buf,int nbyte) reads nbyte characters from the file with file number handle into buf int _read(int handle,void *buf,int nbyte) reads nbyte characters from the file with file number handle into buf, directly calling MSDOS for the operation. int write(int handle,void *buf,int nbyte) writes nbyte characters from buf to the file with file number handle int _write(int handle,void *buf,int nbyte) writes nbyte characters from buf to the file with file number handle int dup(int handle) duplicates a file handle handle and returns this handle int dup2(int handle,int newhandle) duplicates a file handle handle to newhandle int eof(int *handle) checks whether the file has ended, returns 1 if ended, otherwise returns 0 long filelength(int handle) returns the file length, handle is the file number |
|
| Floor5 Kinglion | Posted 2004-02-27 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
| Floor6 Kinglion | Posted 2004-02-27 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
int biosdisk(int cmd,int drive,int head,int track, int sector,int nsects,void *buffer)
this function is used to perform certain operations on a drive, cmd is the function number, drive is the drive number (0=A,1=B,0x80=C,0x81=D,0x82=E etc.). cmd can be the following values: 0 Reset floppy disk system. This forces the drive controller to perform a hard reset. Ignore all other parameters. 1 Return the status of the last hard disk operation. Ignore all other parameters 2 Read one or more disk sectors into memory. The starting sector to read is given by head、track、sector. The number of sectors is given by nsects. Read the 512 bytes of data of each sector into buffer 3 Write data read from memory to one or more sectors. The starting sector to write is given by head、track、sector. The number of sectors is given by nsects. The data to be written is in buffer, 512 bytes per sector. 4 Verify one or more sectors. The starting sector is given by head、track、sector. The number of sectors is given by nsects. 5 Format a track, this track is given by head and track. buffer points to a table of sector header identifiers written on the specified track. The following cmd values are only allowed for XT or AT microcomputers: 6 Format a track and set bad sector marks. 7 Format the drive beginning on the specified track. 8 Return current drive parameters, drive information is written back into buffer (expressed in four bytes). 9 Initialize a pair of drive characteristics. 10 Perform a long read, reading 512 plus 4 extra bytes per sector 11 Perform a long write, writing 512 plus 4 extra bytes per sector 12 Perform a disk seek 13 Alternate disk reset 14 Read sector buffer 15 Write sector buffer 16 Check whether the specified drive is ready 17 Recalibrate drive 18 Controller RAM diagnostic 19 Drive diagnostic 20 Controller internal diagnostic The function returns a status byte composed of the following bit values: 0x00 operation successful 0x01 bad command 0x02 address mark not found 0x04 record not found 0x05 reset failed 0x07 drive parameter activity failed 0x09 attempt DMA across 64K boundary 0x0B check bad disk mark 0x10 bad ECC on disk read 0x11 ECC corrected data error (note that it is not an error) 0x20 controller failure 0x40 seek failed 0x80 responding connection failed 0xBB undefined error occurred 0xFF read operation failed int biodquip() check device equipment, the function returns a word, each bit of the word represents one piece of information, as follows: Bit 15 printer number Bit 14 printer number Bit 13 unused Bit 12 connected game I/O Bit 11 RS232 port number Bit 8 unused Bit 7 floppy disk number Bit 6 floppy disk number, 00 means drive 1, 01 means drive 2, 10 means drive 3, 11 means drive 4 Bit 5 initialization Bit 4 display mode 00 unused, 01 40x25BW color display card 10 80x25BW color display card, 11 80x25BW monochrome display card Bit 3 motherboard part Bit 2 random memory capacity, 00 means 16K, 01 means 32K, 10 means 48K, 11 means 64K Bit 1 floating-point coprocessor Bit 0 boot from floppy disk int bioskey(int cmd)this function is used to perform various keyboard operations, the operation is determined by cmd. cmd can be the following values: 0 Return the next key struck on the keyboard. If the low 8 bits are nonzero, it is an ASCII character; if the low 8 bits are 0, then it returns an extended keyboard code. 1 Test whether the keyboard is available for reading. Return 0 means no key is available; otherwise return the value of the next key struck. The key itself remains until the value returned by the next call to bioskey with cmd value 0. 2 Return the current keyboard status, represented by each bit of the returned integer, see the table below: ┌──┬───────────┬───────────┐ │ bit │meaning when 0 │meaning when 1 │ ├──┼───────────┼───────────┤ │ 7 │insert mode │overwrite mode │ │ 6 │uppercase mode │lowercase mode │ │ 5 │numeric mode, NumLock light on │cursor mode, NumLock light off │ │ 4 │ScrollLock light on │ScrollLock light off │ │ 3 │Alt pressed │Alt not pressed │ │ 2 │Ctrl pressed │Ctrl not pressed │ │ 1 │left Shift pressed │left Shift not pressed │ │ 0 │right Shift pressed │right Shift not pressed │ └──┴───────────┴───────────┘ int biosmemory() returns memory size, in K. int biosprint(int cmd,int byte,int port) controls printer input/output. port is the printer number, 0 is LPT1, 1 is LPT2, 2 is LPT3, etc. cmd can be the following values: 0 print character, send character byte to the printer 1 initialize printer port 2 read printer status The function return value is composed of the following bit values indicating current printer status 0x01 device timeout 0x08 input/output error 0x10 selected 0x20 paper feed 0x40 acknowledge 0x80 not busy int biostime(int cmd,long newtime)timer control, cmd is the function number, can be the following values 0 function returns the current value of the timer 1 set the timer to the new value newtime struct country *country(int countrycmode,struct country *countryp) this function is used to control information related to a certain country, such as date, time, currency, etc. If countryp=-1, the current country is set to the value countrycode (must be nonzero). Otherwise, the country structure pointed to by countryp is filled with the following country-related information: (1)the current country (if countrycode is 0 or 2) the country specified by countrycode. The structure country is defined as follows: ┌────────────────────┐ │struct country │ │{ │ │ int co_date; /*date format*/ │ │ char co_curr[5]; /*currency symbol*/ │ │ char co_thsep[2]; /*number separator*/ │ │ char co_desep[2]; /*decimal point*/ │ │ char co_dtsep[2]; /*date separator*/ │ │ char co_tmsep[2]; /*time separator*/ │ │ char co_currstyle; /*currency style*/ │ │ char co_digits; /*significant digits*/ │ │ int (far *co_case)(); /*event handler*/ │ │ char co_dasep; /*data separator*/ │ │ char co_fill[10]; /*fill characters*/ │ │} │ └────────────────────┘ The date format represented by the value of co_date is: 0 month-day-year 1 day-month-year 2 year-month-day The currency display method represented by the value of co_currstrle is 0 currency symbol before the value, no space in between 1 currency symbol after the value, no space in between 2 currency symbol before the value, with a space in between 3 currency symbol after the value, with a space in between Operation functions, in the libraries string.h、mem.h mem…memory array operations void *memccpy(void *destin,void *source,unsigned char ch,unsigned n) void *memchr(void *s,char ch,unsigned n) void *memcmp(void *s1,void *s2,unsigned n) int memicmp(void *s1,void *s2,unsigned n) void *memmove(void *destin,void *source,unsigned n) void *memcpy(void *destin,void *source,unsigned n) void *memset(void *s,char ch,unsigned n) These functions, all members of the mem… series, operate on memory arrays. In all these functions, the array is n bytes long. memcpy copies an n-byte block from source to destin. If the source block and destination block overlap, the copy direction is chosen so as to correctly copy the overwritten bytes. memmove is the same as memcpy. memset sets all bytes of s to byte ch. The length of array s is given by n. memcmp compares two strings s1 and s2 that are exactly n bytes long. These functions compare bytes as unsigned characters, therefore, memcmp("0xFF","\x7F",1) returns a value greater than 0. memicmp compares the first n bytes of s1 and s2 regardless of upper or lower case. memccpy copies bytes from source to destin. Copying ends as soon as any one of the following occurs: (1)character ch is first copied to destin. (2)n bytes have been copied to destin. memchr searches the first n bytes of array s for character ch. Return values: memmove and memcpy return destin memset returns the value of s memcmp and memicmp─┬─if s1s2 the return value is greater than 0 memccpy if ch was copied, returns a pointer to the byte in destin immediately following ch; otherwise returns NULL memchr returns a pointer to the first occurrence of ch in s; if ch does not appear in array s, returns NULL. void movedata(int segsrc,int offsrc, int segdest,int offdest, unsigned numbytes) this function copies numbytes bytes from source address (segsrc:offsrc) to destination address (segdest:offdest) void movemem(void *source,void *destin,unsigned len) this function copies a block of data len bytes long from source to destin. If the source address and destination address strings overlap, the copy direction is chosen so that the data is copied correctly. void setmem(void *addr,int len,char value) this function sets the first byte of the block pointed to by addr to byte value. |
|
| Floor7 Kinglion | Posted 2004-02-27 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
str…string operation functions
char stpcpy(char *dest,const char *src) copies string src to dest char strcat(char *dest,const char *src) appends string src to the end of dest char strchr(const char *s,int c) searches for and returns the first occurrence position of character c in string s int strcmp(const char *s1,const char *s2) compares the sizes of strings s1 and s2, and returns s1-s2 char strcpy(char *dest,const char *src) copies string src to dest size_t strcspn(const char *s1,const char *s2) scans s1, returning the number of characters that are in s1 and also in s2 char strdup(const char *s) copies string s to the most recently created unit int stricmp(const char *s1,const char *s2) compares strings s1 and s2, and returns s1-s2 size_t strlen(const char *s) returns the length of string s char strlwr(char *s) converts all uppercase letters in string s to lowercase letters and returns the converted string char strncat(char *dest,const char *src,size_t maxlen) copies at most maxlen characters from string src to string dest int strncmp(const char *s1,const char *s2,size_t maxlen) compares the first maxlen characters in strings s1 and s2 char strncpy(char *dest,const char *src,size_t maxlen) copies the first maxlen characters in src to dest int strnicmp(const char *s1,const char *s2,size_t maxlen) compares the first maxlen characters in strings s1 and s2 char strnset(char *s,int ch,size_t n) sets the first n characters of string s to ch char strpbrk(const char *s1,const char *s2) scans string s1 and returns the number of characters present in both s1 and s2 char strrchr(const char *s,int c) scans a string s for the last occurrence of a given character c char strrev(char *s) reverses the order of all characters in string s and returns the rearranged string char strset(char *s,int ch) sets all characters in string s to a given character ch size_t strspn(const char *s1,const char *s2) scans string s1 and returns the number of characters present in both s1 and s2 char strstr(const char *s1,const char *s2) scans string s2 and returns the first position where s1 appears char strtok(char *s1,const char *s2) searches string s1, which is separated by delimiters defined in string s2 char strupr(char *s) converts all lowercase letters in string s to uppercase letters and returns the converted string Memory allocation subroutines, in the libraries dos.h、alloc.h、malloc.h、stdlib.h、process.h int allocmem(unsigned size,unsigned *seg) uses DOS to allocate free memory, size is the size of memory to allocate, seg is the pointer to the allocated memory int freemem(unsigned seg) frees the memory previously allocated by allocmem, seg is the specified memory pointer int setblock(int seg,int newsize) this function is used to modify the length of allocated memory, seg is the memory pointer of already allocated memory, newsize is the new length int brk(void *endds) this function is used to change the amount of space allocated to the calling program's data segment, the end address of the new space is endds char *sbrk(int incr) this function is used to increase the amount of space allocated to the calling program's data segment, increasing by incr bytes unsigned long coreleft() this function returns the length of unused storage area, in bytes void *calloc(unsigned nelem,unsigned elsize) allocates memory space of length elsize for nelem elements and returns a pointer to the allocated memory void *malloc(unsigned size) allocates size bytes of memory space and returns a pointer to the allocated memory void free(void *ptr) frees the previously allocated memory, ptr is the pointer to the memory to be freed void *realloc(void *ptr,unsigned newsize) changes the size of the allocated memory, ptr is the pointer to the already allocated memory area, newsize is the new length, returns the allocated memory pointer. long farcoreleft() this function returns the length of unused storage area in the far heap, in bytes void far *farcalloc(unsigned long units,unsigned long unitsz) allocates memory space of length unitsz for units elements from the far heap and returns a pointer to the allocated memory void *farmalloc(unsigned long size) allocates size bytes of memory space and returns the pointer to the allocated memory void farfree(void far *block) frees the memory space previously allocated from the far heap, block is the pointer to the far heap memory to be freed void far *farrealloc(void far *block,unsigned long newsize) changes the size of allocated far heap memory, block is the pointer to the already allocated memory area, newzie is the new length, returns the allocated memory pointer Time and date functions, libraries are time.h、dos.h In the time and date functions, the following structures are mainly used: Total time/date storage structure tm ┌──────────────────────┐ │struct tm │ │{ │ │ int tm_sec; /*seconds,0-59*/ │ │ int tm_min; /*minutes,0-59*/ │ │ int tm_hour; /*hours,0-23*/ │ │ int tm_mday; /*day number,1-31*/ │ │ int tm_mon; /*month number,0-11*/ │ │ int tm_year; /*years since 1900*/ │ │ int tm_wday; /*days since Sunday 0-6*/ │ │ int tm_yday; /*days since January 1,0-365*/ │ │ int tm_isdst; /*whether daylight saving time is used, positive if used*/│ │} │ └──────────────────────┘ Date storage structure date ┌───────────────┐ │struct date │ │{ │ │ int da_year; /*years since 1900*/│ │ char da_day; /*day number*/ │ │ char da_mon; /*month number 1=Jan*/ │ │} │ └───────────────┘ Time storage structure time ┌────────────────┐ │struct time │ │{ │ │ unsigned char ti_min; /*minute*/│ │ unsigned char ti_hour; /*hour*/│ │ unsigned char ti_hund; │ │ unsigned char ti_sec; /*second*/ │ │ │ └────────────────┘ char *ctime(long *clock) this function converts the time pointed to by clock (for example the time returned by function time) into a string in the following format: Mon Nov 21 11:31:54 1983\n\0 char asctime(struct tm *tm) this function converts the time in the specified tm structure class into a string in the following format: Mon Nov 21 11:31:54 1983\n\0 double difftime(time_t time2,time_t time1) calculates the time difference between structures time2 and time1 (in seconds) struct tm *gmtime(long *clock) this function converts the time pointed to by clock (for example the time returned by function time) into Greenwich time, and returns it in tm structure form struct tm *localtime(long *clock) this function converts the time pointed to by clock (for example the time returned by function time) into local standard time, and returns it in tm structure form void tzset()this function provides compatibility with the UNIX operating system long dostounix(struct date *dateptr,struct time *timeptr) this function converts the date pointed to by dateptr and the time pointed to by timeptr into UNIX format, and returns the number of seconds from Greenwich time 1970-01-01 midnight to the present void unixtodos(long utime,struct date *dateptr,struct time *timeptr) this function converts utime, the number of seconds from Greenwich time 1970-01-01 midnight to the present, into DOS format and stores it in the user-specified structures dateptr and timeptr void getdate(struct date *dateblk) this function writes the computer's date into structure dateblk for user use void setdate(struct date *dateblk) this function changes the computer's date to the date specified by structure dateblk void gettime(struct time *timep) this function writes the computer's time into structure timep for user use void settime(struct time *timep) this function changes the computer's time to the time pointed to by structure timep long time(long *tloc) this function gives the number of seconds elapsed from Greenwich time 1970-01-01 midnight to the present, and stores this value in the unit pointed to by tloc. int stime(long *tp)this function writes the time pointed to by tp (for example the time returned by time) into the computer. |
|
| Floor8 终极战士 | Posted 2004-02-27 00:00 |
| 初级用户 Posts 28 Credits 214 From 江苏 | |
|
It may be written in a mixture of assembly and C.
|
|
| Floor9 李桦 | Posted 2004-02-28 00:00 |
| 初级用户 Posts 5 Credits 118 | |
|
It's assembly, it's assembly
|
|
| Floor10 dosgui | Posted 2004-02-28 00:00 |
| 初级用户 Posts 3 Credits 118 | |
|
I am deeply grateful to expert kinglion, my admiration for you is like the surging river, endless and unbroken!!!!!!
|
|
| Floor11 凌晨一点 | Posted 2004-03-03 00:00 |
| 初级用户 Posts 54 Credits 255 | |
|
Whoa! I agree with post #9, it's mixed.
|
|
| Floor12 sunny1979 | Posted 2004-03-09 00:00 |
| 初级用户 Posts 86 Credits 376 | |
|
To be exact, it's mixed-language programming!!!
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |