Enabled use of Xorriso_parse_line() with xorriso==NULL

master
Thomas Schmitt 10 years ago
parent fa9ed1d2c3
commit 7e7b575153
  1. 32
      xorriso/parse_exec.c
  2. 17
      xorriso/xorriso.h
  3. 2
      xorriso/xorriso_timestamp.h

@ -1778,7 +1778,7 @@ next_command:;
ret= Xorriso_stop_msg_watcher(xorriso, 0);
fprintf(stderr, "xorriso -test: Xorriso_stop_msg_watcher() = %d\n", ret);
} else if(strcmp(arg1, "parse") == 0) {
} else if(strcmp(arg1, "parse") == 0 || strcmp(arg1, "nullparse") == 0) {
(*idx)+= 5;
pline= "";
if(*idx - 5 < argc)
@ -1795,7 +1795,8 @@ next_command:;
pflag= 0;
if(*idx - 1 < argc)
sscanf(argv[*idx - 1], "%d", &pflag);
ret= Xorriso_parse_line(xorriso, pline, prefix, separators, max_words,
ret= Xorriso_parse_line(strcmp(arg1, "nullparse") == 0 ? NULL : xorriso,
pline, prefix, separators, max_words,
&pargc, &pargv, pflag);
fprintf(stderr,
"xorriso_test: Xorriso_parse_line: ret= %d , argc= %d , argv= 0x%lX\n",
@ -1909,13 +1910,17 @@ int Xorriso_parse_line(struct XorrisO *xorriso, char *line,
int *argc, char ***argv, int flag)
{
int ret, bsl_mode;
char *to_parse;
char *to_parse, *progname= "";
if(xorriso == NULL && (flag & (32 | 64))) {
ret= -2; goto ex;
}
*argc= 0;
*argv= NULL;
to_parse= line;
if(flag & 1)
if((flag & 1) || xorriso == NULL)
bsl_mode= (flag >> 1) & 3;
else
bsl_mode= xorriso->bsl_interpretation & 3;
@ -1927,18 +1932,23 @@ int Xorriso_parse_line(struct XorrisO *xorriso, char *line,
}
}
ret= Sfile_sep_make_argv(xorriso->progname, to_parse, separators,
if(xorriso != NULL)
progname= xorriso->progname;
ret= Sfile_sep_make_argv(progname, to_parse, separators,
max_words, argc, argv,
(!(flag & 32)) | 4 | (bsl_mode << 5));
if(ret < 0) {
Xorriso_msgs_submit(xorriso, 0,
"Severe lack of resources during command line parsing", 0, "FATAL", 0);
goto ex;
if(xorriso != NULL)
Xorriso_msgs_submit(xorriso, 0,
"Severe lack of resources during command line parsing", 0, "FATAL", 0);
ret= -1; goto ex;
}
if(ret == 0) {
sprintf(xorriso->info_text, "Incomplete quotation in %s line: %s",
(flag & 32) ? "command" : "parsed", to_parse);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
if((flag & 64) && xorriso != NULL) {
sprintf(xorriso->info_text, "Incomplete quotation in %s line: %s",
(flag & 32) ? "command" : "parsed", to_parse);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
}
goto ex;
}
ret= 1;

@ -364,8 +364,18 @@ int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag);
/* Parse a text line into words. This parsing obeys the same rules as
command line parsing but allows to skip a prefix, to use a user provided
set of separator characters, and to restrict the number of parsed words.
If parameter xorriso is NULL, then this call is safe for usage by
a concurrent thread while a xorriso API call is being executed.
@since 1.2.6
@param xorriso The context object which provides settings for parsing
and output channels for error messages.
May be NULL in order to allow concurrent execution e.g.
by a callback function of Xorriso_start_msg_watcher().
If xorriso is NULL then:
flag bit1-bit4 are in effect even if bit0 is not set.
flag bit5 and bit6 may not be set.
@param line A text of one or more words according to man xorriso
paragraph "Command processing" up to and including
"Backslash Interpretation".
@ -391,8 +401,8 @@ int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag);
Do not forget to dispose the allocated memory by a
call to Xorriso__dispose_words().
@param flag Bitfield for control purposes
bit0= Override setting of -backslash_codes
bit1-4= With bit1: backslash behavior
bit0= Override setting of -backslash_codes.
bit1-4= With bit0: backslash behavior
0= off
1= in_double_quotes
2= in_quotes
@ -400,10 +410,13 @@ int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag);
bit5= Prepend the program name as (*argv)[0], so that
*argv is suitable for Xorriso_interpreter()
and other calls which expect this.
Not allowed if xorriso is NULL.
bit6= Issue failure message in case of return 0
Not allowed if xorriso is NULL.
@return <=0 means error and invalidity of *argv:
0 = Input format error. E.g. bad quotation mark.
-1 = Lack of resources. E.g. memory.
-2 = Improper combination of call parameters.
>0 means success but not necessarily a valid result:
1 = Result in argc and argv is valid (but may
be empty by argc == 0, argv == NULL).

@ -1 +1 @@
#define Xorriso_timestamP "2012.10.02.134601"
#define Xorriso_timestamP "2012.10.03.124152"

Loading…
Cancel
Save