From 786010c598f79d20280e6ea9ea458cad4a7e9af7 Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 15 Jun 2006 12:43:27 +0200 Subject: [PATCH] integrate para_client into para_audiod This allows major simplifications: - get rid of exec.o: para_audiod no longer executes any external programs - get rid of close_on_fork.o - get rid of the sigchld handler. --- Makefile.in | 10 ++++- NEWS | 3 +- afs.c | 1 - audioc.c | 6 +-- audiod.c | 96 +++++++++++++++++++---------------------------- audiod.h | 13 ++----- client_common.c | 13 ++++--- command.c | 1 - configure.ac | 8 ++-- dccp_send.c | 2 +- fade.c | 6 +-- filter.c | 6 +-- grab_client.c | 2 - gui.c | 10 ++--- http_recv.c | 5 +-- http_send.c | 2 - mysql_selector.c | 1 - ortp_send.c | 2 - random_selector.c | 1 - recv.c | 4 +- sdl_gui.c | 6 +-- server.c | 6 +-- server.h | 1 + stat.c | 2 - write.c | 4 +- 25 files changed, 92 insertions(+), 119 deletions(-) diff --git a/Makefile.in b/Makefile.in index ed887fa4..9a85952b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -141,10 +141,16 @@ grab_client.cmdline.h grab_client.cmdline.c: grab_client.ggo --func-name $(subst _write.ggo,,$<)_cmdline_parser < $< %.cmdline.h %.cmdline.c: %.ggo - case $< in client.ggo) O="--unamed-opts=command --arg-struct-name=$(subst .ggo,,$<)_args_info";; \ + case $< in client.ggo) O="--unamed-opts=command";; \ audioc.ggo) O="--unamed-opts=command";; \ esac; \ - gengetopt $$O --conf-parser --file-name=$(*F).cmdline --set-package="para_$(subst .cmdline,,$(*F))" --set-version="$V" < $< + gengetopt $$O \ + --conf-parser \ + --file-name=$(*F).cmdline \ + --func-name $(*F)_cmdline_parser \ + --arg-struct-name=$(*F)_args_info \ + --set-package="para_$(subst .cmdline,,$(*F))" \ + --set-version="$V" < $< aacdec.o: aacdec.c $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $< diff --git a/NEWS b/NEWS index 4a2941fe..dd02a36a 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,8 @@ A bunch of new features and core changes. - Support for m4a files via the new aac filter/ and audio format handler. (requires libfaad) - new writer: osxplay (thanks to Gerd Becker) - - writers are integrated into para_audiod + - writers are integrated in para_audiod + - para_client is integrated in para_audiod - each writer of para_write has its own command line parser, just like para_recv and para_filter. - random/playlist selector: improved info strings diff --git a/afs.c b/afs.c index 608bdde8..49aabafb 100644 --- a/afs.c +++ b/afs.c @@ -41,7 +41,6 @@ static struct timeval eof_barrier; extern struct misc_meta_data *mmd; extern struct audio_file_selector selectors[]; extern struct sender senders[]; -extern struct gengetopt_args_info conf; static FILE *audio_file = NULL; diff --git a/audioc.c b/audioc.c index 1723114f..0f4c5c50 100644 --- a/audioc.c +++ b/audioc.c @@ -27,7 +27,7 @@ INIT_AUDIOC_ERRLISTS; -struct gengetopt_args_info conf; +struct audioc_args_info conf; char *tmpfifo; @@ -81,11 +81,11 @@ int main(int argc, char *argv[]) *buf = NULL, *hn = para_hostname(), *args, *home = para_homedir(); - if (cmdline_parser(argc, argv, &conf)) + if (audioc_cmdline_parser(argc, argv, &conf)) goto out; cf = configfile_exists(); if (cf) { - if (cmdline_parser_configfile(cf, &conf, 0, 0, 0)) { + if (audioc_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) { fprintf(stderr, "parse error in config file\n"); exit(EXIT_FAILURE); } diff --git a/audiod.c b/audiod.c index 8b9f181b..032b608c 100644 --- a/audiod.c +++ b/audiod.c @@ -22,14 +22,13 @@ #include "audiod.cmdline.h" #include "list.h" -#include "close_on_fork.h" #include "sched.h" #include "recv.h" #include "filter.h" #include "grab_client.cmdline.h" #include "grab_client.h" - -#include "error.h" +#include "client.cmdline.h" +#include "client.h" #include "audiod.h" #include "net.h" #include "daemon.h" @@ -37,6 +36,7 @@ #include "fd.h" #include "write.h" #include "write_common.h" +#include "error.h" /** define the array of error lists needed by para_audiod */ INIT_AUDIOD_ERRLISTS; @@ -70,7 +70,7 @@ struct slot_info slot[MAX_STREAM_SLOTS]; int audiod_status = AUDIOD_ON; -struct gengetopt_args_info conf; +struct audiod_args_info conf; static char *socket_name; static FILE *logfile; static struct audio_format_info afi[NUM_AUDIO_FORMATS]; @@ -163,10 +163,8 @@ static void setup_signal_handling(void) PARA_INFO_LOG("signal pipe: fd %d\n", sig_task->fd); para_install_sighandler(SIGINT); para_install_sighandler(SIGTERM); - para_install_sighandler(SIGCHLD); para_install_sighandler(SIGHUP); - para_install_sighandler(SIGPIPE); -// signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); } static void clear_slot(int slot_num) @@ -261,13 +259,10 @@ static void close_stat_pipe(void) { int i; - if (stat_task->fd < 0) + if (!stat_task->pcd) return; - PARA_NOTICE_LOG("%s", "closing status pipe\n"); - close(stat_task->fd); - del_close_on_fork_list(stat_task->fd); - stat_task->fd = -1; -// kill_all_decoders(); + client_close(stat_task->pcd); + stat_task->pcd = NULL; for (i = 0; i < NUM_STAT_ITEMS; i++) { free(stat_task->stat_item_values[i]); stat_task->stat_item_values[i] = NULL; @@ -449,7 +444,7 @@ static int open_current_receiver(struct sched *s) int i; struct timeval diff; - if (!stat_task->af_status) + if (!stat_task->af_status || !stat_task->pcd) return 0; i = get_audio_format_num(stat_task->af_status); if (i < 0) @@ -554,13 +549,6 @@ static void check_stat_line(char *line) static void handle_signal(int sig) { switch (sig) { - case SIGCHLD: - for (;;) { - pid_t pid = para_reap_child(); - if (pid <= 0) - return; - PARA_CRIT_LOG("para_client died (pid %d)\n", pid); - } case SIGINT: case SIGTERM: case SIGHUP: @@ -880,26 +868,10 @@ static int audiod_get_socket(void) PARA_EMERG_LOG("%s", "can not listen on socket\n"); exit(EXIT_FAILURE); /* do not unlink socket */ } - add_close_on_fork_list(fd); mark_fd_nonblock(fd); return fd; } -static int open_stat_pipe(void) -{ - int ret, fd[3] = {-1, 1, 0}; - pid_t pid; - ret = para_exec_cmdline_pid(&pid, BINDIR "/para_client stat", fd); - if (ret >= 0) { - ret = fd[1]; - PARA_NOTICE_LOG("stat pipe opened, fd %d\n", ret); - add_close_on_fork_list(ret); - mark_fd_nonblock(ret); - } else - clean_exit(EXIT_FAILURE, "failed to open status pipe"); - return ret; -} - void signal_event_handler(struct task *t) { struct signal_task *st = t->private_data; @@ -968,6 +940,15 @@ static void init_command_task(struct command_task *ct) sprintf(ct->task.status, "command task"); } +static void client_task_event_handler(__a_unused struct task *t) +{ + struct private_client_data *pcd = t->private_data; + if (t->ret == -E_HANDSHAKE_COMPLETE) + return; + unregister_task(t); + pcd->eof = 1; +} + static void status_event_handler(__a_unused struct task *t) { struct timeval delay = {1, 0}; @@ -985,34 +966,34 @@ static void status_event_handler(__a_unused struct task *t) static void status_pre_select(struct sched *s, struct task *t) { struct status_task *st = t->private_data; + int argc = 2; + char *argv[] = {"audiod", "stat", NULL}; t->ret = 1; - if (st->fd >= 0 && audiod_status == AUDIOD_OFF) + if (st->pcd && (audiod_status == AUDIOD_OFF || st->pcd->eof)) close_stat_pipe(); - if (st->fd < 0 && audiod_status != AUDIOD_OFF + if (!st->pcd && audiod_status != AUDIOD_OFF && tv_diff(now, &st->restart_barrier, NULL) > 0) { - st->fd = open_stat_pipe(); - st->loaded = 0; - st->buf[0] = '\0'; + t->ret = client_parse_config(argc, argv, &st->pcd); + if (t->ret < 0) + return; + t->ret = client_open(st->pcd); + if (t->ret < 0) + return; + st->pcd->task.event_handler = client_task_event_handler; + s->timeout.tv_sec = 0; + s->timeout.tv_usec = 1; } - if (st->fd >= 0 && audiod_status != AUDIOD_OFF) - para_fd_set(st->fd, &s->rfds, &s->max_fileno); } -static void status_post_select(struct sched *s, struct task *t) +static void status_post_select(__a_unused struct sched *s, struct task *t) { struct status_task *st = t->private_data; t->ret = 1; - if (st->fd < 0 || !FD_ISSET(st->fd, &s->rfds)) - return; - t->ret = read(st->fd, st->buf + st->loaded, STRINGSIZE - 1 - st->loaded); - if (t->ret <= 0) { - if (!t->ret) - t->ret = -E_STATUS_EOF; + if (!st->pcd || !st->pcd->loaded + || st->pcd->status != CL_RECEIVING_SERVER_OUTPUT) return; - } - st->buf[t->ret + st->loaded] = '\0'; - st->loaded = for_each_line(st->buf, t->ret + st->loaded, + st->pcd->loaded = for_each_line(st->pcd->buf, st->pcd->loaded, &check_stat_line); } @@ -1023,7 +1004,6 @@ static void init_status_task(struct status_task *st) st->task.post_select = status_post_select; st->task.event_handler = status_event_handler; st->task.private_data = st; - st->fd = -1; st->sa_time_diff_sign = 1; sprintf(st->task.status, "status task"); } @@ -1054,11 +1034,11 @@ int main(int argc, char *argv[]) struct task audiod_task_struct, *audiod_task = &audiod_task_struct; valid_fd_012(); - cmdline_parser(argc, argv, &conf); + audiod_cmdline_parser(argc, argv, &conf); para_drop_privileges(conf.user_arg, conf.group_arg); cf = configfile_exists(); if (cf) { - if (cmdline_parser_configfile(cf, &conf, 0, 0, 0)) { + if (audiod_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) { PARA_EMERG_LOG("%s", "parse error in config file\n"); exit(EXIT_FAILURE); } @@ -1091,7 +1071,7 @@ int main(int argc, char *argv[]) register_task(&cmd_task->task); register_task(&stat_task->task); register_task(audiod_task); - s.default_timeout.tv_sec = 3; + s.default_timeout.tv_sec = 0; s.default_timeout.tv_usec = 99 * 1000; ret = sched(&s); diff --git a/audiod.h b/audiod.h index f77ebcd1..c8d5fc2e 100644 --- a/audiod.h +++ b/audiod.h @@ -54,16 +54,11 @@ struct audiod_task { * \sa struct task, struct sched */ struct status_task { - /** the output of the stat command is read from this fd */ - int fd; - /** stat data is stored here */ - char buf[STRINGSIZE]; - /** number of bytes loaded in \a buf */ - unsigned loaded; + /** the associated task structure of audiod */ + struct task task; + struct private_client_data *pcd; /** the array of status items sent by para_server */ char *stat_item_values[NUM_STAT_ITEMS]; - /** the associated task structure */ - struct task task; /** do not restart client command until this time */ struct timeval restart_barrier; /** the offset value announced by para_server */ @@ -84,7 +79,7 @@ struct status_task { extern struct status_task *stat_task; extern struct slot_info slot[MAX_STREAM_SLOTS]; -extern struct gengetopt_args_info conf; +extern struct audiod_args_info conf; extern int audiod_status; extern const char *status_item_list[NUM_STAT_ITEMS]; diff --git a/client_common.c b/client_common.c index 330c9f70..c2ae2d31 100644 --- a/client_common.c +++ b/client_common.c @@ -27,6 +27,7 @@ #include "net.h" #include "fd.h" #include "string.h" +#include "client.cmdline.h" #include "client.h" #include "error.h" @@ -67,7 +68,7 @@ int client_parse_config(int argc, char *argv[], para_calloc(sizeof(struct private_client_data)); pcd->fd = -1; - cmdline_parser(argc, argv, &pcd->conf); + client_cmdline_parser(argc, argv, &pcd->conf); ret = - E_CLIENT_SYNTAX; if (!pcd->conf.inputs_num) goto out; @@ -87,7 +88,8 @@ int client_parse_config(int argc, char *argv[], goto out; } if (!ret) - cmdline_parser_configfile(pcd->config_file, &pcd->conf, 0, 0, 0); + client_cmdline_parser_configfile(pcd->config_file, + &pcd->conf, 0, 0, 0); ret = 1; *pcd_ptr = pcd; PARA_INFO_LOG( @@ -111,7 +113,6 @@ void client_pre_select(struct sched *s, struct task *t) { struct private_client_data *pcd = t->private_data; - PARA_INFO_LOG("status %d\n", pcd->status); t->ret = 1; pcd->check_r = 0; pcd->check_w = 0; @@ -171,7 +172,7 @@ void client_post_select(struct sched *s, struct task *t) { struct private_client_data *pcd = t->private_data; - PARA_INFO_LOG("status %d\n", pcd->status); +// PARA_INFO_LOG("status %d\n", pcd->status); t->ret = 1; if (pcd->fd < 0) return; @@ -228,7 +229,7 @@ void client_post_select(struct sched *s, struct task *t) if (t->ret < 0) return; bytes_received = t->ret; - PARA_INFO_LOG("++++ server info ++++\n%s\n++++ end of server " + PARA_DEBUG_LOG("++++ server info ++++\n%s\n++++ end of server " "info ++++\n", pcd->buf); /* check if server has sent "Proceed" message */ t->ret = -E_CLIENT_AUTH; @@ -259,7 +260,7 @@ void client_post_select(struct sched *s, struct task *t) free(tmp); } command = para_strcat(command, EOC_MSG "\n"); - PARA_INFO_LOG("--> %s\n", command); + PARA_DEBUG_LOG("--> %s\n", command); t->ret = send_buffer(pcd->fd, command); free(command); if (t->ret > 0) diff --git a/command.c b/command.c index 9098ad3c..ea42ef43 100644 --- a/command.c +++ b/command.c @@ -38,7 +38,6 @@ static unsigned char rc4_buf[2 * RC4_KEY_LEN]; extern const char *status_item_list[NUM_STAT_ITEMS]; extern struct misc_meta_data *mmd; -extern struct gengetopt_args_info conf; extern struct audio_file_selector selectors[]; extern struct sender senders[]; extern char *user_list; diff --git a/configure.ac b/configure.ac index 49b3198a..edb0637a 100644 --- a/configure.ac +++ b/configure.ac @@ -68,10 +68,11 @@ audioc_cmdline_objs="audioc.cmdline" audioc_errlist_objs="audioc string net fd" audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline - http_recv.cmdline dccp_recv.cmdline file_write.cmdline" -audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net + http_recv.cmdline dccp_recv.cmdline file_write.cmdline client.cmdline" +audiod_errlist_objs="audiod signal string daemon stat net time grab_client filter_chain wav compress http_recv dccp dccp_recv - recv_common fd sched write_common file_writer audiod_command" + recv_common fd sched write_common file_writer audiod_command crypt + client_common" audiod_ldflags="" server_cmdline_objs="server.cmdline" @@ -137,6 +138,7 @@ if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi CHECK_SSL($enable_ssldir) server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS" client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS" +audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS" ########################################################################### ucred diff --git a/dccp_send.c b/dccp_send.c index cfff3093..08930ad1 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -34,7 +34,7 @@ #include "fd.h" #include "close_on_fork.h" #include "server.cmdline.h" -extern struct gengetopt_args_info conf; + /** the list of connected clients **/ static struct list_head clients; static int listen_fd = -1; diff --git a/fade.c b/fade.c index ceb91daf..b42e4a1c 100644 --- a/fade.c +++ b/fade.c @@ -34,7 +34,7 @@ #include "string.h" -struct gengetopt_args_info args_info; +struct fade_args_info args_info; void para_log(__a_unused int ll, const char *fmt,...) { @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) { int ret; - if (cmdline_parser(argc, argv, &args_info)) + if (fade_cmdline_parser(argc, argv, &args_info)) exit(EXIT_FAILURE); ret = configfile_exists(); if (!ret && args_info.config_file_given) { @@ -288,7 +288,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } if (ret) - cmdline_parser_configfile(args_info.config_file_arg, + fade_cmdline_parser_configfile(args_info.config_file_arg, &args_info, 0, 0, 0); if ((ret = open_mixer()) < 0) { PARA_EMERG_LOG("can not open mixer device %s.", diff --git a/filter.c b/filter.c index f49042f8..0d1c2e24 100644 --- a/filter.c +++ b/filter.c @@ -37,7 +37,7 @@ static struct filter_chain *fc = &filter_chain_struct; static struct stdout_task stdout_task_struct; static struct stdout_task *sot = &stdout_task_struct; -struct gengetopt_args_info conf; +struct filter_args_info conf; __printf_2_3 void para_log(int ll, const char* fmt,...) { @@ -113,7 +113,7 @@ static int parse_config(int argc, char *argv[]) struct stat statbuf; int i; - if (cmdline_parser(argc, argv, &conf)) + if (filter_cmdline_parser(argc, argv, &conf)) return -E_FILTER_SYNTAX; if (!cf) { char *home = para_homedir(); @@ -121,7 +121,7 @@ static int parse_config(int argc, char *argv[]) free(home); } if (!stat(cf, &statbuf)) { - if (cmdline_parser_configfile(cf, &conf, 0, 0, 0)) + if (filter_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) return -E_FILTER_SYNTAX; } if (!conf.list_filters_given) diff --git a/grab_client.c b/grab_client.c index f505fa87..735e5b4b 100644 --- a/grab_client.c +++ b/grab_client.c @@ -24,7 +24,6 @@ */ #include "para.h" -#include "close_on_fork.h" #include "grab_client.cmdline.h" #include "list.h" #include "sched.h" @@ -145,7 +144,6 @@ static void gc_close(struct filter_callback *fcb) if (gc->conf->one_shot_given || gc->error) { PARA_INFO_LOG("closing fd %d (grab client %p)\n", gc->fd, gc); - del_close_on_fork_list(gc->fd); close(gc->fd); gc_free(gc); /* close on fork ?*/ diff --git a/gui.c b/gui.c index 49f8f46f..8b1b39a8 100644 --- a/gui.c +++ b/gui.c @@ -61,7 +61,7 @@ static pid_t external_cmd_pid; static int command_pipe = -1; static int audiod_pipe = -1; -static struct gengetopt_args_info conf; +static struct gui_args_info conf; enum {GETCH_MODE, COMMAND_MODE, EXTERNAL_MODE}; @@ -1157,8 +1157,8 @@ static void com_reread_conf(void) return; } PARA_INFO_LOG("%s", "rereading command line options and config file"); - cmdline_parser(_argc, _argv, &conf); - cmdline_parser_configfile(cf, &conf, 1, 1, 0); + gui_cmdline_parser(_argc, _argv, &conf); + gui_cmdline_parser_configfile(cf, &conf, 1, 1, 0); PARA_NOTICE_LOG("%s", "configuration read"); if (check_key_map_args() < 0) finish(EXIT_FAILURE); @@ -1315,7 +1315,7 @@ int main(int argc, char *argv[]) _argc = argc; _argv = argv; - if (cmdline_parser(argc, argv, &conf)) { + if (gui_cmdline_parser(argc, argv, &conf)) { fprintf(stderr, "parse error while reading command line\n"); exit(EXIT_FAILURE); } @@ -1332,7 +1332,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } if (cf) - cmdline_parser_configfile(cf, &conf, 0, 0, 0); + gui_cmdline_parser_configfile(cf, &conf, 0, 0, 0); if (check_key_map_args() < 0) { fprintf(stderr, "invalid key map in config file\n"); exit(EXIT_FAILURE); diff --git a/http_recv.c b/http_recv.c index 09654167..6a2f60f1 100644 --- a/http_recv.c +++ b/http_recv.c @@ -121,7 +121,7 @@ static void http_recv_post_select(struct sched *s, struct task *t) if (!FD_ISSET(phd->fd, &s->wfds)) goto out; rq = make_request_msg(); - PARA_NOTICE_LOG("%s", "sending http request\n"); + PARA_INFO_LOG("%s", "sending http request\n"); t->ret = send_va_buffer(phd->fd, "%s", rq); free(rq); if (t->ret > 0) @@ -134,7 +134,7 @@ static void http_recv_post_select(struct sched *s, struct task *t) t->ret = recv_pattern(phd->fd, HTTP_OK_MSG, MAXLINE); if (t->ret < 0) goto out; - PARA_NOTICE_LOG("%s", "received ok msg, streaming\n"); + PARA_INFO_LOG("%s", "received ok msg, streaming\n"); t->ret = 1; phd->status = HTTP_STREAMING; goto out; @@ -184,7 +184,6 @@ static int http_recv_open(struct receiver_node *rn) rn->buf = para_calloc(BUFSIZE); rn->private_data = para_calloc(sizeof(struct private_http_recv_data)); phd = rn->private_data; - PARA_NOTICE_LOG("phd = %p, rn = %p\n", phd, rn); ret = get_host_info(conf->host_arg, &he); if (!ret < 0) goto err_out; diff --git a/http_send.c b/http_send.c index 5eebba56..f0c9851f 100644 --- a/http_send.c +++ b/http_send.c @@ -38,8 +38,6 @@ #define HTTP_ERR_MSG "HTTP/1.0 400 Bad Request\n" /** \endcond */ -extern struct gengetopt_args_info conf; - /** the possible states of a client from the server's POV */ enum http_status { HTTP_CONNECTED, diff --git a/mysql_selector.c b/mysql_selector.c index e2c9562c..054c797e 100644 --- a/mysql_selector.c +++ b/mysql_selector.c @@ -32,7 +32,6 @@ #include "net.h" #include "string.h" -extern struct gengetopt_args_info conf; /** pointer to the shared memory area */ extern struct misc_meta_data *mmd; diff --git a/ortp_send.c b/ortp_send.c index 9d244225..dd4ee884 100644 --- a/ortp_send.c +++ b/ortp_send.c @@ -32,8 +32,6 @@ #define TARGET_ADDR(oc) inet_ntoa((oc)->addr) /** \endcond */ -extern struct gengetopt_args_info conf; - /** describes one entry in the list of targets for the ortp sender */ struct ortp_target { /** address info */ diff --git a/random_selector.c b/random_selector.c index 3bd637d5..123425b0 100644 --- a/random_selector.c +++ b/random_selector.c @@ -27,7 +27,6 @@ #include "string.h" static int com_random_info(int, int, char **); -extern struct gengetopt_args_info conf; extern struct misc_meta_data *mmd; static unsigned int num_audio_files, audio_file_count; diff --git a/recv.c b/recv.c index 555b7c51..bfc7a45d 100644 --- a/recv.c +++ b/recv.c @@ -25,7 +25,7 @@ #include "error.h" #include "stdout.h" -struct gengetopt_args_info conf; +struct recv_args_info conf; INIT_RECV_ERRLISTS; @@ -45,7 +45,7 @@ static void *parse_config(int argc, char *argv[], int *receiver_num) { int i; - if (cmdline_parser(argc, argv, &conf)) + if (recv_cmdline_parser(argc, argv, &conf)) return NULL; if (conf.list_receivers_given) { printf("available receivers: "); diff --git a/sdl_gui.c b/sdl_gui.c index a8c0327a..c30465e5 100644 --- a/sdl_gui.c +++ b/sdl_gui.c @@ -43,7 +43,7 @@ static int width = 0; static int height = 0; extern const char *status_item_list[NUM_STAT_ITEMS]; -struct gengetopt_args_info args_info; +struct sdl_gui_args_info args_info; #define FRAME_WIDTH 10 #define FONT_HEIGHT 36 @@ -742,7 +742,7 @@ int main(int argc, char *argv[]) int i, ret, pipe; SDLKey sym; - cmdline_parser(argc, argv, &args_info); + sdl_gui_cmdline_parser(argc, argv, &args_info); ret = configfile_exists(); // printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg); @@ -752,7 +752,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } if (ret) - cmdline_parser_configfile(args_info.config_file_arg, + sdl_gui_cmdline_parser_configfile(args_info.config_file_arg, &args_info, 0, 0, 0); signal(SIGCHLD, SIG_IGN); width = args_info.width_arg; diff --git a/server.c b/server.c index 2391e07c..ce56494f 100644 --- a/server.c +++ b/server.c @@ -56,7 +56,7 @@ struct misc_meta_data *mmd; * It also contains the options for all audio file selectors and all supported * senders. */ -struct gengetopt_args_info conf; +struct server_args_info conf; char *user_list = NULL; extern void dccp_send_init(struct sender *); extern void http_send_init(struct sender *); @@ -234,7 +234,7 @@ static void parse_config(int override) } if (!ret) { int tmp = conf.daemon_given; - cmdline_parser_configfile(cf, &conf, override, 0, 0); + server_cmdline_parser_configfile(cf, &conf, override, 0, 0); conf.daemon_given = tmp; } /* logfile */ @@ -339,7 +339,7 @@ static unsigned do_inits(int argc, char **argv) init_random_seed(); /* parse command line options */ - cmdline_parser(argc, argv, &conf); + server_cmdline_parser(argc, argv, &conf); para_drop_privileges(conf.user_arg, conf.group_arg); /* parse config file, open log and set defaults */ parse_config(0); diff --git a/server.h b/server.h index 7f10a9fc..9d18561e 100644 --- a/server.h +++ b/server.h @@ -149,6 +149,7 @@ struct misc_meta_data{ struct sender_command_data sender_cmd_data; }; +extern struct server_args_info conf; int handle_connect(int fd, struct sockaddr_in *addr); void mmd_unlock(void); diff --git a/stat.c b/stat.c index 9def5075..39aab43e 100644 --- a/stat.c +++ b/stat.c @@ -129,7 +129,6 @@ int stat_client_add(int fd, long unsigned mask) new_client = para_malloc(sizeof(struct stat_client)); new_client->fd = fd; new_client->item_mask = mask; - add_close_on_fork_list(fd); list_add(&new_client->node, &client_list); dump_stat_client_list(); num_clients++; @@ -171,7 +170,6 @@ void stat_client_write(char *msg, int itemnum) } /* write error or fd not ready for writing */ close(fd); - del_close_on_fork_list(fd); num_clients--; PARA_INFO_LOG("deleting client on fd %d\n", fd); list_del(&sc->node); diff --git a/write.c b/write.c index 66cdd7f0..498dd78d 100644 --- a/write.c +++ b/write.c @@ -43,7 +43,7 @@ struct initial_delay_task { struct task task; }; -static struct gengetopt_args_info conf; +static struct write_args_info conf; struct stdin_task sit; struct check_wav_task cwt; struct initial_delay_task idt; @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) int ret = -E_WRITE_SYNTAX; struct sched s; - cmdline_parser(argc, argv, &conf); + write_cmdline_parser(argc, argv, &conf); init_supported_writers(); wng = check_args(); -- 2.39.5