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