]> git.tuebingen.mpg.de Git - adu.git/commitdiff
Add yet more source code documentation.
authorAndre Noll <maan@systemlinux.org>
Tue, 11 Nov 2008 22:08:43 +0000 (23:08 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 11 Nov 2008 22:08:43 +0000 (23:08 +0100)
adu.h
create.c
error.h
fd.h
format.c
format.h
interactive.c
select.h
string.c
string.h
user.h

diff --git a/adu.h b/adu.h
index 31050444a6ef74dc8790b003c0376a49a78334aa..c67dd6bc657b910293eba97b43138d3d05ed781b 100644 (file)
--- a/adu.h
+++ b/adu.h
@@ -4,7 +4,7 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file adu.h Global definitions. */
+/** \file adu.h \brief Global definitions. */
 
 #include <sys/stat.h>
 #include <fcntl.h>
 /** Log messages with lower priority than that will not be compiled in. */
 #define COMPILE_TIME_LOGLEVEL 0
 
+/**
+ *  A variant of static inline that requires the object being documented.
+ *
+ * If doxygen finds the \p static keyword in any context, that part will not be
+ * included in the documentation. However, we want static inline functions in
+ * header files to be documented while static functions in C files and
+ * statically declared variables should be left out. As a workaround for this
+ * flaw we use \p _static_inline_ for static inline functions declared in
+ * header files.
+ */
+#define _static_inline_ static inline
+
 /** \cond */
 #if DEBUG > COMPILE_TIME_LOGLEVEL
 #define DEBUG_LOG(f,...) __log(DEBUG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
@@ -157,7 +169,7 @@ extern struct select_args_info select_conf;
  *
  * \sa osl_compare_func, osl_hash_compare().
  */
-static inline int uint64_compare(const struct osl_object *obj1,
+_static_inline_ int uint64_compare(const struct osl_object *obj1,
                const struct osl_object *obj2)
 {
        uint64_t d1 = read_u64((const char *)obj1->data);
@@ -180,7 +192,7 @@ static inline int uint64_compare(const struct osl_object *obj1,
  * equal, the address of \a obj1 and \a obj2 are compared. So this compare function
  * returns zero if and only if \a obj1 and \a obj2 point to the same memory area.
  */
-static inline int size_compare(const struct osl_object *obj1, const struct osl_object *obj2)
+_static_inline_ int size_compare(const struct osl_object *obj1, const struct osl_object *obj2)
 {
        uint64_t d1 = *(uint64_t *)obj1->data;
        uint64_t d2 = *(uint64_t *)obj2->data;
index 3a221ca58947eab378543717714593270a6ceb24..65567e03ee592065cfd4126ac6398b8890dd71e6 100644 (file)
--- a/create.c
+++ b/create.c
@@ -151,6 +151,11 @@ out:
        return ret;
 }
 
+/**
+ * The main function of the create mode.
+ *
+ * \return Standard.
+ */
 int com_create(void)
 {
        uint64_t zero = 0ULL;
diff --git a/error.h b/error.h
index 9874003903b202fceecb53ee318cc3e1982419df..00bdede471394e7a051a81674bdda18aa4d1c4cd 100644 (file)
--- a/error.h
+++ b/error.h
@@ -4,6 +4,8 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
+/** \file error.h \brief Error handling functions and macros. */
+
 /**
  * This bit indicates whether a number is considered a system error code.
  * If yes, the system errno is just the result of clearing this bit from
@@ -17,6 +19,7 @@
 /** Set the system error bit for the given number. */
 #define ERRNO_TO_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT))
 
+/** The list of all adu error codes with descriptions. */
 #define ALL_ERRORS \
        _ERROR(SUCCESS, "success") \
        _ERROR(SYNTAX, "syntax error") \
  */
 #define _ERROR(err, msg) E_ ## err,
 
+/**
+ * \cond (doxygen can not handle multiple definitions of the same macro).
+ *
+ * This just creates an enum consisting of the first argument of the above
+ * error list.
+ */
 enum error_codes {
        ALL_ERRORS
 };
 #undef _ERROR
+
+/*
+ * Here we define the array of error texts used by adu_strerror().
+ */
 #define _ERROR(err, msg) msg,
 #define DEFINE_ERRLIST char *adu_errlist[] = {ALL_ERRORS}
+/** \endcond */
 
 extern int osl_errno;
+
+/** Contains the description of all adu error codes. */
 extern char *adu_errlist[];
 
 
@@ -66,7 +82,7 @@ extern char *adu_errlist[];
  *
  * \return The error text of \a num.
  */
-static inline const char *adu_strerror(int num)
+_static_inline_ const char *adu_strerror(int num)
 {
        assert(num > 0);
        if (num == E_OSL) {
@@ -81,13 +97,15 @@ static inline const char *adu_strerror(int num)
 /**
  * Wrapper for osl library calls.
  *
+ * \param ret The return value of an osl library function.
+ *
  * This should be used for all calls to osl functions that return an osl error
  * code. It changes the return value to \p -E_OSL appropriately so that it can
  * be used for printing the correct error message.
  *
  * \return \a ret if \a ret >= 0, \p -E_OSL otherwise.
  */
-static inline int osl(int ret)
+_static_inline_ int osl(int ret)
 {
        if (ret >= 0)
                return ret;
diff --git a/fd.h b/fd.h
index 87083c2dcc81292499b417cd7c7366e205ad6295..6ebd9c90cb67f5917b50c923491d8f5a8fe9d1a1 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -4,7 +4,7 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file fd.h exported symbols from fd.c */
+/** \file fd.h \brief Exported symbols from fd.c */
 
 int adu_opendir(const char *dirname, DIR **dir, int *cwd);
 int adu_fchdir(int fd);
index f1d1247074da8c97c41368aa3663b037dbbfc4bd..e8a9a28617656700fda8352ec82bd1fb2517e144 100644 (file)
--- a/format.c
+++ b/format.c
@@ -14,6 +14,7 @@
 #include "error.h"
 #include "format.h"
 
+/** The three different alignment types. */
 enum alignment {ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER};
 
 struct num_format {
index 9761ea2548e9362db9fc37cad284dfa3a328c5f7..b5ca1af78b6ae8b37fcc330446daf45f0b1b9f3b 100644 (file)
--- a/format.h
+++ b/format.h
@@ -4,7 +4,7 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file format.h Exported symbols from \p format.c. */
+/** \file format.h \brief Exported symbols from \p format.c. */
 
 /** The possible types of format string directives (aka atoms). */
 enum atom_type {
index 4c0392784604d4af06701dcdee355197d7ba868a..7327ee168eaf264c6830a1ed54052972ff244ce5 100644 (file)
@@ -4,6 +4,8 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
+/** \file interactive.c \brief Commands for interactive mode. */
+
 #include <ctype.h> /* isspace() */
 
 #include "adu.h"
@@ -32,6 +34,7 @@ struct interactive_command {
 static struct uid_range *admissible_uids;
 static struct format_info *fi;
 
+/** The set of supported interactive commands. */
 #define INTERACTIVE_COMMANDS \
        INTERACTIVE_COMMAND(set, "change the current configuration") \
        INTERACTIVE_COMMAND(reset, "reset configuration to defaults") \
@@ -40,6 +43,7 @@ static struct format_info *fi;
        INTERACTIVE_COMMAND(source, "read and execute interactive commands from a file")
 
 
+/** \cond doxygen is not smart enough for this */
 #define INTERACTIVE_COMMAND(name, desc) \
        static int icom_ ## name (char *line);
 
@@ -58,7 +62,9 @@ struct interactive_command icmds[] = {
        INTERACTIVE_COMMANDS
        {.name  = NULL}
 };
+/** \endcond */
 
+/** Iterate over the list of all interactive commands. */
 #define FOR_EACH_COMMAND(c) for (c = icmds; c->name; c++)
 
 static int read_input_line(char *line, size_t size)
@@ -80,6 +86,9 @@ static int icom_help(__a_unused char *line)
        return 1;
 }
 
+/**
+ * Print the list of commands with short descriptions.
+ */
 void print_interactive_help(void)
 {
        struct interactive_command *c;
@@ -190,6 +199,11 @@ out:
        return ret;
 }
 
+/**
+ * The main function for interactive mode.
+ *
+ * \return Standard.
+ */
 int com_interactive(void)
 {
        char line[255];
index 7891ff8220e0631e858dd4912f1a5cb8bc8d70fa..06ee0347432139f08da26ef0640b041263c8f6b7 100644 (file)
--- a/select.h
+++ b/select.h
@@ -4,6 +4,7 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
+/** \file select.h \brief Exported functions from string.c. */
 int parse_select_options(char *string, struct select_cmdline_parser_params *params,
                struct uid_range **admissible_uids, struct format_info **fi);
 int run_select_query(struct uid_range *admissible_uids, struct format_info *fi);
index 07dd8459cda272666a4714941549d68bec1cc9b9..17edffc5e9d9bef56d3f491ac12a83a01c2494cd 100644 (file)
--- a/string.c
+++ b/string.c
@@ -196,14 +196,14 @@ __must_check int atoi64(const char *str, int64_t *result)
 }
 
 /**
- * Split string and return pointers to its parts.
+ * Split string and return pointers to its parts.
  *
  * \param args The string to be split.
  * \param argv_ptr Pointer to the list of substrings.
  * \param delim Delimiter.
  *
  * This function modifies \a args by replacing each occurance of \a delim by
- * zero. A \p NULL-terminated array of pointers to char* is allocated dynamically
+ * zero. A \p NULL terminated array of pointers to char* is allocated dynamically
  * and these pointers are initialized to point to the broken-up substrings
  * within \a args. A pointer to this array is returned via \a argv_ptr.
  *
@@ -245,10 +245,11 @@ __must_check unsigned split_args(char *args, char *** const argv_ptr, const char
        return n;
 }
 
-enum line_state_flags {LSF_HAVE_WORD = 1, LSF_BACKSLASH = 2, LSF_QUOTE = 4};
 
 static int get_next_word(const char *line, char **word)
 {
+       enum line_state_flags {LSF_HAVE_WORD = 1, LSF_BACKSLASH = 2,
+               LSF_QUOTE = 4};
        const char *in;
        char *out;
        int ret, state = 0;
@@ -320,6 +321,11 @@ out:
        return ret;
 }
 
+/**
+ * Free an array of words created by create_argv().
+ *
+ * \param argv A pointer previously obtained by \ref create_argv().
+ */
 void free_argv(char **argv)
 {
        int i;
@@ -330,6 +336,16 @@ void free_argv(char **argv)
 }
 
 /**
+ * Split a line into words which are separated by whitespace.
+ *
+ * In contrast to gengetopt's string parser, double quotes, backslash-escaped
+ * characters and special characters like \p \\n are honored. The result
+ * contains pointers to copies of the words contained in \line and has to be
+ * freed by using \ref free_argv().
+ *
+ * \param line The line to be split.
+ * \param result The array of words is returned here.
+ *
  * \return Number of words in \a line, negative on errors.
  */
 int create_argv(const char *line, char ***result)
index 1eb8f0150d92a690850e0f3b20cdb31a37f20e8b..128376995c0b45c1b565ba4527a8fdec0fd0aa2a 100644 (file)
--- a/string.h
+++ b/string.h
@@ -4,7 +4,7 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file string.h exported sybmols from string.c */
+/** \file string.h \brief Exported sybmols from string.c */
 
 __must_check __malloc void *adu_realloc(void *p, size_t size);
 __must_check __malloc void *adu_malloc(size_t size);
diff --git a/user.h b/user.h
index c561a3fe8335a90d1cc8261ba4fafa63543273a3..acd0b8d85243220e42a09ec972233a238c4d393b 100644 (file)
--- a/user.h
+++ b/user.h
@@ -4,6 +4,8 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
+/** \file user.h \brief User structures and exported symbols from user.c. */
+
 /** The columns of the id table. */
 enum user_table_columns {
        /** The numer of the directory. */