-
Notifications
You must be signed in to change notification settings - Fork 2
/
util.h
43 lines (33 loc) · 1 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*================================================================
* utility routines
*================================================================*/
#ifndef UTIL_H_DEF
#define UTIL_H_DEF
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define numberof(ary) (sizeof(ary)/sizeof(ary[0]))
#ifndef offsetof
#define offsetof(s_type,field) ((int)(((char*)(&(((s_type*)NULL)->field)))-((char*)NULL)))
#endif
#define BITON(var,flag) ((var) |= (flag))
#define BITOFF(var,flag) ((var) &= ~(flag))
#define BITSWT(var,flag) ((var) ^= (flag))
extern int verbose, debug;
#define DEBUG(LVL,XXX) {if (verbose > LVL) { XXX; }}
/* cmpopen.c */
int CmpSearchFile(char *name);
char *CmpExtension(int type);
FILE *CmpOpenFile(char *name, int *flag);
void CmpCloseFile(FILE *fp, int flag);
/* malloc.c */
void *safe_malloc(int size);
void safe_free(void *ptr);
/* signal.c */
void add_signal(int sig, void (*handler)(), int exit_after);
/* fskip.c */
void fskip(int size, FILE *fd, int seekable);
#endif