Mercurial > mplayer.hg
annotate parser-mecmd.c @ 28522:fee39b6b62ea
Remove local copy of xvmc_render.h, it is now an installed header in FFmpeg.
Also adapt MPlayer to definition name changes in libavcodec/xvmc.h.
author | diego |
---|---|
date | Sat, 14 Feb 2009 17:18:55 +0000 |
parents | 75837c33484b |
children | 0f1b5b68af32 |
rev | line source |
---|---|
18265 | 1 |
2 /// \file | |
3 /// \ingroup ConfigParsers MEntry | |
4 | |
8164 | 5 #include "config.h" |
6 | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <errno.h> | |
11 | |
12 #ifdef MP_DEBUG | |
13 #include <assert.h> | |
14 #endif | |
15 | |
16 #include "mp_msg.h" | |
21312 | 17 #include "help_mp.h" |
8164 | 18 #include "m_option.h" |
19 #include "m_config.h" | |
20 #include "parser-mecmd.h" | |
21 | |
22 void | |
23 m_entry_list_free(m_entry_t* lst) { | |
24 int i,j; | |
25 | |
26 for(i = 0 ; lst[i].name != NULL ; i++){ | |
27 free(lst[i].name); | |
28 for(j = 0 ; lst[i].opts[2*j] != NULL ; j++) { | |
29 free(lst[i].opts[2*j]); | |
30 free(lst[i].opts[2*j+1]); | |
31 } | |
32 free(lst[i].opts); | |
33 } | |
34 free(lst); | |
35 } | |
36 | |
37 int | |
38 m_entry_set_options(m_config_t *config, m_entry_t* entry) { | |
39 int i,r; | |
40 | |
41 for(i = 0 ; entry->opts[2*i] != NULL ; i++){ | |
42 r = m_config_set_option(config,entry->opts[2*i],entry->opts[2*i+1]); | |
43 if(r < 0) | |
44 return 0; | |
45 } | |
46 return 1; | |
47 } | |
48 | |
49 | |
50 | |
51 | |
52 m_entry_t* | |
53 m_config_parse_me_command_line(m_config_t *config, int argc, char **argv) | |
54 { | |
55 int i,nf = 0,no = 0; | |
56 int tmp; | |
57 char *opt; | |
58 int no_more_opts = 0; | |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
59 int opt_exit = 0; |
8164 | 60 m_entry_t *lst = NULL, *entry = NULL; |
61 | |
62 #ifdef MP_DEBUG | |
63 assert(config != NULL); | |
64 assert(argv != NULL); | |
65 assert(argc >= 1); | |
66 #endif | |
67 | |
68 config->mode = M_COMMAND_LINE; | |
69 | |
70 lst = calloc(1,sizeof(m_entry_t)); | |
71 | |
72 for (i = 1; i < argc; i++) { | |
73 //next: | |
74 opt = argv[i]; | |
75 /* check for -- (no more options id.) except --help! */ | |
15245
4fdfe0860cc5
Make "mplayer -- --a" play the file --a instead of bailing out with a useless
reimar
parents:
14541
diff
changeset
|
76 if ((*opt == '-') && (*(opt+1) == '-') && (*(opt+2) == 0)) |
8164 | 77 { |
78 no_more_opts = 1; | |
79 if (i+1 >= argc) | |
80 { | |
21312 | 81 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGivenOnCommandLine); |
8164 | 82 goto err_out; |
83 } | |
84 continue; | |
85 } | |
86 | |
87 if ((no_more_opts == 0) && (*opt == '-') && (*(opt+1) != 0)) /* option */ | |
88 { | |
25227 | 89 const m_option_t* mp_opt = NULL; |
8164 | 90 /* remove trailing '-' */ |
91 opt++; | |
92 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt); | |
93 mp_opt = m_config_get_option(config,opt); | |
94 if(!mp_opt) { | |
10595
522afd56703c
100l to albeu for his english grammar, and 10l to me becouse I noticed that lately (my backward compatibilty macro uses M_OPT_UNKNOWN)
alex
parents:
10594
diff
changeset
|
95 tmp = M_OPT_UNKNOWN; |
21312 | 96 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NotAnMEncoderOption, opt); |
8164 | 97 goto err_out; |
98 } | |
8893 | 99 if(!entry || (mp_opt->flags & M_OPT_GLOBAL)){ |
8164 | 100 tmp = m_config_set_option(config, opt, argv[i + 1]); |
17467
d631b3c09c53
Fix multiple help clauses on the command line with mencoder.
albeu
parents:
16345
diff
changeset
|
101 if (tmp <= M_OPT_EXIT) { |
d631b3c09c53
Fix multiple help clauses on the command line with mencoder.
albeu
parents:
16345
diff
changeset
|
102 opt_exit = 1; |
d631b3c09c53
Fix multiple help clauses on the command line with mencoder.
albeu
parents:
16345
diff
changeset
|
103 tmp = M_OPT_EXIT - tmp; |
d631b3c09c53
Fix multiple help clauses on the command line with mencoder.
albeu
parents:
16345
diff
changeset
|
104 } |
18148
280f93388ac3
also print an error when parsing fails with M_OPT_INVALID or M_OPT_PARSER_ERR.
reimar
parents:
17467
diff
changeset
|
105 else |
8893 | 106 if(tmp < 0){ |
107 // mp_msg(MSGT_CFGPARSER, MSGL_ERR, "m_config_set_option() failed (%d)\n",tmp); | |
21312 | 108 mp_msg(MSGT_CFGPARSER, MSGL_FATAL, MSGTR_ErrorParsingOptionOnCommandLine, opt); |
8893 | 109 goto err_out; |
110 } | |
111 } else { | |
8164 | 112 tmp = m_config_check_option(config, opt, argv[i + 1]); |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
113 if (tmp <= M_OPT_EXIT) { |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
114 opt_exit = 1; |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
115 tmp = M_OPT_EXIT - tmp; |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
116 } |
8164 | 117 if(tmp >= 0) { |
118 entry->opts = realloc(entry->opts,(no+2)*2*sizeof(char*)); | |
119 entry->opts[2*no] = strdup(opt); | |
120 entry->opts[2*no+1] = argv[i + 1] ? strdup(argv[i + 1]) : NULL; | |
121 entry->opts[2*no+2] = entry->opts[2*no+3] = NULL; | |
122 no++; | |
8893 | 123 } else { |
124 // mp_msg(MSGT_CFGPARSER, MSGL_ERR, "m_config_set_option() failed (%d)\n",tmp); | |
125 goto err_out; | |
8164 | 126 } |
127 } | |
128 i += tmp; | |
9747
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
129 } else {/* filename */ |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
130 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Adding file %s\n",argv[i]); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
131 lst = realloc(lst,(nf+2)*sizeof(m_entry_t)); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
132 lst[nf].name = strdup(argv[i]); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
133 lst[nf].opts = calloc(2,sizeof(char*)); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
134 entry = &lst[nf]; |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
135 no = 0; |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
136 memset(&lst[nf+1],0,sizeof(m_entry_t)); |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
137 nf++; |
264cb5f03131
Remove the hack used to pass -dvd, etc into the playlist
albeu
parents:
9096
diff
changeset
|
138 } |
8164 | 139 } |
140 | |
16345
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
141 if (opt_exit) |
feb16d0117c8
allow multiple help clauses on the command line, Patch by kiriuja " mplayer-patches AH en-directo POUM net "
gpoirier
parents:
15742
diff
changeset
|
142 exit(0); |
8164 | 143 if(nf == 0) { |
144 m_entry_list_free(lst); | |
21312 | 145 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGiven); |
8164 | 146 return NULL; |
147 } | |
148 return lst; | |
149 | |
150 err_out: | |
151 m_entry_list_free(lst); | |
152 return NULL; | |
153 } |