From 82037a75eae9deaf6ec80b5ecc3bb89aab6e6dd8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 30 Aug 2007 23:15:12 +0000 Subject: r24814: Fix headers, trim core.h even more. (This used to be commit 9647f860bdd5c0a74583e886182bd041a45e7655) --- source4/lib/util/config.mk | 1 - source4/lib/util/module.c | 111 --------------------------------------------- source4/lib/util/util.h | 45 +++++++++--------- 3 files changed, 23 insertions(+), 134 deletions(-) delete mode 100644 source4/lib/util/module.c (limited to 'source4/lib/util') diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk index 0912c897db..702e3df5aa 100644 --- a/source4/lib/util/config.mk +++ b/source4/lib/util/config.mk @@ -27,7 +27,6 @@ OBJ_FILES = xfile.o \ ms_fnmatch.o \ mutex.o \ idtree.o \ - module.o \ become_daemon.o PUBLIC_DEPENDENCIES = \ LIBTALLOC LIBCRYPTO \ diff --git a/source4/lib/util/module.c b/source4/lib/util/module.c deleted file mode 100644 index 170ea0bacb..0000000000 --- a/source4/lib/util/module.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Jelmer Vernooij 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file - * @brief Module initialization function handling - */ - -#include "includes.h" -#include "system/dir.h" - -/** - * Obtain the init function from a shared library file - */ -_PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path) -{ - void *handle; - void *init_fn; - - handle = dlopen(path, RTLD_NOW); - if (handle == NULL) { - DEBUG(0, ("Unable to open %s: %s\n", path, dlerror())); - return NULL; - } - - init_fn = dlsym(handle, "init_module"); - - if (init_fn == NULL) { - DEBUG(0, ("Unable to find init_module() in %s: %s\n", path, dlerror())); - DEBUG(1, ("Loading module '%s' failed\n", path)); - dlclose(handle); - return NULL; - } - - return (init_module_fn)init_fn; -} - -/** - * Obtain list of init functions from the modules in the specified - * directory - */ -_PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) -{ - DIR *dir; - struct dirent *entry; - char *filename; - int success = 0; - init_module_fn *ret = talloc_array(mem_ctx, init_module_fn, 2); - - ret[0] = NULL; - - dir = opendir(path); - if (dir == NULL) { - talloc_free(ret); - return NULL; - } - - while((entry = readdir(dir))) { - if (ISDOT(entry->d_name) || ISDOTDOT(entry->d_name)) - continue; - - filename = talloc_asprintf(mem_ctx, "%s/%s", path, entry->d_name); - - ret[success] = load_module(mem_ctx, filename); - if (ret[success]) { - ret = talloc_realloc(mem_ctx, ret, init_module_fn, success+2); - success++; - ret[success] = NULL; - } - - talloc_free(filename); - } - - closedir(dir); - - return ret; -} - -/** - * Run the specified init functions. - * - * @return true if all functions ran successfully, false otherwise - */ -_PUBLIC_ bool run_init_functions(NTSTATUS (**fns) (void)) -{ - int i; - bool ret = true; - - if (fns == NULL) - return true; - - for (i = 0; fns[i]; i++) { ret &= (bool)NT_STATUS_IS_OK(fns[i]()); } - - return ret; -} diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index 0c784d1c97..8259e08512 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -254,6 +254,14 @@ void CatchChildLeaveStatus(void); /* The following definitions come from lib/util/system.c */ +/* + we use struct ipv4_addr to avoid having to include all the + system networking headers everywhere +*/ +struct ipv4_addr { + uint32_t addr; +}; + /************************************************************************** A wrapper for gethostbyname() that tries avoids looking up hostnames in the root domain, which can cause dial-on-demand links to come up for no @@ -769,6 +777,21 @@ _PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize); * @file * @brief MS-style Filename matching */ + +/* protocol types. It assumes that higher protocols include lower protocols + as subsets. FIXME: Move to one of the smb-specific headers */ +enum protocol_types { + PROTOCOL_NONE, + PROTOCOL_CORE, + PROTOCOL_COREPLUS, + PROTOCOL_LANMAN1, + PROTOCOL_LANMAN2, + PROTOCOL_NT1, + PROTOCOL_SMB2 +}; + + + int ms_fnmatch(const char *pattern, const char *string, enum protocol_types protocol); /** a generic fnmatch function - uses for non-CIFS pattern matching */ @@ -820,30 +843,8 @@ _PUBLIC_ void *idr_find(struct idr_context *idp, int id); */ _PUBLIC_ int idr_remove(struct idr_context *idp, int id); -/* The following definitions come from lib/util/module.c */ - - -/** - * Obtain the init function from a shared library file - */ -_PUBLIC_ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path); - -/** - * Obtain list of init functions from the modules in the specified - * directory - */ -_PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path); - -/** - * Run the specified init functions. - * - * @return true if all functions ran successfully, false otherwise - */ -_PUBLIC_ bool run_init_functions(NTSTATUS (**fns) (void)); - /* The following definitions come from lib/util/become_daemon.c */ - /** Become a daemon, discarding the controlling terminal. **/ -- cgit