[Initng-svn] r4052 - initng/trunk/src
svn at initng.thinktux.net
svn at initng.thinktux.net
Mon May 8 08:02:27 CEST 2006
Author: jimmy
Date: Mon May 8 08:02:26 2006
New Revision: 4052
Modified:
initng/trunk/src/initng_active_db.c
initng/trunk/src/initng_service_cache.c
Log:
Update find_in_name functions to use the new match_in_service();
Modified: initng/trunk/src/initng_active_db.c
==============================================================================
--- initng/trunk/src/initng_active_db.c (original)
+++ initng/trunk/src/initng_active_db.c Mon May 8 08:02:26 2006
@@ -140,8 +140,6 @@
active_db_h *initng_active_db_find_in_name(const char *service)
{
active_db_h *current = NULL;
- char *copy = NULL;
- int i = 0;
assert(service);
@@ -151,58 +149,17 @@
if ((current = initng_active_db_find_by_name(service)))
return (current);
- /* if the string contains a '/' it is looking for an exact match, so no searching here */
- for (i = 0; service[i]; i++)
- if (service[i] == '/')
- return (NULL);
-
- /* remove starting wildcards */
- while (service[0] == '*' || service[0] == '?')
- service++;
-
- copy = i_strdup(service);
- assert(copy);
-
- /* remove last wildcards */
- for (i = 0; copy[i]; i++)
- {
- if (copy[i] == '*' || copy[i] == '?')
- copy[i] = '\0';
- }
-
/* then search for a word match */
current = NULL;
while_active_db(current)
{
- char *see = current->name;
-
assert(current->name);
-
- /* go to end of string */
- while (see[0])
- see++;
-
- /* go back to the first '/' */
- while (see != current->name && see[0] != '/')
- see--;
-
- /* and skip that '/' char */
- if (see[0] == '/')
- see++;
-
-
- /* check if this service name is like service */
- if (strstr(see, copy))
- {
- D_("search on %s matched on %s\n", service, current->name);
- free(copy);
- return (current); /* return it */
- }
+ if(match_in_service(current->name, service))
+ return(current);
}
- free(copy);
/* did not find any */
- return NULL;
+ return(NULL);
}
/* return index of service in active data structure or -1 if not found */
Modified: initng/trunk/src/initng_service_cache.c
==============================================================================
--- initng/trunk/src/initng_service_cache.c (original)
+++ initng/trunk/src/initng_service_cache.c Mon May 8 08:02:26 2006
@@ -217,52 +217,23 @@
service_cache_h *initng_service_cache_find_in_name(const char *service)
{
service_cache_h *current = NULL;
- char *copy = NULL;
- int i = 0;
-
assert(service);
- D_("(%s);\n", service);
-
/* first search by name */
if ((current = initng_service_cache_find_by_name(service)))
return (current);
- /* Don't return any match, if the user was searching for an exact match */
- if (!strchr(service, '/'))
- return NULL;
-
- /* remove starting wildcards */
- while (service[0] == '*' || service[0] == '?')
- service++;
-
- copy = i_strdup(service);
- assert(copy);
-
- /* remove last wildcards */
- for (i = 0; copy[i]; i++)
- {
- if (copy[i] == '*' || copy[i] == '?')
- copy[i] = '\0';
- }
-
/* then search for a word match */
current = NULL;
while_service_cache(current)
{
assert(current->name);
- /* check if this service name is like service */
- if (strstr(current->name, copy))
- {
- D_("Warning, the return is not an exact match!\n");
- free(copy);
- return (current); /* return it */
- }
+ if(match_in_service(current->name, service))
+ return(current);
}
- free(copy);
/* did not find any */
- return NULL;
+ return(NULL);
}
/*
More information about the Initng-svn
mailing list