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