New option -iso_rr_pattern, influencing several options with multiple args
This commit is contained in:
351
test/xorriso.c
351
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 || *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; i<was_empty; i++) {
|
||||
if(i==was_empty-1 && (flag&8))
|
||||
filev[filec++]= strdup(argv[idx + *optc - 1]);
|
||||
else
|
||||
filev[filec++]= strdup("");
|
||||
if(filev[filec-1]==NULL)
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
#ifdef Xorriso_verbous_pattern_expansioN
|
||||
{ int l;
|
||||
sprintf(xorriso->info_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; i<filec; i++) {
|
||||
l= strlen(xorriso->info_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; i<end_idx; i++) {
|
||||
ret= Xorriso_set_time(xorriso, argv[i], t, t_type);
|
||||
sprintf(xorriso->info_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; i<optc; i++) {
|
||||
ret= Xorriso_set_time(xorriso, optv[i], t, t_type);
|
||||
if(ret<0)
|
||||
goto ex;
|
||||
if(ret==0)
|
||||
@@ -3750,6 +3890,7 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
|
||||
ret= 1;
|
||||
ex:;
|
||||
(*idx)= end_idx;
|
||||
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(!was_failure);
|
||||
@@ -3948,17 +4089,19 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
|
||||
int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
|
||||
int argc, char **argv, int *idx, int flag)
|
||||
{
|
||||
int i, end_idx, ret, was_failure= 0;
|
||||
int i, ret, was_failure= 0, end_idx;
|
||||
gid_t gid_number;
|
||||
|
||||
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
|
||||
int optc= 0;
|
||||
char **optv= NULL;
|
||||
|
||||
ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
|
||||
for(i= *idx; i<end_idx; i++) {
|
||||
ret= Xorriso_set_gid(xorriso, argv[i], gid_number, 0);
|
||||
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
for(i= 0; i<optc; i++) {
|
||||
ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0);
|
||||
if(ret<0)
|
||||
goto ex;
|
||||
if(ret==0)
|
||||
@@ -3967,6 +4110,7 @@ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
|
||||
ret= 1;
|
||||
ex:;
|
||||
(*idx)= end_idx;
|
||||
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(!was_failure);
|
||||
@@ -3977,12 +4121,12 @@ ex:;
|
||||
int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
|
||||
int argc, char **argv, int *idx, int flag)
|
||||
{
|
||||
int i, end_idx, ret, who_val= 0, was_failure= 0;
|
||||
int i, ret, who_val= 0, was_failure= 0, end_idx;
|
||||
unsigned int num;
|
||||
mode_t mode_and= ~0, mode_or= 0, mode_val, mask;
|
||||
char sfe[5*SfileadrL], *mpt, *opt, *vpt;
|
||||
|
||||
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
|
||||
int optc= 0;
|
||||
char **optv= NULL;
|
||||
|
||||
if(mode[0]=='0') {
|
||||
mode_and= 0;
|
||||
@@ -4070,9 +4214,11 @@ unrecognizable:;
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
|
||||
ret= 1;
|
||||
for(i= *idx; i<end_idx; i++) {
|
||||
ret= Xorriso_set_st_mode(xorriso, argv[i], mode_and, mode_or, 0);
|
||||
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
for(i= 0; i<optc; i++) {
|
||||
ret= Xorriso_set_st_mode(xorriso, optv[i], mode_and, mode_or, 0);
|
||||
if(ret<0)
|
||||
break;
|
||||
if(ret==0)
|
||||
@@ -4081,6 +4227,7 @@ unrecognizable:;
|
||||
ret= 1;
|
||||
ex:;
|
||||
(*idx)= end_idx;
|
||||
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(!was_failure);
|
||||
@@ -4091,17 +4238,19 @@ ex:;
|
||||
int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
|
||||
int argc, char **argv, int *idx, int flag)
|
||||
{
|
||||
int i, end_idx, ret, was_failure= 0;
|
||||
int i, ret, was_failure= 0, end_idx;
|
||||
uid_t uid_number;
|
||||
|
||||
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
|
||||
int optc= 0;
|
||||
char **optv= NULL;
|
||||
|
||||
ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
|
||||
for(i= *idx; i<end_idx; i++) {
|
||||
ret= Xorriso_set_uid(xorriso, argv[i], uid_number, 0);
|
||||
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
for(i= 0; i<optc; i++) {
|
||||
ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0);
|
||||
if(ret<0)
|
||||
goto ex;
|
||||
if(ret==0)
|
||||
@@ -4110,6 +4259,7 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
|
||||
ret= 1;
|
||||
ex:;
|
||||
(*idx)= end_idx;
|
||||
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(!was_failure);
|
||||
@@ -4335,6 +4485,24 @@ int Xorriso_option_end(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
|
||||
/* Option -iso_rr_pattern "on"|"ls"|"off" */
|
||||
int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,int flag)
|
||||
{
|
||||
if(strcmp(mode, "off")==0)
|
||||
xorriso->do_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<end_idx-1; i++) {
|
||||
ret= Xorriso_normalize_img_path(xorriso, argv[i], eff_origin, 0);
|
||||
for(i= 0; i<optc; i++) {
|
||||
ret= Xorriso_normalize_img_path(xorriso, optv[i], eff_origin, 0);
|
||||
if(ret<=0)
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
/* Evaluate target address */
|
||||
ret= Xorriso_normalize_img_path(xorriso, argv[end_idx-1], eff_dest, 1);
|
||||
ret= Xorriso_normalize_img_path(xorriso, destv[0], eff_dest, 1);
|
||||
if(ret<0)
|
||||
{ret= 0; goto ex;}
|
||||
if(ret==2) {
|
||||
is_dir= 1;
|
||||
strcpy(dest_dir, eff_dest);
|
||||
} else if(end_idx - *idx > 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; i<end_idx-1; i++) {
|
||||
ret= Xorriso_normalize_img_path(xorriso, argv[i], eff_origin, 0);
|
||||
for(i= 0; i<optc; i++) {
|
||||
ret= Xorriso_normalize_img_path(xorriso, optv[i], eff_origin, 0);
|
||||
if(ret<=0)
|
||||
{ret= 0; goto ex;}
|
||||
if(is_dir) {
|
||||
@@ -4916,6 +5109,8 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
|
||||
ret= !was_failure;
|
||||
ex:;
|
||||
(*idx)= end_idx;
|
||||
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256);
|
||||
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &destc, &destv, 256);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -5241,13 +5436,16 @@ int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity,
|
||||
int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int *idx, int flag)
|
||||
{
|
||||
int i, end_idx, ret;
|
||||
int i, ret, end_idx;
|
||||
char path[SfileadrL], eff_path[SfileadrL];
|
||||
int optc= 0;
|
||||
char **optv= NULL;
|
||||
|
||||
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
|
||||
|
||||
for(i= *idx; i<end_idx; i++) {
|
||||
if(Sfile_str(path,argv[i],0)<=0)
|
||||
ret= Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
for(i= 0; i<optc; i++) {
|
||||
if(Sfile_str(path,optv[i],0)<=0)
|
||||
{ret= -1; goto ex;}
|
||||
if(path[0]!='/') {
|
||||
ret= Sfile_prepend_path(xorriso->wdi, 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; i<end_idx; i++)
|
||||
fprintf(stderr, "%s ", argv[i]);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
(*idx)= end_idx;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* Option -rollback */
|
||||
int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
@@ -5635,6 +5816,10 @@ next_command:;
|
||||
return(ret);
|
||||
{ret= 3; goto ex;}
|
||||
|
||||
} else if(strcmp(cmd,"-iso_rr_pattern")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_iso_rr_pattern(xorriso, arg1, 0);
|
||||
|
||||
} else if(strcmp(cmd,"-f")==0) {
|
||||
ret= Xorriso_option_f(xorriso, 0);
|
||||
|
||||
|
Reference in New Issue
Block a user