]> git.tuebingen.mpg.de Git - adu.git/blobdiff - adu.h
Add the latex and html directories to .gitignore.
[adu.git] / adu.h
diff --git a/adu.h b/adu.h
index 3e06c9509ff8d670e71ab582a017648b56f86a1c..b9e6ee9f67812764c8b65b7baf41bc9d31ef5978 100644 (file)
--- a/adu.h
+++ b/adu.h
@@ -8,7 +8,7 @@
 
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/wait.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h> /* time(), localtime() */
 #include <errno.h>
 #include <limits.h>
 #include <stdarg.h>
-#include <ctype.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <sys/un.h> /* needed by create_pf_socket */
+#include <inttypes.h>
 #include <string.h>
 #include <assert.h>
 #include <osl.h>
 #include "gcc-compat.h"
+#include "select.cmdline.h"
 
 /** debug loglevel, gets really noisy */
 #define DEBUG 1
        } \
 }
 
-#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 {
@@ -149,6 +146,7 @@ enum user_table_columns {
        NUM_UT_COLUMNS
 };
 
+/** Flags for the user hash table. */
 enum uid_info_flags {
        /** Whether this slot of the hash table is used. */
        UI_FL_SLOT_USED = 1,
@@ -156,19 +154,36 @@ enum uid_info_flags {
        UI_FL_ADMISSIBLE = 2,
 };
 
+/** Information about one admissible user. */
 struct user_info {
+       /** User ID. */
        uint32_t uid;
+       /** \sa enum uid_info_flags. */
        uint32_t flags;
+       /** The user name.  */
        char *pw_name;
+       /** The user table of this user.*/
        struct osl_table *table;
+       /** Total number of files owned by this user. */
        uint64_t files;
+       /** Total number of bytes owned by this user. */
        uint64_t bytes;
+       /** Total number of directories that contain at least one file */
        uint64_t dirs;
+       /** The description of the user table. */
        struct osl_table_description *desc;
 };
 
+/**
+ * Describes one range of admissible user IDs.
+ *
+ * adu converts the admissible user ids given at the command line
+ * into an array of such structs.
+ */
 struct uid_range {
+       /** Lowest admissible user ID. */
        uint32_t low;
+       /** Greatest admissible user ID. */
        uint32_t high;
 };
 
@@ -177,15 +192,22 @@ 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;
+
+/** The adu command line options. */
 extern struct gengetopt_args_info conf;
 
+/**
+ * The select command line options.
+ *
+ * Either given at the command line, or via the \a set command
+ * in interactive mode.
+ */
+extern struct select_args_info select_conf;
+
 /* adu.c */
 __printf_2_3 void __log(int, const char*, ...);
 int open_dir_table(int create);
@@ -193,21 +215,15 @@ void check_signals(void);
 void close_all_tables(void);
 char *get_uid_list_name(void);
 void create_hash_table(unsigned bits);
-int search_uid(uint32_t uid, enum search_uid_flags flags,
-               struct user_info **ui_ptr);
-
-/* select.c */
-int com_select(void);
+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.h */
+/* create.c */
 int com_create(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;
-}
+/* interactive.c */
+void print_interactive_help(void);
+int com_interactive(void);