X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=adu.c;h=82c876a96eb550956f60db458207c2777e67cb86;hb=c7d5ddb6906ab8a18181fee29ac78d604db5fdb9;hp=cbc42cb5769bc86b8e7c4ae214adaf781a63871e;hpb=63ef06be534ab9a8f31865ef6c2324f0a951aef9;p=adu.git diff --git a/adu.c b/adu.c index cbc42cb..82c876a 100644 --- a/adu.c +++ b/adu.c @@ -1,4 +1,20 @@ -/** \file adu.c The main functions used by all modes of operation. */ +/* + * Copyright (C) 2008 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file adu.c \brief The main functions used by all modes of operation. */ + +/** + * \mainpage adu API reference + * + * - Modes of operation: \ref select.c, \ref create.c, \ref interactive.c + * - User handling: \ref user.c + * - Error handling: \ref error.h + * - Library-type functions: \ref fd.c, \ref format.c, \ref string.c, \ref portable_io.h + */ + #include "adu.h" #include /* readdir() */ #include @@ -11,7 +27,14 @@ #include "string.h" #include "error.h" +/** Define the array of error descriptions. */ DEFINE_ERRLIST; + +/** + * The error code of the last called osl library function. + * + * \sa osl(). + */ int osl_errno; /** In case a signal is received, its number is stored here. */ @@ -114,7 +137,7 @@ static void close_dir_table(void) dir_table = NULL; } -void close_all_tables(void) +static void close_all_tables(void) { close_dir_table(); close_user_tables(); @@ -125,6 +148,12 @@ static void signal_handler(int s) signum = s; } +/** + * Check whether to terminate adu. + * + * Check whether a signal was caught that should terminate the + * adu process. If yes, close all osl tables and exit gracefully. + */ void check_signals(void) { if (likely(!signum)) @@ -145,6 +174,13 @@ static int init_signals(void) return 1; } +/** + * Open the directory table. + * + * \param create If non-zero, create the table first. + * + * \return Standard. + */ int open_dir_table(int create) { @@ -185,7 +221,7 @@ static int check_args(void) return 1; } -static int print_complete_help_and_die(void) +static void print_complete_help_and_die(void) { const char **line; @@ -215,6 +251,17 @@ static int print_complete_help_and_die(void) exit(EXIT_FAILURE); } +/** + * The main function of adu. + * + * \param argc Usual argument count. + * \param argv Usual argument vector. + * + * Check command line options, init the signal handlers and + * call the main function of the selected mode. + * + * \return \p EXIT_SUCCESS on success, \p EXIT_FAILURE otherwise. + */ int main(int argc, char **argv) { int ret;