]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - misc.h
d9b381196c3a682ee147feb4899db94ec8b313c1
[PuTTY.git] / misc.h
1 #ifndef PUTTY_MISC_H
2 #define PUTTY_MISC_H
3
4 #include "puttymem.h"
5
6 struct bufchain_granule;
7 typedef struct bufchain_tag {
8     struct bufchain_granule *head, *tail;
9     int buffersize;                    /* current amount of buffered data */
10 } bufchain;
11
12 void bufchain_init(bufchain *ch);
13 void bufchain_clear(bufchain *ch);
14 int bufchain_size(bufchain *ch);
15 void bufchain_add(bufchain *ch, void *data, int len);
16 void bufchain_prefix(bufchain *ch, void **data, int *len);
17 void bufchain_consume(bufchain *ch, int len);
18
19 /*
20  * Debugging functions.
21  *
22  * Output goes to debug.log
23  *
24  * debug(()) (note the double brackets) is like printf().
25  *
26  * dmemdump() and dmemdumpl() both do memory dumps.  The difference
27  * is that dmemdumpl() is more suited for when where the memory is is
28  * important (say because you'll be recording pointer values later
29  * on).  dmemdump() is more concise.
30  */
31
32 #ifdef DEBUG
33 void dprintf(char *fmt, ...);
34 void debug_memdump(void *buf, int len, int L);
35 #define debug(x) (dprintf x)
36 #define dmemdump(buf,len) debug_memdump (buf, len, 0);
37 #define dmemdumpl(buf,len) debug_memdump (buf, len, 1);
38 #else
39 #define debug(x)
40 #define dmemdump(buf,len)
41 #define dmemdumpl(buf,len)
42 #endif
43
44
45 #ifndef lenof
46 #define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
47 #endif
48
49
50 #endif