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