annotate parser-mpcmd.c @ 35948:ab41adf81569

configure: cosmetics: Group some libdvdcss-related config.h entries together.
author diego
date Fri, 22 Mar 2013 19:59:37 +0000
parents 389d43c448b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30429
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
1 /*
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
2 * This file is part of MPlayer.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
3 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
5 * it under the terms of the GNU General Public License as published by
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
7 * (at your option) any later version.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
8 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
12 * GNU General Public License for more details.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
13 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
14 * You should have received a copy of the GNU General Public License along
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29850
diff changeset
17 */
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
18
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
19 /// \file
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
20 /// \ingroup ConfigParsers Playtree
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
21
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
22 #include "config.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
23
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
24 #include <stdio.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
25 #include <stdlib.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
26 #include <string.h>
35903
389d43c448b3 Add missing strings.h #includes for strcasecmp().
diego
parents: 34167
diff changeset
27 #include <strings.h>
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
28 #include <errno.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
29
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
30 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
31 #include <assert.h>
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
32 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
33
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
34 #include "mp_msg.h"
21312
d78e7d5bc6d5 localization of parser-m*cmd.c messages
ptt
parents: 18265
diff changeset
35 #include "help_mp.h"
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
36 #include "m_option.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
37 #include "m_config.h"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
38 #include "playtree.h"
26263
65d1238b3631 Include some .h files in corresponding .c files
uau
parents: 25227
diff changeset
39 #include "parser-mpcmd.h"
30675
059153d06619 Add header for macosx_finder_args() instead of forward declaring it.
diego
parents: 30429
diff changeset
40 #include "osdep/macosx_finder_args.h"
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
41
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
42 static int mode = 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
43
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
44 #define GLOBAL 0
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
45 #define LOCAL 1
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
46 #define DROP_LOCAL 2
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
47
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
48 #define dvd_range(a) (a>0 && a<256)
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
49 #define UNSET_GLOBAL (mode = LOCAL)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
50 // Use this 1 if you want to have only global option (no per file option)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
51 // #define UNSET_GLOBAL (mode = GLOBAL)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
52
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
53
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
54 static int is_entry_option(char *opt, char *param, play_tree_t** ret) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
55 play_tree_t* entry = NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
56
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
57 *ret = NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
58
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
59 if(strcasecmp(opt,"playlist") == 0) { // We handle playlist here
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
60 if(!param)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
61 return M_OPT_MISSING_PARAM;
12267
14bdbd687113 Fail if empty or nonexitant playlist
rtognimp
parents: 10595
diff changeset
62
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
63 entry = parse_playlist_file(param);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
64 if(!entry)
12267
14bdbd687113 Fail if empty or nonexitant playlist
rtognimp
parents: 10595
diff changeset
65 return -1;
14bdbd687113 Fail if empty or nonexitant playlist
rtognimp
parents: 10595
diff changeset
66 else {
14bdbd687113 Fail if empty or nonexitant playlist
rtognimp
parents: 10595
diff changeset
67 *ret=entry;
14bdbd687113 Fail if empty or nonexitant playlist
rtognimp
parents: 10595
diff changeset
68 return 1;
14bdbd687113 Fail if empty or nonexitant playlist
rtognimp
parents: 10595
diff changeset
69 }
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
70 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
71 return 0;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
72 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
73
10542
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
74 static inline void add_entry(play_tree_t **last_parentp,
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
75 play_tree_t **last_entryp, play_tree_t *entry) {
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
76 if(*last_entryp == NULL)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
77 play_tree_set_child(*last_parentp,entry);
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
78 else
10542
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
79 play_tree_append_entry(*last_entryp,entry);
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
80 *last_entryp = entry;
10513
b3f144efb724 c vs c++ syntax
alex
parents: 10397
diff changeset
81 }
b3f144efb724 c vs c++ syntax
alex
parents: 10397
diff changeset
82
18265
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
83 /// Setup the \ref Config from command line arguments and build a playtree.
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
84 /** \ingroup ConfigParsers
1a14fde7680d Doxygen Attack! - Chapter 3
albeu
parents: 18209
diff changeset
85 */
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
86 play_tree_t*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
87 m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
88 {
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
89 int i,j,start_title=-1,end_title=-1;
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
90 char *opt,*splitpos=NULL;
29850
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
91 char entbuf[15];
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
92 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
93 int opt_exit = 0; // flag indicating whether mplayer should exit without playing anything
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
94 play_tree_t *last_parent, *last_entry = NULL, *root;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
95
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
96 #ifdef MP_DEBUG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
97 assert(config != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
98 assert(argv != NULL);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
99 assert(argc >= 1);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
100 #endif
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
101
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
102 config->mode = M_COMMAND_LINE;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
103 mode = GLOBAL;
27397
d47744b95b78 Give a CONFIG_ prefix to preprocessor directives that lacked one and
diego
parents: 27394
diff changeset
104 #ifdef CONFIG_MACOSX_FINDER
13909
07dadc3066f3 add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
nplourde
parents: 12816
diff changeset
105 root=macosx_finder_args(config, argc, argv);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
106 if(root)
13909
07dadc3066f3 add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
nplourde
parents: 12816
diff changeset
107 return root;
07dadc3066f3 add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
nplourde
parents: 12816
diff changeset
108 #endif
07dadc3066f3 add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
nplourde
parents: 12816
diff changeset
109
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
110 last_parent = root = play_tree_new();
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
111
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
112 for (i = 1; i < argc; i++) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
113 //next:
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
114 opt = argv[i];
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
115 /* 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
116 if ((*opt == '-') && (*(opt+1) == '-') && (*(opt+2) == 0))
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
117 {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
118 no_more_opts = 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
119 if (i+1 >= argc)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
120 {
21312
d78e7d5bc6d5 localization of parser-m*cmd.c messages
ptt
parents: 18265
diff changeset
121 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_NoFileGivenOnCommandLine);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
122 goto err_out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
123 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
124 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
125 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
126 if((opt[0] == '{') && (opt[1] == '\0'))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
127 {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
128 play_tree_t* entry = play_tree_new();
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
129 UNSET_GLOBAL;
8175
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
130 if(last_parent->flags & PLAY_TREE_RND)
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
131 entry->flags |= PLAY_TREE_RND;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
132 if(last_entry == NULL) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
133 play_tree_set_child(last_parent,entry);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
134 } else {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
135 play_tree_append_entry(last_entry,entry);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
136 last_entry = NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
137 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
138 last_parent = entry;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
139 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
140 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
141
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
142 if((opt[0] == '}') && (opt[1] == '\0'))
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
143 {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
144 if( ! last_parent || ! last_parent->parent) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
145 mp_msg(MSGT_CFGPARSER, MSGL_ERR, "too much }-\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
146 goto err_out;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
147 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
148 last_entry = last_parent;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
149 last_parent = last_entry->parent;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
150 continue;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
151 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
152
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
153 if ((no_more_opts == 0) && (*opt == '-') && (*(opt+1) != 0)) /* option */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
154 {
13932
f845791e2823 fix: when doing -loop 0 -shuffle, the arg after shuffle was skipped
reimar
parents: 13909
diff changeset
155 int tmp = 0;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
156 /* remove trailing '-' */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
157 opt++;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
158
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
159 mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
160 // We handle here some specific option
17472
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 16345
diff changeset
161 // Loop option when it apply to a group
526abfe30498 Make -list-options work in both MPlayer and MEncoder.
albeu
parents: 16345
diff changeset
162 if(strcasecmp(opt,"loop") == 0 &&
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
163 (! last_entry || last_entry->child) ) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
164 int l;
18097
df9633d451dc avoid crash when running "mplayer -loop" (dereferencing uninitialize pointer).
reimar
parents: 17472
diff changeset
165 char* end = NULL;
8400
587b62cd4119 10l noticed by "Puk Madick" <pingy@swirvemail.com>
arpi
parents: 8175
diff changeset
166 l = (i+1<argc) ? strtol(argv[i+1],&end,0) : 0;
18097
df9633d451dc avoid crash when running "mplayer -loop" (dereferencing uninitialize pointer).
reimar
parents: 17472
diff changeset
167 if(!end || *end != '\0') {
21312
d78e7d5bc6d5 localization of parser-m*cmd.c messages
ptt
parents: 18265
diff changeset
168 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_TheLoopOptionMustBeAnInteger, argv[i+1]);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
169 tmp = ERR_OUT_OF_RANGE;
9106
2c1aee5bb754 Ok, firstly fixed the bug in parser-mpcmd.c where it
arpi
parents: 8458
diff changeset
170 } else {
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
171 play_tree_t* pt = last_entry ? last_entry : last_parent;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
172 l = l <= 0 ? -1 : l;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
173 pt->loop = l;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
174 tmp = 1;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
175 }
8452
418b0017a8d2 -rnd --> -shuffle
diego
parents: 8426
diff changeset
176 } else if(strcasecmp(opt,"shuffle") == 0) {
8175
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
177 if(last_entry && last_entry->child)
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
178 last_entry->flags |= PLAY_TREE_RND;
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
179 else
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
180 last_parent->flags |= PLAY_TREE_RND;
8452
418b0017a8d2 -rnd --> -shuffle
diego
parents: 8426
diff changeset
181 } else if(strcasecmp(opt,"noshuffle") == 0) {
8175
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
182 if(last_entry && last_entry->child)
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
183 last_entry->flags &= ~PLAY_TREE_RND;
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
184 else
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
185 last_parent->flags &= ~PLAY_TREE_RND;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
186 } else {
25227
75837c33484b Mark more m_option_t uses as const
reimar
parents: 21312
diff changeset
187 const m_option_t* mp_opt = NULL;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
188 play_tree_t* entry = NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
189
8458
92a7bf835d98 2*10l=20l
arpi
parents: 8452
diff changeset
190 tmp = is_entry_option(opt,(i+1<argc) ? argv[i + 1] : NULL,&entry);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
191 if(tmp > 0) { // It's an entry
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
192 if(entry) {
10542
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
193 add_entry(&last_parent,&last_entry,entry);
8175
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
194 if((last_parent->flags & PLAY_TREE_RND) && entry->child)
bf5d1da56ecd Basic support for random playing (-rnd and -nornd)
albeu
parents: 8164
diff changeset
195 entry->flags |= PLAY_TREE_RND;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
196 UNSET_GLOBAL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
197 } else if(mode == LOCAL) // Entry is empty we have to drop his params
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
198 mode = DROP_LOCAL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
199 } else if(tmp == 0) { // 'normal' options
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
200 mp_opt = m_config_get_option(config,opt);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
201 if (mp_opt != NULL) { // Option exist
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
202 if(mode == GLOBAL || (mp_opt->flags & M_OPT_GLOBAL))
8426
ca2813aafb35 more i+1<argc checks
arpi
parents: 8400
diff changeset
203 tmp = (i+1<argc) ? m_config_set_option(config, opt, argv[i + 1])
ca2813aafb35 more i+1<argc checks
arpi
parents: 8400
diff changeset
204 : m_config_set_option(config, opt, NULL);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
205 else {
8458
92a7bf835d98 2*10l=20l
arpi
parents: 8452
diff changeset
206 tmp = m_config_check_option(config, opt, (i+1<argc) ? argv[i + 1] : NULL);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
207 if(tmp >= 0 && mode != DROP_LOCAL) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
208 play_tree_t* pt = last_entry ? last_entry : last_parent;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
209 play_tree_set_param(pt,opt, argv[i + 1]);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
210 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
211 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
212 } else {
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
213 tmp = M_OPT_UNKNOWN;
21312
d78e7d5bc6d5 localization of parser-m*cmd.c messages
ptt
parents: 18265
diff changeset
214 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_UnknownOptionOnCommandLine, opt);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
215 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
216 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
217 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
218
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
219 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
220 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
221 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
222 } else
9792
4c34dc17e43d Exit when the option parser return M_OPT_EXIT
albeu
parents: 9747
diff changeset
223 if (tmp < 0) {
21312
d78e7d5bc6d5 localization of parser-m*cmd.c messages
ptt
parents: 18265
diff changeset
224 mp_msg(MSGT_CFGPARSER, MSGL_FATAL, MSGTR_ErrorParsingOptionOnCommandLine, opt);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
225 goto err_out;
9792
4c34dc17e43d Exit when the option parser return M_OPT_EXIT
albeu
parents: 9747
diff changeset
226 }
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
227 i += tmp;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
228 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
229 else /* filename */
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
230 {
29850
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
231 int is_dvdnav = strstr(argv[i],"dvdnav://") != NULL;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
232 play_tree_t* entry = play_tree_new();
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
233 mp_msg(MSGT_CFGPARSER, MSGL_DBG2,"Adding file %s\n",argv[i]);
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
234 // if required expand DVD filename entries like dvd://1-3 into component titles
29850
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
235 if ( strstr(argv[i],"dvd://") != NULL || is_dvdnav)
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
236 {
29850
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
237 int offset = is_dvdnav ? 9 : 6;
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
238 splitpos=strstr(argv[i]+offset,"-");
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
239 if(splitpos != NULL)
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
240 {
29850
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
241 start_title=strtol(argv[i]+offset,NULL,10);
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
242 if (start_title<0) { //entries like dvd://-2 start title implied 1
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
243 end_title=abs(start_title);
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
244 start_title=1;
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
245 } else {
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
246 end_title=strtol(splitpos+1,NULL,10);
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
247 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
248
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
249 if (dvd_range(start_title) && dvd_range(end_title) && (start_title<end_title))
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
250 {
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
251 for (j=start_title;j<=end_title;j++)
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
252 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
253 if (j!=start_title)
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
254 entry=play_tree_new();
29850
93947ce0e2cb Support the range syntax (like dvd://2-5) also for dvdnav.
reimar
parents: 29263
diff changeset
255 snprintf(entbuf,sizeof(entbuf),is_dvdnav ? "dvdnav://%d" : "dvd://%d",j);
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
256 play_tree_add_file(entry,entbuf);
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
257 add_entry(&last_parent,&last_entry,entry);
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
258 last_entry = entry;
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
259 }
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
260 } else {
21312
d78e7d5bc6d5 localization of parser-m*cmd.c messages
ptt
parents: 18265
diff changeset
261 mp_msg(MSGT_CFGPARSER, MSGL_ERR, MSGTR_InvalidPlayEntry, argv[i]);
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
262 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
263
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
264 } else { // dvd:// or dvd://x entry
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
265 play_tree_add_file(entry,argv[i]);
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
266 }
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
267 } else {
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
268 play_tree_add_file(entry,argv[i]);
12543
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
269 }
2cbc9f1f728f Support dvd://start_title-end_title as requested on wishlist
rtognimp
parents: 12267
diff changeset
270
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
271 // Lock stdin if it will be used as input
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
272 if(strcasecmp(argv[i],"-") == 0)
12816
fba780800efe -use-stdin renamed to -noconsolecontrols.
diego
parents: 12543
diff changeset
273 m_config_set_option(config,"noconsolecontrols",NULL);
10542
928c02fa9949 fix the bug where only the last file of the command line is found
pl
parents: 10513
diff changeset
274 add_entry(&last_parent,&last_entry,entry);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
275 UNSET_GLOBAL; // We start entry specific options
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
276
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
277 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
278 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
279
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
280 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
281 goto err_out;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
282 if(last_parent != root)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
283 mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Missing }- ?\n");
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
284 return root;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
285
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
286 err_out:
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
287 play_tree_free(root,1);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
288 return NULL;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
289 }