runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

buffer.h (1333B)


      1 /* Public domain. */
      2 
      3 #ifndef BUFFER_H
      4 #define BUFFER_H
      5 
      6 typedef int (*buffer_op)( int fd, const char* buf, unsigned int len );
      7 typedef struct buffer {
      8   char *x;
      9   unsigned int p;
     10   unsigned int n;
     11   int fd;
     12 	buffer_op op;
     13 } buffer;
     14 
     15 #define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
     16 #define BUFFER_INSIZE 8192
     17 #define BUFFER_OUTSIZE 8192
     18 
     19 extern void buffer_init(buffer *,buffer_op op,int,char *,unsigned int);
     20 
     21 extern int buffer_flush(buffer *);
     22 extern int buffer_put(buffer *,const char *,unsigned int);
     23 extern int buffer_putalign(buffer *,const char *,unsigned int);
     24 extern int buffer_putflush(buffer *,const char *,unsigned int);
     25 extern int buffer_puts(buffer *,const char *);
     26 extern int buffer_putsalign(buffer *,const char *);
     27 extern int buffer_putsflush(buffer *,const char *);
     28 
     29 extern int buffer_get(buffer *,char *,unsigned int);
     30 extern int buffer_bget(buffer *,char *,unsigned int);
     31 extern int buffer_feed(buffer *);
     32 
     33 extern char *buffer_peek(buffer *);
     34 extern void buffer_seek(buffer *,unsigned int);
     35 
     36 extern int buffer_copy(buffer *,buffer *);
     37 
     38 extern int buffer_unixread(int,char *,unsigned int);
     39 extern int buffer_unixwrite(int,const char *,unsigned int);
     40 
     41 extern buffer *buffer_0;
     42 extern buffer *buffer_0small;
     43 extern buffer *buffer_1;
     44 extern buffer *buffer_1small;
     45 extern buffer *buffer_2;
     46 
     47 #endif