ucx/cx/streams.h

branch
dav-2
changeset 889
42cdbf9bbd49
parent 854
1c8401ece69e
equal deleted inserted replaced
887:26541c37b619 889:42cdbf9bbd49
52 * @param dest the destination stream 52 * @param dest the destination stream
53 * @param rfnc the read function 53 * @param rfnc the read function
54 * @param wfnc the write function 54 * @param wfnc the write function
55 * @param buf a pointer to the copy buffer or @c NULL if a buffer 55 * @param buf a pointer to the copy buffer or @c NULL if a buffer
56 * shall be implicitly created on the heap 56 * shall be implicitly created on the heap
57 * @param bufsize the size of the copy buffer - if @p buf is @c NULL you can 57 * @param bufsize the size of the copy buffer - if @p buf is @c NULL, you can
58 * set this to zero to let the implementation decide 58 * set this to zero to let the implementation decide
59 * @param n the maximum number of bytes that shall be copied. 59 * @param n the maximum number of bytes that shall be copied.
60 * If this is larger than @p bufsize, the content is copied over multiple 60 * If this is larger than @p bufsize, the content is copied over multiple
61 * iterations. 61 * iterations.
62 * @return the total number of bytes copied 62 * @return the total number of bytes copied
63 */ 63 */
64 cx_attr_nonnull_arg(1, 2, 3, 4) 64 cx_attr_nonnull_arg(1, 2, 3, 4)
65 cx_attr_access_r(1) 65 cx_attr_access_r(1) cx_attr_access_w(2) cx_attr_access_w(5)
66 cx_attr_access_w(2) 66 CX_EXPORT size_t cx_stream_bncopy(void *src, void *dest,
67 cx_attr_access_w(5) 67 cx_read_func rfnc, cx_write_func wfnc,
68 cx_attr_export 68 char *buf, size_t bufsize, size_t n);
69 size_t cx_stream_bncopy(
70 void *src,
71 void *dest,
72 cx_read_func rfnc,
73 cx_write_func wfnc,
74 char *buf,
75 size_t bufsize,
76 size_t n
77 );
78 69
79 /** 70 /**
80 * Reads data from a stream and writes it to another stream. 71 * Reads data from a stream and writes it to another stream.
81 * 72 *
82 * @param src (@c void*) the source stream 73 * @param src (@c void*) the source stream
84 * @param rfnc (@c cx_read_func) the read function 75 * @param rfnc (@c cx_read_func) the read function
85 * @param wfnc (@c cx_write_func) the write function 76 * @param wfnc (@c cx_write_func) the write function
86 * @param buf (@c char*) a pointer to the copy buffer or @c NULL if a buffer 77 * @param buf (@c char*) a pointer to the copy buffer or @c NULL if a buffer
87 * shall be implicitly created on the heap 78 * shall be implicitly created on the heap
88 * @param bufsize (@c size_t) the size of the copy buffer - if @p buf is 79 * @param bufsize (@c size_t) the size of the copy buffer - if @p buf is
89 * @c NULL you can set this to zero to let the implementation decide 80 * @c NULL, you can set this to zero to let the implementation decide
90 * @return total number of bytes copied 81 * @return total number of bytes copied
91 */ 82 */
92 #define cx_stream_bcopy(src, dest, rfnc, wfnc, buf, bufsize) \ 83 #define cx_stream_bcopy(src, dest, rfnc, wfnc, buf, bufsize) \
93 cx_stream_bncopy(src, dest, rfnc, wfnc, buf, bufsize, SIZE_MAX) 84 cx_stream_bncopy(src, dest, rfnc, wfnc, buf, bufsize, SIZE_MAX)
94 85
95 /** 86 /**
96 * Reads data from a stream and writes it to another stream. 87 * Reads data from a stream and writes it to another stream.
97 * 88 *
98 * The data is temporarily stored in a stack allocated buffer. 89 * The data is temporarily stored in a stack-allocated buffer.
99 * 90 *
100 * @param src the source stream 91 * @param src the source stream
101 * @param dest the destination stream 92 * @param dest the destination stream
102 * @param rfnc the read function 93 * @param rfnc the read function
103 * @param wfnc the write function 94 * @param wfnc the write function
104 * @param n the maximum number of bytes that shall be copied. 95 * @param n the maximum number of bytes that shall be copied.
105 * @return total number of bytes copied 96 * @return total number of bytes copied
106 */ 97 */
107 cx_attr_nonnull 98 cx_attr_nonnull cx_attr_access_r(1) cx_attr_access_w(2)
108 cx_attr_access_r(1) 99 CX_EXPORT size_t cx_stream_ncopy(void *src, void *dest,
109 cx_attr_access_w(2) 100 cx_read_func rfnc, cx_write_func wfnc, size_t n);
110 cx_attr_export
111 size_t cx_stream_ncopy(
112 void *src,
113 void *dest,
114 cx_read_func rfnc,
115 cx_write_func wfnc,
116 size_t n
117 );
118 101
119 /** 102 /**
120 * Reads data from a stream and writes it to another stream. 103 * Reads data from a stream and writes it to another stream.
121 * 104 *
122 * The data is temporarily stored in a stack allocated buffer. 105 * The data is temporarily stored in a stack-allocated buffer.
123 * 106 *
124 * @param src (@c void*) the source stream 107 * @param src (@c void*) the source stream
125 * @param dest (@c void*) the destination stream 108 * @param dest (@c void*) the destination stream
126 * @param rfnc (@c cx_read_func) the read function 109 * @param rfnc (@c cx_read_func) the read function
127 * @param wfnc (@c cx_write_func) the write function 110 * @param wfnc (@c cx_write_func) the write function

mercurial