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