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