From 6cc5a50ba4a3f360e6efc42c52ed5f924e69919d Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 9 Nov 2007 19:30:25 +0000 Subject: [PATCH] New option -iso_rr_pattern, influencing several options with multiple args --- libisoburn/trunk/test/xorriso.1 | 108 ++++--- libisoburn/trunk/test/xorriso.c | 351 +++++++++++++++++----- libisoburn/trunk/test/xorriso.h | 4 + libisoburn/trunk/test/xorriso_private.h | 3 + libisoburn/trunk/test/xorriso_timestamp.h | 2 +- libisoburn/trunk/test/xorrisoburn.c | 44 ++- libisoburn/trunk/test/xorrisoburn.h | 3 +- 7 files changed, 387 insertions(+), 128 deletions(-) diff --git a/libisoburn/trunk/test/xorriso.1 b/libisoburn/trunk/test/xorriso.1 index 898f5016..2c98b4fa 100644 --- a/libisoburn/trunk/test/xorriso.1 +++ b/libisoburn/trunk/test/xorriso.1 @@ -198,11 +198,20 @@ characters. Rock Ridge fulfills this demand. .br Commands are either actions or settings. They consist of a command word, followed by zero or more parameter words. If the list of parameter words -is of variable length (indicated by "[...]") then it has to be terminated -by either the word "--" or the end of argument list or an end of an input -line. It is not an error if "--" appears after the parameters of a command +is of variable length (indicated by "[...]" or "[***]") then it has to be +terminated by either the word "--" or the end of argument list or an end of +an input line. +It is not an error if "--" appears after the parameters of a command with a fixed list length. .PP +.B Pattern expansion +is a property of some particular commands and not a general +feature. It gets controlled by command -iso_rr_pattern. Commands which +eventually use pattern expansion all have variable argument lists which +are marked in this man page by [***] rather than [...]. +.br +Some other commands perform pattern matching unconditionally. +.PP Command and parameter words are either read from program arguments, where one argument is one word, or from input lines where words are recognized similar to the quotation rules of a shell parser. @@ -210,16 +219,16 @@ to the quotation rules of a shell parser. xorriso is not a shell, although it might appear so on first glimpse. Be aware that the interaction of quotation marks and pattern symbols like "*" differs from the usual shell parsers. In xorriso, a quotation mark does not -make a pattern symbol literal. Pattern expansion is a property of some -particular commands and not a general feature. +make a pattern symbol literal. .PP When the program begins then it first looks for its startup files and eventually reads their content as command input lines. Then it interprets the program arguments as commands and parameters and finally it enters dialog mode if command -dialog was executed up to then. .PP -The program ends either by command -end or by the end of program arguments -if not command -dialog was encountered up to that moment. +The program ends either by command -end, or by the end of program arguments +if not command -dialog was encountered up to that moment, or by a problem +event which triggers the threshold of command -abort_on. .br .SH OPTIONS .br @@ -253,21 +262,23 @@ Once set, this command cannot be revoked. .TP .B Data manipulations: .PP +The following commands expect file addresses of two kinds: +.br .B disk_path is a path to an object in the local filesystem tree. .br .B iso_rr_path is the Rock Ridge name of a file object in the ISO image. (Do not confuse with the lowlevel ISO 9660 names visible if Rock Ridge gets ignored.) -.br -The following commands may depend on settings listed further below. .PP Note that in the ISO image you are as powerful as the superuser. Access permissions of the existing files in the image do not apply to your write operations. They are intended to be in effect with the read-only mounted image. .PP If the iso_rr_path of a newly inserted file leads to an existing -file object in the ISO image, then the following collision handling happens: +file object in the ISO image, then the following +.B collision handling +happens: .br If both objects are directories then they get merged by recursively inserting the subobjects from filesystem into ISO image. @@ -278,6 +289,24 @@ be replaced, not merged. .PP The commands in this section alter the ISO image and not the local filesystem. .TP +\fB\-iso_rr_pattern\fR "on"|"ls"|"off" +Set the pattern expansion mode for the iso_rr_path arguments of several +commands which support this feature. +.br +.B Pattern expansion +converts a list of pattern words into a list of existing file addresses. +Eventual unmatched pattern words appear themselves in that result list, though. +.br +Pattern matching supports the usual shell parser wildcards '*' '?' '[a-z]' +and respects '/' as separator which may only be matched literally. +.br +Setting "off" disables this feature for all commands which are marked in this +man page by "iso_rr_path [***]" or "pattern [***]. +Setting "on" enables it for all those commands. +Setting "ls" enables it only for those which are marked by "pattern [***]". +.br +Default is "on". +.TP \fB\-add\fR path [...] Insert the given files or directory trees from filesystem into the ISO image. @@ -295,7 +324,7 @@ into the ISO image. Use the same rules for generating the ISO addresses as would be done with shell command cp -r. .TP -\fB\-rm\fR iso_rr_path [...] +\fB\-rm\fR iso_rr_path [***] Delete the given files from the ISO image. .br Note: This does not free any space on the -indev media, even if @@ -304,23 +333,27 @@ the deletion is committed to that same media. > The image size will shrink if the image is written to a different media in modification mode. .TP -\fB\-rm_r\fR iso_rr_path [...] +\fB\-rm_r\fR iso_rr_path [***] Delete the given files or directory trees from the ISO image. See also the note with option -rm. .TP -\fB\-mv\fR iso_rr_path [...] iso_rr_path +\fB\-mv\fR iso_rr_path [***] iso_rr_path Rename the given file objects in the ISO tree to the last argument in the list. Use the same rules as with shell command mv. +.br +If pattern expansion is enabled and if the last argument contains wildcard +characters then it must match exactly one existing file address, or else the +command fails with a SORRY event. .TP -\fB\-chown\fR uid iso_rr_path [...] +\fB\-chown\fR uid iso_rr_path [***] Set ownership of file objects in the ISO image. uid may either be a decimal number or the name of a user known to the operating system. .TP -\fB\-chgrp\fR gid iso_rr_path [...] +\fB\-chgrp\fR gid iso_rr_path [***] Set group attribute of file objects in the ISO image. gid may either be a decimal number or the name of a group known to the operating system. .TP -\fB\-chmod\fR mode iso_rr_path [...] +\fB\-chmod\fR mode iso_rr_path [***] Equivalent to shell command chmod in the ISO image. mode is either an octal number beginning with "0" or a comma separated list of statements of the form [ugoa]*[+-=][rwxst]* . Like: go-rwx,u+rwx . @@ -337,7 +370,7 @@ r=read, w=write, x=execute|inspect, s=setuid|setgid, t=sticky bit .br For octal numbers see man 2 stat. .TP -\fB\-alter_date\fR type timestring iso_rr_path [...] +\fB\-alter_date\fR type timestring iso_rr_path [***] Alter the date entries of a file in the ISO image. type is one of "a", "m", "b" for access time, modification time, both times. @@ -354,7 +387,8 @@ As produced by program date: Relative times counted from current clock time: +|-Number["s"|"h"|"d"|"w"|"m"|"y"] .br -where "s" means seconds, "h" hours, "d" days, "w" weeks, "m" = 30d, y=365.25d. +where "s" means seconds, "h" hours, "d" days, "w" weeks, "m"=30d, +"y"=365.25d plus 1d added multiplication result. .br Absolute seconds counted from Jan 1 1970: =Number @@ -372,7 +406,7 @@ Create empty directories if they do not exist yet. Existence as directory generates a WARNING event, existence as other file cause a SORRY event. .TP -\fB\-rmdir\fR iso_rr_path [...] +\fB\-rmdir\fR iso_rr_path [***] Delete empty directories. .TP \fB\-\-\fR @@ -457,20 +491,9 @@ SORRY event occured. .TP .B Settings for data insertion: .TP -RockRidge info will be generated by the program unconditionally. -.TP -\fB\-J\fR -Generate Joliet info additional to Rock Ridge info. -.TP > \fB\-f\fR Follow symbolic links. .TP -\fB\-uid\fR uid -User id to be used for all files when inserted into the new ISO tree. -.TP -\fB\-gid\fR gid -Group id for the same purpose. -.TP \fB\-graft-points\fR For xorriso action -add this enables pathspecs of the form .B target=source @@ -478,9 +501,20 @@ like with program mkisofs. .TP .B Settings for result writing: .TP +RockRidge info will be generated by the program unconditionally. +.TP +? \fB\-J\fR +Generate Joliet info additional to Rock Ridge info. +.TP > \fB\-V\fR volid Specifies the volume ID. .TP +\fB\-uid\fR uid +User id to be used for all files when the new ISO tree gets written to media. +.TP +\fB\-gid\fR gid +Group id to be used for all files when the new ISO tree gets written to media. +.TP \fB\-speed\fR number[k|m|c|d] Set the burn speed. Default is 0 = maximum speed. Speed can be given in media dependent numbers or as a @@ -518,7 +552,7 @@ and is one aspect of growisofs -dvd-compat. .B Exception processing: .TP \fB\-abort_on\fR severity -Set the threshhold for events to abort the program. +Set the threshold for events to abort the program. Events are classified by severity : "NEVER", "ABORT", "FATAL", "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL" @@ -531,10 +565,10 @@ the setting by this option. Expect not many "ABORT" events to be ignorable. .TP \fB\-report_about\fR severity -Set the threshhold for events to be reported. +Set the threshold for events to be reported. Events are the same as with -abort_on. Regardless what is set by -report_about, messages get always reported if they -reach the severity threshhold of -abort_on . +reach the severity threshold of -abort_on . .br Event messages are sent to the info channel "I" which is usually stderr but may be influenced by command -pkt_output. @@ -620,7 +654,7 @@ Tell the current working directory in the ISO image. \fB\-pwdx\fR Tell the current working directory on local filesystem. .TP -\fB\-ls\fR pattern [...] +\fB\-ls\fR pattern [***] List files from the current working directory in the ISO image which match shell patterns (i.e. with wildcards '*' '?' '[a-z]'). Note that this resembles rather shell command ls -d than command ls. @@ -629,18 +663,18 @@ Note that this resembles rather shell command ls -d than command ls. List files from the current working directory on local filesystem which match shell patterns. .TP -\fB\-ls_l\fR pattern [...] +\fB\-ls_l\fR pattern [***] Like -ls but also list some of the file attributes. Output format resembles shell command ls -ldn. .TP > \fB\-ls_lx\fR pattern [...] Like -lsx but also list some of the file attributes. .TP -\fB\-du\fR pattern [...] +\fB\-du\fR pattern [***] Recursively list size of directories and files matching one of the patterns, similar to shell command du -k. .TP -\fB\-du_s\fR pattern [...] +\fB\-du_s\fR pattern [***] List size of directories and files matching one of the patterns, similar to shell command du -sk. .TP diff --git a/libisoburn/trunk/test/xorriso.c b/libisoburn/trunk/test/xorriso.c index e21aee84..48588153 100644 --- a/libisoburn/trunk/test/xorriso.c +++ b/libisoburn/trunk/test/xorriso.c @@ -1,6 +1,4 @@ - - /* ( cd .. ; libisoburn-develop/test/compile_xorriso.sh -g ) @@ -2245,6 +2243,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->dialog= 0; m->search_mode= 0; m->structured_search= 1; + m->do_iso_rr_pattern= 1; m->temp_mem_limit= 16*1024*1024; m->use_stdin= 0; m->result_page_length= 0; @@ -2442,7 +2441,7 @@ int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag) abort_really_text= "done reading"; } else { abort_req_text= "request to abort"; - abort_really_text= "abort"; + abort_really_text= "abort this command"; } ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1); xorriso->result_line_counter= 0; @@ -2458,7 +2457,7 @@ int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag) if(flag&1) { strcpy(previous_line,cpt); sprintf(xorriso->info_text, - "....... [%s = %s registered. Really %s ? (y/n) ] .......\n", + ".... [%s = %s registered. Really %s ? (y/n) ] ....\n", cpt,abort_req_text,abort_really_text); Xorriso_info(xorriso,0); ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1); @@ -3242,6 +3241,11 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) sprintf(line,"-prog %s\n",Text_shellsafe(xorriso->progname,sfe,0)); Xorriso_status_result(xorriso,filter,fp,flag&2); + if(xorriso->ban_stdio_write) { + sprintf(line,"-ban_stdio_write\n"); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + sprintf(line,"-cd %s\n", (xorriso->wdi[0] ? Text_shellsafe(xorriso->wdi,sfe,0) : "'/'")); Xorriso_status_result(xorriso,filter,fp,flag&2); @@ -3249,10 +3253,12 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) (xorriso->wdx[0] ? Text_shellsafe(xorriso->wdx,sfe,0) : "'/'")); Xorriso_status_result(xorriso,filter,fp,flag&2); - if(xorriso->ban_stdio_write) { - sprintf(line,"-ban_stdio_write\n"); + is_default= (xorriso->do_iso_rr_pattern==1); + sprintf(line,"-iso_rr_pattern %s\n", + (xorriso->do_iso_rr_pattern == 1 ? "on" : + (xorriso->do_iso_rr_pattern == 2 ? "ls" : "off"))); + if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); - } is_default= (xorriso->volid[0]==0); sprintf(line,"-V %s\n",Text_shellsafe(xorriso->volid,sfe,0)); @@ -3439,9 +3445,11 @@ ex: int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag) { - if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL) { + if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL || + strchr(path,'[')!=NULL) { sprintf(xorriso->info_text, - "Xorriso does not support address wildcards '*' and '?'"); + "Pattern expansion of wildcards \"*?[\" is disabled%s", + xorriso->do_iso_rr_pattern!=1 ? "command -iso_rr_pattern off" : ""); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); return(1); } @@ -3449,7 +3457,7 @@ int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag) } -/* @param flag bit0= do not warn of wirldcards +/* @param flag bit0= do not warn of wildcards */ int Xorriso_end_idx(struct XorrisO *xorriso, int argc, char **argv, int idx, int flag) @@ -3466,6 +3474,131 @@ int Xorriso_end_idx(struct XorrisO *xorriso, } +/* Returns a vector of strings which belong to an open ended arg list. + If expansion is enabled, the vector might be allocated, else it is + a pointer into the argv input vector. + Thus the release of that memory is an expert task to be done by this + function only. Use bit8 for that. Wiith bit8 parameter argc MUST be the + same value as with the call which might have allocated memory. + @param xorriso The environment object + @param argc Length of argv + @param argv The vector with arguments, eventual "--" and then eventual + unrelated words + @param idx Start index in argv of the argument list + @param optc Length of the effective possibly expanded option vector + @param optv The option vector. Maybe a pointer into argv or maybe + an own allocated vector. + @param flag bit0= do not warn of wildcards + bit1= these are disk_paths + bit2= never expand wildcards + bit3= do not expand last argument + bit4= ignore last argument + bit5= demand exactly one match + bit6= with bit allow 0 matches if pattern is a constant + bit8= free the eventually allocated sub_vector +*/ +int Xorriso_opt_args(struct XorrisO *xorriso, + int argc, char **argv, int idx, + int *end_idx, int *optc, char ***optv, int flag) +{ + int i, do_expand, nump, was_empty= 0, filec= 0, ret; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + + do_expand= xorriso->do_iso_rr_pattern==1 && (!(flag&4)) && (!(flag&2)); + if(flag&256) { + if(*optv=argv+argc) + Sfile_destroy_argv(optc, optv, 0); + return(1); + } + if(idx>=argc) { + *end_idx= argc; + *optc= 0; + *optv= NULL; + return(-1); + } + *end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, (flag&1) || do_expand); + if(*end_idx<0) + return(*end_idx); + if((flag&16) && (*end_idx)>idx) + (*end_idx)--; + *optc= *end_idx - idx; + *optv= argv+idx; + if(*optc<=0 || !do_expand) + return(1); + patterns= calloc(sizeof(char *), *optc); + if(patterns==NULL) { +no_memory:; + sprintf(xorriso->info_text, + "Cannot allocate enough memory for pattern expansion"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 0; + if(flag&8) { + was_empty= 1; + mem+= strlen(argv[idx + *optc - 1])+1+sizeof(char *); + } + for(i= 0; i<*optc-!!(flag&8); i++) { + if(argv[i + idx][0]==0) { + was_empty++; + mem+= sizeof(char *); /* as upper limit for size of an empty string */ + continue; + } + patterns[nump++]= argv[i + idx]; + } + if(nump<=0) { /* Only empty texts. May the caller get happy with them. */ + free(patterns); + return(1); + } + ret= Xorriso_expand_pattern(xorriso, nump, patterns, was_empty, + &filec, &filev, &mem, (flag>>5)&3); + if(ret<=0) + {ret= 0; goto ex;} + for(i= 0; iinfo_text, "Pattern expansion yields %d items:", filec); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + l= 0; + xorriso->info_text[0]= 0; + for(i= 0; iinfo_text); + if(l>0 && l+1+strlen(filev[i])>60) { + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + xorriso->info_text[0]= 0; + l= 0; + } + sprintf(xorriso->info_text+l, " %s", filev[i]); + } + l= strlen(xorriso->info_text); + if(l>0) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); +} +#endif /* Xorriso_verbous_pattern_expansioN */ + + ret= 1; +ex:; + if(ret<=0) { + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + } else { + *optc= filec; + *optv= filev; + } + return(ret); +} + + int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80], int flag) { @@ -3716,10 +3849,10 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso, char *time_type, char *timestring, int argc, char **argv, int *idx, int flag) { - int i, end_idx, ret, was_failure= 0, t_type= 0; + int i, ret, was_failure= 0, t_type= 0, end_idx; time_t t; - - end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); + int optc= 0; + char **optv= NULL; if(strcmp(time_type, "a")==0) t_type|= 1; @@ -3740,8 +3873,15 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); ret= 0; goto ex; } - for(i= *idx; iinfo_text, "Understanding timestring '%s' as: %s", + timestring, ctime(&t)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0); + if(ret<=0) + goto ex; + for(i= 0; ido_iso_rr_pattern= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_iso_rr_pattern= 1; + else if(strcmp(mode, "ls")==0) + xorriso->do_iso_rr_pattern= 2; + else { + sprintf(xorriso->info_text, "-iso_rr_pattern: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + /* Option -f */ int Xorriso_option_f(struct XorrisO *xorriso, int flag) { @@ -4472,6 +4640,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) "if they are followed by another option. In dialog and with options read from", "files, the line end serves as such a mark. With program arguments this mark", "can be omitted only with the last option in the list of arguments.", +"Options marked by [***] have variable argument length and perform pattern", +"expansion if enabled by -iso_rr_pattern.", "", " -add pathspec [...] Insert the given files or directory trees from", " filesystem into the ISO image. Much like mkisofs.", @@ -4482,34 +4652,34 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) "> -cp_r disk_path [...] iso_rr_path", " Insert the given files or directory trees from filesystem", " into the ISO image.", -" -rm iso_rr_path [...]", +" -rm iso_rr_path [***]", " Delete the given files from the ISO image.", -" -rm_r iso_rr_path [...]", +" -rm_r iso_rr_path [***]", " Delete the given directory trees from ISO image.", " -mv iso_rr_path [...] iso_rr_path", " Rename the given file objects in the ISO tree to the last", " argument in the list.", -"> -chown uid iso_rr_path [...]", +" -chown uid iso_rr_path [***]", " Equivalent to chown in the ISO image.", -"> -chgrp gid iso_rr_path [...]", +" -chgrp gid iso_rr_path [***]", " Equivalent to chgrp in the ISO image.", -"> -chmod mode iso_rr_path [...]", +" -chmod mode iso_rr_path [***]", " Equivalent to chmod in the ISO image.", -"> -alter_date type timestring iso_rr_path [...]", +" -alter_date type timestring iso_rr_path [***]", " Alter the date entries of a file in the ISO image. type is", " one of \"a\", \"m\", \"b\" for:", " access time, modification time, both times.", " -mkdir iso_rr_path [...]", " Create empty directories if they do not exist yet", -" -rmdir iso_rr_path [...]", +" -rmdir iso_rr_path [***]", " Delete empty directories.", " -- Mark end of particular action argument list.", "", "> -f Follow symbolic links within disk_path.", "", -" -overwrite \"on\"|\"off\"", +" -overwrite \"on\"|\"nondir\"|\"off\"", " Allow or disallow to overwrite existing files in ISO image.", -" -reassure \"on\"|\"off\"", +" -reassure \"on\"|\"tree\"|\"off\"", " If \"on\" then ask the user for \"y\" or \"n\" with any", " file before deleting or overwriting it in the ISO image.", "", @@ -4547,22 +4717,26 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " -pwdi same as -pwd.", " -pwdx tells the current working directory in the local filesystem.", "", -" -ls pattern [...] lists files of the ISO image which match one of the", +" -iso_rr_pattern \"on\"|\"ls\"|\"off\"", +" Enable or disable pattern expansions for commands marked", +" by [***]. \"ls\" restricts it to -ls and -du.", +"", +" -ls pattern [***] lists files of the ISO image which match one of the", " given shell parser patterns. (I.e. wildcards '*' '?')", -" -lsi pattern [...] same as -ls.", +" -lsi pattern [***] same as -ls.", "> -lsx pattern [...] lists files of the local filesystem which match one", " of the patterns.", "", -" -ls_l pattern [...] like -ls but also telling some file attributes.", -" -ls_li pattern [...] same as -ls_l.", +" -ls_l pattern [***] like -ls but also telling some file attributes.", +" -ls_li pattern [***] same as -ls_l.", "> -ls_lx pattern [...] like -lsx but also telling some file attributes.", "", -" -du pattern [...] recursively lists sizes of files or directories which", +" -du pattern [***] recursively lists sizes of files or directories which", " match one of the shell parser patterns.", -" -dui pattern [...] same as -du.", -" -du_s pattern [...] like -du but summing up subdirectories without", +" -dui pattern [***] same as -du.", +" -du_s pattern [***] like -du but summing up subdirectories without", " listing them explicitely.", -" -dui pattern [...] same as -du_s.", +" -du_si pattern [***] same as -du_s.", "", "> -find pattern lists matching files below current working directory in", " the ISO image.", @@ -4702,6 +4876,8 @@ int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, off_t mem= 0; end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + if(xorriso->do_iso_rr_pattern==0) + flag|= 2; nump= end_idx - *idx; if(flag&2) { @@ -4735,7 +4911,7 @@ no_memory:; /* save temporary memory by calling simpler function */ ret= Xorriso_ls(xorriso, (flag&1)|4); } else { - ret= Xorriso_expand_pattern(xorriso, nump, patterns, &filec, &filev, + ret= Xorriso_expand_pattern(xorriso, nump, patterns, 0, &filec, &filev, &mem, 0); if(ret<=0) {ret= 0; goto ex;} @@ -4849,42 +5025,59 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, char sfe[5*SfileadrL], sfe2[5*SfileadrL]; char eff_origin[SfileadrL], eff_dest[SfileadrL]; char dest_dir[SfileadrL], *leafname; + int optc= 0,destc= 0; + char **optv= NULL, **destv= NULL; - end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, + xorriso->do_iso_rr_pattern==1); if(end_idx - *idx < 2) { sprintf(xorriso->info_text, "-mvi: not enough arguments"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); {ret= 0; goto ex;} } +#ifdef NIX + optc= end_idx - *idx; + optv= argv + *idx; +#else + ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, + 16); /* ignore last argument */ + if(ret<=0) + goto ex; + ret= Xorriso_opt_args(xorriso, argc, argv, end_idx, &end_idx, &destc, &destv, + 32|64); /* demand one match, or 0 with a constant */ + if(ret<=0) + goto ex; +#endif /* ! NIX */ + /* Check existence of old addresses */ - for(i= *idx; i 2) { + } else if(optc > 2) { sprintf(xorriso->info_text, "-mvi: more than one origin given, destination is a non-directory: %s", - Text_shellsafe(argv[end_idx-1], sfe, 0)); + Text_shellsafe(destv[0], sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); {ret= 0; goto ex;} } if(ret==0) { /* compute complete eff_dest */ - ret= Xorriso_normalize_img_path(xorriso, argv[end_idx-1], eff_dest, 2); + ret= Xorriso_normalize_img_path(xorriso, destv[0], eff_dest, 2); if(ret<0) {ret= 0; goto ex;} } /* Perform movements */ - for(i= *idx; iwdi, path, 0); @@ -5271,28 +5469,11 @@ int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, ret= 1; ex:; (*idx)= end_idx; + Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); return(ret); } -/* Option -rmdir alias -rmdiri */ -int Xorriso_option_rmdiri(struct XorrisO *xorriso, int argc, char **argv, - int *idx, int flag) -{ - int i, end_idx; - - end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); - - fprintf(stderr, ">>> LIBISOFS : -rmdiri "); - for(i= *idx; iwdi does not exist yet, but one may not use it as base for relative address searches. */ @@ -2396,8 +2400,19 @@ cannot_compile:; 1 | abs_adr); if(ret<=0) goto ex; - if(was_count==count && strcmp(patterns[i],"*")!=0) { + if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) { count++; + + /* Is this a constant pattern ? */ + for(k= 0; kre_fill; k++) { + if(xorriso->re_constants[k]==NULL) + break; + if(xorriso->re_constants[k][0]==0) + break; + } + if(kre_fill) + nonconst_mismatches++; /* it is not */ + l= strlen(patterns[i])+1; (*mem)+= sizeof(char *)+l; if(l % sizeof(char *)) @@ -2405,13 +2420,30 @@ cannot_compile:; } } + if((flag&1) && (count!=1 || nonconst_mismatches)){ + if(count-nonconst_mismatches>0) + sprintf(xorriso->info_text, + "Pattern match with more than one file object"); + else + sprintf(xorriso->info_text, "No pattern match with any file object"); + if(num_patterns==1) + sprintf(xorriso->info_text+strlen(xorriso->info_text), ": %s", + Text_shellsafe(patterns[0], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= 0; goto ex; + } + + count+= extra_filec; + mem+= extra_filec*sizeof(char *); + if(count<=0) {ret= 0; goto ex;} Sfile_scale((double) *mem, mem_text,5,1e4,0); sprintf(xorriso->info_text, "Temporary memory needed for pattern expansion : %s", mem_text); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + if(!(flag&1)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); if(*mem > xorriso->temp_mem_limit) { Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); sprintf(xorriso->info_text, diff --git a/libisoburn/trunk/test/xorrisoburn.h b/libisoburn/trunk/test/xorrisoburn.h index 01abe4fb..b792f769 100644 --- a/libisoburn/trunk/test/xorrisoburn.h +++ b/libisoburn/trunk/test/xorrisoburn.h @@ -91,8 +91,9 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest,int flag); */ int Xorriso_mkdir(struct XorrisO *xorriso, char *img_path, int flag); +/* @param flag bit0= a match count !=1 is a SORRY event */ int Xorriso_expand_pattern(struct XorrisO *xorriso, - int num_patterns, char **patterns, + int num_patterns, char **patterns, int extra_filec, int *filec, char ***filev, off_t *mem, int flag); int Xorriso_set_st_mode(struct XorrisO *xorriso, char *path,