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