X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=blobdiff_plain;f=adu.h;h=85ab63a6e04db918f14f37e3e5f40d9294cb555a;hp=69488a40215790e8c83fc63c375ed0ff6ee43f21;hb=8ed63fbd0795ed861124c5ea90ef8b1fb5cc929f;hpb=cab88f141a9550dcceee0ad8eab978660e0ae0de diff --git a/adu.h b/adu.h index 69488a4..85ab63a 100644 --- a/adu.h +++ b/adu.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include /* time(), localtime() */ @@ -16,15 +16,12 @@ #include #include #include -#include -#include -#include -#include -#include /* needed by create_pf_socket */ +#include #include #include #include #include "gcc-compat.h" +#include "select.cmdline.h" /** debug loglevel, gets really noisy */ #define DEBUG 1 @@ -118,8 +115,8 @@ } \ } -#define FOR_EACH_USER(ui) for (ui = uid_hash_table; ui && ui < uid_hash_table \ - + uid_hash_table_size; ui++) +/** Evaluates to 1 if x < y, to -1 if x > y and to 0 if x == y. */ +#define NUM_COMPARE(x, y) ((int)((x) < (y)) - (int)((x) > (y))) /** The columns of the directory table. */ enum dir_table_columns { @@ -177,34 +174,29 @@ enum search_uid_flags { CREATE_USER_TABLE = 2, }; +#define FOR_EACH_UID_RANGE(ur, urs) for (ur = urs; ur->low <= ur->high; ur++) + extern uint32_t num_uids; -extern uint32_t uid_hash_table_size; extern struct osl_table *dir_table; -extern struct user_info *uid_hash_table; -extern uint64_t num_dirs; -extern uint64_t num_files; -extern uint64_t num_bytes; extern struct gengetopt_args_info conf; +extern struct select_args_info select_conf; /* adu.c */ __printf_2_3 void __log(int, const char*, ...); -int open_dir_table(void); +int open_dir_table(int create); void check_signals(void); void close_all_tables(void); char *get_uid_list_name(void); -void create_hash_table(void); -int search_uid(uint32_t uid, enum search_uid_flags flags, - struct user_info **ui_ptr); - -/* select.c */ -int com_select(void); - -static inline int ui_used(struct user_info *ui) -{ - return ui->flags & UI_FL_SLOT_USED; -} - -static inline int ui_admissible(struct user_info *ui) -{ - return ui->flags & UI_FL_ADMISSIBLE; -} +void create_hash_table(unsigned bits); +int search_uid(uint32_t uid, struct uid_range *urs, + enum search_uid_flags flags, struct user_info **ui_ptr); +int for_each_admissible_user(int (*func)(struct user_info *, void *), + void *data); +void sort_hash_table(int (*comp)(const void *, const void *)); + +/* create.c */ +int com_create(void); + +/* interactive.c */ +void print_interactive_help(void); +int com_interactive(void);