db9c0f86 |
1 | #ifndef PUTTY_MISC_H |
2 | #define PUTTY_MISC_H |
3 | |
4 | #include "puttymem.h" |
5 | |
57356d63 |
6 | #include <stdarg.h> /* for va_list */ |
7 | |
3f2d010c |
8 | #ifndef FALSE |
9 | #define FALSE 0 |
10 | #endif |
11 | #ifndef TRUE |
12 | #define TRUE 1 |
13 | #endif |
14 | |
9a30e26b |
15 | typedef struct Filename Filename; |
16 | typedef struct FontSpec FontSpec; |
17 | |
57356d63 |
18 | char *dupstr(const char *s); |
19 | char *dupcat(const char *s1, ...); |
20 | char *dupprintf(const char *fmt, ...); |
21 | char *dupvprintf(const char *fmt, va_list ap); |
03f64569 |
22 | |
1549e076 |
23 | void base64_encode_atom(unsigned char *data, int n, char *out); |
24 | |
5471d09a |
25 | struct bufchain_granule; |
26 | typedef struct bufchain_tag { |
27 | struct bufchain_granule *head, *tail; |
28 | int buffersize; /* current amount of buffered data */ |
29 | } bufchain; |
30 | |
31 | void bufchain_init(bufchain *ch); |
32 | void bufchain_clear(bufchain *ch); |
33 | int bufchain_size(bufchain *ch); |
e0e7dff8 |
34 | void bufchain_add(bufchain *ch, const void *data, int len); |
5471d09a |
35 | void bufchain_prefix(bufchain *ch, void **data, int *len); |
36 | void bufchain_consume(bufchain *ch, int len); |
7983f47e |
37 | void bufchain_fetch(bufchain *ch, void *data, int len); |
db9c0f86 |
38 | |
39 | /* |
40 | * Debugging functions. |
41 | * |
42 | * Output goes to debug.log |
43 | * |
44 | * debug(()) (note the double brackets) is like printf(). |
45 | * |
46 | * dmemdump() and dmemdumpl() both do memory dumps. The difference |
47 | * is that dmemdumpl() is more suited for when where the memory is is |
48 | * important (say because you'll be recording pointer values later |
49 | * on). dmemdump() is more concise. |
50 | */ |
51 | |
52 | #ifdef DEBUG |
d0912d1f |
53 | void debug_printf(char *fmt, ...); |
32874aea |
54 | void debug_memdump(void *buf, int len, int L); |
d0912d1f |
55 | #define debug(x) (debug_printf x) |
db9c0f86 |
56 | #define dmemdump(buf,len) debug_memdump (buf, len, 0); |
57 | #define dmemdumpl(buf,len) debug_memdump (buf, len, 1); |
58 | #else |
59 | #define debug(x) |
60 | #define dmemdump(buf,len) |
61 | #define dmemdumpl(buf,len) |
62 | #endif |
63 | |
db9c0f86 |
64 | #ifndef lenof |
65 | #define lenof(x) ( (sizeof((x))) / (sizeof(*(x)))) |
66 | #endif |
67 | |
1709795f |
68 | #ifndef min |
69 | #define min(x,y) ( (x) < (y) ? (x) : (y) ) |
70 | #endif |
71 | #ifndef max |
7ffb2b52 |
72 | #define max(x,y) ( (x) > (y) ? (x) : (y) ) |
1709795f |
73 | #endif |
db9c0f86 |
74 | |
75 | #endif |