aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-14 17:07:32 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-14 17:07:32 +0000
commit5e4b2db3dbdf0ff1ef8e0bfa817b7588015e412c (patch)
tree9dabe9c71ebbdb67f1c56fb97b780a5a823d132f /libbb
parenta22cdd2b4b32287b1e486cd80381e9edce438cc9 (diff)
downloadbusybox-w32-5e4b2db3dbdf0ff1ef8e0bfa817b7588015e412c.tar.gz
busybox-w32-5e4b2db3dbdf0ff1ef8e0bfa817b7588015e412c.tar.bz2
busybox-w32-5e4b2db3dbdf0ff1ef8e0bfa817b7588015e412c.zip
Per suggestion from Vladimir, eliminate check_wildcard_match(), which
was only being used by insmod these days. Also, I spent a minute adjusting insmod so that it first searches /lib/modules/`uname -r` and then (if that fails) searches /lib/modules, which makes bb insmod behave much more like the real insmod, and should avoid nasty surprises (such as the recent "Modutils vs. Busybox..." thread). -Erik git-svn-id: svn://busybox.net/trunk/busybox@2634 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/check_wildcard_match.c141
-rw-r--r--libbb/libbb.h1
2 files changed, 0 insertions, 142 deletions
diff --git a/libbb/check_wildcard_match.c b/libbb/check_wildcard_match.c
deleted file mode 100644
index ab856797b..000000000
--- a/libbb/check_wildcard_match.c
+++ /dev/null
@@ -1,141 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) tons of folks. Tracking down who wrote what
6 * isn't something I'm going to worry about... If you wrote something
7 * here, please feel free to acknowledge your work.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
24 * Permission has been granted to redistribute this code under the GPL.
25 *
26 */
27
28#include <stdio.h>
29#include <string.h>
30#include "libbb.h"
31
32
33/*
34 * Routine to see if a text string is matched by a wildcard pattern.
35 * Returns TRUE if the text is matched, or FALSE if it is not matched
36 * or if the pattern is invalid.
37 * * matches zero or more characters
38 * ? matches a single character
39 * [abc] matches 'a', 'b' or 'c'
40 * \c quotes character c
41 * Adapted from code written by Ingo Wilken, and
42 * then taken from sash, Copyright (c) 1999 by David I. Bell
43 * Permission is granted to use, distribute, or modify this source,
44 * provided that this copyright notice remains intact.
45 * Permission to distribute this code under the GPL has been granted.
46 */
47extern int check_wildcard_match(const char *text, const char *pattern)
48{
49 const char *retryPat;
50 const char *retryText;
51 int ch;
52 int found;
53 int len;
54
55 retryPat = NULL;
56 retryText = NULL;
57
58 while (*text || *pattern) {
59 ch = *pattern++;
60
61 switch (ch) {
62 case '*':
63 retryPat = pattern;
64 retryText = text;
65 break;
66
67 case '[':
68 found = FALSE;
69
70 while ((ch = *pattern++) != ']') {
71 if (ch == '\\')
72 ch = *pattern++;
73
74 if (ch == '\0')
75 return FALSE;
76
77 if (*text == ch)
78 found = TRUE;
79 }
80 len=strlen(text);
81 if (found == FALSE && len!=0) {
82 return FALSE;
83 }
84 if (found == TRUE) {
85 if (strlen(pattern)==0 && len==1) {
86 return TRUE;
87 }
88 if (len!=0) {
89 text++;
90 continue;
91 }
92 }
93
94 /* fall into next case */
95
96 case '?':
97 if (*text++ == '\0')
98 return FALSE;
99
100 break;
101
102 case '\\':
103 ch = *pattern++;
104
105 if (ch == '\0')
106 return FALSE;
107
108 /* fall into next case */
109
110 default:
111 if (*text == ch) {
112 if (*text)
113 text++;
114 break;
115 }
116
117 if (*text) {
118 pattern = retryPat;
119 text = ++retryText;
120 break;
121 }
122
123 return FALSE;
124 }
125
126 if (pattern == NULL)
127 return FALSE;
128 }
129
130 return TRUE;
131}
132
133
134/* END CODE */
135/*
136Local Variables:
137c-file-style: "linux"
138c-basic-offset: 4
139tab-width: 4
140End:
141*/
diff --git a/libbb/libbb.h b/libbb/libbb.h
index fde58b0a6..02cf607a7 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -127,7 +127,6 @@ extern void mtab_read(void);
127extern char *mtab_first(void **iter); 127extern char *mtab_first(void **iter);
128extern char *mtab_next(void **iter); 128extern char *mtab_next(void **iter);
129extern char *mtab_getinfo(const char *match, const char which); 129extern char *mtab_getinfo(const char *match, const char which);
130extern int check_wildcard_match(const char* text, const char* pattern);
131extern long atoi_w_units (const char *cp); 130extern long atoi_w_units (const char *cp);
132extern pid_t* find_pid_by_name( char* pidName); 131extern pid_t* find_pid_by_name( char* pidName);
133extern int find_real_root_device_name(char* name); 132extern int find_real_root_device_name(char* name);