home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff314.lha / zc / zc.lzh / Docs / zc.lib.doc < prev   
Text File  |  1989-06-15  |  79KB  |  1,822 lines

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