home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man3 / putc.3 < prev    next >
Encoding:
Text File  |  1975-06-26  |  1.6 KB  |  101 lines

  1. .th PUTC III 6/12/72
  2. .sh NAME
  3. putc, putw, fcreat, fflush  \*-  buffered output
  4. .sh SYNOPSIS
  5. .ft B
  6. .nf
  7. mov    $filename,r0
  8. jsr    r5,fcreat; iobuf
  9. .s3
  10. fcreat(file, iobuf)
  11. char *file;
  12. struct buf *iobuf;
  13. .s3
  14. .ft R
  15. (get byte in r0)
  16. .ft B
  17. jsr    r5,putc; iobuf
  18. .s3
  19. putc(c, iobuf)
  20. int c;
  21. struct buf *iobuf;
  22. .s3
  23. .ft R
  24. (get word in r0)
  25. .ft B
  26. jsr    r5,putw; iobuf
  27. .s3
  28. putw(w, iobuf);
  29. .br
  30. int w;
  31. .br
  32. struct buf *iobuf;
  33. .s3
  34. jsr    r5,flush; iobuf
  35. .s3
  36. fflush(iobuf)
  37. struct buf *iobuf;
  38. .fi
  39. .ft R
  40. .sh DESCRIPTION
  41. .it Fcreat
  42. creates
  43. the given file (mode 666) and sets up the buffer
  44. .it iobuf
  45. (size 518 bytes);
  46. .it putc
  47. and
  48. .it putw
  49. write a byte or word respectively
  50. onto the file;
  51. .it flush
  52. forces the contents of the buffer to be written, but
  53. does not close the file.
  54. The structure of the buffer is:
  55. .nf
  56. .ft B
  57. .nf
  58. struct buf {
  59.     int fildes;    /* File descriptor */
  60.     int nunused;    /* Remaining slots */
  61.     char *xfree;    /* Ptr to next free slot */
  62.     char buff[512];    /* The buffer */
  63. };
  64. .ft R
  65. .s3
  66. .fi
  67. Before terminating, a program should call
  68. .it flush
  69. to force out the last of the output
  70. .it (fflush
  71. from C).
  72. .s3
  73. The user must supply
  74. .it iobuf,
  75. which should begin on a word boundary.
  76. .s3
  77. To write a new file using the same buffer, it
  78. suffices to call
  79. .it [f]flush,
  80. close the file,
  81. and
  82. call
  83. .it fcreat
  84. again.
  85. .sh "SEE ALSO"
  86. creat (II), write (II), getc (III)
  87. .sh DIAGNOSTICS
  88. .it Fcreat
  89. sets the error bit (c-bit) if the 
  90. file creation failed (from C, returns \*-1).
  91. .it Putc
  92. and
  93. .it putw
  94. return their character (word) argument.
  95. In all calls 
  96. .it errno
  97. is set appropriately to 0 or to
  98. a system error number.
  99. See introduction (II).
  100. .sh BUGS
  101.