1/*
2 * misc.h
3 *
4 * Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
5 *
6 * See the file "license.txt" for usage and redistribution license requirements
7 *
8 * $Id: uemf.h,v 1.3 2007-02-01 07:41:01 winfred Exp $
9 *
10 * Copied from Ralink GoAhead web Server
11 */
12
13#ifndef _h_MISC
14#define _h_MISC 1
15
16#include	<stdarg.h>
17
18#define TRACE_MAX			(4096 - 48)
19#define VALUE_MAX_STRING	(4096 - 48)
20#define FMT_STATIC_MAX		256				/* Maximum for fmtStatic calls */
21#define BUFSIZE				1024
22
23#ifndef CHAR_T_DEFINED
24#define CHAR_T_DEFINED 1
25#define	T(s) 				s
26typedef char				char_t;
27#define	TSZ(x)				(sizeof(x))
28#define	TASTRL(x)			(strlen(x) + 1)
29#endif /* ! CHAR_T_DEFINED */
30
31#define a_assert(C)		if (1) ; else
32
33#ifndef max
34#define max(a,b)  (((a) > (b)) ? (a) : (b))
35#endif /* max */
36
37#ifndef min
38#define min(a,b)  (((a) < (b)) ? (a) : (b))
39#endif /* min */
40
41
42/*
43 *	Block allocation (balloc) definitions
44 */
45#ifndef B_L
46#define B_L				T(__FILE__), __LINE__
47#define B_ARGS_DEC		char_t *file, int line
48#define B_ARGS			file, line
49#endif /* B_L */
50
51#define balloc(B_ARGS, num) malloc(num)
52#define bfree(B_ARGS, p) free(p)
53#define bfreeSafe(B_ARGS, p) \
54	if (p) { free(p); } else
55#define brealloc(B_ARGS, p, num) realloc(p, num)
56
57extern void		trace(int lev, char_t *fmt, ...);
58extern void		traceRaw(char_t *buf);
59
60extern int		fmtValloc(char_t **s, int n, char_t *fmt, va_list arg);
61extern int		fmtAlloc(char_t **s, int n, char_t *fmt, ...);
62extern int		fmtStatic(char_t *s, int n, char_t *fmt, ...);
63#endif
64