X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=blobdiff_plain;f=adu.c;h=fe0caa501a2ce35e5f83273af8dace42f420bde4;hp=0cd1644c236c17908656eb25c24c12084b7c9967;hb=2e24b91148dda8ea52b308a4b5e0ef08c0f11267;hpb=2a506d3256329ead41afe0bb720fdeae4e5ed08c diff --git a/adu.c b/adu.c index 0cd1644..fe0caa5 100644 --- a/adu.c +++ b/adu.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Andre Noll + * Copyright (C) 2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -125,6 +125,25 @@ __printf_2_3 void __log(int ll, const char* fmt,...) va_end(argp); } +/** + * adu's version of strerror(3). + * + * \param num The error number. + * + * \return The error text of \a num. + */ +const char *adu_strerror(int num) +{ + assert(num > 0); + if (num == E_OSL) { + assert(osl_errno > 0); + return osl_strerror((osl_errno)); + } + if (IS_SYSTEM_ERROR(num)) + return strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1)); + return adu_errlist[num]; +} + static void close_dir_table(void) { int ret; @@ -277,9 +296,15 @@ static void get_database_dir_or_die(void) if (conf.database_dir_given) tmp = adu_strdup(conf.database_dir_arg); - else + else { + if (!conf.base_dir_arg) { + EMERG_LOG("fatal: neither database dir " + "nor base dir given\n"); + exit(EXIT_FAILURE); + } tmp = make_message("%s%s", conf.database_root_arg, conf.base_dir_arg); + } /* * As we change the cwd during database creation, database_dir * must be an absolute path.