Skip to main content.
home | support | download

Back to List Archive

RE: [SWISH-E:451] RE: Only indexing certain filenames

From: David Norris <kg9ae(at)not-real.geocities.com>
Date: Fri Aug 14 1998 - 11:05:35 GMT
Well.  I like the idea of adding filenames to the IndexOnly directive.  That
seems like a good thing, anyway.

Meanwhile, I have added another rule to the FileRules in my copy of SWISH-E.
FileRules filename must contain  Someone suggested yesterday that reversing
the logic would make the FileRules work the opposite.  Well, not quite true.
Or, NOT NOT NOT quite true.  I am unsure which?

Anyway, this:
if (!strcmp(dp->d_name, tmplist->line))

Doesn't act the opposite of this:
if (strcmp(dp->d_name, tmplist->line))

Well, actually it almost does.  The problem lies somewhere in the code that
parses each directory.  Or, my understanding of it.

When I use:
if (!strcmp(dp->d_name, tmplist->line))

it will run through each filename in the current directory and all
subdirectories checking for files to add to the list of files to index.

However, when I use:
if (strcmp(dp->d_name, tmplist->line))

it will run through each filename in the current directory checking for
files to add to the list of files to index.  Subdirectories do not follow
the rules, as it were.  Can someone tell me why?  I am sure this is simple.
I will continue to run around the code.  (Which has hideous [mostly
nonexistent] source comments, for those whom haven't tried to figure out how
this thing works.)

I have covered all of the obvious problems.  Before anyone asks, I have
added the filemustlist variable to the SWLINE structure in the swish.h.
And, I even bothered to intialize the value of filemustlist to NULL in the
main routine in swish.c.  My code works great in the current directory.  So,
here are some modification excerpts from the index.c file.  This is the
first real look I have had at the indexing code.  So, I am, hopefully,
missing something simple.  I hope you can figure out where this code goes in
the file ;)  I can't seem to get MSVC++ to give me line numbers.

/**** Begin - David L Norris 08-13-1998 - Added a filename limiter ***/
                badfile = 0;
                tmplist = filemustlist;
				while (tmplist != NULL) {
                        if (!lstrstr(dp->d_name, tmplist->line)) {
                                badfile = 1;
								break;
                        }
                        tmplist = tmplist->next;
                }
				if (badfile)
					continue;

/**** End - David L Norris 08-13-1998 - Added a filename limiter ***/

/**** Begin - David L Norris 08-13-1998 - Added a filename limiter ***/
        badfile = 0;
        tmplist = filemustlist;
        while (tmplist != NULL) {
                if (!lstrstr(path, tmplist->line)) {
                        badfile = 1;
                        break;
                }
                tmplist = tmplist->next;
        }
        if (badfile)
                return;
/**** End - David L Norris 08-13-1998 - Added a filename limiter ***/

And, of course, this was added to the file.c:

/**** Begin - David L Norris 08-13-1998 - Added a filename limiter ***/
               else if ((c = (char *) lstrstr(line, "filename must
contain")) &&
		(char *) lstrstr(line, "FileRules")) {
                        c += strlen("filename must contain");
                        while (1) {
                                strcpy(value, (char *) getword(c,
&skiplen));
                                if (!skiplen | value[0] == '\0' ||
                                value[0] == '\n')
                                        break;
                                else {
                                        c += skiplen;
                                        filemustlist = (struct swline *)
                                        addswline(filemustlist, value);
                                }
                        }
                }
/**** End - David L Norris 08-13-1998 - Added a filename limiter ****/

,David Norris

World Wide Web - http://www.geocities.com/CapeCanaveral/Lab/1652/
Illusionary Web - http://illusionary.dyn.ml.org/ <-- 02:00 - 10:00 GMT
Video/Audio Phone - callto:illusionary.dyn.ml.org
Page via mail - 412039@pager.mirabilis.com
ICQ Universal Internet Number - 412039
E-Mail - kg9ae@geocities.com

-----Original Message-----
From: swish-e@sunsite.berkeley.edu
[mailto:swish-e@sunsite.berkeley.edu]On Behalf Of Mark Gaulin
Sent: Thursday, 13 August, 1998 21:24
To: Multiple recipients of list
Subject: [SWISH-E:451] RE: Only indexing certain filenames

Hi.
I like the idea you have for matching extensions and also matching file
names, when they are given in the config file. How about this
as an alternative solution: treat the items listed on the IndexOnly
line as true suffixes... a file will match if the last X characters of the
filename match one of the suffixes exactly. That way people could
specific ".html", or "html", or "index.html" and they all do what is
expected.  (But only if you expect "myindex.html" to match.)

My implementation left in one odd behavior from the original
implementation, and that is any filename with no dot in it is rejected,
even if it would have matched a suffix. I figure that changing
that would cause someone some grief, so I left it alone, although
I bet it is just an optimization.

I'm collecting these changes together and plan on posting them all
soon (for NT). I've gotten a little feedback on the other mods I made and
so far so good.
	Mark
Received on Fri Aug 14 04:16:47 1998