Lines Matching refs:buffer
107 static size_t line_length(const char *buffer, int bytestocheck)
111 while(*buffer != '\n' && --bytestocheck) {
113 buffer++;
115 if(*buffer != '\n') {
130 * Reads a complete line from a file into a dynamically allocated buffer.
132 * Calling function may call this multiple times with same 'buffer'
133 * and 'bufsize' pointers to avoid multiple buffer allocations. Buffer
135 * buffer before returning it.
137 * Calling function is responsible to free allocated buffer.
145 static int readline(char **buffer, size_t *bufsize, size_t *length,
151 if(!*buffer) {
152 *buffer = calloc(1, 128);
153 if(!*buffer)
161 if(!fgets(*buffer + offset, bytestoread, stream))
164 *length = offset + line_length(*buffer + offset, bytestoread);
165 if(*(*buffer + *length - 1) == '\n')
171 newptr = realloc(*buffer, *bufsize * 2);
175 *buffer = newptr;
185 * This appends data from a given source buffer to the end of the used part of
186 * a destination buffer. Arguments relative to the destination buffer are, the
187 * address of a pointer to the destination buffer 'dst_buf', the length of data
188 * in destination buffer excluding potential null string termination 'dst_len',
189 * the allocated size of destination buffer 'dst_alloc'. All three destination
190 * buffer arguments may be modified by this function. Arguments relative to the
191 * source buffer are, a pointer to the source buffer 'src_buf' and indication
192 * whether the source buffer is base64 encoded or not 'src_b64'.
194 * If the source buffer is indicated to be base64 encoded, this appends the
195 * decoded data, binary or whatever, to the destination. The source buffer
198 * Destination buffer will be enlarged and relocated as needed.
201 * buffer and also to deallocate it when no longer needed.
208 static int appenddata(char **dst_buf, /* dest buffer */
209 size_t *dst_len, /* dest buffer data length */
210 size_t *dst_alloc, /* dest buffer allocated size */
211 char *src_buf, /* source buffer */
212 size_t src_len, /* source buffer length */
230 /* enlarge destination buffer if required */
249 static int decodedata(char **buf, /* dest buffer */
250 size_t *len) /* dest buffer data length */
259 /* base64 decode the given buffer */
293 * Data is returned in a dynamically allocated buffer, a pointer to this data
300 * Calling function is responsible to free returned buffer.
317 char *buffer = NULL;
348 while((error = readline(&buffer, &bufsize, &datalen, stream)) == GPE_OK) {
350 ptr = buffer;
355 show(("=> %s", buffer));
356 error = appenddata(outbuf, outlen, &outalloc, buffer, datalen,
450 show(("* ignoring (%s)", buffer));
502 show(("=> %s", buffer));
503 error = appenddata(outbuf, outlen, &outalloc, buffer, datalen, base64);
510 free(buffer);