home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / HITECH-C / Z8051H83.EXE / LIBRARY.HLP < prev    next >
Text File  |  1993-05-21  |  73KB  |  2,664 lines

  1. INDEX 154 92 C Library Reference
  2. 10242 13 _EXIT
  3. 22985 74 _GETARGS
  4. 25 24 ACOS
  5. 728 20 ASCTIME
  6. 25 24 ASIN
  7. 1183 23 ASSERT
  8. 25 24 ATAN
  9. 25 24 ATAN2
  10. 2042 17 ATOF
  11. 2042 17 ATOI
  12. 2042 17 ATOL
  13. 2473 26 BDOS
  14. 3252 21 BIOS
  15. 3914 16 CALLOC
  16. 10922 13 CEIL
  17. 4319 19 CGETS
  18. 4797 21 CHDIR
  19. 5238 23 CHMOD
  20. 5975 16 CLOSE
  21. 6329 18 CLREOF
  22. 6329 18 CLRERR
  23. 6839 13 COS
  24. 7032 11 COSH
  25. 4319 19 CPUTS
  26. 7240 23 CREAT
  27. 8087 27 CTIME
  28. 8578 8 DI
  29. 8713 16 DUP
  30. 8578 8 EI
  31. 9104 20 EXECL
  32. 9104 20 EXECV
  33. 9727 15 EXIT
  34. 10515 15 EXP
  35. 10922 13 FABS
  36. 11242 15 FCLOSE
  37. 11566 18 FEOF
  38. 11566 18 FERROR
  39. 11991 16 FFLUSH
  40. 12365 21 FGETC
  41. 12902 15 FGETS
  42. 13445 14 FILENO
  43. 10922 13 FLOOR
  44. 13777 89 FOPEN
  45. 17284 19 FPRINTF
  46. 17852 17 FPUTC
  47. 18318 14 FPUTS
  48. 18597 23 FREAD
  49. 19219 14 FREE
  50. 19475 17 FREOPEN
  51. 19921 18 FREXP
  52. 20570 18 FSCANF
  53. 21104 28 FSEEK
  54. 22144 16 FTELL
  55. 22508 18 FWRITE
  56. 25853 12 GETC
  57. 26188 21 GETCH
  58. 26796 17 GETCHAR
  59. 26188 21 GETCHE
  60. 27239 18 GETCWD
  61. 27702 33 GETENV
  62. 29026 15 GETS
  63. 29344 16 GETUID
  64. 29698 20 GETW
  65. 30338 22 GMTIME
  66. 31120 11 INP
  67. 31443 30 INT86
  68. 31443 30 INT86X
  69. 31443 30 INTDOS
  70. 31443 30 INTDOSX
  71. 32740 41 ISALNUM
  72. 32740 41 ISALPHA
  73. 33817 13 ISATTY
  74. 32740 41 ISCNTRL
  75. 32740 41 ISDIGIT
  76. 32740 41 ISGRAPH
  77. 32740 41 ISLOWER
  78. 32740 41 ISPRINT
  79. 32740 41 ISPUNCT
  80. 32740 41 ISSPACE
  81. 34211 17 KBHIT
  82. 19921 18 LDEXP
  83. 30338 22 LOCALTIME
  84. 10515 15 LOG
  85. 10515 15 LOG10
  86. 34500 52 LONGJMP
  87. 36047 18 LSEEK
  88. 36552 19 MALLOC
  89. 37140 25 MEMCMP
  90. 37140 25 MEMCPY
  91. 37140 25 MEMSET
  92. 38093 18 MKDIR
  93. 38526 29 MSDOS
  94. 38526 29 MSDOSCX
  95. 39507 80 OPEN
  96. 31120 11 OUTP
  97. 41919 21 PERROR
  98. 10515 15 POW
  99. 42619 92 PRINTF
  100. 46150 14 PUTC
  101. 26188 21 PUTCH
  102. 46428 14 PUTCHAR
  103. 46642 15 PUTS
  104. 46934 16 PUTW
  105. 47282 38 QSORT
  106. 48432 15 RAND
  107. 48699 20 READ
  108. 49336 20 REALLOC
  109. 49993 15 REMOVE
  110. 50270 15 RENAME
  111. 50600 17 REWIND
  112. 38093 18 RMDIR
  113. 51049 16 SBRK
  114. 51527 79 SCANF
  115. 54685 13 SEGREAD
  116. 56887 21 SET_VECTOR
  117. 55390 36 SETBUF
  118. 54944 13 SETJMP
  119. 55172 14 SETUID
  120. 55390 36 SETVBUF
  121. 57601 26 SIGNAL
  122. 58689 13 SIN
  123. 7032 11 SINH
  124. 58898 21 SPAWNL
  125. 58898 21 SPAWNV
  126. 58898 21 SPAWNVE
  127. 59660 19 SPRINTF
  128. 60264 14 SQRT
  129. 60840 18 SRAND
  130. 60457 16 SSCANF
  131. 61320 41 STAT
  132. 63066 29 STRCAT
  133. 64450 18 STRCHR
  134. 63066 29 STRCMP
  135. 63066 29 STRCPY
  136. 63066 29 STRLEN
  137. 63066 29 STRNCAT
  138. 63066 29 STRNCMP
  139. 63066 29 STRNCPY
  140. 64450 18 STRRCHR
  141. 64992 24 SYSTEM
  142. 65672 13 TAN
  143. 7032 11 TANH
  144. 65835 19 TIME
  145. 66421 19 TOASCII
  146. 66421 19 TOLOWER
  147. 66421 19 TOUPPER
  148. 66935 18 UNGETC
  149. 26188 21 UNGETCH
  150. 67413 15 UNLINK
  151. 67822 47 VA_ARG
  152. 67822 47 VA_END
  153. 67822 47 VA_START
  154. 42619 92 VPRINTF
  155. 69847 71 WRITE
  156. %ACOS
  157. %ASIN
  158. %ATAN
  159. %ATAN2
  160.  
  161. SYNOPSIS
  162.      #include  <math.h>
  163.  
  164.      double    acos(double f)
  165.      double    asin(double f)
  166.      double    atan(double f)
  167.  
  168.      double    atan2(double x, double y)
  169.  
  170. DESCRIPTION
  171.  
  172.      These functions are the converse of the  trignometric  func-
  173.      tions  cos, sin and tan. Acos and asin are undefined for ar-
  174.      guments whose absolute value is greater than  1.0.  The  re-
  175.      turned value is in radians, and always in the range -pi/2 to
  176.      +pi/2, except for ■#cos(), which returns a value in the  range
  177.      0  to  pi.   ■%Atan2() returns the inverse tan of x/y but uses
  178.      the signs of its arguments to return a value  in  the  range
  179.      -pi to +pi.
  180.  
  181. SEE ALSO
  182.      sin, cos, tan
  183.  
  184. %ASCTIME
  185.  
  186. SYNOPSIS
  187.      #include  <time.h>
  188.  
  189.      char *    asctime(time_t t)
  190.  
  191. DESCRIPTION
  192.  
  193.      ■'Asctime() takes the broken down time pointed to by its argu-
  194.      ment,  and  returns  a  26  character  string describing the
  195.      current date and time in the format
  196.  
  197.            Sun Sep 16 01:03:52 1973\n\0
  198.  
  199.      Note the newline at the end of the string. The width of each
  200.      field in the string is fixed.
  201.  
  202. SEE ALSO
  203.      ctime, time, gmtime, localtime
  204.  
  205. %ASSERT
  206.  
  207. SYNOPSIS
  208.      #include  <assert.h>
  209.  
  210.      void      assert(int e)
  211.  
  212. DESCRIPTION
  213.  
  214.      This macro is used for debugging purposes; the basic  method
  215.      of  usage  is  to place assertions liberally throughout your
  216.      code at points where correct operation of the  code  depends
  217.      upon  certain  conditions  being true initially. An ■&assert()
  218.      may be used to ensure  at  run  time  that  that  assumption
  219.      holds. For is non-null:
  220.  
  221.            assert(tp);
  222.  
  223.      If at run time the expression evaluates to false,  the  pro-
  224.      gram  will  abort with a message identifying the source file
  225.      and line number of the assertion, and the expression used as
  226.      an argument to it. A fuller discussion of the uses of assert
  227.      is impossible in limited space, but it is closely linked  to
  228.      methods of proving program correctness.
  229. %ATOF
  230. %ATOI
  231. %ATOL
  232.  
  233. SYNOPSIS
  234.      #include  <math.h>
  235.  
  236.      double    atof(char * s)
  237.      int       atoi(char * s)
  238.  
  239.      #include  <stdlib.h>
  240.  
  241.      long      atol(char * s)
  242.  
  243. DESCRIPTION
  244.  
  245.      These routines convert a  decimal  number  in  the  argument
  246.      string  s  into  a  double  float,  integer  or long integer
  247.      respectively. Leading blanks are skipped over. In  the  case
  248.      of ■$atof(), the number may be in scientific notation.
  249. %BDOS
  250.  
  251. SYNOPSIS
  252.      #include  <cpm.h>
  253.  
  254.      char      bdos(int func, int arg)
  255.  
  256.      short bdoshl(int func, int arg)(CP/M-80 only)
  257.  
  258. DESCRIPTION
  259.  
  260.      ■$Bdos() calls the CP/M BDOS with func in register C  (CL  for
  261.      CP/M-86)  and  arg  in register DE (DX). The return value is
  262.      the byte returned by the BDOS in register A (AX).   ■&Bdoshl()
  263.      is  the  same, except that the return value is the value re-
  264.      turned by the BDOS in HL.  Constant values for  the  various
  265.      BDOS function values are defined in cpm.h.
  266.  
  267.  
  268. These functions should be avoided except in  programs  which  are
  269.      not  intended  to  be used on an operating system other than
  270.      CP/M. The standard I/O routines are to be  preferred,  since
  271.      they are portable.
  272.  
  273. SEE ALSO
  274.      bios, msdos
  275.  
  276. %BIOS
  277.  
  278. SYNOPSIS
  279.      #includ   <cpm.h>
  280.  
  281.      char bios(int n, int a1, int a2)
  282.  
  283. DESCRIPTION
  284.  
  285.      This function will call the n'th bios entry point (cold boot
  286.      =  0,  warm boot = 1, etc.) with register BC (CX) set to the
  287.      argument a1 and DE (DX) set to the argument a2.  The  return
  288.      value  is  the  contents  of  register A (AX) after the bios
  289.      call. On CP/M-86, bdos function 50 is used  to  perform  the
  290.      bios call.  This function should not be used unless unavoid-
  291.      able, since it is highly  non-portable.  There  is  even  no
  292.      guarantee  of  portability  of  bios calls between differing
  293.      CP/M systems.
  294.  
  295. SEE ALSO
  296.      bdos
  297.  
  298. %CALLOC
  299.  
  300. SYNOPSIS
  301.      #include  <stdlib.h>
  302.  
  303.      char * calloc(size_t cnt, size_t size)
  304.  
  305. DESCRIPTION
  306.  
  307.      ■&Calloc() attempts to obtain a contiguous  block  of  dynamic
  308.      memory which will hold cnt objects, each of length size. The
  309.      block is filled with zeroes.  A pointer to the block is  re-
  310.      turned, or 0 if the memory could not be allocated.
  311.  
  312. SEE ALSO
  313.      brk, sbrk, malloc, free
  314.  
  315. %CGETS
  316. %CPUTS
  317.  
  318. SYNOPSIS
  319.      #include  <conio.h>
  320.  
  321.      char *    cgets(char * s)
  322.  
  323.      void      cputs(char * s)
  324.  
  325. DESCRIPTION
  326.  
  327.      ■%Cputs() will read one line of input from  the  console  into
  328.      the  buffer  passed  as  an argument. It does so by repeated
  329.      calls to ■&getche().  ■%Cputs() writes its  argument  string  to
  330.      the console, outputting carriage returns before each newline
  331.      in the string. It calls ■%putch() repeatedly.
  332.  
  333. SEE ALSO
  334.      getch, getche, putch
  335.  
  336. %CHDIR
  337.  
  338. SYNOPSIS
  339.      #include  <sys.h>
  340.  
  341.      int       chdir(char * s)
  342.  
  343. DESCRIPTION
  344.  
  345.      This function is availble only under MS-DOS. It changes  the
  346.      current working directory to the path name supplied as argu-
  347.      ment. This path name be be absolute, as in A:\FRED, or rela-
  348.      tive, as in ..\SOURCES.  A return value of -1 indicates that
  349.      the requested change could not be performed.
  350.  
  351.  
  352.  
  353.  
  354.  
  355. SEE ALSO
  356.      mkdir, rmdir, getcwd
  357.  
  358. %CHMOD
  359.  
  360. SYNOPSIS
  361.      #include  <stat.h>
  362.  
  363.      int       chmod(char * name, int )
  364.      char *    name;
  365.      int       mode;
  366.  
  367. DESCRIPTION
  368.  
  369.      This function changes the file attributes (or modes) of  the
  370.      named  file.   The argument name may be any valid file name.
  371.      The mode argument may include all bits defined in ■$stat.■!h ex-
  372.      cept  those  relating to the type of the file, e.g. S_IFDIR.
  373.      Note however that not all bits  may  be  changed  under  all
  374.      operating  systems,  e.g. neither DOS nor CP/M permit a file
  375.      to be made unreadable, thus even if mode  does  not  include
  376.      S_IREAD  the  file  will  still be readable (and ■$stat() will
  377.      still return S_IREAD in flags).
  378.  
  379. SEE ALSO
  380.      stat, creat
  381.  
  382. %CLOSE
  383.  
  384. SYNOPSIS
  385.      #include  <unixio.h>
  386.  
  387.      int close(int fd)
  388.  
  389. DESCRIPTION
  390.  
  391.      This routine  closes  the  file  associated  with  the  file
  392.      descriptor fd, which will have been previously obtained from
  393.      a call to ■$open(). ■%Close() returns 0 for a successful  close,
  394.      or -1 otherwise.
  395.  
  396. SEE ALSO
  397.      open, read, write, seek
  398.  
  399. %CLRERR
  400. %CLREOF
  401.  
  402. SYNOPSIS
  403.      #include  <stdio.h>
  404.      void clrerr(FILE * stream)
  405.      void clreof(FILE * stream)
  406.  
  407. DESCRIPTION
  408.  
  409.      These are macros, defined in stdio.h, which reset the  error
  410.      and end of file flags respectively for the specified stream.
  411.      They should be used with care; the major valid  use  is  for
  412.      clearing an EOF status on input from a terminal-like device,
  413.      where it may be valid to continue to read after having  seen
  414.      an end-of-file indication.
  415.  
  416. SEE ALSO
  417.      fopen, fclose
  418.  
  419. %COS
  420.  
  421. SYNOPSIS
  422.      #include  <math.h>
  423.  
  424.      double    cos(double f)
  425.  
  426. DESCRIPTION
  427.  
  428.      This function yields the cosine of its argument.
  429.  
  430. SEE ALSO
  431.      sin, tan, asin, acos, atan
  432.  
  433. %COSH
  434. %SINH
  435. %TANH
  436.  
  437. SYNOPSIS
  438.      #include  <math.h>
  439.  
  440.      double    cosh(double f)
  441.      double    sinh(double f)
  442.      double    tanh(double f)
  443.  
  444. DESCRIPTION
  445.  
  446.      These functions implement the hyperbolic trig functions.
  447. %CREAT
  448.  
  449. SYNOPSIS
  450.      #include  <stat.h>
  451.  
  452.      int       creat(char * name, int mode)
  453.  
  454. DESCRIPTION
  455.  
  456.      This routine attempts to create the file named by name.   If
  457.      the  file  exists  and  is writeable, it will be removed and
  458.      re-created. The return value is -1 if the create failed,  or
  459.      a  small non-negative number if it succeeded. This number is
  460.      a valuable token which must be used to write to or close the
  461.      file  subsequently.   Mode  is used to initialize the attri-
  462.      butes of the created file.  The allowable bits are the  same
  463.      as for ■%chmod(), but for Unix compatibility it is recommended
  464.      that a mode of 0666 or 0600 be used. Under CP/M the mode  is
  465.      ignored  - the only way to set a files attributes is via the
  466.      ■%chmod() function.
  467.  
  468. SEE ALSO
  469.      open, close, read, write, seek, stat, chmod
  470.  
  471. %CTIME
  472.  
  473. SYNOPSIS
  474.      #include  <time.h>
  475.  
  476.      char *    ctime(time_t t)
  477.  
  478. DESCRIPTION
  479.  
  480.      ■%Ctime() converts the time in seconds pointed to by its argu-
  481.      ment  to a string of the same form as described for asctime.
  482.      Thus the following program prints the current time and date:
  483.  
  484.  
  485.        #include    <time.h>
  486.  
  487.        main()
  488.        {
  489.              time_t      t;
  490.  
  491.              time(&t);
  492.              printf("%s", ctime(&t));
  493.        }
  494.  
  495.  
  496. SEE ALSO
  497.      gmtime, localtime, asctime, time
  498.  
  499. %DI
  500. %EI
  501.  
  502. SYNOPSIS
  503.      void ei(void);
  504.      void di(void);
  505.  
  506. DESCRIPTION
  507.  
  508.      ■"Ei() and ■"di() enable and disable interrupts respectivly.
  509. %DUP
  510.  
  511. SYNOPSIS
  512.      #include  <unixio.h>
  513.  
  514.      int dup(int fd)
  515.  
  516. DESCRIPTION
  517.  
  518.      Given a file descriptor, such as returned  by  ■$open(),  this
  519.      routine will return another file descriptor which will refer
  520.      to the same open file.  -1 is returned if the fd argument is
  521.      a bad descriptor or does not refer to an open file.
  522.  
  523. SEE ALSO
  524.      open, close, creat, read, write
  525.  
  526. %EXECL
  527. %EXECV
  528.  
  529. SYNOPSIS
  530.      #include  <sys.h>
  531.  
  532.      int execl(char * name, pname, ...)
  533.      int execv(char * name, ppname)
  534.  
  535. DESCRIPTION
  536.  
  537.      ■%Execl() and ■%execv() load and execute the  program  specified
  538.      by the string name. ■%Execl() takes the arguments for the pro-
  539.      gram from the zero-terminated list of string arguments.  ■#Ex-
  540.      ■#ecv() is passed a pointer to an array of strings.  The array
  541.      must be zero-terminated. If the named program is  found  and
  542.      can  be read, the call does not return. Thus any return from
  543.      these routines may be treated as an error.
  544.  
  545. SEE ALSO
  546.      spawnl, spawnv, system
  547.  
  548. %EXIT
  549.  
  550. SYNOPSIS
  551.      #include  <stdlib.h>
  552.  
  553.      void      exit(int status)
  554.  
  555. DESCRIPTION
  556.  
  557.      This call will close all open files and exit from  the  pro-
  558.      gram. On CP/M, this means a return to CCP level. Status will
  559.      be stored in a known place for  examination  by  other  pro-
  560.      grams.  This is only useful if the program executing was ac-
  561.      tually invoked by another program  which  is  trapping  warm
  562.      boots. The status value will be stored on CP/M at 80H.  This
  563.      call will never return.
  564. %_EXIT
  565.  
  566. SYNOPSIS
  567.      #include  <stdlib.h>
  568.      void      _exit(int status)
  569.  
  570. DESCRIPTION
  571.  
  572.      This function will cause an immediate exit from the program,
  573.      without  the  normal  flushing of stdio buffers that is per-
  574.      formed by ■$exit().
  575.  
  576. SEE ALSO
  577.  
  578. %EXP
  579. %LOG
  580. %LOG10
  581. %POW
  582.  
  583. SYNOPSIS
  584.      #include  <math.h>
  585.  
  586.      double    exp(double f)
  587.      double    log(double f)
  588.      double    log10(double f)
  589.      double    pow(double x, y)
  590.  
  591. DESCRIPTION
  592.  
  593.      ■#Exp() returns the  exponential  function  of  its  argument,
  594.      ■#log()  the natural logarithm of f, and ■%log10() the logarithm
  595.      to base 10. ■#Pow() returns the value of x raised to the  y'th
  596.      power.
  597. %FABS
  598. %CEIL
  599. %FLOOR
  600.  
  601. SYNOPSIS
  602.      #include  <math.h>
  603.  
  604.      double    fabs(double f)
  605.      double    ceil(double f)
  606.      double    floor(double f)
  607.  
  608. DESCRIPTION
  609.  
  610.      These routines return respectively the absolute value of  f,
  611.      the smallest integral value not less than f, and the largest
  612.      integral value not greater than f.
  613. %FCLOSE
  614.  
  615. SYNOPSIS
  616.      #include  <stdio.h>
  617.  
  618.      int       fclose(FILE * stream)
  619.  
  620. DESCRIPTION
  621.  
  622.      This routine closes the specified i/o stream. Stream  should
  623.      be  a token returned by a previous call to ■%fopen().  NULL is
  624.      returned on a successful close, EOF otherwise.
  625.  
  626. SEE ALSO
  627.      fopen, fread, fwrite
  628.  
  629. %FEOF
  630. %FERROR
  631.  
  632. SYNOPSIS
  633.      #include  <stdio.h>
  634.  
  635.      feof(FILE * stream)
  636.      ferror(FILE * stream)
  637.  
  638. DESCRIPTION
  639.  
  640.      These macros test the status  of  the  EOF  and  ERROR  bits
  641.      respectively  for the specified stream. Each will be true if
  642.      the corresponding flag is set. The  macros  are  defined  in
  643.      stdio.h.  Stream  must  be  a  token  returned by a previous
  644.      ■%fopen() call.
  645.  
  646. SEE ALSO
  647.      fopen, fclose
  648.  
  649. %FFLUSH
  650.  
  651. SYNOPSIS
  652.      #include  <stdio.h>
  653.  
  654.      int fflush(FILE * stream)
  655.  
  656. DESCRIPTION
  657.  
  658.      ■&Fflush() will output  to  the  disk  file  or  other  device
  659.      currently  open  on the specified stream the contents of the
  660.      associated buffer. This is typically used for flushing  buf-
  661.      fered standard output in interactive applications.
  662.  
  663. SEE ALSO
  664.      fopen, fclose
  665.  
  666. %FGETC
  667.  
  668. SYNOPSIS
  669.      #include  <stdio.h>
  670.  
  671.      int       fgetc(FILE * stream)
  672.  
  673. DESCRIPTION
  674.  
  675.      ■%Fgetc() returns the next character from  the  input  stream.
  676.      If  end-of-file is encountered EOF will be returned instead.
  677.      It is for this reason that the function is declared as  int.
  678.      The  integer  EOF  is  not a valid byte, thus end-of-file is
  679.      distinguishable from reading a byte of all 1 bits  from  the
  680.      file.  ■%Fgetc() is the non-macro version of ■$getc().
  681.  
  682.  
  683.  
  684.  
  685. SEE ALSO
  686.      fopen, fclose, fputc, getc, putc
  687.  
  688. %FGETS
  689.  
  690. SYNOPSIS
  691.      #include  <stdio.h>
  692.  
  693.      char * fgets(char * s, size_t n, char * stream)
  694.  
  695. DESCRIPTION
  696.  
  697.      ■%Fgets() places in the buffer s up to n-1 characters from the
  698.      input  stream.  If a newline is seen in the input before the
  699.      correct number of characters is read, then ■%fgets() will  re-
  700.      turn  immediately.  The  newline will be left in the buffer.
  701.      The buffer will be null terminated in any case.  A  success-
  702.      ful ■%fgets() will return its first argument; NULL is returned
  703.      on end-of-file or error.
  704. %FILENO
  705.  
  706. SYNOPSIS
  707.      fileno(FILE * stream)
  708.  
  709. DESCRIPTION
  710.  
  711.      ■&Fileno() is a macro  from  stdio.h  which  yields  the  file
  712.      descriptor associated with stream. It is mainly used when it
  713.      is desired to perform some low-level  operation  on  a  file
  714.      opened as a stdio stream.
  715.  
  716. SEE ALSO
  717.      fopen, fclose, open, close
  718.  
  719. %FOPEN
  720.  
  721. SYNOPSIS
  722.      #include  <stdio.h>
  723.  
  724.      FILE * fopen(char * name, char * mode);
  725.  
  726. DESCRIPTION
  727.  
  728.  
  729. DESCRIPTION
  730.  
  731.      ■%Fopen() attempts to open file for  reading  or  writing  (or
  732.      both)  according  to  the  mode  string  supplied.  The mode
  733.      string is interpreted as follows:
  734. r
  735.  
  736.      The file is opend for reading if it exists. If the file does
  737.      not exist the call fails.
  738. r+
  739.  
  740.      If the file exists it is opened for reading and writing.  If
  741.      the file does not already exist the call fails.
  742. w
  743.  
  744.      The file is created if it does not exist, or truncated if it
  745.      does. It is then opened for writing.
  746. w+
  747.  
  748.      The file is created if it does not already exist,  or  trun-
  749.      cated  if it does.  The file is opened for reading and writ-
  750.      ing.
  751. a
  752.  
  753.      The file is created if it does not already exist, and opened
  754.      for  writing.   All writes will be dynamically forced to the
  755.      end of file, thus this mode is known as ■&append mode.
  756. a+
  757.  
  758.      The file is created if it does not already exist, and opened
  759.      for  reading  and  writing.  All  writes to the file will be
  760.      dynamically forced to the end of the file,  i.e.  while  any
  761.      portion  of the file may be read, all writes will take place
  762.      at the end of the file and will not overwrite  any  existing
  763.      data.   Calling  ■%fseek() in an attempt to write at any other
  764.      place in the file will not be effective.  The  "b"  modifier
  765.      may  be  appended  to  any of the above modes, e.g. "r+b" or
  766.      "rb+" are equivalent. Adding the "b" modifier will cause the
  767.      file  to be opened in binary rather than ASCII mode. Opening
  768.      in ASCII mode ensures that text files are read in  a  manner
  769.      compatible with the Unix-derived conventions for C programs,
  770.      i.e. that text files  contain  lines  delimited  by  newline
  771.      characters.   The special treatment of read or written char-
  772.      acters varies with the operating system, but  includes  some
  773.      or all of the following:
  774. NEWLINE (LINE FEED)
  775.  
  776.      Converted to carriage return, line feed on output.
  777. RETURN
  778.  
  779.      Ignored on input, inserted before NEWLINE on output.
  780. CTRL-Z
  781.  
  782.      Signals EOF on input, appended on fclose on output if neces-
  783.      sary on CP/M.
  784.  
  785.  
  786. Opening a file in binary mode will allow  each  character  to  be
  787.      read  just  as written, but because the exact size of a file
  788.      is not known to CP/M, the file may contain more  bytes  than
  789.      were  written  to  it.  See ■$open() for a description of what
  790.      constitutes a file name.  When using one of  the  read/write
  791.      modes  (with  a  '+' character in the string), although they
  792.      permits reading and writing on the same stream,  it  is  not
  793.      possible  to  arbitrarily  mix input and output calls to the
  794.      same stream. At any given time a stream opened  with  a  "+"
  795.      mode  will  be in either an input or output state. The state
  796.      may only be changed when the  associated  buffer  is  empty,
  797.      which  is  only  guaranteed  immediately  after  a  call  to
  798.      ■&fflush() or one of the file positioning functions ■%fseek() or
  799.      ■&rewind().  The  buffer will also be empty after encountering
  800.      EOF while reading a binary stream,  but  it  is  recommended
  801.      that an explicit call to ■&fflush() be used to ensure this si-
  802.      tuation. Thus after reading from a stream  you  should  call
  803.      ■&fflush()  or  ■%fseek()  before  attempting  to  write on that
  804.      stream, and vice versa.
  805.  
  806. SEE ALSO
  807.      fclose, fgetc, fputc, freopen
  808.  
  809. %FPRINTF
  810.  
  811. SYNOPSIS
  812.      #include  <stdio.h>
  813.  
  814.      fprintf(FILE * stream, char * fmt, ...);
  815.      vfprintf(FILE * stream, va_list va_arg);
  816.  
  817. DESCRIPTION
  818.  
  819.      ■'Fprintf()  performs  formatted  printing  on  the  specified
  820.      stream.  Refer  to ■&printf() for the details of the available
  821.      formats.  ■(Vfprintf() is similar to  ■'fprintf()  but  takes  a
  822.      variable  argument  list pointer rather than a list of argu-
  823.      ments. See the description of ■"va_■%start() for  more  informa-
  824.      tion on variable argument lists.
  825.  
  826. SEE ALSO
  827.      printf, fscanf, sscanf
  828.  
  829. %FPUTC
  830.  
  831. SYNOPSIS
  832.      #include  <stdio.h>
  833.  
  834.      int       fputc(int c, FILE * stream)
  835.  
  836. DESCRIPTION
  837.  
  838.      The character c is written to the supplied stream.  This  is
  839.      the  non-macro  version of ■$putc(). The character is returned
  840.      if it was successfully written, EOF is  returned  otherwise.
  841.      Note  that "written to the stream" may mean only placing the
  842.      character in the buffer associated with the stream.
  843.  
  844. SEE ALSO
  845.      putc, fgetc, fopen, fflush
  846.  
  847. %FPUTS
  848.  
  849. SYNOPSIS
  850.      #include  <stdio.h>
  851.  
  852.      int       fputs(char * s, FILE * stream)
  853.  
  854. DESCRIPTION
  855.  
  856.      The null-terminated string s is written to  the  stream.  No
  857.      newline is appended (cf. ■$puts() ). The error return is EOF.
  858.  
  859. SEE ALSO
  860.      puts, fgets, fopen, fclose
  861.  
  862. %FREAD
  863.  
  864. SYNOPSIS
  865.      #include  <stdio.h>
  866.  
  867.      int       fread(void * buf, size_t size, size_t cnt,
  868.                     FILE * stream)
  869.  
  870. DESCRIPTION
  871.  
  872.      Up to cnt objects, each of length size, are read into memory
  873.      at  buf  from  the stream. The return value is the number of
  874.      objects read. If none is read, 0  will  be  returned.   Note
  875.      that  a  return value less than cnt, but greater than 0, may
  876.      not represent an error (cf. ■&fwrite() ).  No  word  alignment
  877.      in  the stream is assumed or necessary. The read is done via
  878.      successive ■$getc()'s.
  879.  
  880.  
  881.  
  882.  
  883. SEE ALSO
  884.      fwrite, fopen, fclose, getc
  885.  
  886. %FREE
  887.  
  888. SYNOPSIS
  889.      #include  <stdlib.h>
  890.  
  891.      void      free(void * ptr)
  892.  
  893. DESCRIPTION
  894.  
  895.      ■$Free() deallocates the block of memory at  ptr,  which  must
  896.      have been obtained from a call to ■&malloc() or ■&calloc().
  897.  
  898. SEE ALSO
  899.      malloc, calloc
  900.  
  901. %FREOPEN
  902.  
  903. SYNOPSIS
  904.      #include  <stdio.h>
  905.  
  906.      FILE * freopen(char * name, char * mode, FILE * stream)
  907.  
  908. DESCRIPTION
  909.  
  910.      ■'Freopen() closes the given stream (if  open)  then  re-opens
  911.      the  stream attached to the file described by name. The mode
  912.      of opening is given by mode.  It either returns  the  stream
  913.      argument,  if  successful,  or  NULL if not. See ■%fopen() for
  914.      more information.
  915.  
  916. SEE ALSO
  917.      fopen, fclose
  918.  
  919. %FREXP
  920. %LDEXP
  921.  
  922. SYNOPSIS
  923.      #include  <math.h>
  924.  
  925.      double    frexp(double f, int * p)
  926.  
  927.      double    ldexp(double f, int i)
  928.  
  929. DESCRIPTION
  930.  
  931.      ■%Frexp() breaks a floating point  number  into  a  normalized
  932.      fraction  and  an integral power of 2. The integer is stored
  933.      into the int object pointed to by p.  Its return value x  is
  934.      in  the  interval [0.5, 1.0) or zero, and f equals x times 2
  935.      raised to the power stored in *p.  If f is zero, both  parts
  936.      of the result are zero.  ■%Ldexp() performs the reverse opera-
  937.      tion; the integer i is added to the exponent of the floating
  938.      point f and the resultant value returned.
  939. %FSCANF
  940.  
  941. SYNOPSIS
  942.      #include  <stdio.h>
  943.  
  944.      int       fscanf(FILE * stream, char * fmt, ...)
  945.  
  946. DESCRIPTION
  947.  
  948.      This routine performs formatted  input  from  the  specified
  949.      stream.  See ■%scanf() for a full description of the behaviour
  950.      of the routine.  ■'Vfscanf() is similar to ■&fscanf() but  takes
  951.      a variable argument list pointer rather than a list of argu-
  952.      ments. See the description of ■"va_■%start() for  more  informa-
  953.      tion on variable argument lists.
  954.  
  955. SEE ALSO
  956.      scanf, sscanf, fopen, fclose
  957.  
  958. %FSEEK
  959.  
  960. SYNOPSIS
  961.      #include  <stdio.h>
  962.  
  963.      int       fseek(FILE * stream, long offs, int wh)
  964.  
  965. DESCRIPTION
  966.  
  967.      ■%Fseek() positions the "file pointer" (i.e. a pointer to  the
  968.      next  character  to  be  read  or  written) of the specified
  969.      stream as follows: center box; c|c n|l.  wh    resultant lo-
  970.      cation    _    0     offs    1     offs+previous    location
  971.      2     offs+length of file
  972.  
  973.  
  974. It should be noted that offs is a signed value. Thus  the  3  al-
  975.      lowed modes give postioning relative to the beginning of the
  976.      file, the current file pointer  and  the  end  of  the  file
  977.      respectively.  EOF  is  returned  if the positioning request
  978.      could not be satisfied. Note however that positioning beyond
  979.      the  end of the file is legal, but will result in an EOF in-
  980.      dication if an attempt is made to read  data  there.  It  is
  981.      quite  in  order  to  write  data beyond the previous end of
  982.      file.  ■%Fseek() correctly accounts for any buffered data.
  983.  
  984. SEE ALSO
  985.      lseek, fopen, fclose
  986.  
  987. %FTELL
  988.  
  989. SYNOPSIS
  990.      #include  <stdio.h>
  991.  
  992.      long      ftell(FILE * stream)
  993.  
  994. DESCRIPTION
  995.  
  996.      This function returns the current position of the conceptual
  997.      read/write  pointer associated with stream.  This is the po-
  998.      sition relative to the beginning of the  file  of  the  next
  999.      byte to be read from or written to the file.
  1000.  
  1001. SEE ALSO
  1002.      fseek
  1003.  
  1004. %FWRITE
  1005.  
  1006. SYNOPSIS
  1007.      #include  <stdio.h>
  1008.  
  1009.      int       fwrite(void * buf, size_t size, size_t cnt,
  1010.                    FILE * stream)
  1011.  
  1012. DESCRIPTION
  1013.  
  1014.      Cnt objects of length size bytes will be written from memory
  1015.      at buf, to the specified stream. The number of whole objects
  1016.      written will be returned, or 0 if none could be written. Any
  1017.      return  value not equal to cnt should be treated as an error
  1018.      (cf. ■%fread() ).
  1019.  
  1020. SEE ALSO
  1021.      fread, fopen, fclose
  1022.  
  1023. %_GETARGS
  1024.  
  1025. SYNOPSIS
  1026.      #include  <sys.h>
  1027.  
  1028.      char ** _getargs(char * buf, char * name)
  1029.      extern int _argc_;
  1030.  
  1031. DESCRIPTION
  1032.  
  1033.      This routine performs I/O redirection (CP/M only)  and  wild
  1034.      card expansion. Under MS-DOS I/O redirection is performed by
  1035.      the operating system. It is  called  from  startup  code  to
  1036.      operate  on the command line if the -R option is used to the
  1037.      C command, but may also be called by user-written  code.  If
  1038.      the  buf  argument  is null, it will read lines of text from
  1039.      standard input. If the standard input is a terminal (usually
  1040.      the  console) the name argument will be written to the stan-
  1041.      dard error stream as a prompt. If the buf  argument  is  not
  1042.      null, it will be used as the source of the string to be pro-
  1043.      cessed.  The returned value is a  pointer  to  an  array  of
  1044.      strings, exactly as would be pointed to by the argv argument
  1045.      to the main() function. The number of strings in  the  array
  1046.      may be obtained from the global _argc_. For example, a typi-
  1047.      cal use of this function would be:
  1048.  
  1049.        #include    <sys.h>
  1050.  
  1051.        main(argc, argv)
  1052.        char ** argv;
  1053.        {
  1054.            extern char ** _getargs();
  1055.            extern int    _argc_;
  1056.  
  1057.            if(argc == 1) {     /* no arguments */
  1058.              argv = _getargs(0, "myname");
  1059.              argc = _argc_;
  1060.            }
  1061.            .
  1062.            .
  1063.            .
  1064.        }
  1065.  
  1066.      There will be one string in the array for each word  in  the
  1067.      buffer  processed.   Quotes, either single (') or double (")
  1068.      may be used to include white space in "words". If  any  wild
  1069.      card  characters  (?  or  *) appear in a non-quoted word, it
  1070.      will be expanded into a string of words, one for  each  file
  1071.      matching  the  word. The usual CP/M conventions are followed
  1072.      for this expansion. On CP/M any occurence of the redirection
  1073.      characters  >  and  <  outside quotes will be handled in the
  1074.      following manner:
  1075. > name
  1076.  
  1077.      will cause standard output to  be  redirected  to  the  file
  1078.      name.
  1079. < name
  1080.  
  1081.      will cause standard input to be  redirected  from  the  file
  1082.      name.
  1083. >> name
  1084.  
  1085.      will cause standard output to append to file name.
  1086.  
  1087.  
  1088. White space is optional between the > or < character and the file
  1089.      name, however it is an error for a redirection character not
  1090.      to be followed by a file name.  It is also  an  error  if  a
  1091.      file  cannot  be opened for input or created for output.  An
  1092.      append redirection (>>) will create the file if it does  not
  1093.      exist.   If  the  source of text to be processed is standard
  1094.      input, several lines may be supplied  by  ending  each  line
  1095.      (except  the  last)  with a backslash (\).  This serves as a
  1096.      continuation character. Note that the newline following  the
  1097.      backslash is ignored, and not treated as white space.
  1098. %GETC
  1099.  
  1100. SYNOPSIS
  1101.      #include  <stdio.h>
  1102.  
  1103.      int       getc(FILE * stream)
  1104.      FILE * stream;
  1105.  
  1106. DESCRIPTION
  1107.  
  1108.      One character is read from  the  specified  stream  and  re-
  1109.      turned.  EOF will be returned on end-of-file or error.  This
  1110.      is the macro version of ■%fgetc(), and is defined in stdio.h.
  1111. %GETCH
  1112. %GETCHE
  1113. %UNGETCH
  1114. %PUTCH
  1115.  
  1116. SYNOPSIS
  1117.      #include  <conio.h>
  1118.  
  1119.      char      getch(void)
  1120.      char      getche(void)
  1121.      void      putch(int c)
  1122.  
  1123. DESCRIPTION
  1124.  
  1125.      ■%Getch() reads a single character from the  console  keyboard
  1126.      and  returns  it  without  echoing.  ■&Getche() is similar but
  1127.      does echo the character typed.  ■'Ungetch() will push back one
  1128.      character  such  that  the  next call to ■%getch() or ■&getche()
  1129.      will return that character.  ■%Putch() outputs the character c
  1130.      to  the  console screen, prepending a carriage return if the
  1131.      character is a newline.
  1132.  
  1133. SEE ALSO
  1134.      cgets, cputs
  1135.  
  1136. %GETCHAR
  1137.  
  1138. SYNOPSIS
  1139.      #include  <stdio.h>
  1140.  
  1141.      int       getchar(void)
  1142.  
  1143. DESCRIPTION
  1144.  
  1145.      ■'Getchar() is a ■$getc(■%stdin) operation. It is a macro  defined
  1146.      in  stdio.h.  Note that under normal circumstances getchar()
  1147.      will NOT return unless a carriage return has been  typed  on
  1148.      the  console. To get a single character immediately from the
  1149.      console, use the routine ■%getch().
  1150.  
  1151. SEE ALSO
  1152.      getc, fgetc, freopen, fclose
  1153.  
  1154. %GETCWD
  1155.  
  1156. SYNOPSIS
  1157.      #include  <sys.h>
  1158.  
  1159.      char *    getcwd(int drive)
  1160.  
  1161. DESCRIPTION
  1162.  
  1163.      ■&Getcwd() returns the path name of the current working direc-
  1164.      tory on the specified drive, where drive == 0 represents the
  1165.      current  drive,  drive  ==  1  represents  A:,  drive  ==  2
  1166.      represents B: etc.  The return value is a pointer to a stat-
  1167.      ic area of memory which will be overwritten on the next call
  1168.      to ■&getcwd().
  1169.  
  1170. SEE ALSO
  1171.      chdir
  1172.  
  1173. %GETENV
  1174.  
  1175. SYNOPSIS
  1176.      #include  <stdlib.h>
  1177.  
  1178.      char *    getenv(char * s)
  1179.      extern char **    environ;
  1180.  
  1181. DESCRIPTION
  1182.  
  1183.      ■&Getenv() will search the vector of environment  strings  for
  1184.      one  matching  the  argument  supplied, and return the value
  1185.      part of that environment string. For  example,  if  the  en-
  1186.      vironment contains the string
  1187.  
  1188.            COMSPEC=A:\COMMAND.COM
  1189.  
  1190.      then ■&getenv("■'COMSPEC") will return A:\COMMAND.COM.  The glo-
  1191.      bal variable environ is a pointer to an array of pointers to
  1192.      environment strings, terminated by a null pointer. This  ar-
  1193.      ray is initialized at startup time under MS-DOS from the en-
  1194.      vironment pointer supplied when the  program  was  executed.
  1195.      Under  CP/M  no  such  environment is supplied, so the first
  1196.      call to ■&getenv() will attempt to open a file in the  current
  1197.      user  number  on the current drive called ENVIRON. This file
  1198.      should contain definitions  for  any  environment  variables
  1199.      desired to be accessible to the program, e.g.
  1200.  
  1201.      HITECH=0:C:
  1202.  
  1203.      Each variable definition should be on a separate line,  con-
  1204.      sisting  of  the  variable name (conventionally all in upper
  1205.      case) followed without intervening white space by  an  equal
  1206.      sign ('=') then the value to be assigned to that variable.
  1207. %GETS
  1208.  
  1209. SYNOPSIS
  1210.      #include  <stdio.h>
  1211.  
  1212.      char * gets(char * s)
  1213.  
  1214. DESCRIPTION
  1215.  
  1216.      ■$Gets() reads a line from standard input into the  buffer  at
  1217.      s,  deleting  the newline (cf. ■%fgets() ). The buffer is null
  1218.      terminated. It returns its argument, or NULL on end-of-file.
  1219.  
  1220. SEE ALSO
  1221.      fgets, freopen
  1222.  
  1223. %GETUID
  1224.  
  1225. SYNOPSIS
  1226.      #include  <sys.h>
  1227.  
  1228.      int getuid(void)
  1229.  
  1230. DESCRIPTION
  1231.  
  1232.      ■&Getuid() returns the current  user  number.   On  CP/M,  the
  1233.      current  user  number  determines the user number associated
  1234.      with an opened or created file, unless overridden by an  ex-
  1235.      plicit user number prefix in the file name.
  1236.  
  1237. SEE ALSO
  1238.      setuid, open
  1239.  
  1240. %GETW
  1241.  
  1242. SYNOPSIS
  1243.      #include  <stdio.h>
  1244.  
  1245.      int       getw(FILE * stream)
  1246.  
  1247. DESCRIPTION
  1248.  
  1249.      ■$Getw() returns one word (16 bits for the Z80 and 8086)  from
  1250.      the  nominated  stream.  EOF is returned on end-of-file, but
  1251.      since this is a perfectly good word, the ■$feof() macro should
  1252.      be used for testing for end-of-file.  When reading the word,
  1253.      no special alignment in the file is necessary, as  the  read
  1254.      is  done  by two consecutive ■$getc()'s.  The byte ordering is
  1255.      however undefined. The word read should in general have been
  1256.      written by ■$putw().
  1257.  
  1258. SEE ALSO
  1259.      putw, getc, fopen, fclose
  1260.  
  1261. %GMTIME
  1262. %LOCALTIME
  1263.  
  1264. SYNOPSIS
  1265.      #include  <time.h>
  1266.  
  1267.      struct tm *       gmtime(time_t * t)
  1268.      struct tm *       localtime(time_t * t)
  1269.  
  1270. DESCRIPTION
  1271.  
  1272.      These functions convert the time pointed to by t which is in
  1273.      seconds  since  00:00:00  on Jan 1, 1970, into a broken down
  1274.      time stored in a structure as defined in  ■$time.■!h.   ■&Gmtime()
  1275.      performs a straight conversion, while ■)localtime() takes into
  1276.      account the contents of the global integer time_zone.   This
  1277.      should  contain  the  number  of minutes that the local time
  1278.      zone is WESTWARD of Greenwich. Since there is no  way  under
  1279.      MS-DOS  of  actually  pre-determining this value, by default
  1280.      ■)localtime() will return the same result as ■&gmtime().
  1281.  
  1282. SEE ALSO
  1283.      ctime, asctime, time
  1284.  
  1285. %INP
  1286. %OUTP
  1287.  
  1288. SYNOPSIS
  1289.      char inp(unsigned port)
  1290.  
  1291.      void outp(unsigned, unsigned data)
  1292.  
  1293. DESCRIPTION
  1294.  
  1295.      These routines read and write bytes to and from  I/O  ports.
  1296.      ■#Inp()  returns  the  data byte read from the specified port,
  1297.      and ■$outp() outputs the data byte to the specified port.
  1298. %INT86
  1299. %INT86X
  1300. %INTDOS
  1301. %INTDOSX
  1302.  
  1303. SYNOPSIS
  1304.      #include  <dos.h>
  1305.  
  1306.      int       int86(int intno, union REGS * inregs,
  1307.                union REGS * outregs)
  1308.      int       int86x(int intno, union REGS inregs,
  1309.                union REGS outregs, struct SREGS * segregs)
  1310.      int       intdos(union REGS * inregs, union REGS * outregs)
  1311.      int       intdosx(union REGS * inregs, union REGS * outregs,
  1312.                struct SREGS * segregs)
  1313.  
  1314. DESCRIPTION
  1315.  
  1316.      These functions allow calling of software interrupts from  C
  1317.      programs.   ■%Int86() and ■&int86x() execute the software inter-
  1318.      rupt specified by ■%intno while ■&intdos() and ■'intdosx() execute
  1319.      interrupt  21(hex),  which  is the MS-DOS system call inter-
  1320.      rupt.  The inregs pointer should point to a union containing
  1321.      values  for  each of the general purpose registers to be set
  1322.      when executing the interrupt, and the values of  the  regis-
  1323.      ters  on  return  are  copied  into  the union pointed to by
  1324.      outregs. The ■!x versions of the calls also take a pointer  to
  1325.      a  union  defining  the segment register values to be set on
  1326.      execution of the interrupt, though only ES and DS are  actu-
  1327.      ally set from this structure.
  1328.  
  1329. SEE ALSO
  1330.      segread
  1331.  
  1332. %ISALNUM
  1333. %ISALPHA
  1334. %ISDIGIT
  1335. %ISLOWER
  1336. %ISCNTRL
  1337. %ISPRINT
  1338. %ISGRAPH
  1339. %ISPUNCT
  1340. %ISSPACE
  1341.  
  1342. SYNOPSIS
  1343.      #include <ctype.h>
  1344.  
  1345.      isalnum(char c)
  1346.      isalpha(char c)
  1347.      isascii(char c)
  1348.      iscntrl(char c)
  1349.      isdigit(char c)
  1350.      islower(char c)
  1351.      isprint(char c)
  1352.      isgraph(char c)
  1353.      ispunct(char c)
  1354.      isspace(char c)
  1355.      isupper(char c)
  1356.      char c;
  1357.  
  1358. DESCRIPTION
  1359.  
  1360.      These macros, defined in ctype.h, test the supplied  charac-
  1361.      ter  for  membership in one of several overlapping groups of
  1362.      characters. Note that all except isascii are defined  for  ■!c
  1363.      iff ■'isascii(■!c) is true.
  1364.  
  1365.        isalnum(c)  c is alphanumeric
  1366.        isalpha(c)  c is in A-Z or a-z
  1367.        isascii(c)  c is a 7 bit ascii character
  1368.        iscntrl(c)  c is a control character
  1369.        isdigit(c)  c is a decimal digit
  1370.        islower(c)  c is in a-z
  1371.        isprint(c)  c is a printing char
  1372.        isgraph(c)  c is a non-space printable character
  1373.        ispunct(c)  c is not alphanumeric
  1374.        isspace(c)  c is a space, tab or newline
  1375.        isupper(c)  c is in A-Z
  1376.        isxdigit(c) c is in 0-9 or a-f or A-F
  1377.  
  1378.  
  1379. SEE ALSO
  1380.      toupper, tolower, toascii
  1381.  
  1382. %ISATTY
  1383.  
  1384. SYNOPSIS
  1385.      #include  <unixio.h>
  1386.  
  1387.      int isatty(int fd)
  1388.  
  1389. DESCRIPTION
  1390.  
  1391.      This tests the type of the file associated with fd.  It  re-
  1392.      turns  true  if  the  file is attached to a tty-like device.
  1393.      This would normally be used for testing if standard input is
  1394.      coming  from  a  file  or  the  console.  For  testing STDIO
  1395.      streams, use ■&isatty(■&fileno(■&stream)).
  1396. %KBHIT
  1397.  
  1398. SYNOPSIS
  1399.      #include  <conio.h>
  1400.  
  1401.      int       kbhit(void)
  1402.  
  1403. DESCRIPTION
  1404.  
  1405.      This function returns 1 if a character has been  pressed  on
  1406.      the  console  keyboard,  0 otherwise. Normally the character
  1407.      would then be read via ■%getch().
  1408.  
  1409.  
  1410.  
  1411. SEE ALSO
  1412.      getch, getche
  1413.  
  1414. %LONGJMP
  1415.  
  1416. SYNOPSIS
  1417.      #include <setjmp.h>
  1418.  
  1419.      void      longjmp(jmp_buf buf, int val)
  1420.  
  1421. DESCRIPTION
  1422.  
  1423.      ■'Longjmp(), in conjunction with ■&setjmp(), provides a  mechan-
  1424.      ism  for  non-local  gotos.  To  use this facility, ■&setjmp()
  1425.      should be called with a jmp_buf argument in some outer level
  1426.      function. The call from ■&setjmp() will return 0. To return to
  1427.      this level of execution, ■&lonjmp() may  be  called  with  the
  1428.      same jmp_buf argument from an inner level of execution. Note
  1429.      however that the function which called ■&setjmp()  must  still
  1430.      be active when ■'longjmp() is called. Breach of this rule will
  1431.      cause disaster, due to the use of a stack containing invalid
  1432.      data.  The  val  argument to ■'longjmp() will be the value ap-
  1433.      parently returned from the ■&setjmp(). This should normally be
  1434.      non-zero,  to distinguish it from the genuine ■&setjmp() call.
  1435.      For example:
  1436.  
  1437.        #include <setjmp.h>
  1438.  
  1439.        static jmp_buf    jb_err;
  1440.  
  1441.        main()
  1442.        {
  1443.            if(setjmp(jb_err)) {
  1444.              printf("An error occured\n");
  1445.              exit(1);
  1446.            }
  1447.            a_func();
  1448.        }
  1449.  
  1450.        a_func()
  1451.        {
  1452.            if(do_whatever() != 0)
  1453.              longjmp(jb_err, 1);
  1454.            if(do_something_else() != 0)
  1455.              longjmp(jb_err, 2);
  1456.        }
  1457.  
  1458.  
  1459.  
  1460. The calls to ■'longjmp() above will never return; rather  the  call
  1461.      to  ■&setjmp()  will appear to return, but with a return value
  1462.      equal to the argument supplied to ■'longjmp().
  1463.  
  1464. SEE ALSO
  1465.      setjmp
  1466.  
  1467. %LSEEK
  1468.  
  1469. SYNOPSIS
  1470.      #include  <unixio.h>
  1471.  
  1472.      long lseek(int fd, long offs, int wh)
  1473.  
  1474. DESCRIPTION
  1475.  
  1476.      This function operates in an analogous  manner  to  ■%fseek(),
  1477.      however it does so on unbuffered low-level i/o file descrip-
  1478.      tors, rather than on STDIO  streams.  It  also  returns  the
  1479.      resulting  pointer  location.  Thus ■%lseek(■"fd, ■"0L, ■!1) returns
  1480.      the current pointer location without moving it.  -1  is  re-
  1481.      turned on error.
  1482.  
  1483. SEE ALSO
  1484.      open, close, read, write
  1485.  
  1486. %MALLOC
  1487.  
  1488. SYNOPSIS
  1489.      #include  <stdlib.h>
  1490.  
  1491.      void * malloc(size_t cnt)
  1492.  
  1493. DESCRIPTION
  1494.  
  1495.      ■&Malloc() attempts to allocate cnt bytes of memory  from  the
  1496.      "heap",  the  dynamic memory allocation area. If successful,
  1497.      it returns a pointer to the block, otherwise 0 is  returned.
  1498.      The memory so allocated may be freed with ■$free(), or changed
  1499.      in size via  ■'realloc().  ■&Malloc()  calls  ■$sbrk()  to  obtain
  1500.      memory, and is in turn called by ■&calloc(). ■&Malloc() does not
  1501.      clear the memory it obtains.
  1502.  
  1503. SEE ALSO
  1504.      calloc, free, realloc
  1505.  
  1506. %MEMSET
  1507. %MEMCPY
  1508. %MEMCMP
  1509.  
  1510. SYNOPSIS
  1511.      #include  <string.h>
  1512.  
  1513.      void      memset(void s, char c, int n)
  1514.      void      memcpy(void * d, void * s, int n)
  1515.      int       memcmp(void * s1, void * s2, int n)
  1516.  
  1517. DESCRIPTION
  1518.  
  1519.      ■&Memset() initializes n bytes of memory starting at the loca-
  1520.      tion pointed to by s with the character c. ■&Memcpy() copies n
  1521.      bytes of memory starting from the location pointed to  by  s
  1522.      to the block of memory pointed to by d.  The result of copy-
  1523.      ing overlapping blocks is undefined.  ■&Memcmp() compares  two
  1524.      blocks  of  memory,  of length n, and returns a signed value
  1525.      similar to ■'strncmp(). Unlike ■'strncmp() the comparision  does
  1526.      not  stop  on a null character. The ascii collating sequence
  1527.      is used for the comparision, but  the  effect  of  including
  1528.      non-ascii  characters  in  the memory blocks on the sense of
  1529.      the return value is indeterminate.
  1530.  
  1531. SEE ALSO
  1532.      strncpy, strncmp
  1533.  
  1534. %MKDIR
  1535. %RMDIR
  1536.  
  1537. SYNOPSIS
  1538.      #include  <sys.h>
  1539.  
  1540.      int       mkdir(char * s)
  1541.      int       rmdir(char * s)
  1542.  
  1543. DESCRIPTION
  1544.  
  1545.      These functions allow the creation  (■%mkdir())  and  deletion
  1546.      (■%rmdir()) of sub-directories under the MS-DOS operating sys-
  1547.      tem. The argument s may be an arbitrary  pathname,  and  the
  1548.      return  value  will be -1 if the creation or removal was un-
  1549.      successful.
  1550.  
  1551. SEE ALSO
  1552.      chdir
  1553.  
  1554. %MSDOS
  1555. %MSDOSCX
  1556.  
  1557. SYNOPSIS
  1558.      #include  <dos.h>
  1559.  
  1560.      long      msdos(int ax, int dx, int cx,
  1561.                int bx, int si, int di)
  1562.      long      msdoscx(int ax, int dx, int cx,
  1563.                int bx, int si, int di)
  1564.  
  1565. DESCRIPTION
  1566.  
  1567.      These functions allow direct access to MS-DOS system  calls.
  1568.      The  arguments  will  be  placed in the registers implied by
  1569.      their names, while the return value will be the contents  of
  1570.      AX  and  DX  (for ■%msdos()) or the contents of DX and CX (for
  1571.      ■'msdoscx()).  Only as many arguments  as  necessary  need  be
  1572.      supplied, e.g. if only AH and DX need have specified valued,
  1573.      then only 2 argument would be required. The following  piece
  1574.      of code outputs a form-feed to the printer.
  1575.  
  1576.            msdos(0x500, '\f');
  1577.  
  1578.      Note that the system call number (in this case  5)  must  be
  1579.      multiplied  by 0x100 since MS-DOS expects the call number in
  1580.      AH, the high byte of AX.
  1581.  
  1582. SEE ALSO
  1583.      intdos, intdosx, int86, int86x
  1584.  
  1585. %OPEN
  1586.  
  1587. SYNOPSIS
  1588.      #include  <unixio.h>
  1589.  
  1590.      int       open(char * name, int mode)
  1591.  
  1592. DESCRIPTION
  1593.  
  1594.      ■$Open() is the fundamental means of opening files for reading
  1595.      and  writing.   The file specified by name is sought, and if
  1596.      found is opened for reading, writing or both. Mode is encod-
  1597.      ed as follows:
  1598.  
  1599.        Mode  Meaning
  1600.        0     Open for reading only
  1601.        1     Open for writing only
  1602.        2     Open for both reading and writing
  1603.  
  1604.  
  1605.  
  1606. The file must already exist - if it does not, ■%creat()  should  be
  1607.      used  to create it.  On a successful open, a file descriptor
  1608.      is returned. This is a non-negative  integer  which  may  be
  1609.      used  to  refer  to the open file subsequently.  If the open
  1610.      fails, -1 is returned.  The syntax of a CP/M filename is:
  1611.  
  1612.        [uid:][drive:]name.type
  1613.  
  1614.  
  1615.  
  1616. where uid is a decimal number 0 to 15, drive is a letter A  to  P
  1617.      or  a  to  p,  name  is 1 to 8 characters and type is 0 to 3
  1618.      characters. Though there are few  inherent  restrictions  on
  1619.      the  characters in the name and type, it is recommended that
  1620.      they be restricted to the alphanumerics and standard  print-
  1621.      ing  characters.   Use of strange characters may cause prob-
  1622.      lems in accessing and/or deleting the file.
  1623.  
  1624.  
  1625. One or both of uid: and drive: may be omitted; if both  are  sup-
  1626.      plied,  the  uid: must come first. Note that the [ and ] are
  1627.      meta-symbols only. Some examples are:
  1628.  
  1629.        fred.dat
  1630.        file.c
  1631.        0:xyz.com
  1632.        0:a:file1.p
  1633.        a:file2.
  1634.  
  1635.  
  1636.  
  1637. If the uid: is omitted, the file will be sought with uid equal to
  1638.      the  current user number, as returned by getuid(). If drive:
  1639.      is omitted, the file will be sought on the currently select-
  1640.      ed drive. The following special file names are recognized:
  1641.  
  1642.        lst:  Accesses the list device - write only
  1643.        pun:  Accesses the punch device - write only
  1644.        rdr:  Accesses the reader device - read only
  1645.        con:  Accesses the system console - read/write
  1646.  
  1647.  
  1648.  
  1649. File names may be in any case - they are converted to upper  case
  1650.      during processing of the name.
  1651.  
  1652.  
  1653. MS-DOS filenames may be any valid MS-DOS 2.xx filename, e.g.
  1654.  
  1655.        fred.nrk
  1656.        A:\\HITECH\\STDIO.H
  1657.  
  1658.  
  1659.  
  1660. The special device names (e.g. CON,  LST)  are  also  recognized.
  1661.      These do not require (and should not have) a trailing colon.
  1662.  
  1663. SEE ALSO
  1664.      close, fopen, fclose, read, write, creat
  1665.  
  1666. %PERROR
  1667.  
  1668. SYNOPSIS
  1669.      #include  <stdio.h>
  1670.  
  1671.      void      perror(char * s)
  1672.  
  1673. DESCRIPTION
  1674.  
  1675.      This routine will print on the stderr stream the argument s,
  1676.      followed  by  a descriptive message detailing the last error
  1677.      returned from an open, close  read  or  write  call.  Unfor-
  1678.      tunately CP/M does not provide definitive information relat-
  1679.      ing to the error, except in the case of  a  random  read  or
  1680.      write.  Thus  this  routine  is  of limited usefulness under
  1681.      CP/M. MS-DOS provides much more information however, and use
  1682.      of  ■&perror() after MS-DOS file handling calls will certainly
  1683.      give useful diagnostics.
  1684.  
  1685. SEE ALSO
  1686.      open, close, read, write
  1687.  
  1688. %PRINTF
  1689. %VPRINTF
  1690.  
  1691. SYNOPSIS
  1692.      #include  <stdio.h>
  1693.  
  1694.      int       printf(char * fmt, ...)
  1695.      int       vprintf(char * fmt, va_list va_arg)
  1696.  
  1697. DESCRIPTION
  1698.  
  1699.      ■&Printf() is a formatted output routine, operating on stdout.
  1700.      There are corresponding routines operating on a given stream
  1701.      (■'fprintf()) or into a string buffer (■'sprintf()). ■&Printf() is
  1702.      passed  a  format string, followed by a list of zero or more
  1703.      arguments. In the format string  are  conversion  specifica-
  1704.      tions,  each  of which is used to print out one of the argu-
  1705.      ment list values.  Each conversion specification is  of  the
  1706.      form  %m.nc  where the percent symbol % introduces a conver-
  1707.      sion, followed by an optional width specification m.   n  is
  1708.      an  optional precision specification (introduced by the dot)
  1709.      and c is a letter specifying the type of the conversion.   A
  1710.      minus  sign  ('-')  preceding  m  indicates left rather than
  1711.      right adjustment of the converted value in the field.  Where
  1712.      the  field width is larger than required for the conversion,
  1713.      blank padding is performed at the left or  right  as  speci-
  1714.      fied.  Where  right  adjustment  of  a numeric conversion is
  1715.      specified, and the first digit of m is 0, then padding  will
  1716.      be performed with zeroes rather than blanks.
  1717.  
  1718.  
  1719. If the character * is used in place of a decimal  constant,  e.g.
  1720.      in  the  format %*d, then one integer argument will be taken
  1721.      from the list to provide that value.  The types  of  conver-
  1722.      sion are:
  1723. f
  1724.  
  1725.      Floating point - m is the total width and n is the number of
  1726.      digits after the decimal point.  If n is omitted it defaults
  1727.      to 6.
  1728. e
  1729.  
  1730.      Print the corresponding  argument  in  scientific  notation.
  1731.      Otherwise similar to f.
  1732. g
  1733.  
  1734.      Use e or f format,  whichever  gives  maximum  precision  in
  1735.      minimum width.
  1736. o x X u d
  1737.  
  1738.      Integer conversion - in radices 8, 16, 10 and 10 respective-
  1739.      ly. The conversion is signed in the case of d, unsigned oth-
  1740.      erwise. The precision value is the total number of digits to
  1741.      print,  and  may be used to force leading zeroes. E.g. %8.4x
  1742.      will print at least  4  hex  digits  in  an  8  wide  field.
  1743.      Preceding  the key letter with an l indicates that the value
  1744.      argument is a long integer or unsigned value.  The letter  X
  1745.      prints  out hexadecimal numbers using the upper case letters
  1746.      ■!A-■!F rather than ■!a-■!f as would be printed when using x.
  1747. s
  1748.  
  1749.      Print a string - the value argument is assumed to be a char-
  1750.      acter  pointer. At most n characters from the string will be
  1751.      printed, in a field m characters wide.
  1752. c
  1753.  
  1754.      The argument is assumed to be  a  single  character  and  is
  1755.      printed literally.
  1756.  
  1757.  
  1758. Any other characters used as conversion  specifications  will  be
  1759.      printed.  Thus  %% will produce a single percent sign.  Some
  1760.      examples:
  1761.  
  1762.        printf("Total = %4d%%", 23)
  1763.              yields 'Total =   23%'
  1764.        printf("Size is %lx" , size)
  1765.              where size is a long, prints size
  1766.              as hexadecimal.
  1767.        printf("Name = %.8s", "a1234567890")
  1768.              yields 'Name = a1234567'
  1769.        printf("xx%*d", 3, 4)
  1770.              yields 'xx  4'
  1771.  
  1772.  
  1773.  
  1774. Printf returns EOF on error, 0 otherwise.  ■'Vprintf()  is  similar
  1775.      to ■&printf() but takes a variable argument list pointer rath-
  1776.      er  than  a  list  of  arguments.  See  the  description  of
  1777.      ■"va_■%start() for more information on variable argument lists.
  1778.  
  1779. SEE ALSO
  1780.      fprintf, sprintf
  1781.  
  1782. %PUTC
  1783.  
  1784. SYNOPSIS
  1785.      #include  <stdio.h>
  1786.  
  1787.      int       putc(int c, FILE * stream)
  1788.  
  1789. DESCRIPTION
  1790.  
  1791.      ■$Putc() is the macro version of ■%fputc()  and  is  defined  in
  1792.      stdio.h. See ■%fputc() for a description of its behaviour.
  1793.  
  1794. SEE ALSO
  1795.      fputc, getc, fopen, fclose
  1796.  
  1797. %PUTCHAR
  1798.  
  1799. SYNOPSIS
  1800.      #include  <stdio.h>
  1801.  
  1802.      int       putchar(int c)
  1803.  
  1804. DESCRIPTION
  1805.  
  1806.      ■'Putchar() is  a  ■$putc()  operation  on  stdout,  defined  in
  1807.      stdio.h.
  1808.  
  1809. SEE ALSO
  1810.      putc, getc, freopen, fclose
  1811.  
  1812. %PUTS
  1813.  
  1814. SYNOPSIS
  1815.      #include  <stdio.h>
  1816.  
  1817.      int       puts(char * s)
  1818.  
  1819. DESCRIPTION
  1820.  
  1821.      ■$Puts() writes the string s to the stdout stream, appending a
  1822.      newline. The null terminating the string is not copied.  EOF
  1823.      is returned on error.
  1824.  
  1825. SEE ALSO
  1826.      fputs, gets, freopen, fclose
  1827.  
  1828. %PUTW
  1829.  
  1830. SYNOPSIS
  1831.      #include  <stdio.h>
  1832.  
  1833.      int       putw(int w, FILE * stream)
  1834.  
  1835. DESCRIPTION
  1836.  
  1837.      ■$Putw() copies the word w to the given stream. It returns  w,
  1838.      except  on  error, in which case EOF is returned. Since this
  1839.      is a good integer, ■&ferror() should be used to check for  er-
  1840.      rors.
  1841.  
  1842. SEE ALSO
  1843.      getw, fopen, fclose
  1844.  
  1845. %QSORT
  1846.  
  1847. SYNOPSIS
  1848.      #include  <stdlib.h>
  1849.  
  1850.      void      qsort(void * base, size_t nel,
  1851.                size_t width, int (*func)())
  1852.  
  1853. DESCRIPTION
  1854.  
  1855.      ■%Qsort() is an implementation of the quicksort algorithm.  It
  1856.      sorts an array of nel items, each of length width bytes, lo-
  1857.      cated contiguously in memory at base.  Func is a pointer  to
  1858.      a  function  used by ■%qsort() to compare items. It calls func
  1859.      with pointers to two items to be  compared.   If  the  first
  1860.      item is considered to be greater than, equal to or less than
  1861.      the second then ■$func() should return a  value  greater  than
  1862.      zero, equal to zero or less than zero respectively.
  1863.  
  1864.        static short      array[100];
  1865.  
  1866.        #define SIZE  sizeof array/sizeof array[0]
  1867.        a_func(p1, p2)
  1868.        short * p1, * p2;
  1869.        {
  1870.              return *p1 - *p2;
  1871.        }
  1872.  
  1873.        sort_em()
  1874.        {
  1875.              qsort(array, SIZE,
  1876.                    sizeof array[0], a_func);
  1877.        }
  1878.  
  1879.  
  1880.  
  1881. This will sort the array into ascending values. Note the  use  of
  1882.      sizeof  to make the code independent of the size of a short,
  1883.      or the number of elements in the array.
  1884. %RAND
  1885.  
  1886. SYNOPSIS
  1887.      #include  <stdlib.h>
  1888.  
  1889.      int rand(void)
  1890.  
  1891. DESCRIPTION
  1892.  
  1893.      ■$Rand() is a pseudo-random number generator.  It  returns  an
  1894.      integer  in the range 0 to 32767, which changes in a pseudo-
  1895.      random fashion on each call.
  1896.  
  1897. SEE ALSO
  1898.      srand
  1899.  
  1900. %READ
  1901.  
  1902. SYNOPSIS
  1903.      #include  <unixio.h>
  1904.  
  1905.      int       read(int fd, void * buf, size_t cnt)
  1906.  
  1907. DESCRIPTION
  1908.  
  1909.      ■$Read() will read from the file associated with fd up to  cnt
  1910.      bytes into a buffer located at buf. It returns the number of
  1911.      bytes actually read. A zero return indicates end-of-file.  A
  1912.      negative  return  indicates  error.  Fd should have been ob-
  1913.      tained from a previous call to ■$open().  It is  possible  for
  1914.      ■$read()  to return less bytes than requested, e.g. when read-
  1915.      ing from the console, in which case  ■$read()  will  read  one
  1916.      line of input.
  1917.  
  1918. SEE ALSO
  1919.      open, close, write
  1920.  
  1921. %REALLOC
  1922.  
  1923. SYNOPSIS
  1924.      void * realloc(void * ptr, size_t cnt)
  1925.  
  1926. DESCRIPTION
  1927.  
  1928.      ■'Realloc() frees the block of memory  at  ptr,  which  should
  1929.      have  been obtained by a previous call to ■&malloc(), ■&calloc()
  1930.      or ■'realloc(), then attempts to allocate cnt bytes of dynamic
  1931.      memory,  and  if successful copies the contents of the block
  1932.      of memory located at ptr into the new block.  At most, ■%real-
  1933.      ■#loc()  will  copy  the number of bytes which were in the old
  1934.      block, but if the new block is smaller, will only  copy  cnt
  1935.      bytes.  If the block could not be allocated, 0 is returned.
  1936.  
  1937.  
  1938.  
  1939. SEE ALSO
  1940.      malloc, calloc, realloc
  1941.  
  1942. %REMOVE
  1943.  
  1944. SYNOPSIS
  1945.      #include  <stdio.h>
  1946.  
  1947.      int       remove(char * s)
  1948.  
  1949. DESCRIPTION
  1950.  
  1951.      ■&Remove() will attempt to remove the file named by the  argu-
  1952.      ment  s  from  the directory. A return value of -1 indicates
  1953.      that the attempt failed.
  1954.  
  1955. SEE ALSO
  1956.      unlink
  1957.  
  1958. %RENAME
  1959.  
  1960. SYNOPSIS
  1961.      #include  <stdio.h>
  1962.  
  1963.      int       rename(char * name1, char * name2)
  1964.  
  1965. DESCRIPTION
  1966.  
  1967.      The file named by name1 will be renamed to name2. -1 will be
  1968.      returned if the rename was not successful. Note that renames
  1969.      across user numbers or drives are not permitted.
  1970.  
  1971. SEE ALSO
  1972.      open, close, unlink
  1973.  
  1974. %REWIND
  1975.  
  1976. SYNOPSIS
  1977.      #include  <stdio.h>
  1978.  
  1979.      int       rewind(FILE * stream)
  1980.  
  1981. DESCRIPTION
  1982.  
  1983.      This function will attempt  to  re-position  the  read/write
  1984.      pointer  of  the  nominated  stream  to the beginning of the
  1985.      file. A return value of -1 indicates that  the  attempt  was
  1986.      not  successful,  perhaps  because  the stream is associated
  1987.      with a non-random access file such as a character device.
  1988.  
  1989. SEE ALSO
  1990.      fseek, ftell
  1991.  
  1992. %SBRK
  1993.  
  1994. SYNOPSIS
  1995.      char *    sbrk(int incr)
  1996.  
  1997. DESCRIPTION
  1998.  
  1999.      ■$Sbrk() increments the current highest memory location  allo-
  2000.      cated to the program by incr bytes.  It returns a pointer to
  2001.      the  previous  highest  location.  Thus  ■$sbrk(■!0)  returns  a
  2002.      pointer  to  the  current highest location, without altering
  2003.      its value.  If there is insufficient memory to  satisfy  the
  2004.      request, -1 is returned.
  2005.  
  2006. SEE ALSO
  2007.      brk, malloc, calloc, realloc, free
  2008.  
  2009. %SCANF
  2010.  
  2011. SYNOPSIS
  2012.      #include  <stdio.h>
  2013.  
  2014.      int       scanf(char * fmt, ...)
  2015.      int       vscanf(char *, va_list ap);
  2016.  
  2017. DESCRIPTION
  2018.  
  2019.      ■%Scanf() performs formatted  input  ("de-editing")  from  the
  2020.      stdin stream. Similar functions are available for streams in
  2021.      general, and for strings.  The function ■&vscanf() is similar,
  2022.      but takes a pointer to an argument list rather than a series
  2023.      of additional arguments. This pointer should have been  ini-
  2024.      tialized  with  ■"va_■%start().   The input conversions are per-
  2025.      formed according to the fmt string; in general  a  character
  2026.      in  the  format  string must match a character in the input;
  2027.      however a space character in the format  string  will  match
  2028.      zero  or  more  "white  space" characters in the input, i.e.
  2029.      spaces, tabs or newlines.  A conversion specification  takes
  2030.      the  form  of the character %, optionally followed by an as-
  2031.      signment suppression character ('*'), optionally followed by
  2032.      a  numerical  maximum  field width, followed by a conversion
  2033.      specification character. Each conversion specification,  un-
  2034.      less  it  incorporates the assignment suppression character,
  2035.      will assign a value to the variable pointed at by  the  next
  2036.      argument. Thus if there are two conversion specifications in
  2037.      the fmt string, there should be two additional pointer argu-
  2038.      ments.  The conversion characters are as follows:
  2039. o x d
  2040.  
  2041.      Skip white space, then convert a number in base 8, 16 or  10
  2042.      radix  respectively.  If a field width was supplied, take at
  2043.      most that many characters from the input.  A  leading  minus
  2044.      sign will be recognized.
  2045. f
  2046.  
  2047.      Skip white space, then convert a floating number  in  either
  2048.      conventional  or  scientific  notation.  The field width ap-
  2049.      plies as above.
  2050. s
  2051.  
  2052.      Skip white space, then copy a  maximal  length  sequence  of
  2053.      non-white-space  characters.  The pointer argument must be a
  2054.      pointer to char.  The field width will limit the  number  of
  2055.      characters  copied.  The  resultant  string  will  be  null-
  2056.      terminated.
  2057. c
  2058.  
  2059.      Copy the next character from the input. The pointer argument
  2060.      is  assumed  to  be  a  pointer to char. If a field width is
  2061.      specified, then copy that many characters. This differs from
  2062.      the  s  format  in  that  white space does not terminate the
  2063.      character sequence.
  2064.  
  2065.  
  2066. The conversion characters o, x, u, d and f may be preceded by  an
  2067.      l  to  indicate that the corresponding pointer argument is a
  2068.      pointer to long or double as appropriate. A preceding h will
  2069.      indicate  that  the  pointer  argument is a pointer to short
  2070.      rather than int.
  2071.  
  2072.  
  2073. ■%Scanf() returns the number of successful conversions; EOF is  re-
  2074.      turned  if  end-of-file was seen before any conversions were
  2075.      performed. Some examples are:
  2076.  
  2077.        scanf("%d %s", &a, &s)
  2078.              with input "      12s"
  2079.        will assign 12 to a, and "s" to s.
  2080.  
  2081.        scanf("%4cd %lf", &c, &f)
  2082.              with input " abcd -3.5"
  2083.        will assign " abc" to c, and -3.5 to f.
  2084.  
  2085.  
  2086. SEE ALSO
  2087.      fscanf, sscanf, printf, va_arg
  2088.  
  2089. %SEGREAD
  2090.  
  2091. SYNOPSIS
  2092.      #include  <dos.h>
  2093.      int       segread(struct SREGS * segregs)
  2094.  
  2095. DESCRIPTION
  2096.  
  2097.      ■'Segread() copies the values of the  segment  registers  into
  2098.      the structure pointed to by segregs.
  2099.  
  2100. SEE ALSO
  2101.      int86, int86x, intdos, intdosx
  2102.  
  2103. %SETJMP
  2104.  
  2105. SYNOPSIS
  2106.      #include <setjmp.h>
  2107.      int       setjmp(jmp_buf buf)
  2108.  
  2109. DESCRIPTION
  2110.  
  2111.      ■&Setjmp() is used with ■'longjmp()  for  non-local  gotos.  See
  2112.      ■'longjmp() for further information.
  2113.  
  2114. SEE ALSO
  2115.      longjmp
  2116.  
  2117. %SETUID
  2118.  
  2119. SYNOPSIS
  2120.      #include  <sys.h>
  2121.  
  2122.      void setuid(int uid)
  2123.  
  2124. DESCRIPTION
  2125.  
  2126.      ■&Setuid() will set the current user number to uid. Uid should
  2127.      be a number in the range 0-15.
  2128.  
  2129. SEE ALSO
  2130.      getuid
  2131.  
  2132. %SETVBUF
  2133. %SETBUF
  2134.  
  2135. SYNOPSIS
  2136.      #include  <stdio.h>
  2137.  
  2138.      int       setvbuf(FILE * stream, char * buf,
  2139.                int mode, size_t size);
  2140.      void      setbuf(FILE * stream, char * buf)
  2141.  
  2142. DESCRIPTION
  2143.  
  2144.      The ■'setvbuf() function allows the buffering behaviour  of  a
  2145.      STDIO  stream to be altered. It supersedes the function ■$set-
  2146.      ■#buf() which is retained for  backwards  compatibility.   The
  2147.      arguments to ■'setvbuf() are as follows: stream designates the
  2148.      STDIO stream to be affected; buf is a pointer  to  a  buffer
  2149.      which will be used for all subsequent I/O operations on this
  2150.      stream. If buf is null, then the  routine  will  allocate  a
  2151.      buffer from the heap if necessary, of size BUFSIZ as defined
  2152.      in <stdio.h>.  mode may take  the  values  _IONBF,  to  turn
  2153.      buffering  off  completely,  _IOFBF,  for full buffering, or
  2154.      _IOLBF for line buffering. Full buffering means that the as-
  2155.      sociated  buffer  will only be flushed when full, while line
  2156.      buffering means that the buffer will be flushed at  the  end
  2157.      of  each  line or when input is requested from another STDIO
  2158.      stream. size is the size of the buffer supplied.  For  exam-
  2159.      ple:
  2160.  
  2161.        setvbuf(stdout, my_buf, _IOLBF, sizeof my_buf);
  2162.  
  2163.      If a buffer is supplied by  the  caller,  that  buffer  will
  2164.      remain   associated  with  that  stream  even  over■&fclose(),
  2165.      ■%fopen() calls until another ■'setvbuf() changes it.
  2166.  
  2167. SEE ALSO
  2168.      fopen, freopen, fclose
  2169.  
  2170. %SET_VECTOR
  2171.  
  2172. SYNOPSIS
  2173.      #include  <intrpt.h>
  2174.      typedef interrupt void (*isr)();
  2175.      isr set_vector(isr * vector, isr func);
  2176.  
  2177. DESCRIPTION
  2178.  
  2179.      This routine allows an interrupt vector to  be  initialized.
  2180.      The  first  argument  should be the address of the interrupt
  2181.      vector (not the vector number but the actual  address)  cast
  2182.      to  a pointer to ■#isr, which is a typedef'd pointer to an in-
  2183.      terrupt function. The second argument should be the function
  2184.      which  you  want the interrupt vector to point to. This must
  2185.      be declared using the ■)interrupt type qualifier.  The  return
  2186.      value  of  ■#set_■&vector() is the previous contents of the vec-
  2187.      tor.
  2188.  
  2189. SEE ALSO
  2190.      di(), ei()
  2191.  
  2192. %SIGNAL
  2193.  
  2194. SYNOPSIS
  2195.      #include <signal.h>
  2196.      void (* signal)(int sig, void (*func)());
  2197.  
  2198. DESCRIPTION
  2199.  
  2200.      ■&Signal()  provides  a  mechanism  for  catching  control-C's
  2201.      (ctrl-BREAK  for  MS-DOS)  typed  on the console during I/O.
  2202.      Under CP/M the console is polled whenever  an  I/O  call  is
  2203.      performed,  while for MS-DOS the polling depends on the set-
  2204.      ting of the BREAK command.  If a control-C is detected  cer-
  2205.      tain action will be performed. The default action is to exit
  2206.      summarily; this may be modified with ■&signal(). The sig argu-
  2207.      ment  to signal may at the present time be only SIGINT, sig-
  2208.      nifying an interrupt condition. The func argument may be one
  2209.      of SIG_DFL, representing the default action, SIG_IGN, to ig-
  2210.      nore control-C's completely, or the address  of  a  function
  2211.      which  will  be  called with one argument, the number of the
  2212.      signal caught, when a control-C is seen. As the only  signal
  2213.      supported  is  SIGINT,  this will always be the value of the
  2214.      argument to the called function.
  2215.  
  2216. SEE ALSO
  2217.      exit
  2218.  
  2219. %SIN
  2220.  
  2221. SYNOPSIS
  2222.      #include  <math.h>
  2223.  
  2224.      double    sin(double f);
  2225.  
  2226. DESCRIPTION
  2227.  
  2228.      This function returns the sine function of its argument.
  2229.  
  2230. SEE ALSO
  2231.      cos, tan, asin, acos, atan
  2232.  
  2233. %SPAWNL
  2234. %SPAWNV
  2235. %SPAWNVE
  2236.  
  2237. SYNOPSIS
  2238.      int       spawnl(char * n, char * argv0, ...);
  2239.      int       spawnv(cahr * n, char ** v)
  2240.      int       spawnve(char * n, char ** v, char ** e)
  2241.  
  2242. DESCRIPTION
  2243.  
  2244.      These functions will load and execute a  sub-program,  named
  2245.      by  the  argument  n. The calling conventions are similar to
  2246.      the functions ■%execl() and ■%execv(), the difference being that
  2247.      the spawn functions return to the calling program after ter-
  2248.      mination of the sub-program, while the exec functions return
  2249.      only  if the program could not be executed.  ■'Spawnve() takes
  2250.      an environment list in the same format as the argument  list
  2251.      which  will  be  supplied to the executed program as its en-
  2252.      vironment.
  2253.  
  2254. SEE ALSO
  2255.      execl, execv
  2256.  
  2257. %SPRINTF
  2258.  
  2259. SYNOPSIS
  2260.      #include  <stdio.h>
  2261.  
  2262.      int       sprintf(char * buf, char * fmt, ...);
  2263.      int       vsprintf(char * buf, char * fmt, va_list ap);
  2264.  
  2265. DESCRIPTION
  2266.  
  2267.      ■'Sprintf() operates in a similar fashion to ■&printf(),  except
  2268.      that  instead  of placing the converted output on the stdout
  2269.      stream, the characters are placed in the buffer at buf.  The
  2270.      resultant  string will be null-terminated, and the number of
  2271.      characters in the buffer will be returned.   ■(Vsprintf  takes
  2272.      an argument pointer rather than a list of arguments.
  2273.  
  2274. SEE ALSO
  2275.      printf, fprintf, sscanf
  2276.  
  2277. %SQRT
  2278.  
  2279. SYNOPSIS
  2280.      #include  <math.h>
  2281.  
  2282.      double    sqrt(double f)
  2283.  
  2284. DESCRIPTION
  2285.  
  2286.      ■$Sqrt() implements a square root function using Newton's  ap-
  2287.      proximation.
  2288.  
  2289. SEE ALSO
  2290.      exp
  2291.  
  2292. %SSCANF
  2293.  
  2294. SYNOPSIS
  2295.      #include  <stdio.h>
  2296.  
  2297.      int       sscanf(char * buf, char * fmt, ...);
  2298.      int       vsscanf(char * buf, char * fmt, va_list ap);
  2299.  
  2300. DESCRIPTION
  2301.  
  2302.      ■&Sscanf() operates in a similar  manner  to  ■%scanf(),  except
  2303.      that instead of the conversions being taken from stdin, they
  2304.      are taken from the string at buf.
  2305.  
  2306. SEE ALSO
  2307.      scanf, fscanf, sprintf
  2308.  
  2309. %SRAND
  2310.  
  2311. SYNOPSIS
  2312.      #include  <stdlib.h>
  2313.  
  2314.      void srand(int seed)
  2315.  
  2316. DESCRIPTION
  2317.  
  2318.      ■%Srand() initializes the random number generator accessed  by
  2319.      ■$rand()  with  the  given seed. This provides a mechanism for
  2320.      varying the starting point  of  the  pseudo-random  sequence
  2321.      yielded  by  ■$rand(). On the z80, a good place to get a truly
  2322.      random seed is from the refresh register. Otherwise timing a
  2323.      response from the console will do.
  2324.  
  2325. SEE ALSO
  2326.      rand
  2327.  
  2328. %STAT
  2329.  
  2330. SYNOPSIS
  2331.      #include  <stat.h>
  2332.  
  2333.      int       stat(char * name, struct stat * statbuf)
  2334.  
  2335. DESCRIPTION
  2336.  
  2337.      This routine returns information about the file by name. The
  2338.      information  returned is operating system dependent, but may
  2339.      include file attributes (e.g.   read  only),  file  size  in
  2340.      bytes, and file modification and/or access times.  The argu-
  2341.      ment name should be the name of the file,  and  may  include
  2342.      path names under DOS, user numbers under CP/M, etc.  The ar-
  2343.      gument statbuf should be the address of a structure  as  de-
  2344.      fined in ■$stat.■!h which will be filled in with the information
  2345.      about the file. The structure of ■&struct ■$stat is as follows:
  2346.  
  2347.        struct stat
  2348.        {
  2349.         short    st_mode;  /* flags */
  2350.         long     st_atime; /* access time */
  2351.         long     st_mtime; /* modification time */
  2352.         long     st_size;  /* file size */
  2353.        };
  2354.  
  2355.      The access and modification times (under DOS these are  both
  2356.      set  to the modification time) are in seconds since 00:00:00
  2357.      Jan 1 1970. The function ■%ctime() may be used to convert this
  2358.      to a readable value.  The file size is self explanatory. The
  2359.      flag bits are as follows: center; cc ll.   Flag      Meaning
  2360.      _ S_IFMT    mask for file type S_IFDIR   file is a directory
  2361.      S_IFREG   file is a regular file S_IREAD   file is  readable
  2362.      S_IWRITE  file  is  writeable  S_IEXEC   file  is executable
  2363.      S_HIDDEN  file is hidden  S_SYSTEM  file  is  marked  system
  2364.      S_ARCHIVE file  has  been  written to ■$Stat returns 0 on suc-
  2365.      cess, -1 on failure, e.g. if the file could not be found.
  2366.  
  2367. SEE ALSO
  2368.      ctime, creat, chmod
  2369.  
  2370. %STRCAT
  2371. %STRCMP
  2372. %STRCPY
  2373. %STRLEN
  2374. %STRNCAT
  2375. %STRNCMP
  2376. %STRNCPY
  2377.  
  2378. SYNOPSIS
  2379.      #include  <string.h>
  2380.  
  2381.      char *    strcat(char * s1, char * s2);
  2382.      int       strcmp(char * s1, char * s2);
  2383.      char *    strcpy(char * s1, char * s2);
  2384.      int       strlen(char * s);
  2385.      char *    strncat(char * s1, char * s2, size_t n);
  2386.      int       strncmp(char * s1, char * s2, size_t n);
  2387.      char *    strncpy(char * s1, char * s2, size_t n);
  2388.  
  2389. DESCRIPTION
  2390.  
  2391.      These  functions  provide  operations   on   null-terminated
  2392.      strings.  ■&Strcat()  appends  the string s2 to the end of the
  2393.      string s1.  The string at s1 will be null terminated.  Need-
  2394.      less  to  say  the buffer at s1 must be big enough. ■&Strcmp()
  2395.      compares the two strings and returns a number  greater  than
  2396.      0,  0  or  a  number  less than 0 according to whether s1 is
  2397.      greater than, equal to or less than s2. The  comparision  is
  2398.      via  the ascii collating order, with the first character the
  2399.      most significant.  ■&Strcpy() copies s2 into the buffer at s1,
  2400.      null terminating it.  ■&Strlen() returns the length of s1, not
  2401.      including the terminating null.   ■'Strncat(),  ■'strncmp()  and
  2402.      ■'strncpy()  will  catenate, compare and copy s2 and s1 in the
  2403.      same manner as their similarly named counterparts above, but
  2404.      involving at most n characters. For ■'strncpy(), the resulting
  2405.      string may not be null terminated.
  2406. %STRCHR
  2407. %STRRCHR
  2408.  
  2409. SYNOPSIS
  2410.      #include  <string.h>
  2411.  
  2412.      char *    strchr(char * s, int c)
  2413.      char *    strrchr(char * s, int c)
  2414.  
  2415. DESCRIPTION
  2416.  
  2417.      These functions locate an instance of the character c in the
  2418.      string s. In the case of ■&strchr() a pointer will be returned
  2419.      to the first instance of the character  found  be  searching
  2420.      from  the  beginning of the string, while ■'strrchr() searches
  2421.      backwards from the end of the string. A null pointer is  re-
  2422.      turned if the character does not exist in the string.
  2423.  
  2424. SEE ALSO
  2425.  
  2426. %SYSTEM
  2427.  
  2428. SYNOPSIS
  2429.      #include  <sys.h>
  2430.  
  2431.      int       system(char * s)
  2432.  
  2433. DESCRIPTION
  2434.  
  2435.      When executed under MS-DOS ■&system() will pass  the  argument
  2436.      string to the command processor, located via the environment
  2437.      string COMSPEC, for execution. The exit status of  the  com-
  2438.      mand  processor  will be returned from the call to system().
  2439.      For example, to set the baud rate on the serial port  on  an
  2440.      MS-DOS machine:
  2441.  
  2442.            system("MODE COM1:96,N,8,1,P");
  2443.  
  2444.      This function will not work on CP/M-86  since  it  does  not
  2445.      have an invokable command interpreter. Under Concurrent CP/M
  2446.      the CLI system call is used.
  2447.  
  2448. SEE ALSO
  2449.      spawnl, spawnv
  2450.  
  2451. %TAN
  2452.  
  2453. SYNOPSIS
  2454.      #include  <math.h>
  2455.  
  2456.      double    tan(double f);
  2457.  
  2458. DESCRIPTION
  2459.  
  2460.      This is the tangent function.
  2461.  
  2462. SEE ALSO
  2463.      sin, cos, asin, acos, atan
  2464.  
  2465. %TIME
  2466.  
  2467. SYNOPSIS
  2468.      #include  <time.h>
  2469.  
  2470.      time_t    time(time_t * t)
  2471.  
  2472. DESCRIPTION
  2473.  
  2474.      This function returns the  current  time  in  seconds  since
  2475.      00:00:00 on Jan 1, 1970.  If the argument t is non-null, the
  2476.      same value is stored into the object pointed to by  t.   The
  2477.      accuracy  of  this  function  is  naturally dependent on the
  2478.      operating system having the correct time. This function does
  2479.      not  work  under  CP/M-86  or  CP/M  2.2 but does work under
  2480.      Concurrent-CP/M and CP/M+.
  2481.  
  2482. SEE ALSO
  2483.      ctime, gmtime, localtime, asctime
  2484.  
  2485. %TOUPPER
  2486. %TOLOWER
  2487. %TOASCII
  2488.  
  2489. SYNOPSIS
  2490.      #include  <ctype.h>
  2491.      char toupper(int c);
  2492.      char tolower(int c);
  2493.      char toascii(int c);
  2494.      char      c;
  2495.  
  2496. DESCRIPTION
  2497.  
  2498.      ■'Toupper() converts its lower  case  alphabetic  argument  to
  2499.      upper  case,  ■'tolower() performs the reverse conversion, and
  2500.      ■'toascii() returns a result that is guaranteed in  the  range
  2501.      0-0177.  ■'Toupper()  and ■'tolower return their arguments if it
  2502.      is not an alphabetic character.
  2503.  
  2504. SEE ALSO
  2505.      islower, isupper, isascii et. al.
  2506.  
  2507. %UNGETC
  2508.  
  2509. SYNOPSIS
  2510.      #include  <stdio.h>
  2511.  
  2512.      int       ungetc(int c, FILE * stream)
  2513.  
  2514. DESCRIPTION
  2515.  
  2516.      ■&Ungetc() will attempt to push back the character c onto  the
  2517.      named  stream,  such that a subsequent ■$getc() operation will
  2518.      return the character. At most one level of pushback will  be
  2519.      allowed,  and  if  the stream is not buffered, even this may
  2520.      not be possible. EOF is returned if the ■&ungetc()  could  not
  2521.      be performed.
  2522.  
  2523. SEE ALSO
  2524.      getc
  2525.  
  2526. %UNLINK
  2527.  
  2528. SYNOPSIS
  2529.      int       unlink(char * name)
  2530.  
  2531. DESCRIPTION
  2532.  
  2533.      ■&Unlink() will remove (delete) the named file, that is  erase
  2534.      the file from its directory. See ■$open() for a description of
  2535.      the file name construction.  Zero will be returned  if  suc-
  2536.      cessful, -1 if the file did not exist or it could not be re-
  2537.      moved.
  2538.  
  2539. SEE ALSO
  2540.      open, close, rename, remove
  2541.  
  2542. %VA_START
  2543. %VA_ARG
  2544. %VA_END
  2545.  
  2546. SYNOPSIS
  2547.      #include  <stdarg.h>
  2548.  
  2549.      void      va_start(va_list ap, ■%parmN);
  2550.      ■$type      va_arg(ap, ■$type);
  2551.      void      va_end(va_list ap);
  2552.  
  2553. DESCRIPTION
  2554.  
  2555.      These macros are provided to give access in a  portable  way
  2556.      to  parameters  to  a function represented in a prototype by
  2557.      the ellipsis symbol (...), where type and  number  of  argu-
  2558.      ments  supplied  to  the  function  are not known at compile
  2559.      time. The rightmost parameter  to  the  function  (shown  as
  2560.      ■%parmN) plays an important role in these macros, as it is the
  2561.      starting point for access to further parameters. In a  func-
  2562.      tion  taking  variable  numbers  of arguments, a variable of
  2563.      type va_list should be declared, then the macro va_start in-
  2564.      voked  with  that  variable and the name of ■%parmN. This will
  2565.      initialize the variable to allow  subsequent  calls  of  the
  2566.      macro  va_arg  to access successive parameters. Each call to
  2567.      va_arg requires two arguments; the variable  previously  de-
  2568.      fined and a type name which is the type that the next param-
  2569.      eter is expected to be. Note that  any  arguments  thus  ac-
  2570.      cessed  will have been widened by the default conventions to
  2571.      ■#int, ■(unsigned ■#int or ■&double.  For example if a character ar-
  2572.      gument  has been passed, it should be accessed by va_arg(ap,
  2573.      int) since the char will have been widened to ■#int.  An exam-
  2574.      ple  is given below of a function taking one integer parame-
  2575.      ter, followed by a number of other parameters. In this exam-
  2576.      ple  the  function  expects  the subsequent parameters to be
  2577.      pointers to char, but note that the compiler is not aware of
  2578.      this,  and  it  is  the programmers responsibility to ensure
  2579.      that correct arguments are supplied.
  2580.  
  2581.        #include    <stdarg.h>
  2582.        prf(int n, ...)
  2583.        {
  2584.            va_list ap;
  2585.  
  2586.            va_start(ap, n);
  2587.            while(n--)
  2588.              puts(va_arg(ap, char *));
  2589.            va_end(ap);
  2590.        }
  2591.  
  2592. %WRITE
  2593.  
  2594. SYNOPSIS
  2595.      #include  <unixio.h>
  2596.  
  2597.      int       write(int fd, void * buf, size_t cnt)
  2598.  
  2599. DESCRIPTION
  2600.  
  2601.      ■%Write() will write from the buffer at buf up to cnt bytes to
  2602.      the  file associated with the file descriptor fd. The number
  2603.      of bytes actually written will be returned. EOF or  a  value
  2604.      less  than  cnt will be returned on error.  In any case, any
  2605.      return value not equal to cnt should be treated as an  error
  2606.      (cf. ■$read() ).
  2607.  
  2608. SEE ALSO
  2609.      open, close, read
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.