Oops, another missing forward-struct-declaration.
[u/mdw/putty] / misc.h
CommitLineData
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 15typedef struct Filename Filename;
16typedef struct FontSpec FontSpec;
17
57356d63 18char *dupstr(const char *s);
19char *dupcat(const char *s1, ...);
20char *dupprintf(const char *fmt, ...);
21char *dupvprintf(const char *fmt, va_list ap);
03f64569 22
1549e076 23void base64_encode_atom(unsigned char *data, int n, char *out);
24
5471d09a 25struct bufchain_granule;
26typedef struct bufchain_tag {
27 struct bufchain_granule *head, *tail;
28 int buffersize; /* current amount of buffered data */
29} bufchain;
30
31void bufchain_init(bufchain *ch);
32void bufchain_clear(bufchain *ch);
33int bufchain_size(bufchain *ch);
e0e7dff8 34void bufchain_add(bufchain *ch, const void *data, int len);
5471d09a 35void bufchain_prefix(bufchain *ch, void **data, int *len);
36void bufchain_consume(bufchain *ch, int len);
7983f47e 37void 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
53void dprintf(char *fmt, ...);
32874aea 54void debug_memdump(void *buf, int len, int L);
db9c0f86 55#define debug(x) (dprintf x)
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