Remove USE_FIND
I think what that code is doing is to parse a find-like command and running a search on the file list from the ISO. This is not what I want, I don't even want to store the file list anywhere, instead I want to call a functor for each file and directory being read and keep the code as stateless as possible. So delete everything here.
This commit is contained in:
parent
35b4e24e98
commit
7cd14d52ec
2 changed files with 2 additions and 167 deletions
|
@ -11,7 +11,6 @@ project('isoinfo', 'c',
|
||||||
|
|
||||||
add_project_arguments(
|
add_project_arguments(
|
||||||
'-DUSE_SCG',
|
'-DUSE_SCG',
|
||||||
'-DUSE_FIND',
|
|
||||||
'-DUSE_ICONV',
|
'-DUSE_ICONV',
|
||||||
'-DUSE_LIBSCHILY',
|
'-DUSE_LIBSCHILY',
|
||||||
'-DUSE_LARGEFILES',
|
'-DUSE_LARGEFILES',
|
||||||
|
|
|
@ -68,10 +68,6 @@ static UConst char sccsid[] =
|
||||||
|
|
||||||
#include <schily/siconv.h>
|
#include <schily/siconv.h>
|
||||||
#include <schily/io.h> /* for setmode() prototype */
|
#include <schily/io.h> /* for setmode() prototype */
|
||||||
#ifdef USE_FIND
|
|
||||||
#include <schily/walk.h>
|
|
||||||
#include <schily/find.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we have a definition for this. If not, take a very conservative
|
* Make sure we have a definition for this. If not, take a very conservative
|
||||||
|
@ -133,11 +129,6 @@ EXPORT BOOL ignerr = FALSE;
|
||||||
LOCAL int use_rock = 0;
|
LOCAL int use_rock = 0;
|
||||||
LOCAL int use_joliet = 0;
|
LOCAL int use_joliet = 0;
|
||||||
LOCAL int do_f = 0;
|
LOCAL int do_f = 0;
|
||||||
LOCAL int do_find = 0;
|
|
||||||
LOCAL int find_ac = 0; /* ac past -find option */
|
|
||||||
LOCAL char *const *find_av = NULL; /* av past -find option */
|
|
||||||
LOCAL int find_pac = 0; /* ac for first find primary */
|
|
||||||
LOCAL char *const *find_pav = NULL; /* av for first find primary */
|
|
||||||
LOCAL int do_sectors = 0;
|
LOCAL int do_sectors = 0;
|
||||||
LOCAL BOOL debug = FALSE;
|
LOCAL BOOL debug = FALSE;
|
||||||
LOCAL char *xtract = 0;
|
LOCAL char *xtract = 0;
|
||||||
|
@ -151,18 +142,6 @@ LOCAL int ucs_level = 0;
|
||||||
LOCAL BOOL iso9660_inodes = FALSE;
|
LOCAL BOOL iso9660_inodes = FALSE;
|
||||||
LOCAL uid_t myuid;
|
LOCAL uid_t myuid;
|
||||||
|
|
||||||
#ifdef USE_FIND
|
|
||||||
LOCAL findn_t *find_node; /* syntaxtree from find_parse() */
|
|
||||||
LOCAL void *plusp; /* residual for -exec ...{} + */
|
|
||||||
LOCAL int find_patlen; /* len for -find pattern state */
|
|
||||||
LOCAL BOOL find_print = FALSE; /* -print or -ls primary found */
|
|
||||||
|
|
||||||
LOCAL int walkflags = WALK_CHDIR | WALK_PHYS | WALK_NOEXIT;
|
|
||||||
LOCAL int maxdepth = -1;
|
|
||||||
LOCAL int mindepth = -1;
|
|
||||||
LOCAL struct WALK walkstate;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LOCAL struct stat fstat_buf;
|
LOCAL struct stat fstat_buf;
|
||||||
LOCAL int found_rr;
|
LOCAL int found_rr;
|
||||||
LOCAL char name_buf[256*3];
|
LOCAL char name_buf[256*3];
|
||||||
|
@ -224,12 +203,6 @@ LOCAL void list_locales __PR((void));
|
||||||
LOCAL int time_cvt __PR((unsigned char *dp, int len));
|
LOCAL int time_cvt __PR((unsigned char *dp, int len));
|
||||||
LOCAL time_t iso9660_time __PR((unsigned char *date, int *hsecp,
|
LOCAL time_t iso9660_time __PR((unsigned char *date, int *hsecp,
|
||||||
BOOL longfmt));
|
BOOL longfmt));
|
||||||
#ifdef USE_FIND
|
|
||||||
LOCAL BOOL find_stat __PR((char *rootname,
|
|
||||||
struct iso_directory_record * idr,
|
|
||||||
char *fname,
|
|
||||||
int extent));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LOCAL int
|
LOCAL int
|
||||||
isonum_731(p)
|
isonum_731(p)
|
||||||
|
@ -522,14 +495,6 @@ dump_stat(rootname, idr, fname, extent)
|
||||||
int off = 0;
|
int off = 0;
|
||||||
char outline[100];
|
char outline[100];
|
||||||
|
|
||||||
if (do_find) {
|
|
||||||
if (!find_stat(rootname, idr, fname, extent))
|
|
||||||
return (FALSE);
|
|
||||||
if (find_print)
|
|
||||||
return (TRUE);
|
|
||||||
} else
|
|
||||||
return (TRUE);
|
|
||||||
|
|
||||||
memset(outline, ' ', sizeof (outline));
|
memset(outline, ' ', sizeof (outline));
|
||||||
|
|
||||||
if (fstat_buf.st_ino != 0)
|
if (fstat_buf.st_ino != 0)
|
||||||
|
@ -936,8 +901,6 @@ parse_dir(dp, rootname, extent, len)
|
||||||
struct todo *td;
|
struct todo *td;
|
||||||
int i;
|
int i;
|
||||||
struct iso_directory_record * idr;
|
struct iso_directory_record * idr;
|
||||||
struct iso_directory_record didr;
|
|
||||||
struct stat dstat;
|
|
||||||
unsigned char cl_buffer[2048];
|
unsigned char cl_buffer[2048];
|
||||||
unsigned char flags = 0;
|
unsigned char flags = 0;
|
||||||
Llong size = 0;
|
Llong size = 0;
|
||||||
|
@ -986,8 +949,6 @@ static int nlen = 0;
|
||||||
/*
|
/*
|
||||||
* The '.' entry.
|
* The '.' entry.
|
||||||
*/
|
*/
|
||||||
didr = *idr;
|
|
||||||
dstat = fstat_buf;
|
|
||||||
}
|
}
|
||||||
blen = strlen(name_buf);
|
blen = strlen(name_buf);
|
||||||
|
|
||||||
|
@ -1050,7 +1011,7 @@ static int nlen = 0;
|
||||||
(idr->name[0] != 0 && idr->name[0] != 1))) {
|
(idr->name[0] != 0 && idr->name[0] != 1))) {
|
||||||
printf("%s\n", n);
|
printf("%s\n", n);
|
||||||
}
|
}
|
||||||
if (Xtract || do_find) {
|
if (Xtract) {
|
||||||
/*
|
/*
|
||||||
* In case if a multi-extent file, remember the
|
* In case if a multi-extent file, remember the
|
||||||
* start extent number.
|
* start extent number.
|
||||||
|
@ -1083,7 +1044,7 @@ static int nlen = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Xtract && find_stat(rootname, idr, n, sextent)) {
|
} else if (Xtract) {
|
||||||
/*
|
/*
|
||||||
* Extract all multi extent files here...
|
* Extract all multi extent files here...
|
||||||
*/
|
*/
|
||||||
|
@ -1113,10 +1074,6 @@ static int nlen = 0;
|
||||||
|
|
||||||
if (nm != rootname)
|
if (nm != rootname)
|
||||||
nm++;
|
nm++;
|
||||||
if (find_stat(rootname, &didr, nm, 0)) {
|
|
||||||
fstat_buf = dstat;
|
|
||||||
extract(rootname, &didr, rootname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,8 +1082,6 @@ main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
int cac;
|
|
||||||
char * const *cav;
|
|
||||||
int c;
|
int c;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
@ -1169,67 +1124,6 @@ main(argc, argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
myuid = getuid();
|
myuid = getuid();
|
||||||
#ifdef USE_FIND
|
|
||||||
if (do_find) {
|
|
||||||
finda_t fa;
|
|
||||||
|
|
||||||
cac = find_ac;
|
|
||||||
cav = find_av;
|
|
||||||
find_firstprim(&cac, &cav);
|
|
||||||
find_pac = cac;
|
|
||||||
find_pav = cav;
|
|
||||||
|
|
||||||
if (cac > 0) {
|
|
||||||
find_argsinit(&fa);
|
|
||||||
fa.walkflags = walkflags;
|
|
||||||
fa.Argc = cac;
|
|
||||||
fa.Argv = (char **)cav;
|
|
||||||
find_node = find_parse(&fa);
|
|
||||||
if (fa.primtype == FIND_ERRARG)
|
|
||||||
comexit(fa.error);
|
|
||||||
if (fa.primtype != FIND_ENDARGS)
|
|
||||||
comerrno(EX_BAD, _("Incomplete expression.\n"));
|
|
||||||
plusp = fa.plusp;
|
|
||||||
find_patlen = fa.patlen;
|
|
||||||
walkflags = fa.walkflags;
|
|
||||||
maxdepth = fa.maxdepth;
|
|
||||||
mindepth = fa.mindepth;
|
|
||||||
|
|
||||||
if (find_node && xtract) {
|
|
||||||
if (find_pname(find_node, "-exec") ||
|
|
||||||
find_pname(find_node, "-exec+") ||
|
|
||||||
find_pname(find_node, "-ok"))
|
|
||||||
comerrno(EX_BAD,
|
|
||||||
"Cannot -exec with '-o -'.\n");
|
|
||||||
}
|
|
||||||
if (find_node && find_hasprint(find_node))
|
|
||||||
find_print = TRUE;
|
|
||||||
}
|
|
||||||
if (find_ac > find_pac) {
|
|
||||||
errmsgno(EX_BAD, _("Unsupported pathspec for -find.\n"));
|
|
||||||
}
|
|
||||||
#ifdef __not_yet__
|
|
||||||
if (find_ac <= 0 || find_ac == find_pac) {
|
|
||||||
errmsgno(EX_BAD, _("Missing pathspec for -find.\n"));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
walkinitstate(&walkstate);
|
|
||||||
if (find_patlen > 0) {
|
|
||||||
walkstate.patstate = ___malloc(sizeof (int) * find_patlen,
|
|
||||||
_("space for pattern state"));
|
|
||||||
}
|
|
||||||
|
|
||||||
find_timeinit(time(0));
|
|
||||||
walkstate.walkflags = walkflags;
|
|
||||||
walkstate.maxdepth = maxdepth;
|
|
||||||
walkstate.mindepth = mindepth;
|
|
||||||
walkstate.lname = NULL;
|
|
||||||
walkstate.tree = find_node;
|
|
||||||
walkstate.err = 0;
|
|
||||||
walkstate.pflags = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USE_NLS) && defined(HAVE_NL_LANGINFO) && defined(CODESET)
|
#if defined(USE_NLS) && defined(HAVE_NL_LANGINFO) && defined(CODESET)
|
||||||
/*
|
/*
|
||||||
|
@ -1483,19 +1377,6 @@ setcharset:
|
||||||
td = td->next;
|
td = td->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Execute all unflushed '-exec .... {} +' expressions.
|
|
||||||
*/
|
|
||||||
if (do_find) {
|
|
||||||
find_plusflush(plusp, &walkstate);
|
|
||||||
#ifdef __use_find_free__
|
|
||||||
find_free(Tree, &fa);
|
|
||||||
#endif
|
|
||||||
if (walkstate.patstate != NULL)
|
|
||||||
free(walkstate.patstate);
|
|
||||||
ret = walkstate.err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (infile != NULL)
|
if (infile != NULL)
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
return (ret);
|
return (ret);
|
||||||
|
@ -1592,48 +1473,3 @@ iso9660_time(date, hsecp, longfmt)
|
||||||
t -= gmtoff * 15 * 60;
|
t -= gmtoff * 15 * 60;
|
||||||
return (t);
|
return (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FIND
|
|
||||||
/*
|
|
||||||
* Called from dump_stat()
|
|
||||||
*/
|
|
||||||
LOCAL BOOL
|
|
||||||
find_stat(rootname, idr, fname, extent)
|
|
||||||
char *rootname;
|
|
||||||
struct iso_directory_record *idr;
|
|
||||||
char *fname;
|
|
||||||
int extent;
|
|
||||||
{
|
|
||||||
BOOL ret;
|
|
||||||
int rlen;
|
|
||||||
|
|
||||||
if (name_buf[0] == '.' && name_buf[1] == '.' && name_buf[2] == '\0')
|
|
||||||
if (find_node)
|
|
||||||
return (FALSE);
|
|
||||||
|
|
||||||
if (find_node == NULL) /* No find(1) rules */
|
|
||||||
return (TRUE); /* so pass everything */
|
|
||||||
|
|
||||||
rlen = strlen(rootname);
|
|
||||||
|
|
||||||
#ifdef HAVE_ST_BLKSIZE
|
|
||||||
fstat_buf.st_blksize = 0;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ST_BLOCKS
|
|
||||||
fstat_buf.st_blocks = (fstat_buf.st_size+1023) / DEV_BSIZE;
|
|
||||||
#endif
|
|
||||||
walkstate.lname = &xname[3];
|
|
||||||
walkstate.pflags = PF_ACL|PF_XATTR;
|
|
||||||
#ifdef XXX
|
|
||||||
if (info->f_xflags & (XF_ACL_ACCESS|XF_ACL_DEFAULT))
|
|
||||||
walkstate.pflags |= PF_HAS_ACL;
|
|
||||||
if (info->f_xflags & XF_XATTR)
|
|
||||||
walkstate.pflags |= PF_HAS_XATTR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = find_expr(fname, &fname[rlen], &fstat_buf, &walkstate, find_node);
|
|
||||||
if (!ret)
|
|
||||||
return (ret);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* USE_FIND */
|
|
||||||
|
|
Loading…
Reference in a new issue