25 #define NMEMB(x) (sizeof((x))/sizeof(typeof((x)[0])))
31 #define MILLISEC(x) (((x).tv_sec*1000)+((x).tv_usec/1000))
36 #define MILLISEC_TO_TV(x,t) \
38 (t).tv_sec=(x)/1000; \
39 (t).tv_usec=((x) - ((x)/1000)*1000)*1000; \
45 #define SET_BIT(a,i) ((a)[(i)/CHAR_BIT] |= 1<<((i)%CHAR_BIT))
46 #define CLR_BIT(a,i) ((a)[(i)/CHAR_BIT] &= ~(1<<((i)%CHAR_BIT)))
47 #define TEST_BIT(a,i) (((a)[(i)/CHAR_BIT] & (1<<((i)%CHAR_BIT))) ? 1 : 0)
56 #define FIND_PTR(p, a, n) \
60 for(_i=0, _ret=-1; _i<(n); _i++) \
61 if((a)[_i] == (p)) { \
76 #define _return(x) ({return (x); (x);})
84 void swap_array(
int nmemb,
size_t nmemb_sz,
void *src,
void *dst);
85 void swap_ints(
int nmemb,
unsigned int *x,
unsigned int *y) ;
86 void swap_shorts(
int nmemb,
unsigned short *x,
unsigned short *y);
92 void strip_char(
char *
string,
char char_to_strip);
93 char **
split_string(
char *str,
const char *div_str,
int *substrings,
94 int max_substrings,
int max_substring_sz);
97 int find_int(
int x,
int *ia,
int nmemb);
99 void xtimer(u_int secs, u_int steps,
int *counter);
int exec_root_script(char *script, char *argv)
Definition: misc.c:346
int rand_range(int _min, int _max)
Definition: misc.c:101
void do_nothing(void)
Definition: misc.c:388
void strip_char(char *string, char char_to_strip)
Definition: misc.c:141
int find_int(int x, int *ia, int nmemb)
Definition: misc.c:222
void swap_array(int nmemb, size_t nmemb_sz, void *src, void *dst)
Definition: misc.c:56
char * last_token(char *string, char tok)
Definition: misc.c:130
void xtimer(u_int secs, u_int steps, int *counter)
Definition: misc.c:244
char ** split_string(char *str, const char *div_str, int *substrings, int max_substrings, int max_substring_sz)
Definition: misc.c:167
void xsrand(void)
Definition: misc.c:111
char xor_int(int i)
Definition: misc.c:34
int check_and_create_dir(char *dir)
Definition: misc.c:295
void swap_shorts(int nmemb, unsigned short *x, unsigned short *y)
Definition: misc.c:87
void swap_ints(int nmemb, unsigned int *x, unsigned int *y)
Definition: misc.c:82
int file_exist(char *filename)
Definition: misc.c:326