From: Daniel Caujolle-B. <f1...@us...> - 2002-02-19 15:53:25
|
Update of /cvsroot/xine/toxine/src In directory usw-pr-cvs1:/tmp/cvs-serv10317 Modified Files: commands.c common.h loader.c main.c Log Message: Remove forgotten global. Add -o to save messages to file. Index: commands.c =================================================================== RCS file: /cvsroot/xine/toxine/src/commands.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- commands.c 18 Feb 2002 20:46:33 -0000 1.8 +++ commands.c 19 Feb 2002 15:53:22 -0000 1.9 @@ -44,8 +44,6 @@ extern int errno; -static int cur_vo = 1; - static struct event_struct_s { char *name; uint32_t event; @@ -364,7 +362,7 @@ return 0; } - tox->video.cur_plugin->video_out_init(tox, tox->video.plugins[cur_vo]); + tox->video.cur_plugin->video_out_init(tox, tox->video.cur_plugin); pthread_attr_init(&pth_attrs); pthread_attr_getschedparam(&pth_attrs, &pth_params); Index: common.h =================================================================== RCS file: /cvsroot/xine/toxine/src/common.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- common.h 16 Feb 2002 21:48:13 -0000 1.4 +++ common.h 19 Feb 2002 15:53:22 -0000 1.5 @@ -94,6 +94,8 @@ char *configfile; config_values_t *config; xine_t *xine; + + int msg_fd; struct { vo_driver_t *driver; Index: loader.c =================================================================== RCS file: /cvsroot/xine/toxine/src/loader.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- loader.c 18 Feb 2002 20:46:34 -0000 1.3 +++ loader.c 19 Feb 2002 15:53:22 -0000 1.4 @@ -80,12 +80,27 @@ vop = (toxine_vo_plugin_t *) initplug(tox); if (vop) { + char buffer[2048]; + int j; + tox->video.plugins[tox->video.plugins_num] = vop; - fprintf(stderr, "%s(%s@%d): video out plugin '%s' found.\n", - __FILE__, __FUNCTION__, __LINE__, + memset(&buffer, 0, sizeof(buffer)); + sprintf(buffer, "%s", "+ supporting:"); + + sprintf(buffer, "video out plugin '%s' found ( ", tox->video.plugins[tox->video.plugins_num]->get_identifier()); - + + { + char **vonames = tox->video.plugins[tox->video.plugins_num]->get_names(); + + for(j = 0; vonames[j] != NULL; j++) { + sprintf(buffer, "%s%s ", buffer, vonames[j]); + } + } + sprintf(buffer, "%s).\n", buffer); + pinfo(buffer); + tox->video.plugins_num++; } } Index: main.c =================================================================== RCS file: /cvsroot/xine/toxine/src/main.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- main.c 18 Feb 2002 20:46:34 -0000 1.6 +++ main.c 19 Feb 2002 15:53:22 -0000 1.7 @@ -31,9 +31,9 @@ #include <stdlib.h> #include <errno.h> #include <unistd.h> -#include <pwd.h> #include <sys/types.h> #include <string.h> +#include <fcntl.h> #ifdef HAVE_GETOPT_LONG # include <getopt.h> @@ -53,11 +53,12 @@ static toxine_t *tox; /* options args */ -static const char *short_options = "?hs:e:vV:A:iI"; +static const char *short_options = "?hs:e:o::vV:A:iI"; static struct option long_options[] = { { "help" , no_argument , 0, 'h' }, { "script" , required_argument, 0, 's' }, { "execute" , required_argument, 0, 'e' }, + { "output" , optional_argument, 0, 'o' }, { "video" , required_argument, 0, 'V' }, { "audio" , required_argument, 0, 'A' }, { "interactive" , required_argument, 0, 'i' }, @@ -82,6 +83,7 @@ printf("usage: toxine [options]\n"); printf(" -s, --script <filename> Use <filename> as toxine script file.\n"); printf(" -e, --execute <commands> Execute commands specified (like in prompt mode).\n"); + printf(" -o, --output [filename] Save all messages in a file (toxine.out if no filename\n"); printf(" -V, --video <name> Use video driver <name>.\n"); printf(" -A, --audio <name> Use audio driver <name>.\n"); printf(" -i, --interactive Disable interactive more (no confirm).\n"); @@ -100,6 +102,9 @@ if(tox) { + if(tox->msg_fd >= 0) + close(tox->msg_fd); + _FREE(tox->configfile); _FREE(tox->video.name); _FREE(tox->audio.name); @@ -135,10 +140,11 @@ tox = (toxine_t *) xine_xmalloc(sizeof(toxine_t)); - tox->command.remain = NULL; - tox->command.line = NULL; + tox->command.remain = NULL; + tox->command.line = NULL; tox->command.command = NULL; tox->command.execute = 0; + tox->msg_fd = -1; /* * parse command line @@ -169,6 +175,16 @@ } break; + case 'o': + { + char *ofile = (optarg) ? optarg : "toxine.out"; + + if((tox->msg_fd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, 0644)) < 0) { + fprintf(stderr, "Cannot open %s: %s\n", ofile, strerror(errno)); + } + } + break; + case 'V': /* video driver name */ if(optarg != NULL) tox->video.name = strdup(optarg); @@ -205,6 +221,19 @@ } } + if(tox->msg_fd >= 0) { + if((!tox->script.use) && (!tox->command.execute)) { + fprintf(stderr, "You can't use message redirection in prompt mode.\n"); + toxine_free(tox); + exit(1); + } + + if(dup2(tox->msg_fd, STDOUT_FILENO) < 0) + fprintf(stderr, "Cannot dup2 stdout: %s\n", strerror(errno)); + if(dup2(tox->msg_fd, STDERR_FILENO) < 0) + fprintf(stderr, "Cannot dup2 stderr: %s\n", strerror(errno)); + } + toxine_show_version(); /* @@ -237,4 +266,3 @@ return 1; } - |