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();
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);
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);
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"
/**
* 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);
*
* \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;
}
/**
- * 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.
*
*
* \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;
/**
* 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);
}
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);
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)
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;