[Initng-svn] r3998 - initng/trunk/src
svn at initng.thinktux.net
svn at initng.thinktux.net
Thu May 4 09:23:36 CEST 2006
Author: jimmy
Date: Thu May 4 09:23:34 2006
New Revision: 3998
Modified:
initng/trunk/src/initng_string_tools.c
Log:
This seems to work, and i can figure out why the hell the old code did exist in there.
Stripping this makes my test_parser go 0.2 sec faster, becouse match_service is really called a lot while parsing.
Modified: initng/trunk/src/initng_string_tools.c
==============================================================================
--- initng/trunk/src/initng_string_tools.c (original)
+++ initng/trunk/src/initng_string_tools.c Thu May 4 09:23:34 2006
@@ -349,10 +349,15 @@
* If string is "net/eth0" then pattern "net/et*" and pattern "net/eth?"
* should return true.
*/
+ // examples:
+ // string pattern do_match
+ // net/eth0 net/et* TRUE
+ // net/eth1 net/eth? TRUE
+ // test/abc/def test/*/* TRUE
+ // daemon/test daemon/*/* FALSE
+
int service_match(const char *string, const char *pattern)
{
- char *service_mask = NULL;
-
assert(string);
assert(pattern);
D_("matching string: \"%s\", to pattern: \"%s\"\n", string, pattern);
@@ -365,11 +370,16 @@
return (FALSE);
}
+ /* use fnmatch that shud serve us well as these matches looks like filename matching */
+ return(fnmatch(pattern, string, FNM_CASEFOLD) == 0);
+
+#ifdef ABOW_DOES_NOT_WORK
+ char *service_mask = NULL;
+
/* if existing service is a pattern */
if (strchr(pattern, '*') || strchr(pattern, '?'))
{
if (fnmatch(pattern, string, FNM_CASEFOLD) == 0)
-
{
/* found */
return (TRUE);
@@ -377,6 +387,7 @@
}
/* create service name mask for pattern matching */
+ D_("Creating a pattern mask: \"%s\", \"%s\"\n", string, pattern);
service_mask = i_calloc(strlen(string) + 3, sizeof(char));
assert(service_mask);
@@ -385,6 +396,7 @@
if (fnmatch(service_mask, pattern, FNM_CASEFOLD) == 0)
{
+ F_("REPORT: fnmach with pattern mask succeded, but not abow: service_match(%s, %s) pattern: %s\n", string, pattern, service_mask);
free(service_mask);
return (TRUE);
}
@@ -392,9 +404,9 @@
/* did not find any */
free(service_mask);
return (FALSE);
+#endif
}
-
/*
* mprintf, a sprintf clone that automaticly mallocs the string
* and new content to same string applys after that content.
More information about the Initng-svn
mailing list