Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.2 KiB

  1. .TH buffer_init 3
  2. .SH NAME
  3. buffer_init \- initialize buffer structure
  4. .SH SYNTAX
  5. .B #include <buffer.h>
  6. void \fBbuffer_init\fR(buffer &\fIb\fR,
  7. int (*\fIop\fR)(int,char*,unsigned int),
  8. int \fIfd\fR, char* \fIy\fR, unsigned long int \fIylen\fR);
  9. .SH DESCRIPTION
  10. buffer_init prepares \fIb\fR to store a string in \fIy\fR[0], \fIy\fR[1], ...,
  11. \fIy\fR[\fIylen\fR-1]. Initially the string is empty.
  12. buffer_init also prepares \fIb\fR to use the read/write operation specified by
  13. \fIop\fR and \fIfd\fR.
  14. You can use
  15. buffer \fIb\fR = BUFFER_INIT(\fIop\fR,\fIfd\fR,\fIy\fR,\fIylen\fR);
  16. to initialize \fIb\fR statically if \fIop\fR, \fIfd\fR, \fIy\fR, and \fIylen\fR
  17. are compile-time constants.
  18. You can call buffer_init again at any time. Note that this discards the
  19. currently buffered string.
  20. .SH EXAMPLE
  21. #include <buffer.h>
  22. #include <open.h>
  23. char buf[4096];
  24. int fd=open_read("/etc/services");
  25. buffer input;
  26. if (fd>=0) {
  27. char x;
  28. buffer_init(&input,read,fd,buf,sizeof buf);
  29. while (buffer_get(&input,&x,1)==1) {
  30. buffer_put(buffer_1,&x,1);
  31. if (x=='\\n') break;
  32. }
  33. buffer_flush(buffer_1);
  34. }
  35. .SH "SEE ALSO"
  36. buffer_flush(3), buffer(3)