[Toxine-cvs] CVS: toxine/src main.c,1.41,1.42 xine_commands.c,1.52,1.53
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2004-07-19 09:00:57
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22218 Modified Files: main.c xine_commands.c Log Message: fix forgotten configfile hack (new -C). Ignore many signals in parent. Index: main.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/main.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- main.c 18 Jul 2004 22:27:02 -0000 1.41 +++ main.c 19 Jul 2004 09:00:47 -0000 1.42 @@ -61,9 +61,10 @@ #define ERROR_CODES 1000 /* options args */ -static const char *short_options = "?hs:e:o::vV:A:iIS"; +static const char *short_options = "?hs:e:o::vV:A:iISC:"; static struct option long_options[] = { { "help" , no_argument , 0, 'h' }, + { "config-file" , required_argument, 0, 'C' }, { "script" , required_argument, 0, 's' }, { "execute" , required_argument, 0, 'e' }, { "output" , optional_argument, 0, 'o' }, @@ -115,6 +116,11 @@ /* Kill the line on C-c */ case SIGINT: + if(tox->interactive != 1) { + tox->video.running = tox->running = 0; + exit(TOX_ERR_SIGINT); + return; + } case SIGTERM: case SIGQUIT: if(rl_prompt) { /* readline is running, otherwise we are in script mode */ @@ -131,7 +137,6 @@ exit(TOX_ERR_SIGQUIT); } break; - } } } @@ -209,6 +214,7 @@ static void toxine_print_usage(void) { printf("Usage: toxine [options]\n"); + printf(" -C, --config-file <filename> Use <filename> as toxine configuration file.\n"); printf(" -s, --script <filename> Use <filename> as toxine script file.\n"); printf(" -S, --stdin Send command lines using stdin.\n"); printf(" -e, --execute <commands> Execute specified commands (like in prompt mode).\n"); @@ -306,6 +312,7 @@ tox->pid = getppid(); pthread_mutex_init(&tox->watchdog.mutex, NULL); + tox->configfile = NULL; tox->watchdog.enabled = 0; tox->watchdog.running = 0; tox->watchdog.timeout = 15; /* 15 secs timeout */ @@ -325,6 +332,13 @@ while((c = getopt_long(argc, argv, short_options, long_options, &option_index)) != EOF) { switch(c) { + case 'C': + { + char *_optarg = toxine_atoa(optarg); + tox->configfile = strdup(_optarg); + } + break; + case 's': /* use a script file */ if(optarg != NULL) { @@ -442,12 +456,12 @@ /* * generate and init a config "object" */ - { + if(!tox->configfile) { char *cfgfile = ".xine/toxine_config"; if (!(tox->configfile = getenv ("XINERC"))) { const char *homedir; - + start_watchdog(tox, "xine_get_homedir"); homedir = xine_get_homedir(); stop_watchdog(tox); @@ -455,7 +469,6 @@ tox->configfile = (char *) xine_xmalloc((strlen(homedir) + strlen(cfgfile))+2); sprintf(tox->configfile, "%s/%s", homedir, cfgfile); } - } tox->playlist.mmk = NULL; @@ -467,9 +480,7 @@ toxine_run(tox, argc - optind, &argv[optind]); - __end: - last_error = tox->last_error; toxine_release(tox); @@ -480,13 +491,21 @@ * ... */ int main(int argc, char **argv) { - int pid, status, ret; + int pid, status, ret; if(getuid() == 0) { fprintf(stderr, "You cannot run this program as root.\n"); exit(TOX_ERR_INTERNAL); } + signal(SIGHUP, SIG_IGN); + signal(SIGUSR1, SIG_IGN); + signal(SIGUSR2, SIG_IGN); + signal(SIGINT, SIG_IGN); + signal(SIGTERM, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + signal(SIGALRM, SIG_IGN); + pid = fork(); switch(pid) { case -1: Index: xine_commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/xine_commands.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- xine_commands.c 12 Jun 2004 11:44:56 -0000 1.52 +++ xine_commands.c 19 Jul 2004 09:00:47 -0000 1.53 @@ -509,7 +509,7 @@ if(!(tox->xine_state & XINE_NEW)) _xine_new(NULL, tox, NULL); - + pinfo("xine_init():\n"); start_watchdog(tox, "xine_init"); xine_init(tox->xine); @@ -2268,18 +2268,9 @@ } void _xine_config_load(commands_t *command, toxine_t *tox, void *data) { - const char *filename = NULL; - return_if_no_new(tox); error_code_clear(tox); - if(toxine_is_args(tox)) { - filename = toxine_get_arg(tox, 1); - if(tox->configfile) - free((char *)tox->configfile); - tox->configfile = strdup(filename); - } - pinfo("xine_config_load(%s):\n", tox->configfile); start_watchdog(tox, "xine_config_load"); xine_config_load(tox->xine, tox->configfile); @@ -2288,18 +2279,14 @@ } void _xine_config_save(commands_t *command, toxine_t *tox, void *data) { - const char *filename = NULL; toxine_unset_last_result(tox); return_if_no_init(tox); error_code_clear(tox); - if(toxine_is_args(tox)) - filename = toxine_get_arg(tox, 1); - - pinfo("xine_config_save(%s):\n", (filename) ? filename : tox->configfile); + pinfo("xine_config_save(%s):\n", tox->configfile); start_watchdog(tox, "xine_config_save"); - xine_config_save(tox->xine, ((filename) ? filename : tox->configfile)); + xine_config_save(tox->xine, tox->configfile); stop_watchdog(tox); pinfo(".\n"); |