+Thu Apr 27 14:21:30 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * setup.c (findhref): Return NULL on empty string. Eat any trailing
+ ";something".
+ (processdirlisting): Attempt to limit recursively processing the same
+ directory.
+
Thu Apr 27 11:42:23 2000 Christopher Faylor <cgf@cygnus.com>
* setup.c (filedel): New function.
{
char *ref = NULL;
char *anchor;
- char *p = buffer;
-
+ char *p;
+ int eatspace;
+ char *q;
+ char digits[20];
+ char *diglast = digits + sizeof (digits) - 1;
+ int len;
+
+ p = buffer;
while ((p = strchr (p, '<')) != NULL)
{
char *q = p;
}
}
- if (ref)
- {
- int eatspace;
- char *p, *q;
- char digits[20];
- char *diglast = digits + sizeof (digits) - 1;
- int len;
-
- ref += ref[5] == '"' ? 6 : 5;
-
- len = strcspn (ref, "\" >");
-
- ref[len] = '\0';
- if (!filesize)
- return ref;
-
- *filesize = 0;
-
- if (anchor == buffer || !isspace (anchor[-1]))
- return ref;
-
- eatspace = 1;
- *diglast = '\0';
- for (p = anchor, q = diglast; --p >= buffer; )
- if (!isspace (*p))
- {
- eatspace = 0;
- if (isdigit (*p))
- *--q = *p;
- }
- else if (!eatspace)
- break;
-
- if (q < diglast)
- *filesize = atoi (q);
- }
+ if (!ref)
+ return NULL;
+
+ ref += ref[5] == '"' ? 6 : 5;
+
+ len = strcspn (ref, "\" >");
+
+ ref[len] = '\0';
+ if (!filesize)
+ goto out;
- return ref;
+ *filesize = 0;
+
+ if (anchor == buffer || !isspace (anchor[-1]))
+ goto out;
+
+ eatspace = 1;
+ *diglast = '\0';
+ for (p = anchor, q = diglast; --p >= buffer; )
+ if (!isspace (*p))
+ {
+ eatspace = 0;
+ if (isdigit (*p))
+ *--q = *p;
+ }
+ else if (!eatspace)
+ break;
+
+ if (q < diglast)
+ *filesize = atoi (q);
+
+out:
+ if (!*ref)
+ return NULL;
+ /* This effectively disallows using a ';' in a file name. Hopefully,
+ this will not be an issue. */
+ if ((p = strrchr (ref, ';')) != NULL)
+ *p = '\0';
+ return *ref ? ref : NULL;
}
static int
processdirlisting (const char *urlbase, const char *file)
{
int retval = 0;
- char buffer[256];
+ char buffer[4096];
static enum {UNKNOWN, ALWAYS, NEVER} download_when = {UNKNOWN};
+ size_t urllen = strlen (urlbase);
FILE *in = fopen (file, "rt");
warning ("Unable to download from %s", ref);
winerror ();
}
+ else if (strlen (url) == urllen || strnicmp (urlbase, url, urllen) != 0)
+ continue;
else if (ref[strlen (ref) - 1] == '/')
{
if (strcmp (url + strlen (url) - 2, "./") != 0)