New options -not_paths, -not_leaf, -not_list, -not_mgt, -as mkisofs -m,

This commit is contained in:
2008-05-04 13:36:15 +00:00
parent 1666ca358e
commit e7cb508cd8
3 changed files with 147 additions and 117 deletions

View File

@ -1857,115 +1857,6 @@ int Lstring_destroy_all(struct LstrinG **lstring, int flag)
}
/*
@param flag Bitfield for control purposes
bit0= return first lstring which begins with text
bit1= do not rewind list before starting to search
bit2= advance to lstring->next before starting to search
*/
int Lstring_find_text(struct LstrinG *lstring, char *text,
struct LstrinG **found, int flag)
{
struct LstrinG *s;
if(lstring==NULL)
return(0);
if(!(flag&2))
for(s= lstring; s->prev!=NULL; s= s->prev);
else
s= lstring;
if(flag&4)
if(s!=NULL)
s= s->next;
if(flag&1) {
for(;s!=NULL;s= s->next)
if(strncmp(s->text,text,strlen(text))==0)
{*found= s; return(1);}
} else {
for(;s!=NULL;s= s->next)
if(strcmp(s->text,text)==0)
{*found= s; return(1);}
}
return(0);
}
/*
@param flag Bitfield for control purposes
bit0= return first lstring which begins with text
bit1= do not rewind list before starting to search
bit2= advance to lstring->next before starting to search
*/
int Lstring_is_listed(struct LstrinG *lstring, char *text, int flag)
{
struct LstrinG *s;
int ret;
ret= Lstring_find_text(lstring,text,&s,flag&7);
return(ret);
}
int Lstring_copy_all(source,target,flag)
struct LstrinG *source;
struct LstrinG **target;
int flag;
{
struct LstrinG *s,*t;
if(source==NULL)
return(0);
for(s= source; s->prev!=NULL; s= s->prev);
t= *target;
if(t!=NULL)
for(;t->next!=NULL;t=t->next);
for(;s!=NULL;s= s->next){
if(Lstring_new(&t,s->text,t,0)<=0)
return(-1);
if((*target)==NULL)
*target= t;
}
return(1);
}
int Lstring_append(struct LstrinG *entry, char *text, int flag)
{
struct LstrinG *target= NULL,*newby;
if(entry!=NULL)
for(target= entry; target->next!=NULL; target= target->next);
if(Lstring_new(&newby,text,target,0)<=0)
return(-1);
return(1);
}
int Lstring_revert(struct LstrinG **start, int flag)
{
struct LstrinG *current,*last,*tr,*next;
if((*start)==NULL)
return(0);
for(current= *start; current!=NULL; current= next) {
next= current->next;
last= current;
tr= current->next;
current->next= current->prev;
current->prev= tr;
}
last->prev= (*start)->next;
(*start)->next= NULL;
*start= last;
return(1);
}
/* Not imported from stic/src/sregex.c :
int Lstring_from_separator_list(result,list_text,link,sep,flag)
*/
int Lstring_append_binary(struct LstrinG **entry, char *data, int data_len,
int flag)
{
@ -7046,7 +6937,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
int argc, char **argv, int flag)
{
int ret, i, k, was_path= 0, was_other_option= 0, mem_graft_points;
int do_print_size= 0, idx_offset= 0, fd;
int do_print_size= 0, idx_offset= 0, fd, idx;
char sfe[5*SfileadrL], adr[SfileadrL+8], ra_text[80], pathspec[2*SfileadrL];
char *ept, *add_pt, eff_path[SfileadrL];
@ -7074,6 +6965,9 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
" -J, -joliet Generate Joliet directory information",
" -no-pad Do not pad output",
" -o FILE, -output FILE Set output file name",
" -m GLOBFILE, -exclude GLOBFILE",
" Exclude file name",
" -exclude-list FILE File with list of file names to exclude",
" -pad Pad output by 300k (default)",
" -path-list FILE File with list of pathnames to process",
" -print-size Print estimated filesystem size and exit",
@ -7106,7 +7000,6 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
fsync(fd);
Xorriso_option_version(xorriso, 0);
/* >>> this would need a ban to write images to stdout */;
} else if(strcmp(argv[i], "-o")==0 || strcmp(argv[i], "-output")==0) {
if(i+1>=argc)
goto not_enough_args;
@ -7233,6 +7126,25 @@ not_enough_args:;
ret= Xorriso_option_publisher(xorriso, argv[i], 0);
if(ret<=0)
goto ex;
} else if(strcmp(argv[i], "-m")==0 || strcmp(argv[i], "-exclude")==0 ||
strcmp(argv[i], "-x")==0 || strcmp(argv[i], "-old-exclude")==0) {
if(i+1>=argc)
goto not_enough_args;
i++;
if(strchr(argv[i], '/')!=NULL) {
idx= i;
ret= Xorriso_option_not_paths(xorriso, i+1, argv, &idx, 0);
} else
ret= Xorriso_option_not_leaf(xorriso, argv[i], 0);
if(ret<=0)
goto ex;
} else if(strcmp(argv[i], "-exclude-list")==0) {
if(i+1>=argc)
goto not_enough_args;
i++;
ret= Xorriso_option_not_leaf(xorriso, argv[i], 0);
if(ret<=0)
goto ex;
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-quiet")==0) {
/* was already handled in first argument scan */;
@ -9111,7 +9023,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" filesystem into the ISO image. Much like mkisofs.",
" -add_plainly \"none\"|\"unknown\"|\"dashed\"|\"any\"",
" Whether to add lonely arguments as pathspec resp. disk_path.",
" -path-list disk_path",
" -path_list disk_path",
" Like -add but read the pathspecs from file disk_path.",
"",
" -update disk_path iso_rr_path",
@ -9172,6 +9084,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Add the given paths to the list of excluded absolute paths.",
" -not_leaf pattern",
" Add the given pattern to the list of leafname exclusions.",
" -not_list disk_path",
" Read lines from disk_path and use as -not_paths (with \"/\")",
" or as -not_leaf (without \"/\").",
" -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\"",
@ -9758,6 +9673,61 @@ cannot_add:;
}
/* Option -not_list */
int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag)
{
int ret, linecount= 0, insertcount= 0, null= 0;
FILE *fp= NULL;
char *argpt, sfe[5*SfileadrL], line[SfileadrL];
Xorriso_pacifier_reset(xorriso, 0);
if(adr[0]==0) {
sprintf(xorriso->info_text,"Empty file name given with -not_list");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
return(0);
}
fp= Afile_fopen(adr,"rb",((!!xorriso->packet_output)<<6));
if(fp==NULL)
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;
}
goto ex;
}
linecount++;
if(line[0]==0)
continue;
if(strchr(line, '/')!=NULL) {
argpt= line;
null= 0;
ret= Xorriso_option_not_paths(xorriso, 1, &argpt, &null, 0);
} else
ret= Xorriso_option_not_leaf(xorriso, line, 0);
if(ret<=0)
goto ex;
insertcount++;
}
ret= 1;
ex:;
if(fp!=NULL)
fclose(fp);
if(ret<=0) {
sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d",
Text_shellsafe(adr, sfe, 0), linecount);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
}
sprintf(xorriso->info_text, "Added %d exclusion list items from file %s\n",
insertcount, Text_shellsafe(adr, sfe, 0));
Xorriso_info(xorriso,0);
return(ret);
}
/* Option -not_mgt */
int Xorriso_option_not_mgt(struct XorrisO *xorriso, char *setting, int flag)
{
@ -10059,6 +10029,8 @@ problem_handler:;
}
ret= 1;
ex:;
if(fp!=NULL)
fclose(fp);
Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
xorriso->pacifier_total, "", 1);
if(ret<=0) {
@ -11064,6 +11036,10 @@ next_command:;
(*idx)++;
ret= Xorriso_option_not_leaf(xorriso, arg1, 0);
} else if(strcmp(cmd,"not_list")==0) {
(*idx)++;
ret= Xorriso_option_not_list(xorriso, arg1, 0);
} else if(strcmp(cmd,"not_mgt")==0) {
(*idx)++;
ret= Xorriso_option_not_mgt(xorriso, arg1, 0);