Lines Matching refs:buf
35 struct buffer *buf; variable
37 buf = (struct buffer *) xmalloc (sizeof (struct buffer));
38 buf->data = NULL;
39 buf->last = NULL;
40 buf->nonblocking = 0;
41 buf->input = input;
42 buf->output = output;
43 buf->flush = flush;
44 buf->block = block;
45 buf->shutdown = shutdown;
46 buf->memory_error = memory ? memory : buf_default_memory_error;
47 buf->closure = closure;
48 return buf;
54 buf_free (buf) in buf_free() argument
55 struct buffer *buf; in buf_free()
57 if (buf->data != NULL)
59 buf->last->next = free_buffer_data;
60 free_buffer_data = buf->data;
62 free (buf);
84 buf_default_memory_error (buf) in buf_default_memory_error() argument
85 struct buffer *buf; in buf_default_memory_error()
141 buf_empty_p (buf) in buf_empty_p() argument
142 struct buffer *buf; in buf_empty_p()
146 for (data = buf->data; data != NULL; data = data->next)
159 buf_count_mem (buf) in buf_count_mem() argument
160 struct buffer *buf; in buf_count_mem()
165 for (data = buf->data; data != NULL; data = data->next)
175 buf_output (buf, data, len) in buf_output() argument
176 struct buffer *buf; in buf_output()
180 if (buf->data != NULL
181 && (((buf->last->text + BUFFER_DATA_SIZE)
182 - (buf->last->bufp + buf->last->size))
185 memcpy (buf->last->bufp + buf->last->size, data, len);
186 buf->last->size += len;
197 (*buf->memory_error) (buf);
201 if (buf->data == NULL)
202 buf->data = newdata;
204 buf->last->next = newdata;
206 buf->last = newdata;
230 buf_output0 (buf, string) in buf_output0() argument
231 struct buffer *buf; in buf_output0()
234 buf_output (buf, string, strlen (string));
240 buf_append_char (buf, ch) in buf_append_char() argument
241 struct buffer *buf; in buf_append_char()
244 if (buf->data != NULL
245 && (buf->last->text + BUFFER_DATA_SIZE
246 != buf->last->bufp + buf->last->size))
248 *(buf->last->bufp + buf->last->size) = ch;
249 ++buf->last->size;
256 buf_output (buf, &b, 1);
267 buf_send_output (buf) in buf_send_output() argument
268 struct buffer *buf; in buf_send_output()
270 if (buf->output == NULL)
273 while (buf->data != NULL)
277 data = buf->data;
283 status = (*buf->output) (buf->closure, data->bufp, data->size,
289 buf->last->next = free_buffer_data;
290 free_buffer_data = buf->data;
291 buf->data = NULL;
292 buf->last = NULL;
303 assert (buf->nonblocking);
312 buf->data = data->next;
317 buf->last = NULL;
330 buf_flush (buf, block) in buf_flush() argument
331 struct buffer *buf; in buf_flush()
337 if (buf->flush == NULL)
340 nonblocking = buf->nonblocking;
343 status = set_block (buf);
348 status = buf_send_output (buf);
350 status = (*buf->flush) (buf->closure);
356 blockstat = set_nonblock (buf);
370 set_nonblock (buf) in set_nonblock() argument
371 struct buffer *buf; in set_nonblock()
375 if (buf->nonblocking)
377 if (buf->block == NULL)
379 status = (*buf->block) (buf->closure, 0);
382 buf->nonblocking = 1;
392 set_block (buf) in set_block() argument
393 struct buffer *buf; in set_block()
397 if (! buf->nonblocking)
399 if (buf->block == NULL)
401 status = (*buf->block) (buf->closure, 1);
404 buf->nonblocking = 0;
417 buf_send_counted (buf) in buf_send_counted() argument
418 struct buffer *buf; in buf_send_counted()
424 for (data = buf->data; data != NULL; data = data->next)
430 (*buf->memory_error) (buf);
434 data->next = buf->data;
435 buf->data = data;
436 if (buf->last == NULL)
437 buf->last = data;
444 return buf_send_output (buf);
457 buf_send_special_count (buf, count) in buf_send_special_count() argument
458 struct buffer *buf; in buf_send_special_count()
466 (*buf->memory_error) (buf);
470 data->next = buf->data;
471 buf->data = data;
472 if (buf->last == NULL)
473 buf->last = data;
480 return buf_send_output (buf);
486 buf_append_data (buf, data, last) in buf_append_data() argument
487 struct buffer *buf; in buf_append_data()
493 if (buf->data == NULL)
494 buf->data = data;
496 buf->last->next = data;
497 buf->last = last;
653 buf_chain_length (buf) in buf_chain_length() argument
654 struct buffer_data *buf; in buf_chain_length()
657 while (buf)
659 size += buf->size;
660 buf = buf->next;
668 buf_length (buf) in buf_length() argument
669 struct buffer *buf; in buf_length()
671 return buf_chain_length (buf->data);
683 buf_input_data (buf, countp) in buf_input_data() argument
684 struct buffer *buf; in buf_input_data()
687 if (buf->input == NULL)
698 if (buf->data == NULL
699 || (buf->last->bufp + buf->last->size
700 == buf->last->text + BUFFER_DATA_SIZE))
707 (*buf->memory_error) (buf);
711 if (buf->data == NULL)
712 buf->data = data;
714 buf->last->next = data;
716 buf->last = data;
722 get = ((buf->last->text + BUFFER_DATA_SIZE)
723 - (buf->last->bufp + buf->last->size));
725 status = (*buf->input) (buf->closure,
726 buf->last->bufp + buf->last->size,
731 buf->last->size += nbytes;
758 buf_read_line (buf, line, lenp) in buf_read_line() argument
759 struct buffer *buf; in buf_read_line()
763 if (buf->input == NULL)
776 for (data = buf->data; data != NULL; data = data->next)
801 data = buf->data;
819 buf->data = data;
833 if (buf->data == NULL
834 || (buf->last->bufp + buf->last->size
835 == buf->last->text + BUFFER_DATA_SIZE))
840 (*buf->memory_error) (buf);
844 if (buf->data == NULL)
845 buf->data = data;
847 buf->last->next = data;
849 buf->last = data;
855 mem = buf->last->bufp + buf->last->size;
856 size = (buf->last->text + BUFFER_DATA_SIZE) - mem;
862 status = (*buf->input) (buf->closure, mem, 1, size, &nbytes);
866 buf->last->size += nbytes;
895 buf_read_data (buf, want, retdata, got) in buf_read_data() argument
896 struct buffer *buf; in buf_read_data()
901 if (buf->input == NULL)
904 while (buf->data != NULL && buf->data->size == 0)
908 next = buf->data->next;
909 buf->data->next = free_buffer_data;
910 free_buffer_data = buf->data;
911 buf->data = next;
913 buf->last = NULL;
916 if (buf->data == NULL)
924 (*buf->memory_error) (buf);
928 buf->data = data;
929 buf->last = data;
938 status = (*buf->input) (buf->closure, data->bufp, get,
946 *retdata = buf->data->bufp;
947 if (want < buf->data->size)
950 buf->data->size -= want;
951 buf->data->bufp += want;
955 *got = buf->data->size;
956 buf->data->size = 0;
1201 buf_shutdown (buf) in buf_shutdown() argument
1202 struct buffer *buf; in buf_shutdown()
1204 if (buf->shutdown)
1205 return (*buf->shutdown) (buf->closure);
1366 struct buffer *buf; member
1410 packetizing_buffer_initialize (buf, inpfn, outfn, fnclosure, memory) in packetizing_buffer_initialize() argument
1411 struct buffer *buf; in packetizing_buffer_initialize()
1422 pb->buf = buf;
1495 status = buf_read_data (pb->buf, get, &bytes, &nread);
1545 (*pb->buf->memory_error) (pb->buf);
1554 status = buf_read_data (pb->buf, get, &bytes, &nread);
1607 (*pb->buf->memory_error) (pb->buf);
1698 (*pb->buf->memory_error) (pb->buf);
1722 buf_output (pb->buf, outbuf, translated + 2);
1726 buf_append_data (pb->buf, outdata, outdata);
1734 return buf_send_output (pb->buf);
1749 return buf_flush (pb->buf, 0);
1762 return set_block (pb->buf);
1764 return set_nonblock (pb->buf);
1775 return buf_shutdown (pb->buf);