r25042: Avoid direct references to global loadparm context.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 8 Sep 2007 21:06:57 +0000 (21:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:05:46 +0000 (15:05 -0500)
(This used to be commit 256532ab4b772c5c38bc7ced21408f3ed42fe6b5)

source4/param/loadparm.c

index 6c3dee239b32db2b814ca79cf83112a7d724bde7..2dbf7cd60ad07593a59bbbb2e51861d9cbb8a054 100644 (file)
@@ -2539,26 +2539,10 @@ struct loadparm_service *lp_servicebynum(int snum)
 }
 
 struct loadparm_service *lp_service(const char *service_name)
-{
-       int snum = lp_servicenumber(service_name);
-       if (snum < 0)
-               return NULL;
-       return loadparm.ServicePtrs[snum];
-}
-
-/***************************************************************************
-Return the number of the service with the given name, or -1 if it doesn't
-exist. Note that this is a DIFFERENT ANIMAL from the internal function
-getservicebyname()! This works ONLY if all services have been loaded, and
-does not copy the found service.
-***************************************************************************/
-
-int lp_servicenumber(const char *pszServiceName)
 {
        int iService;
         char *serviceName;
  
        for (iService = loadparm.iNumServices - 1; iService >= 0; iService--) {
                if (loadparm.ServicePtrs[iService] && 
                    loadparm.ServicePtrs[iService]->szService) {
@@ -2568,17 +2552,16 @@ int lp_servicenumber(const char *pszServiceName)
                         */
                        serviceName = standard_sub_basic(loadparm.ServicePtrs[iService],
                                                         loadparm.ServicePtrs[iService]->szService);
-                       if (strequal(serviceName, pszServiceName))
-                               break;
+                       if (strequal(serviceName, service_name))
+                               return loadparm.ServicePtrs[iService];
                }
        }
 
-       if (iService < 0)
-               DEBUG(7,("lp_servicenumber: couldn't find %s\n", pszServiceName));
-
-       return iService;
+       DEBUG(7,("lp_servicenumber: couldn't find %s\n", service_name));
+       return NULL;
 }
 
+
 /*******************************************************************
  A useful volume label function. 
 ********************************************************************/