New options -quoted_path_list, -quoted_not_list. Multiline for -options_from_file

This commit is contained in:
Thomas Schmitt 2008-10-15 18:26:48 +00:00
parent 97d81a1a4c
commit d0b53ac018
5 changed files with 212 additions and 87 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Oct 10, 2008"
.TH XORRISO 1 "Oct 15, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -665,6 +665,13 @@ Like -add but read the parameter words from file disk_path
or standard input if disk_path is "-".
The list must contain exactly one pathspec resp. disk_path pattern per line.
.TP
\fB\-quoted_path_list\fR disk_path
Like -path_list but with line reading rules of -dialog mode "on".
I.e. newline characters within quotes and trailing backslashes outside quotes
cause the next line to be appended to the pathspec resp. disk_pattern.
Eventual newline characters get part of the line, trailing backslashes get
discarded. Lines get split into words. Whitespace outside quotes is discarded.
.TP
\fB\-map\fR disk_path iso_rr_path
Insert file object disk_path into the ISO image as iso_rr_path. If disk_path
is a directory then its whole sub tree is inserted into the ISO image.
@ -1190,6 +1197,14 @@ Add a single shell parser style pattern to the list of exclusions for
disk leafnames. These patterns are evaluated when the exclusion checks are
made.
.TP
\fB\-not_list\fR disk_path
Read lines from disk_path and use them as -not_paths argument if they contain
a / character. If not use the line as -not_leaf pattern.
.TP
\fB\-quoted_not_list\fR disk_path
Like -not_list but with line reading rules of -dialog mode "on". Each word is
handled as one argument for -not_paths resp. -not_leaf.
.TP
\fB\-follow\fR occasion[:occasion[...]]
Enable or disable resolution of symbolic links and mountpoints under
disk_paths. This applies to actions -add, -du*x, -ls*x, -findx,
@ -1562,7 +1577,7 @@ With occasion "file_extraction" there are three behaviors:
Enable or disable to enter dialog mode after all arguments are processed.
In dialog mode input lines get prompted via readline or from stdin.
.br
Mode "on" supports input of newline characters witing quotation marks and
Mode "on" supports input of newline characters within quotation marks and
line continuation by trailing backslash outside quotation marks.
Mode "single_line" does not.
.TP

View File

