2001-04-28 13:24:19 +04:00
|
|
|
#ifndef PUTTY_MISC_H
|
|
|
|
#define PUTTY_MISC_H
|
|
|
|
|
|
|
|
#include "puttymem.h"
|
|
|
|
|
2002-11-07 22:49:03 +03:00
|
|
|
#include <stdarg.h> /* for va_list */
|
|
|
|
|
2001-12-30 18:58:17 +03:00
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
|
|
|
|
2003-02-01 15:54:40 +03:00
|
|
|
typedef struct Filename Filename;
|
|
|
|
typedef struct FontSpec FontSpec;
|
|
|
|
|
2002-11-07 22:49:03 +03:00
|
|
|
char *dupstr(const char *s);
|
|
|
|
char *dupcat(const char *s1, ...);
|
|
|
|
char *dupprintf(const char *fmt, ...);
|
|
|
|
char *dupvprintf(const char *fmt, va_list ap);
|
2001-08-26 19:31:29 +04:00
|
|
|
|
2002-09-21 18:03:05 +04:00
|
|
|
void base64_encode_atom(unsigned char *data, int n, char *out);
|
|
|
|
|
2001-08-25 21:09:23 +04:00
|
|
|
struct bufchain_granule;
|
|
|
|
typedef struct bufchain_tag {
|
|
|
|
struct bufchain_granule *head, *tail;
|
|
|
|
int buffersize; /* current amount of buffered data */
|
|
|
|
} bufchain;
|
|
|
|
|
|
|
|
void bufchain_init(bufchain *ch);
|
|
|
|
void bufchain_clear(bufchain *ch);
|
|
|
|
int bufchain_size(bufchain *ch);
|
2003-01-10 21:33:35 +03:00
|
|
|
void bufchain_add(bufchain *ch, const void *data, int len);
|
2001-08-25 21:09:23 +04:00
|
|
|
void bufchain_prefix(bufchain *ch, void **data, int *len);
|
|
|
|
void bufchain_consume(bufchain *ch, int len);
|
2002-09-21 20:52:21 +04:00
|
|
|
void bufchain_fetch(bufchain *ch, void *data, int len);
|
2001-04-28 13:24:19 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Debugging functions.
|
|
|
|
*
|
|
|
|
* Output goes to debug.log
|
|
|
|
*
|
|
|
|
* debug(()) (note the double brackets) is like printf().
|
|
|
|
*
|
|
|
|
* dmemdump() and dmemdumpl() both do memory dumps. The difference
|
|
|
|
* is that dmemdumpl() is more suited for when where the memory is is
|
|
|
|
* important (say because you'll be recording pointer values later
|
|
|
|
* on). dmemdump() is more concise.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2003-03-06 16:24:02 +03:00
|
|
|
void debug_printf(char *fmt, ...);
|
2001-05-06 18:35:20 +04:00
|
|
|
void debug_memdump(void *buf, int len, int L);
|
2003-03-06 16:24:02 +03:00
|
|
|
#define debug(x) (debug_printf x)
|
2001-04-28 13:24:19 +04:00
|
|
|
#define dmemdump(buf,len) debug_memdump (buf, len, 0);
|
|
|
|
#define dmemdumpl(buf,len) debug_memdump (buf, len, 1);
|
|
|
|
#else
|
|
|
|
#define debug(x)
|
|
|
|
#define dmemdump(buf,len)
|
|
|
|
#define dmemdumpl(buf,len)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef lenof
|
|
|
|
#define lenof(x) ( (sizeof((x))) / (sizeof(*(x))))
|
|
|
|
#endif
|
|
|
|
|
2002-10-09 22:09:42 +04:00
|
|
|
#ifndef min
|
|
|
|
#define min(x,y) ( (x) < (y) ? (x) : (y) )
|
|
|
|
#endif
|
|
|
|
#ifndef max
|
2002-10-14 13:04:23 +04:00
|
|
|
#define max(x,y) ( (x) > (y) ? (x) : (y) )
|
2002-10-09 22:09:42 +04:00
|
|
|
#endif
|
2001-04-28 13:24:19 +04:00
|
|
|
|
|
|
|
#endif
|