6 #include <stdarg.h> /* for va_list */
15 char *dupstr(const char *s
);
16 char *dupcat(const char *s1
, ...);
17 char *dupprintf(const char *fmt
, ...);
18 char *dupvprintf(const char *fmt
, va_list ap
);
20 void base64_encode_atom(unsigned char *data
, int n
, char *out
);
22 struct bufchain_granule
;
23 typedef struct bufchain_tag
{
24 struct bufchain_granule
*head
, *tail
;
25 int buffersize
; /* current amount of buffered data */
28 void bufchain_init(bufchain
*ch
);
29 void bufchain_clear(bufchain
*ch
);
30 int bufchain_size(bufchain
*ch
);
31 void bufchain_add(bufchain
*ch
, void *data
, int len
);
32 void bufchain_prefix(bufchain
*ch
, void **data
, int *len
);
33 void bufchain_consume(bufchain
*ch
, int len
);
34 void bufchain_fetch(bufchain
*ch
, void *data
, int len
);
37 * Debugging functions.
39 * Output goes to debug.log
41 * debug(()) (note the double brackets) is like printf().
43 * dmemdump() and dmemdumpl() both do memory dumps. The difference
44 * is that dmemdumpl() is more suited for when where the memory is is
45 * important (say because you'll be recording pointer values later
46 * on). dmemdump() is more concise.
50 void dprintf(char *fmt
, ...);
51 void debug_memdump(void *buf
, int len
, int L
);
52 #define debug(x) (dprintf x)
53 #define dmemdump(buf,len) debug_memdump (buf, len, 0);
54 #define dmemdumpl(buf,len) debug_memdump (buf, len, 1);
57 #define dmemdump(buf,len)
58 #define dmemdumpl(buf,len)
62 #define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
66 #define min(x,y) ( (x) < (y) ? (x) : (y) )
69 #define max(x,y) ( (x) > (y) ? (x) : (y) )