@ -135,9 +135,9 @@ or
#ifndef Xorriso_sfile_externaL
char *Sfile_fgets(char *line, int maxl, FILE *fp)
/* @param flag bit0= do not clip of carriage return at line end
*/
char *Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag)
{
int l;
char *ret;
@ -146,9 +146,9 @@ char *Sfile_fgets(char *line, int maxl, FILE *fp)
if(ret==NULL)
return(NULL);
l= strlen(line);
if(l>0) if(line[l-1]=='\r') line[--l]= 0;
if(l > 0 && !(flag & 1)) if(line[l-1] == '\r') line[--l]= 0;
if(l > 0) if(line[l-1] == '\n') line[--l]= 0;
if(l>0) if(line[l-1]=='\r') line[--l]= 0;
if(l > 0 && !(flag & 1)) if(line[l-1] == '\r') line[--l]= 0;
return(ret);
}
@ -3581,7 +3581,8 @@ get_single:;
if(xorriso->use_stdin || xorriso->dev_fd_1>=0) {
if(flag&2)
{ret= 1; goto ex;}
if(Sfile_fgets(linept,linesize - base_length - 1,stdin) == NULL) {
if(Sfile_fgets_n(linept,linesize - base_length - 1, stdin,
(xorriso->dialog == 2)) == NULL) {
/* need a very dramatic end */
kill(getpid(),SIGHUP);
{ret= -1; goto ex;}
@ -3608,11 +3609,14 @@ get_single:;
strcpy(linept, cpt);
}
process_single:;
#else /* Xorriso_with_readlinE */
if(flag&2)
{ret= 1; goto ex;}
if(Sfile_fgets(linept, linesize - base_length - 1, stdin) == NULL) {
if(Sfile_fgets_n(linept, linesize - base_length - 1, stdin,
(xorriso->dialog == 2)) == NULL) {
/* need a very dramatic end */
kill(getpid(),SIGHUP);
{ret= -1; goto ex;}
@ -3620,7 +3624,6 @@ get_single:;
#endif /* ! Xorriso_with_readlinE */
process_single:;
if(xorriso->dialog == 2) {
append_line= 0;
if(linept != line && strcmp(linept, "@@@") == 0) {
@ -3636,18 +3639,11 @@ new_empty:;
Xorriso_info(xorriso,0);
goto get_single;
}
l= strlen(line);
ret= Sfile_make_argv("", line, &argc, &argv, 16);
if(ret < 0)
goto ex;
l= strlen(line);
if(l > 0)
if(line[l - 1] == '\\') {
line[l - 1]= 0;
append_line= 1;
why_append= "Trailing backslash ";
}
if(ret == 0 && strlen(line) < linesize - 1 && !append_line) {
if(ret == 0 && !append_line) {
/* append a newline character */
if(l >= linesize - 1) {
sprintf(xorriso->info_text,"Input line too long !");
@ -3659,6 +3655,12 @@ new_empty:;
append_line= 1;
why_append= "Quoted newline char";
}
if(l > 0 && !append_line)
if(line[l - 1] == '\\') {
line[l - 1]= 0;
append_line= 1;
why_append= "Trailing backslash ";
}
if(append_line) {
base_length= strlen(line);
linept= line + base_length;
@ -3831,6 +3833,101 @@ klammer_affe:;
}
/* @param flag bit0= quoted multiline mode
bit1= release allocated memory and return 1
bit2= with bit0: warn of empty text arguments
bit3= deliver as single quoted text including all whitespace
@return -1=out of memory , 0=line format error , 1=ok, go on , 2=done
*/
int Xorriso_read_lines(struct XorrisO *xorriso, FILE *fp, int *linecount,
int *argc, char ***argv, int flag)
{
char line[5 * SfileadrL + 2], *linept, *fgot;
int l, base_length, append_line, ret, mem_linecount, i;
Sfile_make_argv("", line, argc, argv, 2);
if(flag & 2)
return(1);
mem_linecount= *linecount;
linept= line;
base_length= 0;
while(1) {
fgot= Sfile_fgets_n(linept, SfileadrL - base_length + 1, fp,
!!(flag & (1 | 8)));
if(fgot == NULL) {
if(ferror(fp))
return(0);
if(linept != line) {
sprintf(xorriso->info_text,"Open quotation mark at end of input");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
return(2);
}
l= strlen(line);
(*linecount)++;
append_line= 0;
if(flag & 1) { /* check whether the line is incomplete yet */
ret= Sfile_make_argv("", line, argc, argv, 16);
if(ret < 0)
return(ret);
if(ret == 0 && !append_line) {
line[l]= '\n';
line[l + 1]= 0;
append_line= 1;
}
if(l > 0 && !append_line)
if(line[l - 1] == '\\') {
line[l - 1]= 0;
append_line= 1;
}
}
if(l >= SfileadrL) {
sprintf(xorriso->info_text,"Input line too long !");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(!append_line)
break;
base_length= strlen(line);
linept= line + base_length;
}
if((flag & 1) && !(flag & 8)) {
ret= Sfile_make_argv("", line, argc, argv, 1);
if(ret < 0)
return(ret);
if(flag & 4)
for(i= 0; i < *argc; i++) {
if((*argv)[i][0] == 0) {
sprintf(xorriso->info_text, "Empty text as quoted argument in ");
} else if(strlen((*argv)[i]) >= SfileadrL) {
(*argv)[i][SfileadrL - 1]= 0;
sprintf(xorriso->info_text,
"Input text too long and now truncated in");
} else
continue;
if(mem_linecount + 1 < *linecount)
sprintf(xorriso->info_text + strlen(xorriso->info_text),
"lines %d to %d", mem_linecount + 1, *linecount);
else
sprintf(xorriso->info_text + strlen(xorriso->info_text),
"line %d", mem_linecount + 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
}
} else {
(*argv)= Smem_malloC(sizeof(char *));
if(argv == NULL)
return(-1);
(*argv)[0]= strdup(line);
if((*argv)[0] == NULL)
return(-1);
*argc= 1;
}
return(1);
}
int Xorriso_predict_linecount(struct XorrisO *xorriso, char *line,
int *linecount, int flag)
{
@ -9612,18 +9709,8 @@ int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag)
ret= Xorriso_pull_outlists(xorriso, stack_handle, &results, &infos, 0);
if(ret <= 0)
goto ex;
#ifdef NIX
/* <<< info is no longer redirected */
for(lpt= infos; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0)) {
strcpy(xorriso->info_text, Xorriso_lst_get_text(lpt, 0));
Xorriso_info(xorriso, 0);
}
#endif
if(toc_ret <= 0)
{ret= toc_ret; goto ex;}
l= 0;
for(lpt= results; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0))
l+= strlen(Xorriso_lst_get_text(lpt, 0));
@ -11794,6 +11881,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Whether to add lonely arguments as pathspec resp. disk_path.",
" -path_list disk_path",
" Like -add but read the pathspecs from file disk_path.",
" -quoted_path_list disk_path",
" Like -path_list but with line rules as -dialog \"on\".",
"",
" -map disk_path iso_rr_path",
" Insert disk file object at the given iso_rr_path.",
@ -11867,6 +11956,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -not_list disk_path",
" Read lines from disk_path and use as -not_paths (with \"/\")",
" or as -not_leaf (without \"/\").",
" -quoted_not_list disk_path",
" Like -not_list but with line rules as -dialog \"on\".",
" -not_mgt \"reset\"|\"on\"|\"off\"|\"param_on\"|\"subtree_on\"|\"ignore_on\"",
" Control effect of exclusion lists.",
" -follow \"on\"|\"pattern:param:link:mount:limit=#\"|\"default\"|\"off\"",
@ -12785,16 +12876,18 @@ cannot_add:;
}
/* Option -not_list */
/* Option -not_list , -quoted_not_list */
/* @param flag bit0= -quoted_not_list */
int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag)
{
int ret, linecount= 0, insertcount= 0, null= 0;
int ret, linecount= 0, insertcount= 0, null= 0, argc= 0, i;
FILE *fp= NULL;
char *argpt, sfe[5*SfileadrL], line[SfileadrL];
char sfe[5*SfileadrL], **argv= NULL;
Xorriso_pacifier_reset(xorriso, 0);
if(adr[0]==0) {
sprintf(xorriso->info_text,"Empty file name given with -not_list");
sprintf(xorriso->info_text, "Empty file name given with %s",
(flag & 1) ? "-quoted_not_list" : "-not_list");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
@ -12802,32 +12895,30 @@ int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag)
if(ret <= 0)
return(0);
while(1) {
if(Sfile_fgets(line,sizeof(line),fp)==NULL) {
ret= 1;
if(ferror(fp)) {
Xorriso_msgs_submit(xorriso, 0, "Error on reading text line",
errno, "FAILURE", 0);
ret= 0;
}
ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv,
4 | (flag & 1) );
if(ret <= 0)
goto ex;
}
linecount++;
if(line[0]==0)
if(ret == 2)
break;
for(i= 0; i < argc; i++) {
if(argv[i][0] == 0)
continue;
if(strchr(line, '/')!=NULL) {
argpt= line;
if(strchr(argv[i], '/')!=NULL) {
null= 0;
ret= Xorriso_option_not_paths(xorriso, 1, &argpt, &null, 0);
ret= Xorriso_option_not_paths(xorriso, 1, argv + i, &null, 0);
} else
ret= Xorriso_option_not_leaf(xorriso, line, 0);
ret= Xorriso_option_not_leaf(xorriso, argv[i], 0);
if(ret<=0)
goto ex;
insertcount++;
}
}
ret= 1;
ex:;
if(fp!=NULL)
fclose(fp);
Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2);
if(ret<=0) {
sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d",
Text_shellsafe(adr, sfe, 0), linecount);
@ -12971,8 +13062,10 @@ return:
{
int ret,linecount= 0, argc, was_failure= 0, fret;
FILE *fp= NULL;
char line[5*SfileadrL], shellsafe[5*SfileadrL];
char shellsafe[5*SfileadrL];
char **argv= NULL;
int linec= 0;
char *line= NULL, **linev= NULL;
if(adr[0]==0) {
sprintf(xorriso->info_text,"Empty file name given with -options_from_file");
@ -12989,13 +13082,12 @@ return:
if(ret <= 0)
return(0);
while(1) {
if(Sfile_fgets(line,sizeof(line),fp)==NULL) {
ret= 1;
if(ferror(fp))
ret= 0;
ret= Xorriso_read_lines(xorriso, fp, &linecount, &linec, &linev, 1 | 8);
if(ret <= 0)
goto ex; /* no problem_handler because there is no sense in going on */
if(ret == 2)
break;
}
linecount++;
line= linev[0];
if(line[0]==0 || line[0]=='#')
continue;
@ -13029,7 +13121,9 @@ problem_handler:;
continue;
goto ex;
}
ret= 1;
ex:;
Xorriso_read_lines(xorriso, fp, &linecount, &linec, &linev, 2);
Xorriso_reset_counters(xorriso,0);
if(fp!=NULL)
fclose(fp);
@ -13197,17 +13291,19 @@ int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path,
}
/* Option -path-list */
/* Option -path_list , -quoted_path_list */
/* @param flag bit0= -quoted_path_list */
int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
{
int ret,linecount= 0, insertcount= 0, null= 0, was_failure= 0, fret= 0;
int was_ferror= 0;
int was_ferror= 0, argc= 0, i;
FILE *fp= NULL;
char *argpt, sfe[5*SfileadrL],line[SfileadrL];
char sfe[5*SfileadrL], **argv= NULL;
Xorriso_pacifier_reset(xorriso, 0);
if(adr[0]==0) {
sprintf(xorriso->info_text,"Empty file name given with -path-list");
sprintf(xorriso->info_text,"Empty file name given with %s",
flag & 1 ? "-quoted_path_list" : "-path_list");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
return(0);
}
@ -13215,21 +13311,21 @@ int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
if(ret <= 0)
return(0);
while(1) {
if(Sfile_fgets(line,sizeof(line),fp)==NULL) {
ret= 1;
if(ferror(fp))
was_ferror= 1;
ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv,
4 | (flag & 1) );
if(ret <= 0)
goto ex;
if(ret == 2)
break;
}
linecount++;
if(line[0]==0)
for(i= 0; i < argc; i++) {
if(argv[i][0] == 0)
continue;
argpt= line;
null= 0;
ret= Xorriso_option_add(xorriso, 1, &argpt, &null, 1|2);
ret= Xorriso_option_add(xorriso, 1, argv + i, &null, 1|2);
if(ret<=0 || xorriso->request_to_abort)
goto problem_handler;
insertcount++;
}
continue; /* regular bottom of loop */
problem_handler:;
@ -13241,6 +13337,9 @@ problem_handler:;
}
ret= 1;
ex:;
if(flag & 1)
Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2);
if(fp!=NULL)
fclose(fp);
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
@ -13250,7 +13349,7 @@ ex:;
Text_shellsafe(adr, sfe, 0), linecount);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
(fret==-2 ? "NOTE" : "FAILURE"), 0);
}
} else
ret= !was_ferror;
sprintf(xorriso->info_text, "Added %d items from file %s\n",
insertcount, Text_shellsafe(adr, sfe, 0));
@ -14104,7 +14203,8 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"history","indev","joliet","list_delimiter","mark","not_leaf",
"not_list","not_mgt","options_from_file","osirrox","outdev","overwrite",
"pacifier","padding","path_list","pathspecs","pkt_output","print","prompt",
"prog","prog_help","publisher","reassure","report_about","rom_toc_scan",
"prog","prog_help","publisher","quoted_not_list","quoted_path_list",
"reassure","report_about","rom_toc_scan",
"session_log","speed","split_size","status","status_history_max",
"stream_recording","temp_mem_limit","uid","volid","use_readline",
""
@ -14635,6 +14735,14 @@ next_command:;
} else if(strcmp(cmd,"pwdx")==0) {
Xorriso_option_pwdx(xorriso, 0);
} else if(strcmp(cmd,"quoted_not_list")==0) {
(*idx)++;
ret= Xorriso_option_not_list(xorriso, arg1, 1);
} else if(strcmp(cmd,"quoted_path_list")==0) {
(*idx)++;
ret= Xorriso_option_path_list(xorriso, arg1, 1);
} else if(strcmp(cmd,"reassure")==0) {
(*idx)++;
ret= Xorriso_option_reassure(xorriso, arg1, 0);

View File

@ -522,7 +522,8 @@ int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag);
/* Option -not_leaf */
int Xorriso_option_not_leaf(struct XorrisO *xorriso, char *pattern, int flag);
/* Option -not_list */
/* Option -not_list , -quoted_not_list */
/* @param flag bit0= -quoted_not_list */
int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag);
/* Option -not_paths */
@ -553,7 +554,8 @@ int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag);
int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path,
char *disk_path, char *start, char *count, int flag);
/* Option -path-list */
/* Option -path_list , -quoted_path_list */
/* @param flag bit0= -quoted_path_list */
int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag);
/* Option -pathspecs */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.10.12.133957"
#define Xorriso_timestamP "2008.10.15.182605"