home *** CD-ROM | disk | FTP | other *** search
- /*
- Stuff 2.0.
-
- Checksum: 2711816906 (verify with "brik")
-
- I claim no copyright over the contents of this file -- Rahul Dhesi
- */
-
- #include <stddef.h> /* NULL */
- #include <string.h>
- #include "stuff.h"
-
- #if 1
- int tolower (char c)
- {
- if (c >= 'A' && c <= 'Z')
- return (c - ('A' - 'a'));
- else
- return (c);
- }
-
- char *strlwr (char *str)
- {
- char *p;
- for (p = str; *p; p++)
- *p = tolower(*p);
- return (str);
- }
- #else
- #include <ctype.h>
- #endif
-
- /*
- matchstr() compares a pattern with a string using * and ? wildcards.
-
- Originally written by Jeff Damens of Columbia University Center for
- Computing Activities. Taken from the source code for C-Kermit version
- 4C.
- */
-
- int matchstr (register char *string, register char *pattern)
- {
- char *psave,*ssave; /* back up pointers for failure */
- psave = ssave = NULL;
- while (1) {
- for (;
- tolower(*pattern) == tolower(*string);
- pattern++,string++ ) /* skip first */
-
- if (*string == '\0')
- return(1); /* end of strings, succeed */
- if (*string != '\0' && *pattern == '?') {
- pattern++; /* '?', let it match */
- string++;
- } else if (*pattern == '*') { /* '*' ... */
- psave = ++pattern; /* remember where we saw it */
- ssave = string; /* let it match 0 chars */
- } else if (ssave != NULL && *ssave != '\0') { /* if not at end */
- /* ...have seen a star */
- string = ++ssave; /* skip 1 char from string */
- pattern = psave; /* and back up pattern */
- } else
- return(0); /* otherwise just fail */
- }
- }
-