Cosmetic cleanups.
[adu.git] / user.h
1 /** The columns of the id table. */
2 enum user_table_columns {
3         /** The numer of the directory. */
4         UT_DIR_NUM,
5         /** The number of bytes of all regular files in this dir owned by this id. */
6         UT_BYTES,
7         /** The number of files in this dir owned by this id. */
8         UT_FILES,
9         /** Number of columns in this table. */
10         NUM_UT_COLUMNS
11 };
12
13 /** Information about one admissible user. */
14 struct user_info {
15         /** User ID. */
16         uint32_t uid;
17         /** \sa enum uid_info_flags. */
18         uint32_t flags;
19         /** The user name.  */
20         char *pw_name;
21         /** The user table of this user.*/
22         struct osl_table *table;
23         /** Total number of files owned by this user. */
24         uint64_t files;
25         /** Total number of bytes owned by this user. */
26         uint64_t bytes;
27         /** Total number of directories that contain at least one file */
28         uint64_t dirs;
29         /** The description of the user table. */
30         struct osl_table_description *desc;
31 };
32
33 /** An opaque struct that contains info about which users are admissible. */
34 struct uid_range;
35
36 int create_user_table(uint32_t uid, struct user_info **ui_ptr);
37 int read_uid_file(void);
38 int write_uid_file(void);
39
40 void create_hash_table(unsigned bits);
41 void sort_hash_table(int (*comp)(struct user_info *, struct user_info *));
42
43 int for_each_admissible_user(int (*func)(struct user_info *, void *),
44                 void *data);
45 int parse_uid_arg(const char *orig_arg, struct uid_range **ur);
46 int append_users(char **users, int num_users,
47                 struct uid_range **admissible_uids, int num_uid_ranges);
48 void close_user_tables(void);
49 int open_admissible_user_tables(struct uid_range *admissible_uids);