]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
daemon: Rename public functions.
authorAndre Noll <maan@systemlinux.org>
Thu, 9 Jan 2014 20:55:31 +0000 (20:55 +0000)
committerAndre Noll <maan@systemlinux.org>
Thu, 19 Jun 2014 13:30:22 +0000 (15:30 +0200)
Let's reserve the daemon_ prefix for public functions of daemon.c
to make it clear where these functions are defined.

audiod.c
audiod_command.c
command.c
daemon.c
daemon.h
server.c

index d5c603e94fcdbc5c8b7a2121a8e54fb7f5bc76c5..bd32ad387fd7ee2d6c9816a4a7603354a572fa1f 100644 (file)
--- 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);
index 4485d9e9df28ca0fb2d1689046c1e53cffc9f5a5..e65f747a50625b99fd3c06c69c62f30d475ddbac 100644 (file)
@@ -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);
index eb15875c36b8affba5a3defdce8f787ad73026ba..412769336a2896555142eac66cf6c9469f9c394b 100644 (file)
--- 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"
index cace3b7874e7a3f00c72b134b59ada6d4978959d..3879c0d8c81e1235298aa74b923a7ef968160b24 100644 (file)
--- 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);
 }
index 025b6a5e9ef7b52225af1205bedc0a2b4f4c0400..df9de6a316f5d56dedaece3d37a8847c5902e6ff 100644 (file)
--- 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);
index bdb5df982bbd23ff7c8ebba1101c660b54ae53a2..88ee2425615a543394a88e7941b5b6d5dd3d6a5f 100644 (file)
--- 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;