X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=daemon.c;h=a2fa1caa3b97910c968b4b0e0ee1b8109a54d7ba;hp=666b0a5c645cbc0f34b3347a3e021355a6444193;hb=62414974b55d78a67d4170da85091a915087219f;hpb=471684761a2039bbc89aa1e3c33c62de6bef86cf diff --git a/daemon.c b/daemon.c index 666b0a5c..a2fa1caa 100644 --- a/daemon.c +++ b/daemon.c @@ -1,10 +1,10 @@ /* - * Copyright (C) 1997-2006 Andre Noll + * Copyright (C) 1997-2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ -/** \file daemon.c some helpers for programs that detach from the console */ +/** \file daemon.c Some helpers for programs that detach from the console. */ #include "para.h" #include "daemon.h" #include @@ -16,11 +16,11 @@ #include "string.h" /** - * do the usual stuff to become a daemon + * Do the usual stuff to become a daemon. * * Fork, become session leader, dup fd 0, 1, 2 to /dev/null. * - * \sa fork(2), setsid(2), dup(2) + * \sa fork(2), setsid(2), dup(2). */ void daemon_init(void) { @@ -48,11 +48,11 @@ void daemon_init(void) } /** - * fopen() a file in append mode + * fopen() a file in append mode. * - * \param logfile_name the name of the file to open + * \param logfile_name The name of the file to open. * - * Either calls exit() or returns a valid file handle. + * \return Either calls exit() or returns a valid file handle. */ FILE *open_log(const char *logfile_name) { @@ -62,7 +62,7 @@ FILE *open_log(const char *logfile_name) return NULL; if (!(logfile = fopen(logfile_name, "a"))) { PARA_EMERG_LOG("can not open %s, uid: %d\n", logfile_name, - getuid()); + (int)getuid()); exit(EXIT_FAILURE); } setlinebuf(logfile); @@ -70,11 +70,11 @@ FILE *open_log(const char *logfile_name) } /** - * close the log file of the daemon + * Close the log file of the daemon. * - * \param logfile the log file handle + * \param logfile The log file handle. * - * It's OK to call this with logfile == NULL + * It's OK to call this with logfile == \p NULL. */ void close_log(FILE* logfile) { @@ -85,7 +85,7 @@ void close_log(FILE* logfile) } /** - * log the startup message containing the paraslash version + * Log the startup message containing the paraslash version. */ void log_welcome(const char *whoami, int loglevel) { @@ -95,10 +95,10 @@ void log_welcome(const char *whoami, int loglevel) } /** - * give up superuser privileges + * Give up superuser privileges. * - * \param username the user to switch to - * \param groupname the group to switch to + * \param username The user to switch to. + * \param groupname The group to switch to. * * This function returns immediately if not invoked with EUID zero. Otherwise, * it tries to obtain the GID of \a groupname and the UID of \a username. On @@ -123,7 +123,7 @@ void para_drop_privileges(const char *username, const char *groupname) } if (setgid(g->gr_gid) < 0) { PARA_EMERG_LOG("failed to set group id %d (%s)\n", - g->gr_gid, strerror(errno)); + (int)g->gr_gid, strerror(errno)); exit(EXIT_FAILURE); } } @@ -140,20 +140,22 @@ void para_drop_privileges(const char *username, const char *groupname) } PARA_INFO_LOG("%s", "dropping root privileges\n"); setuid(p->pw_uid); - PARA_DEBUG_LOG("uid: %d, euid: %d\n", getuid(), geteuid()); + PARA_DEBUG_LOG("uid: %d, euid: %d\n", (int)getuid(), (int)geteuid()); } /** - * set/get the server uptime + * Set/get the server uptime. * - * \param set_or_get chose one of the two modes + * \param set_or_get Chose one of the two modes. * * This should be called at startup time with \a set_or_get equal to \p * UPTIME_SET which sets the uptime to zero. Subsequent calls with \a - * set_or_get equal to \p UPTIME_GET return the number of seconds ellapsed - * since the last reset. + * set_or_get equal to \p UPTIME_GET return the uptime. + + * \return Zero if called with \a set_or_get equal to \p UPTIME_SET, the number + * of seconds ellapsed since the last reset otherwise. * - * \sa time(2), difftime(3) + * \sa time(2), difftime(3). */ time_t server_uptime(enum uptime set_or_get) { @@ -171,15 +173,15 @@ time_t server_uptime(enum uptime set_or_get) } /** - * construct string containing uptime + * Construct string containing uptime. * - * The format of the returned string is "days:hours:minutes" + * \return A dynamically allocated string of the form "days:hours:minutes". * - * \sa server_uptime + * \sa server_uptime. */ __malloc char *uptime_str(void) { - time_t t = server_uptime(UPTIME_GET); + long t = server_uptime(UPTIME_GET); return make_message("%li:%02li:%02li", t / 86400, (t / 3600) % 24, (t / 60) % 60); }