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