Remove an unused variable.
[u/mdw/putty] / misc.h
CommitLineData
eaf1e20a 1/*
2 * Header for misc.c.
3 */
4
db9c0f86 5#ifndef PUTTY_MISC_H
6#define PUTTY_MISC_H
7
8#include "puttymem.h"
9
39934deb 10#include <stdio.h> /* for FILE * */
57356d63 11#include <stdarg.h> /* for va_list */
d72d0e81 12#include <time.h> /* for struct tm */
57356d63 13
3f2d010c 14#ifndef FALSE
15#define FALSE 0
16#endif
17#ifndef TRUE
18#define TRUE 1
19#endif
20
9a30e26b 21typedef struct Filename Filename;
22typedef struct FontSpec FontSpec;
23
d57f70af 24unsigned long parse_blocksize(const char *bs);
d45d4c07 25char ctrlparse(char *s, char **next);
d57f70af 26
57356d63 27char *dupstr(const char *s);
28char *dupcat(const char *s1, ...);
29char *dupprintf(const char *fmt, ...);
30char *dupvprintf(const char *fmt, va_list ap);
12b9e82d 31void burnstr(char *string);
03f64569 32
39934deb 33char *fgetline(FILE *fp);
34
1549e076 35void base64_encode_atom(unsigned char *data, int n, char *out);
36
5471d09a 37struct bufchain_granule;
38typedef struct bufchain_tag {
39 struct bufchain_granule *head, *tail;
40 int buffersize; /* current amount of buffered data */
41} bufchain;
42
43void bufchain_init(bufchain *ch);
44void bufchain_clear(bufchain *ch);
45int bufchain_size(bufchain *ch);
e0e7dff8 46void bufchain_add(bufchain *ch, const void *data, int len);
5471d09a 47void bufchain_prefix(bufchain *ch, void **data, int *len);
48void bufchain_consume(bufchain *ch, int len);
7983f47e 49void bufchain_fetch(bufchain *ch, void *data, int len);
db9c0f86 50
aca589d9 51struct tm ltime(void);
52
db9c0f86 53/*
54 * Debugging functions.
55 *
56 * Output goes to debug.log
57 *
58 * debug(()) (note the double brackets) is like printf().
59 *
60 * dmemdump() and dmemdumpl() both do memory dumps. The difference
523c5dd3 61 * is that dmemdumpl() is more suited for when the memory address is
db9c0f86 62 * important (say because you'll be recording pointer values later
63 * on). dmemdump() is more concise.
64 */
65
66#ifdef DEBUG
d0912d1f 67void debug_printf(char *fmt, ...);
32874aea 68void debug_memdump(void *buf, int len, int L);
d0912d1f 69#define debug(x) (debug_printf x)
db9c0f86 70#define dmemdump(buf,len) debug_memdump (buf, len, 0);
71#define dmemdumpl(buf,len) debug_memdump (buf, len, 1);
72#else
73#define debug(x)
74#define dmemdump(buf,len)
75#define dmemdumpl(buf,len)
76#endif
77
db9c0f86 78#ifndef lenof
79#define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
80#endif
81
1709795f 82#ifndef min
83#define min(x,y) ( (x) < (y) ? (x) : (y) )
84#endif
85#ifndef max
7ffb2b52 86#define max(x,y) ( (x) > (y) ? (x) : (y) )
1709795f 87#endif
db9c0f86 88
51e9d3c0 89#define GET_32BIT_LSB_FIRST(cp) \
90 (((unsigned long)(unsigned char)(cp)[0]) | \
91 ((unsigned long)(unsigned char)(cp)[1] << 8) | \
92 ((unsigned long)(unsigned char)(cp)[2] << 16) | \
93 ((unsigned long)(unsigned char)(cp)[3] << 24))
94
95#define PUT_32BIT_LSB_FIRST(cp, value) ( \
96 (cp)[0] = (unsigned char)(value), \
97 (cp)[1] = (unsigned char)((value) >> 8), \
98 (cp)[2] = (unsigned char)((value) >> 16), \
99 (cp)[3] = (unsigned char)((value) >> 24) )
100
101#define GET_16BIT_LSB_FIRST(cp) \
102 (((unsigned long)(unsigned char)(cp)[0]) | \
103 ((unsigned long)(unsigned char)(cp)[1] << 8))
104
105#define PUT_16BIT_LSB_FIRST(cp, value) ( \
106 (cp)[0] = (unsigned char)(value), \
107 (cp)[1] = (unsigned char)((value) >> 8) )
108
109#define GET_32BIT_MSB_FIRST(cp) \
110 (((unsigned long)(unsigned char)(cp)[0] << 24) | \
111 ((unsigned long)(unsigned char)(cp)[1] << 16) | \
112 ((unsigned long)(unsigned char)(cp)[2] << 8) | \
113 ((unsigned long)(unsigned char)(cp)[3]))
114
115#define GET_32BIT(cp) GET_32BIT_MSB_FIRST(cp)
116
117#define PUT_32BIT_MSB_FIRST(cp, value) ( \
118 (cp)[0] = (unsigned char)((value) >> 24), \
119 (cp)[1] = (unsigned char)((value) >> 16), \
120 (cp)[2] = (unsigned char)((value) >> 8), \
121 (cp)[3] = (unsigned char)(value) )
122
123#define PUT_32BIT(cp, value) PUT_32BIT_MSB_FIRST(cp, value)
124
125#define GET_16BIT_MSB_FIRST(cp) \
126 (((unsigned long)(unsigned char)(cp)[0] << 8) | \
127 ((unsigned long)(unsigned char)(cp)[1]))
128
129#define PUT_16BIT_MSB_FIRST(cp, value) ( \
130 (cp)[0] = (unsigned char)((value) >> 8), \
131 (cp)[1] = (unsigned char)(value) )
132
db9c0f86 133#endif