8 # define MAX(x,y) ((x)>(y)?(x):(y))
11 # define MIN(x,y) ((x)<(y)?(x):(y))
14 # define SQR(a) ((a)*(a))
17 # define ABS(a) ((a)>0?(a):-(a))
19 #define ALLOC_OBJ(p) { p = calloc(1, sizeof(*p)); assert(p);}
20 #define FREE_OBJ(p) free(p);
21 #define ALLOC_VEC(p, n) { p = calloc(n, sizeof(*(p))); assert(p); }
22 #define SET_VEC(p, v, i0, i1) { int _i; \
23 for (_i = (i0); _i < (i1); _i++) p[_i] = v; }
24 #define FREE_VEC(p) free(p);
26 #define ALLOC_ARR(v,nl,nc) \
27 { int __i; v = calloc(nl,sizeof(*(v))); assert(v); \
28 v[0]=calloc((nc)*(nl), sizeof(**(v))); assert((v)[0]); \
29 for (__i=1; __i < nl; ++__i) (v)[__i] = (v)[__i-1] + nc; }
30 #define FREE_ARR(p) { free(p[0]); free(p); }
31 #define BASE_ARR(p) (p[0])
34 # define BLAHBLAH(n,x) if (Prefs.verbosity >= n) { x; fflush(stdout); }
36 # define BLAHBLAH(n,x)
39 #define ONLY_ONCE(x) { static int __cnt = 0; if (__cnt++==0) { x;} }
40 #define ONLY_NTIMES(n,x) { static int __cnt = 0; if (__cnt++<n) { x;} }
44 /* macro for str_hache */
45 #define CVINT(a,b,c,d) (a + (b<<8) + (c<<16) + (d<<24))
47 #define IS_INSIDE(x, y, xmin, ymin, xmax, ymax) ((x) >= (xmin) && (x) <= (xmax) && (y) >= (ymin) && (y) <= (ymax))
49 char *str_dup(const char *s
);
50 int str_is_empty(const char *s
);
51 char *str_multi_str(const char *src
, const char **keys
, int nb_keys
, int *key_idx
);
52 char *str_multi_substitute(const char *src
, const char **keys
, const char **substitutions
, int nkeys
);
53 char *str_substitute(const char *src
, const char *key
, const char *substitution
);
54 char *shell_quote(const char *src
);
55 unsigned str_hash(const unsigned char *s
, int max_len
);
56 unsigned char chr_noaccent_tolower(unsigned char c
);
57 void str_noaccent_tolower(unsigned char *s
);
58 unsigned char *str_noaccent_casestr(const unsigned char *meule
, const unsigned char *aiguille
);
59 char *str_printf(const char *fmt
, ...) __attribute__ ((format (printf
, 1, 2)));
60 char *str_fget_line(FILE *f
);
61 void str_trim(unsigned char *s
);
63 typedef struct strlist
{
67 strlist
*strlist_ins(strlist
*head
, const char *s
);