home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / c / sozobon-v2 / dlibs12.lha / DLIBS.DOC < prev    next >
Text File  |  1988-10-21  |  79KB  |  1,780 lines

  1.  _________________________________________________________________________
  2. |                                      |
  3. | Replacement standard library functions for Atari ST with Alcyon C v4.14 |
  4. |       Version 1.20.0, by Dale Schumacher, last modified 10/19/88.      |
  5. |_________________________________________________________________________|
  6.  
  7.  
  8.  
  9. HEADER FILES:
  10.  
  11. ar.h
  12.     This header defines the library archive header used by 'ar'.
  13.  
  14. assert.h
  15.     This header defines the assert() run-time condition checking macro.
  16.  
  17. basepage.h
  18.     The BASEPAGE struct and the _base variable, which is initialized
  19.     to point to the current process basepage, are defined in this file.
  20.  
  21. ctype.h
  22.     The isxxxx() macros and toxxxx() macros are define in this file.
  23.  
  24. errno.h
  25.     This file defines the error code constants, the errno variable
  26.     and related error handling functions.
  27.  
  28. fcntl.h
  29.     This file defines the O_xxxx constants used by open().
  30.  
  31. limits.h
  32.     Various maximum and minimum values are defined by this file.
  33.     Among these are PATHSIZE and MAXINT.
  34.  
  35. macros.h
  36.     This file contains a few useful macros including min(), max(),
  37.     abs() and swap().
  38.  
  39. malloc.h
  40.     This file is defines the return values for the dynamic memory
  41.     managment functions, malloc(), et. al.
  42.  
  43. osbind.h
  44.     Mnemonics for bios(), xbios() and gemdos() calls are defined
  45.     in this file.
  46.  
  47. setjmp.h
  48.     This file defines the buffer needed to save your context when
  49.     using setjmp()/longjmp() or catch()/throw().
  50.  
  51. stat.h
  52.     The struct stat and the file mode flag constants are defined
  53.     in this file.
  54.  
  55. stdarg.h
  56.     This header defines the type and macros needed for variable
  57.     argument list processing.
  58.  
  59. stddef.h
  60.     This is the root header file which should be included in all
  61.     programs.  It defines dLibs, NULL, size_t, ptrdiff_t and the
  62.     offsetof() macro.
  63.  
  64. stdio.h
  65.     This header file should be present in nearly all C programs.
  66.     It contains defines the FILE struct, EOF and contains extern
  67.     declarations for standard i/o and other commonly used functions.
  68.     For convenience, the constants TRUE, FALSE and ERROR are also
  69.     defined in this file, although this is somewhat non-standard.
  70.  
  71. string.h
  72.     This file defines aliases for string function names (since some
  73.     string functions have various names on different systems) and
  74.     extern declarations for all string functions.
  75.  
  76. time.h
  77.     This file defines time related constants and structures, and
  78.     extern declarations for the time functions.
  79.  
  80. types.h
  81.     Thie file contains typedefs for many special and/or non-standard
  82.     type names.  Many of the typedefs in this file define type names
  83.     which are ANSI and/or System V standard.  This file is included
  84.     by several other header files, and includes <stddef.h>.
  85.  
  86. sys\minimum.h
  87.     This file contains C code for new _main() and _initargs() functions.
  88.     It is used as a non-portable hack to make very small programs when
  89.     no standard i/o or argv/argc is needed.
  90.  
  91. sys\until.h
  92.     This file is provided just for fun.  It defines macros needed to
  93.     implement a "repeat { ... } until(HELL_FREEZES_OVER);" construct.
  94.  
  95.  
  96. PROCESS CONTROL:
  97.  
  98. long _STKSIZ = 4096L;
  99.     This variable defines the amount of run-time stack space to be
  100.     reserved.  The default value is 4K, which is more than enough
  101.     for most applications.  Since dynamic memory is NOT allocated
  102.     from the stack, this value need only be large enough to handle
  103.     local variables and deep recursion.
  104.  
  105. char *etext;
  106. char *edata;
  107. char *end;
  108.     These variables point to the first byte beyond the end of the
  109.     text, data and BSS segments respectively.  They are provided
  110.     for compatibility.
  111.  
  112. void _initargs(char *cmdline, int cmdlen)
  113.     Process the command arguments, either parsing the command line
  114.     or copying XARG arguments, and retrieve the environment string.
  115.     This function is called from the startup module very early on.
  116.     Values to be passed to the user's main() function are stored in
  117.     the global variables "_argc" and "_argv".  The startup module
  118.     initiallizes these variables to indicate that no arguments are
  119.     available, and sets "_envp" from the value in the basepage.  If
  120.     a program doesn't use arguments, this function can be replaced
  121.     by one like the one in <sys\minimum.h> to make the program smaller.
  122.  
  123. int _main()
  124.     This function defines the standard streams, check to see which
  125.     of them are devices, and calls the user's main() function.  The
  126.     startup module calls this function to start the C program.  The
  127.     following standard streams are initialized by _main():
  128.         stdin        Standard input, may be redirected
  129.         stdout        Standard output, may be redirected
  130.         stderr        Usually the system console
  131.         stdprn        The standard printer (output only)
  132.         stdaux        The communication port (input/output)
  133.     The global variables "_argc", "_argv" and "_envp" are used to
  134.     store the values to be passed to the user's main().  If main()
  135.     returns, exit() is called, with EXIT_SUCCESS status.  If a
  136.     program doesn't use ANY standard i/o, this function can be
  137.     replaced by one like the one in <sys\minimum.h> to make the
  138.     program smaller.
  139.  
  140. int main(int argc, char *argv[], char *envp)
  141.     This function is not actually in the standard libraries, but
  142.     must be present somewhere in the user's code.  The parameters
  143.     passed to it by _main() are the number of arguments in the
  144.     command line, a pointer to a list of pointers to arguments, and
  145.     a pointer to the initial environment string.  The return value
  146.     from main() is passed, by _main(), to exit().  Therefore, you
  147.     should always return() from main(), or call exit() directly.
  148.  
  149. void exit(int status)
  150.     Flushes and closes all open streams.  Returns <status> value to
  151.     the operating system.
  152.  
  153. void _exit(int status)
  154.     Exits the program immediately, returning <status> to the OS.
  155.  
  156. void abort()
  157.     Prints the message "Abnormal program termination" to stderr and
  158.     calls _exit() with a status code of 3.
  159.  
  160. int getpid()
  161.     Return an integer value unique for this process.
  162.  
  163. char *getenv(char *var)
  164.     Search for <var> in the environment.  If <var> is found, a pointer
  165.     to it's value is returned.  NULL is returned if <var> is not found.
  166.     WARNING:  The returned pointer points into the environment and
  167.     must not be modified!
  168.  
  169. int putenv(char *entry)
  170.     Add <entry> to the environment.  <entry> can be any of the following
  171.     forms:
  172.         <VARIABLE>
  173.         <VARIABLE>=
  174.         <VARIABLE>=<value>
  175.     The first form removes <VARIABLE> from the environment.  getenv()
  176.     will return NULL if looking for this variable.  The second form adds
  177.     <VARIABLE> to the environment, with a null value.  getenv() will
  178.     return a pointer to a '\0' character if looking for this variable.
  179.     Many environment handlers don't support such "tag variables", so
  180.     their use is not recommended.  The final form is the most common,
  181.     and safest to use.  <VARIABLE> is installed (or replaced) with the
  182.     value <value>.  It should be noted that the putenv() function itself
  183.     is not supported in many systems and therefore may not be portable.
  184.     In addition, care should be taken to prevent overflowing the space
  185.     allocated for the environment.  Returns TRUE for success or FALSE
  186.     for failure.  NO OVERFLOW CHECKING IS DONE.
  187.  
  188. void shell()
  189.     Invoke a command line interface shell.  If the "SHELL" environment
  190.     variable is not defined, a prompt showing the current working
  191.     directory will be given.  Each line entered will then be passed
  192.     to the system() function for execution until the command "exit"
  193.     is entered to terminate the shell.  If "SHELL" is defined, and
  194.     the "_shell_p" variable is valid, the value of "SHELL" will be
  195.     passed to the program pointed to by "_shell_p" in order to allow
  196.     the shell to invoke a command line interaction of its own.  If
  197.     the "_shell_p" variable is not valid, the program defined by
  198.     "SHELL" will be searched for along the "PATH", and executed with
  199.     no arguments.  If the "SHELL" can't be found, the internal command
  200.     line described above will be used.
  201.  
  202. int system(char *command)
  203.     Attempts to pass <command> to the shell program pointed to by
  204.     the system variable "_shell_p".  If a valid shell can't be found
  205.     there, the "SHELL" environment variable is searched for.  If it
  206.     exists and is not empty, it will be the name of the shell program
  207.     to execute the given command.  If "SHELL" is not valid, the
  208.     "PATH" variable is used as a list of directories to search for
  209.     the program name which is the first token of the command.  The
  210.     extensions tried (if none is specified) are ".TTP", ".TOS",
  211.     ".PRG" and ".APP".
  212.  
  213. int forkl(char *program[, *arg0, *arg1, ..., *argN], NULL)
  214.     Create a child process.  Since it is not possible to do a true
  215.     Unix-style fork(), the functionality of the fork()/exec() pair
  216.     is provided by these fork*() functions.  A process is created,
  217.     running concurrently if possible, which executes <program> with
  218.     the arguments given.  A process id number is returned, which can
  219.     be compared against the return value from wait().  Note that by
  220.     convention <arg0> should be the name of the program that is
  221.     being called, and is often ignored.  The fork*() functions all
  222.     return ERROR if they for failure, or the child pid for success.
  223.  
  224. int forklp(char *program[, *arg0, *arg1, ..., *argN], NULL)
  225.     Use the environment variable "PATH" to find <program>. (cf: forkl)
  226.  
  227. int forkle(char *program[, *arg0, *arg1, ..., *argN], NULL, *envp)
  228.     Pass the environment <envp> to the child process. (cf: forkl)
  229.  
  230. int forklpe(char *program[, *arg0, *arg1, ..., *argN], NULL, *envp)
  231.     Use the environment variable "PATH" to find <program> and
  232.     pass the environment <envp> to the child process. (cf: forkl)
  233.  
  234. int forkv(char *program, **argv)
  235.     Like forkl() except <argv> points to a NULL terminated list of
  236.     pointers to arguments.  This is particularly useful if the number
  237.     of arguments is not known at compile time.
  238.  
  239. int forkvp(char *program, **argv)
  240.     Use the environment variable "PATH" to find <program>. (cf: forkv)
  241.  
  242. int forkve(char *program, **argv, *envp)
  243.     Pass the environment <envp> to the child process. (cf: forkv)
  244.  
  245. int forkvpe(char *program, **argv, *envp)
  246.     Use the environment variable "PATH" to find <program> and
  247.     pass the environment <envp> to the child process. (cf: forkv)
  248.  
  249. int wait(int *rvp)
  250.     Wait for a child process to terminate.  Return -1 if there are
  251.     no children.  Normal return is the process id number of the
  252.     terminated child.  <rvp> is an pointer to the place to store
  253.     the return value and exit status.  The high byte of the word
  254.     pointed to be <rvp> will contain the value returned from the
  255.     child through exit().  The low byte will contain 0 if the process
  256.     terminated normally, or an error code if abnormally.
  257.  
  258. long gemdos(int func[, arg1, ..., argN])
  259.     Call operating system trap #1 (GEMDOS) function number <func> with
  260.     the arguments given.  Return value returned by the trap call.
  261.  
  262. long bios(int func[, arg1, ..., argN])
  263.     Call operating system trap #13 (BIOS) function number <func> with
  264.     the arguments given.  Return value returned by the trap call.
  265.  
  266. long xbios(int func[, arg1, ..., argN])
  267.     Call operating system trap #14 (XBIOS) function number <func> with
  268.     the arguments given.  Return value returned by the trap call.
  269.  
  270. int bdos(int func, long parameter)
  271.     Call operating system trap #2 (BDOS) function number <func> with
  272.     passing the specified <parameter>.  Note that <parameter> must
  273.     always be a long value, even if only a 16-bit value is required
  274.     by the specified BDOS function.
  275.  
  276. int setjmp(jmp_buf context)
  277.     Save <context> for longjmp(). You MUST include <setjmp.h> to use.
  278.     Calling this function saves the current program context in the
  279.     context buffer provided and returns zero.  A later call to the
  280.     longjmp() function will cause the context to be restored and
  281.     your program will continue as if it just returned from setjmp(),
  282.     but this time with the (non-zero) return value specified in the
  283.     longjmp() call.  THE SAVED CONTEXT WILL NOT BE VALID IF YOU
  284.     EXIT THE FUNCTION THAT CALLED setjmp().
  285.  
  286. void longjmp(jmp_buf context, int rv)
  287.     Return <rv> to the <context> saved by setjmp(). (cf: setjmp)
  288.     You MUST include <setjmp.h> to use.
  289.  
  290. int catch(jmp_buf context, int (*func)())
  291.     Execute <func> with <context> saved for throw().  You MUST include
  292.     <setjmp.h> to use.  Return the value returned by <func>.  The main
  293.     advantage of these functions over catch/throw is the ability to
  294.     return zero from the function executed, and the logically "cleaner"
  295.     encapsulation of the non-local jump operation.  These functions
  296.     are patterned after similar functions in LISP.  (cf: setjmp/longjmp)
  297.  
  298. void throw(jump_buf context, int rv)
  299.     Return <rv> to <context> saved by catch().  You MUST include
  300.     <setjmp.h> to use.
  301.  
  302.  
  303. MEMORY MANAGEMENT:
  304.  
  305.     You should include <malloc.h> in your program if you use functions
  306.     in this section.
  307.  
  308. long _BLKSIZ = 65536;
  309.     This variable controls the granularity of system memory allocation
  310.     used by malloc(), et. al.  This is the amount of memory that is
  311.     requested from the system each time a new "heap" is needed to fill
  312.     dynamic memory requests.  To help avoid a GEMDOS bug, only 16
  313.     heaps can be active at a time.  Therefore, (16 * _BLKSIZ) defines
  314.     the maximum amount of memory which can be managed by these routines
  315.     under normal circumstances.  The exception is if any single request
  316.     for memory exceeds _BLKSIZ.  In this case, a heap will be allocated
  317.     larger than _BLKSIZ.
  318.  
  319. char *malloc(unsigned int size)
  320.     Allocate at least <size> bytes of memory.  A pointer to the
  321.     requested block is returned, or NULL if there is not enough
  322.     free memory available.
  323.  
  324. char *calloc(unsigned int n, size_t size)
  325.     Allocate space for an array of <n> element of <size> bytes each.
  326.     If the storage can be allocated, it is initialized to all zero.
  327.     NULL is returned is there is not enough free memory.
  328.  
  329. char *lalloc(long size)
  330.     Allocate at least <size> bytes of memory.  A pointer to the
  331.     requested block is returned, or NULL if there is not enough
  332.     free memory available.
  333.  
  334. char *realloc(char *addr, unsigned int size)
  335.     Attempt to change the memory block at <addr> to the new <size>.
  336.     Making a block smaller will always work, but making it larger
  337.     may fail if there is not enough free memory.  If there is not
  338.     enough memory, NULL is returned and the block will still reside
  339.     at <addr>.  If realloc() succeeds, a pointer to the (possibly
  340.     moved) new block will be returned.  If <addr> is NULL, realloc()
  341.     will simply act like malloc().  If <size> is 0, and <addr> is
  342.     not NULL, realloc() will work like free().
  343.  
  344. void free(char *addr)
  345.     Release the memory block at <addr> back into the free memory pool.
  346.     WARNING: Unlike some implementations, you may not realloc() a block
  347.     which has been free()ed.
  348.  
  349. long msize(char *addr)
  350.     Return the size, in bytes, of the memory block at <addr>.  Note
  351.     that the size is a long value, since the block may have been
  352.     allocated by lalloc().
  353.  
  354. long memavail()
  355.     Return the size, in bytes, of the largest block of free memory
  356.     available for allocation.  Note that this value is a long.
  357.  
  358. char *alloca(unsigned int size)
  359.     Allocate at least <size> bytes of memory from the stack.  This
  360.     is "automatic" variable space and will be freed when the function
  361.     which called alloca() exits.  DO NOT use the other dynamic memory
  362.     functions like free(), realloc() and msize() on the block returned
  363.     by this function.  A pointer to the requested block is returned,
  364.     or NULL if there is not enough stack space available.
  365.  
  366. char *sbrk(int amount)
  367.     Move the "break" by <amount>.  The break is the line between the
  368.     top of the heap and the bottom of the stack.  The size of the
  369.     stack/heap area is defined by _STKSIZ.  Initially, the heap uses
  370.     zero bytes.  Since malloc() doesn't use the heap, often the heap
  371.     will stay that way.  This function moves the location of the break
  372.     by <amount> bytes, positive or negative, and returns the old value
  373.     of the break.  If this causes a collision with the stack, or a
  374.     negative value reduces the heap below zero bytes, NULL is returned
  375.     and the break is not moved.  Note that the heap pointer is moved by
  376.     EXACTLY the <amount> specified.  If you want to ensure that sbrk()
  377.     will return word-aligned memory segments, you must make sure that
  378.     <amount> is always even, since the heap is initially aligned properly.
  379.  
  380. int brk(char *address)
  381.     Set the "break" to <address>.  Return 0 for success.  If <address>
  382.     is not a valid break value, return -1 and don't move the break.
  383.  
  384.  
  385. FILE HANDLING:
  386.  
  387. int chdir(char *pathname)
  388.     Changes the current working directory to <pathname>.  If a
  389.     drive letter is specified in <pathname>, the current working
  390.     directory for that drive is set.  Returns 0 for success, or
  391.     a negative error code.
  392.  
  393. int mkdir(char *pathname)
  394.     Creates a new directory called <pathname>.  A drive letter may
  395.     be specified.  Returns 0 for success, or a negative error code.
  396.  
  397. int rmdir(char *pathname)
  398.     Removes an existing directory called <pathname>.  A drive letter may
  399.     be specified.  Returns 0 for success, or a negative error code.
  400.  
  401. char *fullpath(char *full, *part)
  402.     <part> is a (possibly) ambiguous file/path specification.  A
  403.     non-ambiguous file/path spec is created which includes a drive
  404.     letter and all intermediate sub-directories.  If the partial
  405.     specification is not valid, NULL is returned, otherwise a
  406.     pointer to <full> is returned.  If NULL is specified for <full>,
  407.     an internal buffer is used and a pointer to it is returned.
  408.  
  409. char *getcwd(char *buffer, int size)
  410.     Get the full pathname of the current working directory.  This
  411.     value will ALWAYS end with a '\\' character.  <pathbuf> is a
  412.     pointer to a buffer of <size> bytes that will be used to store
  413.     the current working directory.  If <buffer> is NULL, a buffer
  414.     of <size> bytes will be malloc()ed.  The function returns a
  415.     pointer to the buffer for success, or NULL for failure, either
  416.     because malloc() failed, or the value is larger than <size>.
  417.     This function uses fullpath() to get the pathname, therefore
  418.     the buffer internal to fullpath() is overwritten.
  419.  
  420. int access(char *name, int amode)
  421.     Return non-zero if a file with the given <name> can be accessed
  422.     in the given <amode>.  Possible <amode> values are:
  423.         0x00        file exists
  424.         0x02        file can be written
  425.         0x04        file can be read
  426.         0x06        file can be read and written
  427.  
  428. char *findfile(char *afn[, *ext])
  429.     Return full file spec for <afn> if found. If <afn> has no extension,
  430.     extensions from <ext> are tried until a match is found, or the list
  431.     ends.  <ext> is a list of extensions separated by '\0' characters
  432.     and ending with an additional '\0', ie. ".ttp\0.tos\0.prg\0" (note
  433.     that the final null is added by the compiler to any string constant.
  434.     If <afn> already has an extension, <ext> is not used.  If no matching
  435.     files are found, NULL is returned.  The pointer returned when a match
  436.     is found points to a buffer which is internal to fullpath().  If you
  437.     want to save the value returned, you must make a copy before the
  438.     buffer is overwritten by subsequent calls.  Note: several dLibs
  439.     functions call filefind(), so don't make too many assumptions about
  440.     how long the internal buffer is going to stay valid.
  441.  
  442. char *pfindfile(char *path, *afn[, *ext])
  443.     Like findfile() but search all directories (separated by ',' or ';')
  444.     in <path>.  If <path> is NULL, the "PATH" environment variable is
  445.     used instead.  If <afn> specifies a drive or directory, <path> is
  446.     not used.  The internal buffer for findfile() is used by pfindfile().
  447.  
  448. char *wildcard(char *pathname)
  449.     Return matches for a wildcard filename.  If <pathname> is not
  450.     NULL, the first file which matches <pathname> will be returned.
  451.     The <pathname> may contain wildcards only in the filename portion,
  452.     not in any sub-directories.  Subsequent calls to wildcard() with
  453.     a NULL argument return the next matching filename.  NULL is
  454.     returned when no more files match.  Note: the pointer returned
  455.     points to an internal buffer which is overwritten with each
  456.     call.  It should not be modified, and should be copied into a
  457.     safe place if you want to save the value.
  458.  
  459. char *_splitpath(char *src, *drive, *path, *file, *ext)
  460.     Parse the <src> filename into component parts. Returns <src>.
  461.     If any of the component pointers is NULL, that component will
  462.     be parsed, but not saved.  If a given component does not exists
  463.     int the <src> string, the component will be empty, (ie.: "").
  464.     The <drive> component will be a drive letter followed by a colon,
  465.     (ie.: "a:").  The <path> component will be the subdirectory names
  466.     leading up to the filename, but will not include a trailing '\'
  467.     unless the path the simply the root path "\", and there will only
  468.     be a leading '\' if the path is fully qualified, or "rooted", ie.:
  469.     "\this\is\a\path\name".  The <file> component is the base filename
  470.     without any extension, ie.: "filename".  The <ext> component is
  471.     the file extention with no leading '.', ie.: "txt".  Recommended
  472.     sizes for the components is Drive[4], Path[128], File[10], Ext[4].
  473.  
  474. char *_makepath(char *dst, *drive, *path, *file, *ext)
  475.     Build the <dst> filename from component parts. Returns <dst>.
  476.     This function is basically in inverse of _splitpath(), and will
  477.     accept the components parsed by _splitpath() as input.  It will
  478.     also allow a little more flexibility in that it will treat any
  479.     component which is a NULL pointer as an empty field, and the
  480.     <path> component may optionally have a trailing '\'.
  481.  
  482. char *tmpnam(char *s)
  483.     Generate a unique filename to be used for a temporary file.
  484.     The filename will have the form "TEMP$nnn.TMP" where "nnn" is a
  485.     sequence of numeric digits.  The name will unique in the current
  486.     working directory.  If <s> is NULL, space will be obtained from
  487.     malloc() to store the filename and thus must be free()'d by the
  488.     caller.  If <s> is not NULL, the filename will be copied into the
  489.     buffer provided.  This function returns NULL for failure, or a
  490.     pointer to the filename for success.
  491.  
  492. char *tempnam(char *dir, *pfx)
  493.     This function is similar to tmpnam(), but is somewhat more flexible.
  494.     <dir> specifies the directory part of the filename.  If <dir> is
  495.     NULL, the TMPDIR environment variable will be used.  If TMPDIR is
  496.     not found, the current directory is used.  <pfx> specifies the
  497.     filename prefix (up to 5 characters).  The form of the filename
  498.     will be "dir\pfxnnn.TMP", similar to tmpnam().  The storage for
  499.     the filename is always obtained from malloc(), so the caller must
  500.     free() it after use.  This function returns NULL for failure, or a
  501.     pointer to the fully expanded filename for success.
  502.  
  503. int stat(char *name, struct stat *statbuf)
  504.     Search for file <name> and load <statbuf> with information
  505.     about that file, if it is found.  Return 0 if found, or
  506.     ERROR (-1) if no file/directory matched <name>.  Volume
  507.     labels are not included in the search.  The file <stat.h>
  508.     must be included if you use this functions, since it defines
  509.     struct stat.
  510.  
  511. long fsize(char *name)
  512.     Return the size of the file <name> in bytes.  Note that this
  513.     is a long value.  Return -1L if the file is not found.
  514.  
  515. int isatty(int handle)
  516.     Return non-zero if <handle> refers to a character device.
  517.     Negative handles always refer to character devices.
  518.  
  519. int creat(char *filename, int pmode)
  520.     Create a new file with the given <filename>.  If a file with
  521.     the name already exists, it will be truncated to zero bytes.
  522.     Since the OS doesn't do this properly, the file is actually
  523.     deleted and then re-created.  <pmode> specifies the attributes
  524.     initially given to the file.  Valid <pmode> values are:
  525.         0x00            normal, read/write
  526.         S_ISRO            read only
  527.         S_IFHID            hidden file
  528.         S_IFSYS            system file
  529.         S_ISVOL            volume label
  530.     If S_ISVOL mode is specified, it must be the only mode given.
  531.     Other modes may be combined with the | operator.  The <stat.h>
  532.     file contains information useful with this function.
  533.  
  534. int chmod(char *filename, int pmode)
  535.     Change the mode attribute of <filename> to <pmode>.  Values for
  536.     <pmode> are the same as for the creat() function.  Returns 0 for
  537.     success, or a negative error code.
  538.  
  539. int open(char *filename, int iomode[, pmode])
  540.     Attempt to open <filename> with the given <iomode>.  A file handle
  541.     is returned if the open succeeds.  A negative error code is returned
  542.     for errors.  Valid <iomode> values are:
  543.         O_RDONLY    read mode
  544.         O_WRONLY    write mode
  545.         O_RDWR        read/write mode
  546.     In addition to the (mutually exclusive) modes above, one or more
  547.     of the following options may be |-ed with <iomode>:
  548.         O_APPEND    start file pointer at end of file
  549.         O_TRUNC        if file exists, truncate to 0 length
  550.         O_CREAT        creat() file if none exists (uses <pmode>)
  551.         O_EXCL        return EEXIST if file exists and
  552.                 O_CREAT is specified (exclusive mode).
  553.     Note: It is possible to open the character devices "con:", "aux:",
  554.     and "prn:" with this call, and negative handles (-1..-3) will be
  555.     returned.  Error returns are always < -3.  The <fcntl.h> file
  556.     contains iomode constants.  The <stat.h> file contains pmode
  557.     constants.
  558.  
  559. int close(int h)
  560.     Close file referenced by the file handle <h>.  Return 0 for
  561.     success, or a negative error code.
  562.  
  563. int dup(int handle)
  564.     Return a second file handle which refers to the same file as
  565.     the given <handle>. (cf: dup2)
  566.  
  567. int dup2(int handle1, int handle2)
  568.     Force <handle2> to refer to the same file as <handle1>.  Return
  569.     0 for success, or a negative error code.  Both dup() and dup2()
  570.     are direct calls to Fdup() and Fforce() GEMDOS calls.  Refer to
  571.     your GEMDOS documentation for further information.
  572.  
  573. int remove(char *filename)
  574.     Delete <filename>, if it exists.  Return 0 for success, or a
  575.     negative error code.
  576.  
  577. int rename(char *oldname, *newname)
  578.     Change the name of file <oldname> to <newname>.  You may use this
  579.     function to move files from one directory (pathname) to another,
  580.     but not from one drive to another.  Return 0 for success, or a
  581.     negative error code.
  582.  
  583. long lseek(int h, long offset, int origin)
  584.     Move file pointer for file <h> to specified location.  <origin>
  585.     specifies the starting point for the <offset> distance.  Valid
  586.     <origin> values are:
  587.         SEEK_SET    from beginning of file    (0)
  588.         SEEK_CUR    from current location    (1)
  589.         SEEK_END    from end of file    (2)
  590.     The <offset> value is the distance in bytes from the origin.
  591.     The final file position, or a negative error code, is returned.
  592.  
  593. long tell(int h)
  594.     Return the current file position for the file <h>.
  595.  
  596. FILE *fopen(char *filename, char *mode)
  597.     Open <filename> as a stream file.  This is the normal open way
  598.     to open a file.  The <mode> is a string specifying the mode(s)
  599.     that are relevent to the file open.  Valid <mode> characters are:
  600.         r        read mode
  601.         w        write mode
  602.         a        append mode
  603.         b        binary mode
  604.         t        text (translated) mode
  605.     At least one of "r", "w" or "a" must be specified.  "t" is assumed
  606.     and indicates that <nl> is translated to <cr><lf> on output and
  607.     vica-versa on input.  If the stream is a character device, the
  608.     translation is slightly different.  The output translation is the
  609.     same, but on input <cr> and <lf> both become <nl> in all cases.
  610.     The "b", for binary mode, overides "t" and indicated that characters
  611.     are not translated during i/o operations.  "a" represents append
  612.     mode and means that the file pointer will initially be placed at
  613.     the end of the file.  "w" mode will create a file if it doesn't
  614.     exists, or zero an existing file.  If "r" is the only mode specified,
  615.     the file must already exist.  A (FILE *) is returned if the open
  616.     succeeds, or NULL if it fails.
  617.  
  618. FILE *freopen(char *filename, char *mode, FILE *fp)
  619.     Closes the file associated with <fp> and opens the new file as with
  620.     fopen(), except that a new FILE structure is not created.  The
  621.     existing FILE structure pointed to by <fp> is re-initialized with
  622.     the new file information.  This is typically used to redirect i/o
  623.     to standard streams stdin, stdout, stderr, stdprn, stdaux.  <fp>
  624.     is returned for success, or NULL for failure.
  625.  
  626. FILE *fdopen(int h, char *mode)
  627.     Associates a stream with the already open file <h>.  The <mode>
  628.     values are the same as for fopen(), but MUST be compatible with
  629.     the mode in which <h> was open()ed.  This functions allows a file
  630.     opened with the low level open()/creat() calls to be used as a
  631.     buffered/translated stream.  A pointer to a FILE struct is returned,
  632.     or NULL for errors.
  633.  
  634. FILE *fopenp(char *filename, char *mode)
  635.     Find <filename> somewhere on the PATH and open it with <mode>.
  636.     Refer to the fopen() function for valid <mode> values.  If you
  637.     want to use a search path other than the PATH environment
  638.     variable, use the pfindfile() function to locate the file, and
  639.     pass that filename to fopen().  (cf: pfindfile, fopen)
  640.  
  641. int fclose(FILE *fp)
  642.     Close the stream <fp>, flushing the buffer.  Returns 0 on success.
  643.  
  644. void setbuf(FILE *fp, char *buf)
  645.     If <buf> is NULL, make <fp> unbuffered; else <buf> points to a buffer
  646.     of BUFSIZ characters to be used as the stream buffer for <fp>.
  647.  
  648. void setvbuf(FILE *fp, char *buf, int bmode, int size)
  649.     If <buf> is NULL or <bmode> is _IONBF, make <fp> unbuffered;
  650.     otherwise <buf> points to a buffer of <size> characters to be
  651.     used as the stream buffer for <fp>.  The <bmode> variable
  652.     indicates the type of buffering desired, as follows:
  653.         _IONBF        No buffering
  654.         _IOFBF        Full buffering (normal)
  655.         _IOLBF        Line buffering (not supported, same as _IOFBF)
  656.  
  657. int fseek(FILE *fp, long offset, int origin)
  658.     Operates like lseek(), except it works on streams.  Note that
  659.     stream file positions may be misleading due to translation of
  660.     <nl> characters during i/o.  ftell() may be used reliably with
  661.     fseek() to reposition a file to a prior location.  WARNING:
  662.     fseek() returns 0 for success, non-zero for failure, according
  663.     to the ANSI standard.  Some implementations use 0 for failure.
  664.     This function is maintained for compatibility with old programs.
  665.     fsetpos() should be used in new code.  (cf: fsetpos)
  666.  
  667. void rewind(FILE *fp)
  668.     Operates like fseek(fp, 0L, SEEK_SET), except it also clears the
  669.     end-of-file and error flags for <fp>.  There is no return value.
  670.  
  671. long ftell(FILE *fp)
  672.     Operates like tell(), except it works on streams.  Note that
  673.     stream file positions may be misleading due to translation of
  674.     <nl> characters during i/o.  This function is maintained for
  675.     compatibility with old programs.  fsetpos() should be used in
  676.     new code.  (cf: fsetpos)
  677.  
  678. int fgetpos(FILE *fp, fpos_t *pos)
  679.     Get the position of the stream <fp> and store it at the location
  680.     pointed to be <pos>.  This is the new X3J11 function to replace
  681.     ftell().  Returns 0 for success and ERROR for failure.
  682.  
  683. int fsetpos(FILE *fp, fpos_t *pos)
  684.     Set the position of the stream <fp> to the valued stored at the
  685.     location pointed to be <pos>.  Note that this function is only
  686.     required to work properly for a <pos> value which was previously
  687.     obtained by fgetpos() on the same stream.  This is the new X3J11
  688.     function to replace fseek().  Returns 0 for success and ERROR for
  689.     failure.
  690.  
  691. int fileno(FILE *fp)
  692.     Return the file handle associated with the stream <fp>.
  693.  
  694. int feof(FILE *fp)
  695.     Return non-zero if <fp>    is at end of file.
  696.  
  697. int ferror(FILE *fp)
  698.     Return non-zero if and error has occurred on <fp>.
  699.  
  700. void clearerr(FILE *fp)
  701.     Clear the error flag on <fp>.
  702.  
  703. sync()
  704.     Provided for compatibility.  #define'ed as a comment.
  705.  
  706.  
  707. INPUT/OUTPUT FUNCTIONS:
  708.  
  709. int read(int h, char *data, int length)
  710.     Read <length> bytes from the file reference by file handle <h>.
  711.     Data is stored in the buffer pointed to by <data>.  The number
  712.     of bytes actually read is returned, 0 for end of file, or a
  713.     negative error code.  Note that the maximum number of bytes
  714.     that can be read by this function is MAXINT.
  715.  
  716. long lread(int h, char *data, long length)
  717.     Same as read(), but uses a long value for number of bytes to read.
  718.  
  719. int write(int h, char *data, int length)
  720.     Write <length> bytes to the file reference by file handle <h>.
  721.     Data is written from the buffer pointed to by <data>.  The number
  722.     of bytes actually written is returned, or a negative error code.
  723.     Note that the maximum number of bytes that can be written by
  724.     this function is MAXINT.
  725.  
  726. long lwrite(int h, char *data, long length)
  727.     Same as write(), but uses a long value for number of bytes to write.
  728.  
  729. int fread(char *data, int size, int count, FILE *fp)
  730.     Read <count> items of <size> characters each from stream <fp>.
  731.     Data is stored in the buffer pointed to by <data>.  The number of
  732.     full items actually read is returned, or a negative error code.
  733.     This call DOES NOT translate characters, even if the stream is
  734.     opened in translate mode.
  735.  
  736. int fwrite(char *data, int size, int count, FILE *fp)
  737.     Write <count> items of <size> characters each to stream <fp>.
  738.     Data is read from the buffer pointed to by <data>.  The number of
  739.     full items actually written is returned, or a negative error code.
  740.     This call DOES NOT translate characters, even if the stream is
  741.     opened in translate mode.
  742.  
  743. int fgetc(FILE *fp)
  744.     Get a character from <fp>.  Returns the character or EOF.
  745.  
  746. int fungetc(char c, FILE *fp)
  747.     Push the character <c> back to be gotten by the next fgetc()
  748.     call on <fp>.  Only 1 character may be ungotten at a time on
  749.     each stream.  Subsequent calls to fungetc() will write over
  750.     the currently saved character.
  751.  
  752. int fputc(char c, FILE *fp)
  753.     Put the character <c> to the stream <fp>.
  754.  
  755. int fflush(FILE *fp)
  756.     Flush the file i/o buffer of the stream <fp>.  The buffer is
  757.     automatically flushed when it is full, the stream is closed,
  758.     or the program terminates through exit().  This function has
  759.     no effect if the stream in unbuffered.  Call this function
  760.     before switching between reading and writing on a stream which
  761.     is opened for both.
  762.  
  763. int getc(FILE *fp)
  764.     Same as fgetc() but implemented as a macro.
  765.  
  766. int ungetc(char c, FILE *fp)
  767.     Same as fungetc() but implemented as a macro.
  768.  
  769. int putc(char c, FILE *fp)
  770.     Same as fputc() but implemented as a macro.
  771.  
  772. int getw(FILE *fp)
  773.     Get a 2-byte value from the stream <fp>.  The high-order byte is
  774.     read first.  Use feof() to test for end-of-file.
  775.  
  776. int putw(int n, FILE *fp)
  777.     Put the 2-byte value <n> to the stream <fp>.  The high-order byte
  778.     is written first.
  779.  
  780. int getl(FILE *fp)
  781.     Get a 4-byte value from the stream <fp>.  The high-order byte is
  782.     read first.  Use feof() to test for end-of-file.
  783.  
  784. int putl(long n, FILE *fp)
  785.     Put the 4-byte value <n> to the stream <fp>.  The high-order byte
  786.     is written first.
  787.  
  788. int getchar()
  789.     Same as "fgetc(stdin)".
  790.  
  791. int ungetchar(char c)
  792.     Same as "fungetc(c, stdin)".  Note that this name will conflict
  793.     with any function beginning "ungetch..." due to having only 7
  794.     significant characters in external identifiers.
  795.  
  796. int putchar(char c)
  797.     Same as "fputc(c, stdin)".
  798.  
  799. int cfg_ch(int cfg)
  800.     Configure getch()/putch() operation.  The following are legal
  801.     values for <cfg> and may be combined with the | operator:
  802.         _CIOB        Use BIOS level i/o calls
  803.         _CIOCH        8-bit character codes only (cf:getch)
  804.         _CIOVT        Enable VT-52 escape sequence processing
  805.     The initial configuration value at run time is _CIOCH.  This
  806.     function returns the previous configuration value, and if <cfg>
  807.     is -1 the value is not set.
  808.  
  809. int getch()
  810.     Machine dependent console input function.  This function normally
  811.     gets a character from the keyboard by calling the GEMDOS "Cconin"
  812.     function.  If cfg_ch() is given the _CIOB option, input is gotten
  813.     from the BIOS "Bconin" function instead.  The BIOS level functions
  814.     don't process ^C, ^S or ^Q, while the GEMDOS functions do.  The
  815.     most common use for getch() is when keyboard scan codes are needed
  816.     to process special function keys.  The return value from getch()
  817.     consists of the scan code in the high-order byte, and the ascii
  818.     character code in the low-order byte.  If cfg_ch() is given the
  819.     _CIOCH option, the return value is always an 8-bit quantity,
  820.     either the scan code with the 8th bit set, or the ascii code with
  821.     the 8th bit clear.  This is somewhat less informative, since the
  822.     scan code form is returned only if the ascii value is 0, but is the
  823.     default configuration value for compatability with Microsoft C.
  824.     In any case, the global unsigned long variable "_getch" will contain
  825.     the full character code value returned by the OS.
  826.  
  827. int getche()
  828.     Same as getch() but calls putch() to echo the character.
  829.  
  830. char putch(char c)
  831.     Machine dependent (typically quite fast) console output function.
  832.     This function normally puts a character to the console by calling
  833.     the GEMDOS "Cconout" function.  If cfg_ch() is given the _CIOB
  834.     option, output is sent to the BIOS "Bconout" function instead.
  835.     The BIOS level functions don't process ^C, ^S or ^Q, while the
  836.     GEMDOS functions do.  At the BIOS level, the _CIOVT option to
  837.     cfg_ch() allows VT-52 escape code processing on output.  The
  838.     GEMDOS function always does VT-52 emulation.  The BIOS function
  839.     defaults to skipping this overhead, but if VT-52 emulation is
  840.     desired, it can still be used through the faster BIOS level
  841.     routine    by using the _CIOVT option.  Control codes, like '\b'
  842.     and '\r', are supported even without VT-52 emulation.  The return
  843.     value of this function is simply the character sent.
  844.  
  845. int kbhit()
  846.     Machine dependent function to detect if input is waiting for the
  847.     getch() function.  Returns non-zero if the console has data ready.
  848.  
  849. char *getln(char *ip, int (*get)(), int (*put)(), char *buffer, int limit)
  850.     Get a line of input from the user.  Allow simple editing of the line
  851.     with BS/DEL, ESC, and CR/LF to terminate input.  Characters are
  852.     retreived by a (*get)(ip) and echoed with (*put)(c).  A pointer to
  853.     <buffer> is returned in any case.  This function is no longer
  854.     needed to handle editable i/o from stdin, since the pseduo-tty
  855.     driver code built into fgetc() now handles line editing, but this
  856.     function is still useful if you want to supply your own get/put
  857.     functions (like curses?).
  858.  
  859. char *fgets(char *data, int limit, FILE *fp)
  860.     Get data from <fp> and puts it in the <data> buffer.  At most,
  861.     <limit>-1 characters will be read.  Input will also be terminated
  862.     when a newline is read.  <data> will be '\0' terminated and the
  863.     newline, if read, will be included.  A pointer to the start of
  864.     <data> is returned, or NULL for EOF.
  865.  
  866. void fputs(char *data, FILE *fp)
  867.     Write the characters in <data> to the stream <fp>.  A newline
  868.     WILL NOT be added.
  869.  
  870. char *gets(char *data)
  871.     Get data from stdin and puts it in the <data> buffer.  Input is
  872.     terminated when a newline is read.  The    newline will be replaced
  873.     by a '\0' to terminate the string.  A backspace character will
  874.     remove the preceeding character from the buffer, but will not
  875.     backspace past the start of the buffer.  A pointer to the start
  876.     of <data> is returned, or NULL for EOF.
  877.  
  878. void puts(char *data)
  879.     Write the characters in <data> to stdout.  A newline WILL be
  880.     written after the data.
  881.  
  882. void cputs(char *data)
  883.     Write the characters in <data> directly to the console using the
  884.     system dependent putch() function.  A newline WILL NOT be written
  885.     after the data.
  886.  
  887. int fprintf(FILE *fp, char *fmt[, arg1, ..., argN])
  888.     Formatted output to the stream <fp>.  See the _printf() function
  889.     for a description of the <fmt> formatting string.
  890.  
  891. int printf(char *fmt[, arg1, ..., argN])
  892.     Formatted output to the stdout stream.  See the _printf() function
  893.     for a description of the <fmt> formatting string.
  894.  
  895. int sprintf(char *buf, *fmt[, arg1, ..., argN])
  896.     Formatted output to the string <buf>.  See the _printf() function
  897.     for a description of the <fmt> formatting string.
  898.  
  899. int cprintf(char *fmt[, arg1, ..., argN])
  900.     Formatted output directly to the console.  This functions uses the
  901.     system dependent putch() for output.  See the _printf() function
  902.     for a description of the <fmt> formatting string.
  903.  
  904. int vfprintf(FILE *fp, char *fmt, va_list ap)
  905.     Formatted output to the stream <fp> with a variable argument list.
  906.     See _printf() for formatting and va_start() for stdarg explaination.
  907.  
  908. int vprintf(FILE *fp, va_list ap)
  909.     Formatted output to the stdout stream with a variable argument list.
  910.     See _printf() for formatting and va_start() for stdarg explaination.
  911.  
  912. int vsprintf(char *buf, *fmt, va_list ap)
  913.     Formatted outout to the string <buf> with a variable argument list.
  914.     See _printf() for formatting and va_start() for stdarg explaination.
  915.  
  916. int fscanf(FILE *fp, char *fmt[, arg1, ..., argN])
  917.     Formatted input from the stream <fp>.  See the _scanf() function
  918.     for a description of the <fmt> formatting string.
  919.  
  920. int scanf(char *fmt[, arg1, ..., argN])
  921.     Formatted input from the stdin stream.  See the _scanf() function
  922.     for a description of the <fmt> formatting string.
  923.  
  924. int sscanf(char *buf, *fmt[, arg1, ..., argN])
  925.     Formatted input from the string <s>.  See the _scanf() function
  926.     for a description of the <fmt> formatting string.
  927.  
  928. int _tttty(FILE *fp)
  929.     "Teeny Tiny TTY" driver function.  This function is internal to
  930.     dLibs, but it's name is documented to allow you to replace it with
  931.     a tty driver of your own.  It's operation can be best understood
  932.     by reading and UNDERSTANDING the code in the routine provided.  In
  933.     brief, this function is supposed to read from <fp>, up to a newline
  934.     character, putting the character in the FILE buffer, and return the
  935.     number of characters read (similar to _fillbuf() in some systems).
  936.     If the stream is in binary mode, a full buffer is to be read, with
  937.     no translation.  If the stream is unbuffered, characters are also
  938.     untranslated, but ^C on input is checked for, however, the code
  939.     which calls this function will translate carriage return characters
  940.     into newlines and ^Z will cause EOF.  Effectively, this means that
  941.     line editing is not allowed if the stream in unbuffered, but most
  942.     translation is done.  Note that this mode of operation is the least
  943.     likely to produce unix-like results, particularly in the way some
  944.     control characters are echoed.  It is recommended that either binary
  945.     mode, or buffered and translated mode be used.
  946.  
  947.  
  948. FORMATTING/TYPE CONVERSION:
  949.  
  950. int _printf(char *op, int (*put)(), char *fmt, int *args)
  951.     This function does all the work for printf(), et al.  Many systems
  952.     don't provide direct access to this function (or it's equivalent),
  953.     but it is useful for writing your own printf()-like functions.
  954.     Since this is a non-standard interface, and v[sf]print() is now
  955.     available, you should probably use the stdarg functions instead.
  956.     <fmt> points to a format control string.  <args> pointers to a
  957.     list of arguments.  The format string is used to create and output
  958.     stream with the arguments.  The <put> function is used to output
  959.     each character.  The <op> parameter is given to the <put> function
  960.     to specify the output stream.  Calls to <put> are of the form:
  961.     "(*put)(c, op);" where <c> is the character to output.  The format
  962.     string is composed of characters and format specifications.  The
  963.     '%' character introduces a format specifier.  The general form of
  964.     a format specifier is:
  965.       %[-][ |+][0][<width>|*][.[<precision>|*]][l]{d|i|u|o|x|p|b|c|s}
  966.     The '-' specifies left justification.  The ' ' or '+' specifies
  967.     the character which preceeds positive numeric values.  The '0'
  968.     specifies that numeric fields will be padded with '0' rather than
  969.     ' '.  The <width> field is a numeric value specifying a minimum
  970.     field width.  The <precision> field is a numeric value specifying
  971.     the maximum number of data characters to display.  If '*' is
  972.     specified for the width or the precision, an "int" value is taken
  973.     from the argument list and used for that value.  If no width is
  974.     specified, the field width varies according to the data width.  If
  975.     no precision is specified, all data characters are included in the
  976.     data width.  If the data width exceeds the field width, the field
  977.     width will expand to allow all data characters to be printed.
  978.     Including the 'l' or capitalizing the trailing character specifies
  979.     that the associated value is a "long" type.  The trailing character
  980.     specifies the format type, as follows:
  981.         d    Signed decimal integer
  982.         i    same as 'd'
  983.         u    Unsigned decimal integer
  984.         o    Unsigned octal integer
  985.         x    Unsigned hexadecimal integer
  986.         b    Unsigned binary integer
  987.         p    Pointer (displayed in %06.8lX format)
  988.         c    Character
  989.         s    String
  990.     If the character following the '%' is not recognized, it is
  991.     simply passed along to the output stream, thus "%%" is used to
  992.     print a single '%' character.
  993.  
  994. char *ltoa(long n, char *buffer, int radix)
  995.     Convert the long value <n> to a string in <buf> using <radix>
  996.     as the number base.  If <n> is negative, '-' will be the first
  997.     character in <buf>.  A pointer to <buf> is returned.
  998.  
  999. char *ultoa(unsigned long n, char *buffer, int radix)
  1000.     Convert the unsigned long value <n> to a string in <buf> using
  1001.     <radix>    as the number base.  A pointer to <buf> is returned.
  1002.  
  1003. char *itoa(int n, char *buffer, int radix)
  1004.     Convert the integer value <n> to a string in <buf> using <radix>
  1005.     as the number base.  If <n> is negative, '-' will be the first
  1006.     character in <buf>.  A pointer to <buf> is returned.
  1007.  
  1008. long atol(char *number)
  1009.     Convert the string <number> to a long value.  Leading whitespace
  1010.     is ignored, a leading +/- is optional.  Characters are processed
  1011.     until a non-digit is reached.  Return value is undefined in an
  1012.     overflow situation.
  1013.  
  1014. int atoi(char *number)
  1015.     Convert the string <number> to an int value.  Leading whitespace
  1016.     is ignored, a leading +/- is optional.  Characters are processed
  1017.     until a non-digit is reached.  Return value is undefined in an
  1018.     overflow situation.
  1019.  
  1020. long strtol(char *number, char **nptr, int base) 
  1021.     Convert the string <number> to a long value of base <base>.  Bases
  1022.     from 0 to 36 are allowed.  Leading whitespace is ignored, and a
  1023.     leading +/- is optional.  If the <base> is 0, a leading '0'
  1024.     indicates base 8 and a leading "0x" or "0X" indicates base 16.
  1025.     Characters are processed until a character is found which is not in
  1026.     the specified base.  If <nptr> is non-NULL, it will be set to point
  1027.     to the character which terminated the translation in <number>.
  1028.     Return value is undefined in an overflow situation.
  1029.  
  1030. unsigned long strtoul(char *number, char **nptr, int base)
  1031.     Convert the string <number> to an unsigned long value of base
  1032.     <base>.  Bases from 0 to 36 are allowed.  Leading whitespace is
  1033.     ignored.  If the <base> is 0, a leading '0' indicates base 8 and a
  1034.     leading "0x" or "0X" indicates base 16.  Characters are processed
  1035.     until a character is found which is not in the specified base.  If
  1036.     <nptr> is non-NULL, it will be set to point to the character which
  1037.     terminated the translation in <number>.  Return value is undefined
  1038.     in an overflow situation.
  1039.  
  1040. int _scanf(char *ip, int (*get)(), int (*unget)(), char *fmt, char **args)
  1041.     This function does all the work for scanf(), et al.  Many systems
  1042.     don't provide direct access to this function (or it's equivalent),
  1043.     but it is useful for writing your own scanf()-like functions.
  1044.     <fmt> points to a format control string.  <args> pointers to a
  1045.     list of arguments, each of which is the address of a variable in
  1046.     which input data may be stored.  The format string is used to
  1047.     control reading of characters from the <get> function.  As each
  1048.     character is needed <get> is called in the form "c = (*get)(ip);"
  1049.     where <c> is the character read (negative for errors) and <ip> is
  1050.     the auxiliary pointer specified by the <ip> parameter.  If a
  1051.     character needs to be un-gotten, a call to <unget> of the form
  1052.     "(*unget)(c, ip);" is made.  The format string is composed of
  1053.     characters and format specifications.  Any characters in <fmt>,
  1054.     except whitespace characters, which are not part of a format
  1055.     specifier are expected to be matched one-to-one by characters in
  1056.     the input stream.  Scanning terminates if a mismatch occurs or if
  1057.     any call to <get> results in an error.  Whitespace characters
  1058.     match 0 or more whitespace characters in the input stream.  The
  1059.     '%' character introduces a format specifier.  The general form of
  1060.     a format specifier is:
  1061.          %[*][<width>][l|h]{d|u|o|x|b|i|c|s}
  1062.     The '*' specifies that a field is to be scanned by not stored.
  1063.     No variable pointer should be provided for non-stored format
  1064.     specs.  The <width> field specifies that maximum number of
  1065.     characters to be process to fill the given format type.  Less
  1066.     than <width> characters will be processed if the field ends
  1067.     before <width> characters have been processed.  A field ends when
  1068.     either a whitespace character, or a character which does not fit
  1069.     the specified format, is read.  The preceding 'l' (or
  1070.     capitalizing the conversion character) specifies that the
  1071.     associated variable is a "long" type.  The trailing character
  1072.     specifies the format type, as follows:
  1073.         d Signed decimal integer
  1074.         u Unsigned decimal integer
  1075.         o Unsigned octal integer
  1076.         x Unsigned hexadecimal integer
  1077.         b Unsigned binary integer
  1078.         i Unsigned decimal/octal/hexadecimal/binary integer
  1079.         c Character
  1080.         s String
  1081.     If a <width> is specified with the 'c' format, exactly <width>
  1082.     characters (including whitespace) are read from the input stream,
  1083.     and written to a string.  No '\0' character is added If the
  1084.     character following the '%' is not recognized, it is expected to
  1085.     match the input stream as a non-format character, thus "%%" is
  1086.     used to match a single '%' character.
  1087.     One additional conversion is the brace-format.  Shown as "%[...]",
  1088.     the '...' represent a list of characters.  If the first character
  1089.     in the list is a '^', the field contains any characters -not- in
  1090.     the list (starting with the 1st character after the '^').  If the
  1091.     first character of the list is not a '^', then the field will
  1092.     only contain those characters found in the list.  A right brace 
  1093.     character (']') can be included as one of the list of characters
  1094.     by placing it as the first character in the list.  If the '^'
  1095.     negation character is the first character, the included brace
  1096.     should be the next character after the '^'.  For maximum
  1097.     portability, a range should be explicitly given (a good example
  1098.     would be "%[0123456789]"), but to allow for porting from
  1099.     systems with smarter scanf functions, this version of scanf
  1100.     also supports ranges represented using a <first>-<last>
  1101.     form (eg: "%[0-9]").  To use the first-last form, the
  1102.     character <first> must be lexically less than or equal to
  1103.     the character <last>.  If this rule is violated, or if the
  1104.     hyphen is the first or last character of the list, the
  1105.     hyphen will be assumed to be just another character in the
  1106.     list and no range expansion will be done.  The resulting
  1107.     string containing the characters in (or not in) the list
  1108.     will be null terminated.  It should be noted that, unlike
  1109.     most of the other formats, this conversion does allow the
  1110.     programmer to specify that whitespace characters will be
  1111.     included in the resulting string.
  1112.  
  1113. char *ctlcnv(char *string)
  1114.     Convert \<char> notation in <string> to actual characters.  This
  1115.     is useful for reading strings from a stream when you want to allow
  1116.     insertion of control character or other characters that may have
  1117.     special meaning otherwise, or may not otherwise be allowed.  The
  1118.     following formats are supported:
  1119.         \n        newline or linefeed
  1120.         \r        carriage return
  1121.         \0        null character (value 0)
  1122.         \b        backspace
  1123.         \t        horizontal tab
  1124.         \v        vertical tab
  1125.         \f        form feed
  1126.         \a        alarm (bell)
  1127.         \\        backslash
  1128.         \'        single quote
  1129.         \"        double quote
  1130.         \NNN        octal constant
  1131.         \xNN        hexadecimal constant
  1132.         \<nl>        "folded" line (both characters removed)
  1133.     A pointer to the modified <string> is returned.
  1134.  
  1135.  
  1136. STRING MANIPULATION:
  1137.  
  1138.     You should include <string.h> in your program if you use functions
  1139.     in this section.
  1140.  
  1141. char *memmove(char *dest, char *source, int len)
  1142.     Copies the <source> block to the <dest>.  <len> bytes are
  1143.     always copied.  No terminator is added to <dest>.  A pointer
  1144.     to <dest> is returned.  Overlap checking IS done.
  1145.  
  1146. char *lmemmove(char *dest, char *source, long len)
  1147.     Same as memmove() except a long value is used for <len>.
  1148.  
  1149. char *memcpy(char *dest, char *source, int len)
  1150.     Copies the <source> block to the <dest>.  <len> bytes are
  1151.     always copied.  No terminator is added to <dest>.  A pointer
  1152.     to <dest> is returned.  Overlap checking IS NOT done.
  1153.  
  1154. char *lmemcpy(char *dest, char *source, long len)
  1155.     Same as memcpy() except a long value is used for <len>.
  1156.  
  1157. char *memset(char *dest, char data, int len)
  1158.         Set <len> bytes of <dest> to <data>.  A pointer to <dest>
  1159.     is returned.
  1160.  
  1161. int memcmp(char *blk1, char *blk2, int len)
  1162.     Lexicographically compare the two blocks.  Return a value
  1163.     indicating the relationship between the blocks.  Possible
  1164.     return values are:
  1165.         negative    blk1 < blk2
  1166.         0        blk1 == blk2
  1167.         positive    blk1 > blk2
  1168.     <len> bytes are always compared.
  1169.  
  1170. int memicmp(char *blk1, char *blk2, int len)
  1171.     Compare blocks as with memcmp(), but ignore the case of any
  1172.     alphabetic characters.
  1173.  
  1174. char *memccpy(char *dst, char *src, char c, int cnt)
  1175.     Copy bytes from <src> to <dst> until either <cnt> bytes have been
  1176.     copied, or the character <c> has been copied.  If <c> is found,
  1177.     a pointer to the character following <c> in <dst> is returned, or
  1178.     NULL is <cnt> reaches 0 before <c> is found.
  1179.  
  1180. char *memchr(char *buf, char c, int cnt)
  1181.     Search the first <cnt> bytes of <buf> for <c>.  Returns a pointer to
  1182.     the matching character, or NULL if not found.
  1183.  
  1184. char *bzero(char *buf, int cnt)
  1185.     Zero <cnt> characters in <buf>.  Returns <buf>.
  1186.  
  1187. int strlen(char *string)
  1188.     Returns the number of characters in a string, not including the
  1189.     terminating '\0'.
  1190.  
  1191. char *strcpy(char *dest, char *source)
  1192.     Copies the <source> string to the <dest> including the '\0'.  A
  1193.     pointer to the start of <dest> is returned.
  1194.  
  1195. char *strncpy(char *dest, char *source, int limit)
  1196.     Copies the <source> string to the <dest>.  At most, <limit>
  1197.     characters are copied.  If <source> ends before <limit> characters
  1198.     have been copied, the '\0' is copied, otherwise <dest> is not
  1199.     terminated by the copy.
  1200.  
  1201. char *strpcpy(char *dest, char *start, char *stop)
  1202.     Copies characters from <start> up to <stop> into <dest>.  The
  1203.     character pointed to by <stop> is not copied, and MUST be in the
  1204.     same string as <start>.  The <dest> pointer is returned.
  1205.  
  1206. char *strdup(char *string)
  1207.     Create a copy of <string> and return a pointer to the copy.
  1208.     Storage for the copy is obtained from malloc().
  1209.  
  1210. char *strset(char *string, char c)
  1211.     Fill <string> with <c> up the the terminating '\0' of <string>.
  1212.  
  1213. char *strnset(char *string, char c, int n)
  1214.     Fill at most <n> characters of <string> with <c>, up the the
  1215.     terminating '\0' of <string>.
  1216.  
  1217. char *substr(char *dest, char *source, int start, int end)
  1218.     Copy characters from <source> to <dest> starting with character
  1219.     <start> and ending with <end>.  A pointer to <dest>, which will
  1220.     be '\0' terminated, is returned.
  1221.  
  1222. char *subnstr(char *dest, char *source, int start, int length)
  1223.     Copy <length> characters from <source> to <dest> starting with
  1224.     character <start>.  A pointer to <dest>, which will be '\0'
  1225.     terminated, is returned.
  1226.  
  1227. char *strcat(char *dest, char *source)
  1228.     Concatenate <source> on the end of <dest>.  The terminator of
  1229.     <dest> will be overwritten by the first character of <source>.
  1230.     The termintor from <source> will be copied.  A pointer to
  1231.     the modified <dest> is returned.
  1232.  
  1233. char *strncat(char *dest, char *source, int limit)
  1234.     Concatenate <limit> characters from <source> onto <dest>.  If
  1235.     <source> contains less than <limit> characters, the length of
  1236.     source is used for <limit>.  The terminating '\0' is always
  1237.     added.  A pointer to <dest> is returned.
  1238.  
  1239. char *strupr(char *string)
  1240.     Convert all alphabetic characters in <string> to upper case.
  1241.  
  1242. char *strlwr(char *string)
  1243.     Convert all alphabetic characters in <string> to lower case.
  1244.  
  1245. char *strrev(char *string)
  1246.     Reverse the order of the characters in <string> in place.
  1247.  
  1248. int strcmp(char *str1, char *str2)
  1249.     Lexicographically compare the two strings.  Return a value
  1250.     indicating the relationship between the strings.  Possible
  1251.     return values are:
  1252.         negative    str1 < str2
  1253.         0        str1 == str2
  1254.         positive    str1 > str2
  1255.  
  1256. int strncmp(char *str1, char *str2, int limit)
  1257.     Compare strings as with strcmp(), but limit comparison to the
  1258.     <limit> characters.
  1259.  
  1260. int stricmp(char *str1, char *str2)
  1261.     Compare strings as with strcmp(), but ignore the case of any
  1262.     alphabetic characters.
  1263.  
  1264. int strnicmp(char *str1, char *str2, int limit)
  1265.     Compare strings as with strncmp(), but ignore the case of any
  1266.     alphabetic characters.
  1267.  
  1268. char *strstr(char *string, char *pattern)
  1269.     Return a pointer to the first occurance of <pattern> in <string>.
  1270.     NULL is returned if <pattern> is not found.
  1271.  
  1272. char *stristr(char *string, char *pattern)
  1273.     Same as strstr(), but ignore the case of any alphabetic characters.
  1274.  
  1275. char *strchr(char *string, char symbol)
  1276.     Return a pointer to the first occurance of <symbol> in <string>.
  1277.     NULL is returned if <symbol> is not found.  '\0' is included in
  1278.     the search.
  1279.  
  1280. char *strrchr(char *string, char symbol)
  1281.     Return a pointer to the last occurance of <symbol> in <string>.
  1282.     NULL is returned if <symbol> is not found.  '\0' is included in
  1283.     the search.
  1284.  
  1285. int strpos(char *string, char symbol)
  1286.     Return the index of the first occurance of <symbol> in <string>.
  1287.     -1 is returned if <symbol> is not found.
  1288.  
  1289. int strrpos(char *string, char symbol)
  1290.     Return the index of the last occurance of <symbol> in <string>.
  1291.     -1 is returned if <symbol> is not found.
  1292.  
  1293. int strspn(char *string, char *set)
  1294.     Return the length of the sub-string of <string> that consists
  1295.     entirely of characters found in <set>.  The terminating '\0'
  1296.     in <set> is not considered part of the match set.  If the first
  1297.     character if <string> is not in <set>, 0 is returned.
  1298.  
  1299. int strcspn(char *string, char *set)
  1300.     Return the length of the sub-string of <string> that consists
  1301.     entirely of characters not found in <set>.  The terminating '\0'
  1302.     in <set> is not considered part of the match set.  If the first
  1303.     character if <string> is in <set>, 0 is returned.
  1304.  
  1305. char *strpbrk(char *string, char *set)
  1306.     Return a pointer to the first occurance in <string> of any
  1307.     character in <set>.
  1308.  
  1309. char *strrpbrk(char *string, char *set)
  1310.     Return a pointer to the last occurance in <string> of any
  1311.     character in <set>.
  1312.  
  1313. char *strtok(char *string, char *delim)
  1314.     Return a token from <string>.  If <string> is not NULL, it is
  1315.     the beginning of a string from which tokens are to be extracted.
  1316.     Characters found in <delim> are skipped over to find the start
  1317.     of a token, characters are then accumulated until a character in
  1318.     <delim> is found, or the terminator of <string> is reached.
  1319.     A pointer to the '\0' terminated token is then returned.  Note
  1320.     that this function modifies <string> (by inserting '\0's) in
  1321.     the process.  Subsequent calls to strtok() may specify NULL as
  1322.     the <string> argument, in which case subsequent tokens are
  1323.     returned, or NULL if there are no more tokens.
  1324.  
  1325. char *strtrim(char *string, char *junk)
  1326.     Remove leading and trailing characters found in <junk>
  1327.     from <string>.  Return a pointer to the modified <string>.
  1328.  
  1329. char *stradj(char *string, int dir)
  1330.     Adjust <string> by adding space if <dir> is positive, or removing
  1331.     space if <dir> is negative.  The magnitude of <dir> is the number
  1332.     of character positions to add or remove.  Characters are added or
  1333.     removed at the beginning of <string>.  A pointer to the modified
  1334.     <string> is returned.
  1335.  
  1336. int strrpl(char *string, char *ptrn, char *rpl, int n)
  1337.     Replace at most <n> occurances of <ptrn> in <string> with <rpl>.
  1338.     If <n> is -1, replace all.  Return the number of replacments.
  1339.  
  1340. int strirpl(char *string, char *ptrn, char *rpl, int n)
  1341.     Same as strrpl() except ignore the case of alphabetic characters.
  1342.  
  1343.  
  1344. CHARACTER FUNCTIONS:
  1345.  
  1346.     To use the functions in this section, you must include <ctype.h>
  1347.     in your source file.  Please note that the isxxxx() functions,
  1348.     except isascii(), only have defined results if isascii() is true.
  1349.     (ie. they only work properly on values 0x00 through 0x7F)
  1350.  
  1351. int toupper(int c)
  1352.     Convert <c> to upper case, if alphabetic.  This is implemeted
  1353.     as a macro and also as a function.  You may force use of the
  1354.     function version rather than the macro (which evaluates its
  1355.     argument twice) by using the "#undef toupper" directive.
  1356.  
  1357. int tolower(int c)
  1358.     Convert <c> to lower case, if alphabetic.  This is implemeted
  1359.     as a macro and also as a function.  You may force use of the
  1360.     function version rather than the macro (which evaluates its
  1361.     argument twice) by using the "#undef tolower" directive.
  1362.  
  1363. MACRO _toupper(int c)
  1364.     This macro should be used only if <c> is known to be lower case.
  1365.     It converts <c> to upper case.  Results are undefined if converting
  1366.     a character which is not lower case.
  1367.  
  1368. MACRO _tolower(int c)
  1369.     This macro should be used only if <c> is known to be upper case.
  1370.     It converts <c> to lower case.  Results are undefined if converting
  1371.     a character which is not upper case.
  1372.  
  1373. MACRO toascii(int c)
  1374.     Convert <c> to 7-bit ascii, putting it into the range 0x00..0x7F.
  1375.  
  1376. MACRO isalnum(int c)
  1377.     Return non-zero if <c> is '0'..'9','A'..'Z','a'..'z'.
  1378.  
  1379. MACRO isalpha(int c)
  1380.     Return non-zero if <c> is 'A'..'Z','a'..'z'.
  1381.  
  1382. MACRO isascii(int c)
  1383.     Return non-zero if <c> is 0x00..0x7F.
  1384.  
  1385. MACRO iscntrl(int c)
  1386.     Return non-zero if <c> is 0x00..0x1F,0x7F.
  1387.  
  1388. MACRO isdigit(int c)
  1389.     Return non-zero if <c> is '0'..'9'.
  1390.  
  1391. MACRO isgraph(int c)
  1392.     Return non-zero if <c> is 0x21..0x7E.
  1393.  
  1394. MACRO islower(int c)
  1395.     Return non-zero if <c> is 'a'..'z'.
  1396.  
  1397. MACRO isprint(int c)
  1398.     Return non-zero if <c> is 0x20..0x7E.
  1399.  
  1400. MACRO ispunct(int c)
  1401.     Return non-zero if <c> is not iscntrl(), isalnum() or isspace().
  1402.  
  1403. MACRO isspace(int c)
  1404.     Return non-zero if <c> is 0x09..0x0D,0x20.
  1405.  
  1406. MACRO isupper(int c)
  1407.     Return non-zero if <c> is 'A'..'Z'.
  1408.  
  1409. MACRO isxdigit(int c)
  1410.     Return non-zero if <c> is '0'..'9','A'..'F','a'..'f'.
  1411.  
  1412.  
  1413. DATE/TIME FUNCTIONS:
  1414.  
  1415.     To use the functions in this section, you must include <time.h>
  1416.     in your source file.
  1417.  
  1418. time_t time(time_t *rawtime)
  1419.     Get the current system clock date/time value.  Altough the value
  1420.     of this function is compatible with the ANSI proposed standard,
  1421.     on some systems (notably System V), this function returns the
  1422.     number of seconds elapsed since 00:00:00 GMT on Jan 1, 1970.
  1423.     This implementation returns an encoded date/time value instead.
  1424.     Therefore any programs which depend on this value being a number
  1425.     of seconds will not work properly.  However, other functions in
  1426.     this section which make use of the raw time value returned by
  1427.     time() are implemented to be compatible with this encoding, and
  1428.     will work properly.  In addition to returning the raw time value,
  1429.     if the <rawtime> pointer is not NULL, the value is stored in
  1430.     the time_t variable <rawtime> points to.
  1431.  
  1432. char *ctime(time_t *rawtime)
  1433.     Convert <rawtime> to a string.  A 26 character fixed field string
  1434.     is created from the raw time value.  The following is an example
  1435.     of what this string might look like:
  1436.         "Wed Jul 08 18:43:07 1987\n\0"
  1437.     A 24-hour clock is used, and due to a limitation in the ST system
  1438.     clock value, only a resolution of 2 seconds is possible.  A pointer
  1439.     to the formatted string, which is held in an internal buffer, is
  1440.     returned.
  1441.  
  1442. struct tm *localtime(time_t *rawtime)
  1443.     Convert <rawtime> to fill time structure fields.  A pointer to an
  1444.     internal structure is returned.  Refer to <time.h> for the values
  1445.     of the various structure fields.
  1446.  
  1447. struct tm *gmtime(time_t *rawtime)
  1448.     Since there is not concept of "time zone" on the ST, this function
  1449.     returns NULL, as specified by the proposed ANSI standard.
  1450.  
  1451. char *asctime(struct tm *time)
  1452.     Convert <time> structure value to a string.  The same format, and
  1453.     the same internal buffer, as for ctime() is used for this function.
  1454.  
  1455. time_t mktime(struct tm *time)
  1456.     Convert <time> structure value to raw time format.
  1457.  
  1458. void stime(long *rawtime)
  1459.     Set the system clock to <rawtime>.
  1460.  
  1461. int utime(char *pathname, long *rawtime)
  1462.     Set the modification date of <pathname> to <rawtime>.  Returns zero
  1463.     for success, or a negative error code.
  1464.  
  1465. clock_t clock()
  1466.     Returns the current value of the system clock.  The difference
  1467.     of two clock() times, divded by CLK_TCK, will give you elapsed
  1468.     seconds.
  1469.  
  1470. clock_t start_timer(clock_t *t)
  1471.     Start a 200Hz timer.  This timer value can later be checked with
  1472.     time_since() to determine elapsed time.  These functions provide
  1473.     a very low-overhead way of timing events.
  1474.  
  1475. clock_t time_since(clock_t *t)
  1476.     Returns the number of 200Hz ticks since start_timer() was called
  1477.     for timer <t>.
  1478.  
  1479. void sleep(int dt)
  1480.     Suspend operation for <dt> seconds.  This is implemented as a
  1481.     start_timer()/time_since() tight loop waiting for the specified
  1482.     amount of time to pass.  In a multi-tasking environment, this
  1483.     function should be replaced by a call which will de-activate
  1484.     this task for a period of time, allowing other tasks to run.
  1485.  
  1486. void usleep(int dt)
  1487.     Suspend operation for <dt> microseconds.  Works like sleep().
  1488.  
  1489.  
  1490. SEARCHING AND SORTING:
  1491.  
  1492. void qsort(char *base, int num, int size, int (*cmp)())
  1493.     Perform a recursive quick-sort on an array starting at <base>
  1494.     containing <num> elements of <size> bytes each.  The function
  1495.     pointed to by <cmp> is used to compare elements.  Pointers to
  1496.     two items in the array are passed to the function, which must
  1497.     return a number representing their relationship as follows:
  1498.         negative    item1 < item2
  1499.         0        item1 == item2
  1500.         positive    item1 > item2
  1501.     The qsort() function requires the use of a temporary data area
  1502.     that is large enough to hold <size> bytes.  The default space
  1503.     provided is 128 bytes large.  If your record size is larger than
  1504.     128 bytes, YOU MUST provide an alternative storage area.  The
  1505.     global variable "_qbuf" points to the storage qsort() will use.
  1506.     Setting "_qbuf" to NULL restores use of the internal buffer.
  1507.     This routine is optimized to avoid N*N sort times for ordered data.
  1508.     In fact, performance on sorted or reverse-sorted data is actually
  1509.     "best case" with this algorithm, rather than "worst case" as with
  1510.     most qsort() implementations.
  1511.  
  1512. void hsort(char *base, int num, int size, int (*cmp)())
  1513.     Perform an N*log(N) heap-sort on an array starting at <base>
  1514.     containing <num> elements of <size> bytes each.  The function
  1515.     pointed to by <cmp> is used to compare elements.  Pointers to
  1516.     two items in the array are passed to the function, which must
  1517.     return a number representing their relationship as follows:
  1518.         negative    item1 < item2
  1519.         0        item1 == item2
  1520.         positive    item1 > item2
  1521.     The hsort() function requires no extra storage, is not recursive,
  1522.     and has an almost constant N*log(N) sort time.  In the average
  1523.     case, it is about half as fast as qsort() on random data.  If
  1524.     portability is a concern, it should be noted that qsort() is
  1525.     almost always available, but hsort() is not.
  1526.  
  1527. char *bsearch(char *key, char *base, int num, int size, int (*cmp)())
  1528.     Perform a binary search for <key> on the sorted data at <base>.
  1529.     <num>, <size> and <cmp> are like the corresponding parameters
  1530.     to qsort().  A pointer to the matching element is returned for
  1531.     success, or NULL for failure.  The global variable "_bsearch"
  1532.     will contain the index of either the matching element, or the
  1533.     index of the element that the <key> value should be inserted
  1534.     after.  The use of "_bsearch" is not supported by most
  1535.     implementations of bsearch().
  1536.  
  1537. char *lsearch(char *key, char *base, int *num, int size, int (*cmp)())
  1538.     Perform a linear search for <key> on the data at <base>. The
  1539.     <num>, <size> and <cmp> parameters are like the corresponding
  1540.     parameters to qsort().  A pointer to the first matching element
  1541.     is returned for success, or NULL for failure.  If <key> is not
  1542.     found, it will be added to the end of the array and <num> will
  1543.     be incremented.  Note that, unlike bsearch() and qsort(), the
  1544.     <num> parameter is a POINTER to a location which holds the
  1545.     number of elements to sort.
  1546.  
  1547. char *lfind(char *key, char *base, int *num, int size, int (*cmp)())
  1548.     Like lsearch(), but do not add elements which are not found.
  1549.     Note that <num> is a POINTER, even though it is not modified.
  1550.  
  1551.  
  1552. ERROR HANDLING FUNCTIONS:
  1553.  
  1554. int errno;
  1555.     This variable is set to zero when the program is loaded.  It is
  1556.     not zeroed by any library functions, but may be set to a non-zero
  1557.     error number by many of them (particularly the standard i/o and
  1558.     system service functions).  The meaning of this error number may
  1559.     be found in the symbolic #defines in <errno.h>, or by calling the
  1560.     seterror() functions as described below.  (cf: seterror)
  1561.  
  1562. void perror(char *msg)
  1563.     Write, to stderr, <msg> (if non-null and non-empty), followed by
  1564.     ": " and a system error messaged derived from the value of errno.
  1565.  
  1566. void perrorf(char *fmt[, arg1, ..., argN])
  1567.     Write, to stderr, the name of the program, followed by ": ",
  1568.     followed by a message formatted as by printf() from <fmt> and
  1569.     the optional arguments, followed by ": " and a system error
  1570.     message derived from the value of errno.  This is a non-standard
  1571.     extended version of perror().  (cf: printf, perror)
  1572.  
  1573. char *strerror(errnum)
  1574.     Return the system error message for error <errnum>.  If <errnum>
  1575.     is outside the range of valid error numbers, NULL is returned.
  1576.  
  1577.  
  1578. VARIABLE ARGUMENT LISTS:
  1579.  
  1580.     The macros in this section are defined in the <stdarg.h> header file.
  1581.  
  1582. typedef    ... va_list;
  1583.     This is the type for a variable argument list traversal variable.
  1584.  
  1585. MACRO va_start(list, param)
  1586.     This macro initializes the va_list variable <list> to begin
  1587.     traversing variable argument lists.  <param> is the last parameter
  1588.     in the function call before the variable arguments begin.  This
  1589.     parameter MUST NOT be a register variable.
  1590.  
  1591. MACRO va_arg(list, type)
  1592.     This macro retrieves a variable argument of type <type>, updates
  1593.     the va_list variable <list>, and returns the value of the retrieved
  1594.     argument.  The <type> should not be parenthesised.
  1595.  
  1596. MACRO va_end(list)
  1597.     This macro must be called after all desired variable arguments have
  1598.     been retrieved, to reset the context of the va_list variable <list>.
  1599.  
  1600.  
  1601. MISCELLANEOUS FUNCTIONS:
  1602.  
  1603. int getopt(int argc, char **argv, char *optstring)
  1604.     This function eases the processing of the command line.  Each call
  1605.     returns a character from <optstring>, with optarg set to a parameter
  1606.     if one is required; or a '?' indicating that an invalid option was
  1607.     found; or EOF indicating that all options have been processed.  The
  1608.     <argc> and <argv> parameters are (of course) the argc and argv values
  1609.     passed to main().  The <opstring> is a string of option characters.
  1610.     If an option takes a parameter, it is followed by a ':' in <optstring>,
  1611.     and the char *optarg variable (global) will be set to point to the
  1612.     parameter string from the command line.  For example, "bno:v" defines
  1613.     the valid option characters as 'b', 'n', 'o' and 'v', and 'o' takes
  1614.     a parameter.  All options must be preceeded (in the command line) by
  1615.     a '-' character.  A single '-' character is taken to indicate stdin
  1616.     as a file, and terminates the argument processing.  A "--" string
  1617.     indicated the end of options, and is skipped over.  When option
  1618.     processing is successfully completed, the global variable optind will
  1619.     contain the index into argv[] of the next argument to be processed.
  1620.     Subsequent arguments should be processed with a loop like this:
  1621.         while(optind < argc)
  1622.             process(argv[optind++]);
  1623.     If an error occurs during argument process, an error message is
  1624.     written to stderr and '?' is returned by getopt().  Your program
  1625.     should then give a usage message and abort.  If the global variable
  1626.     opterr is set to zero, no error message will be given, but '?' will
  1627.     still be returned.  Note that command lines accepted by getopt() are
  1628.     quite flexible.  The command lines "-b -v -o filename -- - file",
  1629.     "-vbofilename - file",  and "-ofilename -bv - file" all will return
  1630.     the 'b', 'v', and 'o' options with the parameter to 'o' set to
  1631.     "filename" and leave the arguments "-" and "file2" for further
  1632.     processing.  Please examine the sample program "echo.c" for an
  1633.     example of getopt() usage.
  1634.  
  1635. int rand()
  1636.     Return a pseudorandom number in the range 0..32767.  This
  1637.     function uses the system random number generator, but grabs
  1638.     it's value out of the middle to avoid the exactly 50%
  1639.     behavior of the lowest order bit.  Source code is also provided,
  1640.     though commented out, showing how to generate your own
  1641.     random number sequence if the system random numbers aren't
  1642.     sufficient or for porting these routines to another machine.
  1643.  
  1644. void srand(unsigned int seed)
  1645.     Seed the random number generator.  This function is #defined as
  1646.     a comment, since no seeding is possible for this implementation
  1647.     of rand().
  1648.  
  1649. void swab(int *src, int *dst, int n)
  1650.     Swap adjacent bytes while copying <n> bytes from <src> to <dst>.
  1651.     This allows bulk translation to/from Intel byte ordering.  Please
  1652.     note the backward order of the <src> and <dst> parameters.  Don't
  1653.     blame me... this is how Microsoft specifies it.
  1654.  
  1655. MACRO abs(x)
  1656.     Return the absolute value of <x>.  This macro evalutes it's
  1657.     argument twice.    ((x)<0?(-(x)):(x))
  1658.  
  1659. MACRO max(x,y)
  1660.     Return the larger of <x> and <y>.  This macro evaluates the
  1661.     larger argument twice and the smaller argument once.
  1662.  
  1663. MACRO min(x,y)
  1664.     Return the smaller of <x> and <y>.  This macro evaluates the
  1665.     smaller argument twice and the larger argument once.
  1666.  
  1667. MACRO swap(a,b)
  1668.     Exchange <a> and <b> by chained XORs.  The macro evaluates
  1669.     each argument several times.
  1670.  
  1671. MACRO assert(condition)
  1672.     If <condition> is not true at run-time, this macro causes an
  1673.     assert failure message to be written to stderr, displaying the
  1674.     line number and source file name, and aborts the program.  If
  1675.     the symbol NDEBUG is #defined (usually with a -D option to cc),
  1676.     all assert() calls are disabled.
  1677.  
  1678.  
  1679. ----- REVISION RECORD -----
  1680.  
  1681. This is an attempt to record changes to dLibs from past versions.
  1682. I make no promises about it's completeness.
  1683.  
  1684. v1.2
  1685.     October 1988.
  1686.  
  1687.     This release corresponds to the release of the Sozobon C
  1688.     compiler for the ST, and includes quite a bit of general code
  1689.     cleanup as dictated by the stricter (and more correct)
  1690.     requirements of the Sozobon compiler.  This code IS still
  1691.     compatible with Alcyon C, but now it is also compatible
  1692.     with Sozobon C.
  1693.  
  1694.     This release fixes many bugs, most minor, some major.  Some
  1695.     of the functions that were improved are:  mktime(), stime(),
  1696.     strtrim(), ctlcnv(), realloc(), fullpath(), findfile(),
  1697.     lsearch(), tell(), putenv(), exec(), _initargs(), main(),
  1698.     qsort(), memccpy() and swab().
  1699.  
  1700.     The header files were somewhat restuctured, and <stddef.h> and
  1701.     <stdarg.h> were added, for more ANSI X3J11 compatibility.  Also
  1702.     <sys\minimum.h> was added as a non-portable hack to make very
  1703.     small programs when no standard i/o or argv/argc is needed.
  1704.  
  1705.     The blkXXX() functions have now all been renames to their X3J11
  1706.     memXXX() names and some were recoded in assembly language.
  1707.  
  1708.     The stream i/o functions were overhauled, resulting in changes
  1709.     to the FILE structure and nearly all associated functions.  The
  1710.     new functions handle interactive i/o with the console much more
  1711.     nicely, emulating (partly) a tty driver which gives essentially
  1712.     line-oriented operation for standard input on a character device.
  1713.     You can now backspace to edit, ^U to retype a line, and ^C to
  1714.     interrupt a program (sorry, only during input) and none of these
  1715.     characters will appear in the input read by the program.  Since
  1716.     there is never agreement about how such a driver should work, all
  1717.     the code is encapsulated in the _tttty() function, which is in
  1718.     a separate object module.
  1719.  
  1720.     The pfindfile() function now has a path parameter, but the PATH
  1721.     environment variable will still be used if NULL is specified.
  1722.     The wildcard() function has also changed slightly in that is
  1723.     no longer expands the filenames with fullpath().
  1724.  
  1725.     Some new functions in this release are: mktime(), usleep(),
  1726.     alloca(), _splitpath(), _makepath(), bzero(), memcpy(), lmemcpy(),
  1727.     strpcpy(), strtol(), strtoul(), perror(), perrorf(), strerror(),
  1728.     fgetpos(), fsetpos(), vprintf(), vfprintf(), vsprintf() and getopt().
  1729.  
  1730. v1.1
  1731.     December 1987.
  1732.  
  1733.     Process control functions, spawn(), spawne(), spawnp() and
  1734.     spawnpe() removed.  New functions forkl(), forklp(), forkle(),
  1735.     forklpe(), forkv(), forkvp(), forkve(), forkvpe() and wait()
  1736.     now handle creation of child processes.
  1737.  
  1738.     XARG format extended argument passing is supported by all the
  1739.     process control functions and _initargs().
  1740.  
  1741.     Many functions which were previously #defined in <stdio.h> to
  1742.     gemdos() calls are now real functions.  This allows you to pass
  1743.     the address of these functions in function pointer.
  1744.  
  1745.     Added brk() and sbrk() functions for managing the heap.  This
  1746.     is not typically a good way to allocate memory.  The normal
  1747.     malloc() functions are much better in most cases.
  1748.  
  1749.     printf() and scanf() now process capital format characters.
  1750.     This feature is provided to support old programs which use
  1751.     capital characters to indicate long values.  It is NOT*
  1752.     recommended for use in current code and is not supported
  1753.     by the ANSI proposed standard.  The scanf() function has
  1754.     been upgraded to support hyphenated ranges and returns what
  1755.     we think are correct values for various end-cases like end-
  1756.     of-input and early format conflicts.
  1757.  
  1758.     findfile() and pfindfile() have been improved and fopenp()
  1759.     had been added to support use of the PATH.  The extension
  1760.     list given for findfile() and pfindfile() has been changed
  1761.     slightly.  You must now include the '.' portion of the
  1762.     extension.  This is to allow searching for the empty extension.
  1763.  
  1764.     The header files have been changed and extended to conform
  1765.     more closely to ANSI and Unix System V.  As a result, some
  1766.     of the structures and actual values for certain flags have
  1767.     changed.  The stat structure and related functions like
  1768.     access(), stat(), creat(), open(), etc. have been significantly
  1769.     changed in implementation.  The open() function supports
  1770.     many more mode flags like O_CREAT, O_APPEND, O_TRUNC and O_EXCL.
  1771.  
  1772.     A few new functions like swab(), tmpnam(), tempnam(), getcwd()
  1773.     and wildcard() have been added.  Only wildcard() is non-standard,
  1774.     but I think it's useful to have around.
  1775.  
  1776. v1.0
  1777.     Original release.  October 1987.
  1778.  
  1779. ----- END OF FILE -----
  1780.