home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 156_01 / args.doc < prev    next >
Text File  |  1985-08-21  |  2KB  |  51 lines

  1.             ARGS Library Documentation
  2.  
  3. ARGS gives the user access to the command line and optionally
  4. redirects the standard input and/or output.
  5.  
  6.  
  7. FUNCTIONS 
  8.  
  9. setargs()
  10.     If access to the command line or I/O redirection is
  11.     wanted, setargs() must be called BEFORE ANY DISK I/O
  12.     IS DONE.  This is because the disk operations can
  13.     overwrite the command line.  setargs() parses the
  14.     command line, which is a series of items separated by
  15.     one or more spaces.  A '<' followed by a file name will
  16.     redirect the standard input (used by getchar() and
  17.     gets()) to that file.  A '>' followed by a file name
  18.     will similarly redirect the standard output (used by
  19.     putchar() and puts()).  If the file exists, it will be
  20.     silently deleted.  '>>' followed by a file name will
  21.     also redirect the standard output, but if the file
  22.     already exists then the new characters will be appended
  23.     to the existing data.  In any of the above cases, one
  24.     or more spaces can appear before the file name.  Items
  25.     other than the above are saved for later access by
  26.     getarg().  As far as getarg() is concerned, I/O
  27.     redirection commands are invisible.  Regardless of I/O
  28.     redirection, err() will always display its message and
  29.     walkback trace (if any) on the console, putc(c,1) or
  30.     putc(c,STDERR) will always send the character c to
  31.     the console, and getc(0) will always get a character
  32.     from the keyboard.
  33. getarg(n,s,size) int n; char *s; int size; 
  34.     places in s the n-th argument.  Returns s if successful
  35.     or, if there was no n-th argument, returns -1.  Assumes
  36.     s has "size" bytes.  The 0-th argument, which under Unix
  37.     would be the name by which the program was invoked, is
  38.     always "*".  
  39.  
  40.  
  41. INTERNAL DOCUMENTATION
  42.  
  43. setargs() uses alloc() to allocate its buffer.
  44.  
  45.  
  46. AUTHOR
  47.  
  48.     These programs were written by Jan-Henrik Johansson
  49.     (Dr. Dobb's Journal no 74 p 62) and extensively
  50.     rewritten by J. R. Van Zandt
  51.