jose_io.3 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. .TH "jose_io" 3 "Tue May 30 2017" "José" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. jose_io \- IO Chaining\&.
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .SS "Data Structures"
  10. .in +1c
  11. .ti -1c
  12. .RI "struct \fBjose_io_t\fP"
  13. .br
  14. .RI "The interface for chained IO\&. "
  15. .in -1c
  16. .SS "Typedefs"
  17. .in +1c
  18. .ti -1c
  19. .RI "typedef \fBjose_io_t\fP \fBjose_io_auto_t\fP"
  20. .br
  21. .RI "Defines a \fBjose_io_t\fP which calls \fBjose_io_decref()\fP at end of scope\&. "
  22. .in -1c
  23. .SS "Functions"
  24. .in +1c
  25. .ti -1c
  26. .RI "\fBjose_io_t\fP * \fBjose_io_incref\fP (\fBjose_io_t\fP *io)"
  27. .br
  28. .RI "Increases the reference count of an IO object\&. "
  29. .ti -1c
  30. .RI "void \fBjose_io_decref\fP (\fBjose_io_t\fP *io)"
  31. .br
  32. .RI "Decreases the reference count of an IO object\&. "
  33. .ti -1c
  34. .RI "\fBjose_io_t\fP * \fBjose_io_malloc\fP (jose_cfg_t *cfg, void **buf, size_t *len)"
  35. .br
  36. .RI "Creates a new IO object which collects data into a dynamic buffer\&. "
  37. .ti -1c
  38. .RI "void * \fBjose_io_malloc_steal\fP (void **buf)"
  39. .br
  40. .RI "Steals the buffer created by the \fBjose_io_malloc()\fP IO object\&. "
  41. .ti -1c
  42. .RI "\fBjose_io_t\fP * \fBjose_io_buffer\fP (jose_cfg_t *cfg, void *buf, size_t *len)"
  43. .br
  44. .RI "Creates a new IO object which collects data into a static buffer\&. "
  45. .ti -1c
  46. .RI "\fBjose_io_t\fP * \fBjose_io_file\fP (jose_cfg_t *cfg, FILE *file)"
  47. .br
  48. .RI "Creates a new IO object which writes data into a FILE\&. "
  49. .ti -1c
  50. .RI "\fBjose_io_t\fP * \fBjose_io_multiplex\fP (jose_cfg_t *cfg, \fBjose_io_t\fP **nexts, bool all)"
  51. .br
  52. .RI "Creates a new IO object which multiplexes data into multiple IO objects\&. "
  53. .in -1c
  54. .SH "Detailed Description"
  55. .PP
  56. IO Chaining\&.
  57. .SH "Typedef Documentation"
  58. .PP
  59. .SS "typedef \fBjose_io_t\fP \fBjose_io_auto_t\fP"
  60. .PP
  61. Defines a \fBjose_io_t\fP which calls \fBjose_io_decref()\fP at end of scope\&. For example:
  62. .PP
  63. .nf
  64. void foo() {
  65. uint8_t *buf = NULL;
  66. size_t len = 0;
  67. jose_io_auto_t *io = jose_io_malloc(NULL, &buf, &len);
  68. // jose_io_decref() implicitly called
  69. }
  70. .fi
  71. .PP
  72. .SH "Function Documentation"
  73. .PP
  74. .SS "\fBjose_io_t\fP* jose_io_incref (\fBjose_io_t\fP * io)"
  75. .PP
  76. Increases the reference count of an IO object\&. This function always succeeds\&.
  77. .PP
  78. \fBParameters:\fP
  79. .RS 4
  80. \fIio\fP The \fBjose_io_t\fP entity you are using\&.
  81. .RE
  82. .PP
  83. \fBReturns:\fP
  84. .RS 4
  85. The value of \fCio\fP (for convenience)\&.
  86. .RE
  87. .PP
  88. .SS "void jose_io_decref (\fBjose_io_t\fP * io)"
  89. .PP
  90. Decreases the reference count of an IO object\&. When the reference count reaches zero, io->free() is called\&.
  91. .PP
  92. \fBParameters:\fP
  93. .RS 4
  94. \fIio\fP The \fBjose_io_t\fP entity you are using\&.
  95. .RE
  96. .PP
  97. .SS "\fBjose_io_t\fP* jose_io_malloc (jose_cfg_t * cfg, void ** buf, size_t * len)"
  98. .PP
  99. Creates a new IO object which collects data into a dynamic buffer\&. The dynamic buffer is allocated into the \fCbuf\fP pointer you provided and the length of the buffer is stored in \fClen\fP\&. The pointer referenced by \fCbuf\fP must remain valid for the entire duration of the returned IO object\&.
  100. .PP
  101. The default behavior is for the IO object to zero and free the buffer when it is freed\&. This means that, by default, you own the buffer pointer but the buffer itself is owned by the IO object\&. You can, however, steal the buffer by setting the buffer pointer to NULL\&.
  102. .PP
  103. \fBSee also:\fP
  104. .RS 4
  105. \fBjose_io_malloc_steal()\fP
  106. .RE
  107. .PP
  108. \fBParameters:\fP
  109. .RS 4
  110. \fIcfg\fP The configuration context (optional)\&.
  111. .br
  112. \fIbuf\fP A buffer pointer pointer\&.
  113. .br
  114. \fIlen\fP A pointer to the length of the buffer\&.
  115. .RE
  116. .PP
  117. \fBReturns:\fP
  118. .RS 4
  119. The new IO object or NULL on error\&.
  120. .RE
  121. .PP
  122. .SS "void* jose_io_malloc_steal (void ** buf)"
  123. .PP
  124. Steals the buffer created by the \fBjose_io_malloc()\fP IO object\&. This convenience function simply returns the value of \fC*buf\fP and then sets \fC*buf\fP to NULL\&.
  125. .PP
  126. \fBSee also:\fP
  127. .RS 4
  128. \fBjose_io_malloc()\fP
  129. .RE
  130. .PP
  131. \fBParameters:\fP
  132. .RS 4
  133. \fIbuf\fP A pointer to the buffer pointer\&.
  134. .RE
  135. .PP
  136. \fBReturns:\fP
  137. .RS 4
  138. The value of \fC*buf\fP before it is set to NULL\&.
  139. .RE
  140. .PP
  141. .SS "\fBjose_io_t\fP* jose_io_buffer (jose_cfg_t * cfg, void * buf, size_t * len)"
  142. .PP
  143. Creates a new IO object which collects data into a static buffer\&. The size of \fCbuf\fP MUST be specified in the variable pointed to by \fClen\fP\&. This will be the maximum data written\&. However, after the function returns, the variable pointed to by \fClen\fP will contain the current length of data in the buffer\&.
  144. .PP
  145. Unlike \fBjose_io_malloc()\fP, you own the buffer and it is not zeroed or freed when the IO object is freed\&.
  146. .PP
  147. \fBParameters:\fP
  148. .RS 4
  149. \fIcfg\fP The configuration context (optional)\&.
  150. .br
  151. \fIbuf\fP A buffer pointer\&.
  152. .br
  153. \fIlen\fP A pointer to the length of the buffer\&.
  154. .RE
  155. .PP
  156. \fBReturns:\fP
  157. .RS 4
  158. The new IO object or NULL on error\&.
  159. .RE
  160. .PP
  161. .SS "\fBjose_io_t\fP* jose_io_file (jose_cfg_t * cfg, FILE * file)"
  162. .PP
  163. Creates a new IO object which writes data into a FILE\&. This function DOES NOT take ownership of the FILE\&. You are still responsible for calling fclose() at the appropriate time\&.
  164. .PP
  165. \fBParameters:\fP
  166. .RS 4
  167. \fIcfg\fP The configuration context (optional)\&.
  168. .br
  169. \fIfile\fP The output file which MUST be opened for writing or appending\&.
  170. .RE
  171. .PP
  172. \fBReturns:\fP
  173. .RS 4
  174. The new IO object or NULL on error\&.
  175. .RE
  176. .PP
  177. .SS "\fBjose_io_t\fP* jose_io_multiplex (jose_cfg_t * cfg, \fBjose_io_t\fP ** nexts, bool all)"
  178. .PP
  179. Creates a new IO object which multiplexes data into multiple IO objects\&. If \fCall\fP is true, the success of all \fCnexts\fP is required\&. Otherwise, all but one of the \fCnexts\fP can fail before the error is propagated upward\&.
  180. .PP
  181. \fBParameters:\fP
  182. .RS 4
  183. \fIcfg\fP The configuration context (optional)\&.
  184. .br
  185. \fInexts\fP A NULL-terminated array of IO object pointers\&.
  186. .br
  187. \fIall\fP Whether or not the success of all \fCnexts\fP is required\&.
  188. .RE
  189. .PP
  190. \fBReturns:\fP
  191. .RS 4
  192. The new IO object or NULL on error\&.
  193. .RE
  194. .PP
  195. .SH "Author"
  196. .PP
  197. Generated automatically by Doxygen for José from the source code\&.