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