Back to index

courier  0.68.2
buf.h
Go to the documentation of this file.
00001 /*
00002 */
00003 #ifndef       buf_h
00004 #define       buf_h
00005 /*
00006 ** Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
00007 ** distribution information.
00008 */
00009 
00010 
00011 
00012  /* Oh, to hell with it, I have to write this... */
00013 
00014 #if    HAVE_CONFIG_H
00015 #include      "config.h"
00016 #endif
00017 
00018 #if    HAVE_UNISTD_H
00019 #include      <unistd.h>
00020 #endif
00021 
00022 #include      <stdlib.h>
00023 #include      <stdio.h>
00024 
00025 struct buf {
00026        char *ptr;
00027        size_t size, cnt;
00028        };
00029 
00030 #define       buf_init(p)   ( (p)->ptr=0, (p)->size=0, (p)->cnt=0)
00031 #define       buf_free(p)   do { if ( (p)->ptr) free ((p)->ptr); buf_init(p);} while (0)
00032 
00033 void   buf_cpy(struct buf *, const char *);
00034 void   buf_cpyn(struct buf *, const char *, size_t);
00035 void   buf_cat(struct buf *, const char *);
00036 void   buf_catn(struct buf *, const char *, size_t);
00037 void   buf_memcpy(struct buf *, const char *, size_t);
00038 void   buf_memcat(struct buf *, const char *, size_t);
00039 void   buf_trimleft(struct buf *, size_t);
00040 void   buf_append(struct buf *, char c);
00041 
00042 #endif