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