2 #ifndef __MIXP_INTERN_UTIL_H
3 #define __MIXP_INTERN_UTIL_H
5 #define MAX(a, b) (a > b ? a : b)
6 #define MIN(a, b) (a < b ? a : b)
8 #define nelem(ary) (sizeof(ary) / sizeof(*ary))
11 unsigned int tokenize(char *res
[], unsigned int reslen
, char *str
, char delim
);
12 void *ixp_erealloc(void *ptr
, unsigned int size
);
13 void ixp_fatal(const char *fmt
, ...);
20 #define ARGBEGIN int _argi, _argtmp, _inargv=0; char *_argv; \
21 if(!argv0)argv0=ARGF(); _inargv=1; \
22 while(argc && argv[0][0] == '-') { \
23 _argi=1; _argv=*argv++; argc--; \
24 while(_argv[_argi]) switch(_argv[_argi++])
25 #define ARGEND }_inargv=0;USED(_argtmp);USED(_argv);USED(_argi)
26 #define ARGF() ((_inargv && _argv[_argi]) ? \
27 (_argtmp=_argi, _argi=strlen(_argv), _argv+_argtmp) \
28 : ((argc > 0) ? (argc--, *argv++) : ((char*)0)))
29 #define EARGF(f) ((_inargv && _argv[_argi]) ? \
30 (_argtmp=_argi, _argi=strlen(_argv), _argv+_argtmp) \
31 : ((argc > 0) ? (argc--, *argv++) : ((f), (char*)0)))
35 #define USED(x) if(x){}else
36 #define SET(x) ((x)=0)