From 823a4ff87a03ff9e1d2bfe8bc501f55ee4213649 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 9 Jan 2014 20:55:31 +0000 Subject: [PATCH] daemon: Rename public functions. Let's reserve the daemon_ prefix for public functions of daemon.c to make it clear where these functions are defined. --- audiod.c | 6 +++--- audiod_command.c | 2 +- command.c | 2 +- daemon.c | 24 ++++++++++++------------ daemon.h | 10 +++++----- server.c | 8 ++++---- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/audiod.c b/audiod.c index d5c603e9..bd32ad38 100644 --- a/audiod.c +++ b/audiod.c @@ -1392,7 +1392,7 @@ int main(int argc, char *argv[]) writer_init(); if (conf.help_given || conf.detailed_help_given) print_help_and_die(); - drop_privileges_or_die(conf.user_arg, conf.group_arg); + daemon_drop_privileges_or_die(conf.user_arg, conf.group_arg); parse_config_or_die(); init_colors_or_die(); init_random_seed_or_die(); @@ -1410,8 +1410,8 @@ int main(int argc, char *argv[]) PARA_EMERG_LOG("%s\n", para_strerror(-ret)); exit(EXIT_FAILURE); } - log_welcome("para_audiod"); - set_server_start_time(); + daemon_log_welcome("para_audiod"); + daemon_set_start_time(); set_initial_status(); FOR_EACH_SLOT(i) clear_slot(i); diff --git a/audiod_command.c b/audiod_command.c index 4485d9e9..e65f747a 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -510,7 +510,7 @@ void audiod_status_dump(bool force) free(new); } - new = get_server_uptime_str(now); + new = daemon_get_uptime_str(now); old = stat_item_values[SI_AUDIOD_UPTIME]; if (force || !old || strcmp(old, new)) { free(old); diff --git a/command.c b/command.c index eb15875c..41276933 100644 --- a/command.c +++ b/command.c @@ -385,7 +385,7 @@ static int com_si(struct command_context *cc) sender_info = para_strcat(sender_info, info); free(info); } - ut = get_server_uptime_str(now); + ut = daemon_get_uptime_str(now); ret = xasprintf(&msg, "version: %s\n" "up: %s\nplayed: %u\n" diff --git a/daemon.c b/daemon.c index cace3b78..3879c0d8 100644 --- a/daemon.c +++ b/daemon.c @@ -229,7 +229,7 @@ void daemon_open_log_or_die(void) /** * Log the startup message containing the paraslash version. */ -void log_welcome(const char *whoami) +void daemon_log_welcome(const char *whoami) { PARA_INFO_LOG("welcome to %s " PACKAGE_VERSION " ("BUILD_DATE")\n", whoami); @@ -249,7 +249,7 @@ void log_welcome(const char *whoami) * * \sa getpwnam(3), getuid(2), setuid(2), getgrnam(2), setgid(2) */ -void drop_privileges_or_die(const char *username, const char *groupname) +void daemon_drop_privileges_or_die(const char *username, const char *groupname) { struct passwd *p; char *tmp; @@ -290,20 +290,20 @@ void drop_privileges_or_die(const char *username, const char *groupname) } /** - * Set the server startup time. + * Set the startup time. * - * This should be called once on startup. It sets the server start time to the + * This should be called once on startup. It sets the start time to the * current time. The stored time is used for retrieving the server uptime. * - * \sa time(2), \ref get_server_uptime(), \ref get_server_uptime_str(). + * \sa time(2), \ref daemon_get_uptime(), \ref daemon_get_uptime_str(). */ -void set_server_start_time(void) +void daemon_set_start_time(void) { time(&me->startuptime); } /** - * Get the server uptime. + * Get the uptime. * * \param current_time The current time. * @@ -312,9 +312,9 @@ void set_server_start_time(void) * * \return This returns the server uptime in seconds, i.e. the difference * between the current time and the value stored previously via \ref - * set_server_start_time(). + * daemon_set_start_time(). */ -time_t get_server_uptime(const struct timeval *current_time) +time_t daemon_get_uptime(const struct timeval *current_time) { time_t t; @@ -327,15 +327,15 @@ time_t get_server_uptime(const struct timeval *current_time) /** * Construct a string containing the current uptime. * - * \param current_time See a \ref get_server_uptime(). + * \param current_time See a \ref daemon_get_uptime(). * * \return A dynamically allocated string of the form "days:hours:minutes". * * \sa server_uptime. */ -__malloc char *get_server_uptime_str(const struct timeval *current_time) +__malloc char *daemon_get_uptime_str(const struct timeval *current_time) { - long t = get_server_uptime(current_time); + long t = daemon_get_uptime(current_time); return make_message("%li:%02li:%02li", t / 86400, (t / 3600) % 24, (t / 60) % 60); } diff --git a/daemon.h b/daemon.h index 025b6a5e..df9de6a3 100644 --- a/daemon.h +++ b/daemon.h @@ -4,11 +4,11 @@ void daemonize(bool parent_waits); void daemon_open_log_or_die(void); void daemon_close_log(void); -void log_welcome(const char *whoami); -void drop_privileges_or_die(const char *username, const char *groupname); -void set_server_start_time(void); -time_t get_server_uptime(const struct timeval *current_time); -__malloc char *get_server_uptime_str(const struct timeval *current_time); +void daemon_log_welcome(const char *whoami); +void daemon_drop_privileges_or_die(const char *username, const char *groupname); +void daemon_set_start_time(void); +time_t daemon_get_uptime(const struct timeval *current_time); +__malloc char *daemon_get_uptime_str(const struct timeval *current_time); void daemon_set_logfile(char *logfile_name); void daemon_set_flag(unsigned flag); void daemon_clear_flag(unsigned flag); diff --git a/server.c b/server.c index bdb5df98..88ee2425 100644 --- a/server.c +++ b/server.c @@ -479,12 +479,12 @@ static void server_init(int argc, char **argv) version_handle_flag("server", conf.version_given); if (conf.help_given || conf.detailed_help_given) print_help_and_die(); - drop_privileges_or_die(conf.user_arg, conf.group_arg); + daemon_drop_privileges_or_die(conf.user_arg, conf.group_arg); /* parse config file, open log and set defaults */ parse_config_or_die(0); - log_welcome("para_server"); + daemon_log_welcome("para_server"); init_ipc_or_die(); /* init mmd struct and mmd->lock */ - set_server_start_time(); + daemon_set_start_time(); init_user_list(user_list_file); /* become daemon */ if (conf.daemon_given) @@ -522,7 +522,7 @@ static void server_init(int argc, char **argv) static void status_refresh(void) { static int prev_uptime = -1, prev_events = -1; - int uptime = get_server_uptime(now); + int uptime = daemon_get_uptime(now); if (prev_events != mmd->events) goto out; -- 2.39.5