File tree 3 files changed +58
-52
lines changed
3 files changed +58
-52
lines changed Original file line number Diff line number Diff line change @@ -438,6 +438,7 @@ extern int get_option(char **str, int *pint);
438
438
extern char * get_options (const char * str , int nints , int * ints );
439
439
extern unsigned long long memparse (const char * ptr , char * * retptr );
440
440
extern bool parse_option_str (const char * str , const char * option );
441
+ extern char * next_arg (char * args , char * * param , char * * val );
441
442
442
443
extern int core_kernel_text (unsigned long addr );
443
444
extern int core_kernel_data (unsigned long addr );
Original file line number Diff line number Diff line change @@ -160,58 +160,6 @@ static int parse_one(char *param,
160
160
return - ENOENT ;
161
161
}
162
162
163
- /* You can use " around spaces, but can't escape ". */
164
- /* Hyphens and underscores equivalent in parameter names. */
165
- static char * next_arg (char * args , char * * param , char * * val )
166
- {
167
- unsigned int i , equals = 0 ;
168
- int in_quote = 0 , quoted = 0 ;
169
- char * next ;
170
-
171
- if (* args == '"' ) {
172
- args ++ ;
173
- in_quote = 1 ;
174
- quoted = 1 ;
175
- }
176
-
177
- for (i = 0 ; args [i ]; i ++ ) {
178
- if (isspace (args [i ]) && !in_quote )
179
- break ;
180
- if (equals == 0 ) {
181
- if (args [i ] == '=' )
182
- equals = i ;
183
- }
184
- if (args [i ] == '"' )
185
- in_quote = !in_quote ;
186
- }
187
-
188
- * param = args ;
189
- if (!equals )
190
- * val = NULL ;
191
- else {
192
- args [equals ] = '\0' ;
193
- * val = args + equals + 1 ;
194
-
195
- /* Don't include quotes in value. */
196
- if (* * val == '"' ) {
197
- (* val )++ ;
198
- if (args [i - 1 ] == '"' )
199
- args [i - 1 ] = '\0' ;
200
- }
201
- }
202
- if (quoted && args [i - 1 ] == '"' )
203
- args [i - 1 ] = '\0' ;
204
-
205
- if (args [i ]) {
206
- args [i ] = '\0' ;
207
- next = args + i + 1 ;
208
- } else
209
- next = args + i ;
210
-
211
- /* Chew up trailing spaces. */
212
- return skip_spaces (next );
213
- }
214
-
215
163
/* Args looks like "foo=bar,bar2 baz=fuz wiz". */
216
164
char * parse_args (const char * doing ,
217
165
char * args ,
Original file line number Diff line number Diff line change 15
15
#include <linux/export.h>
16
16
#include <linux/kernel.h>
17
17
#include <linux/string.h>
18
+ #include <linux/ctype.h>
18
19
19
20
/*
20
21
* If a hyphen was found in get_option, this will handle the
@@ -189,3 +190,59 @@ bool parse_option_str(const char *str, const char *option)
189
190
190
191
return false;
191
192
}
193
+
194
+ /*
195
+ * Parse a string to get a param value pair.
196
+ * You can use " around spaces, but can't escape ".
197
+ * Hyphens and underscores equivalent in parameter names.
198
+ */
199
+ char * next_arg (char * args , char * * param , char * * val )
200
+ {
201
+ unsigned int i , equals = 0 ;
202
+ int in_quote = 0 , quoted = 0 ;
203
+ char * next ;
204
+
205
+ if (* args == '"' ) {
206
+ args ++ ;
207
+ in_quote = 1 ;
208
+ quoted = 1 ;
209
+ }
210
+
211
+ for (i = 0 ; args [i ]; i ++ ) {
212
+ if (isspace (args [i ]) && !in_quote )
213
+ break ;
214
+ if (equals == 0 ) {
215
+ if (args [i ] == '=' )
216
+ equals = i ;
217
+ }
218
+ if (args [i ] == '"' )
219
+ in_quote = !in_quote ;
220
+ }
221
+
222
+ * param = args ;
223
+ if (!equals )
224
+ * val = NULL ;
225
+ else {
226
+ args [equals ] = '\0' ;
227
+ * val = args + equals + 1 ;
228
+
229
+ /* Don't include quotes in value. */
230
+ if (* * val == '"' ) {
231
+ (* val )++ ;
232
+ if (args [i - 1 ] == '"' )
233
+ args [i - 1 ] = '\0' ;
234
+ }
235
+ }
236
+ if (quoted && args [i - 1 ] == '"' )
237
+ args [i - 1 ] = '\0' ;
238
+
239
+ if (args [i ]) {
240
+ args [i ] = '\0' ;
241
+ next = args + i + 1 ;
242
+ } else
243
+ next = args + i ;
244
+
245
+ /* Chew up trailing spaces. */
246
+ return skip_spaces (next );
247
+ //return next;
248
+ }
You can’t perform that action at this time.
0 commit comments