# HG changeset patch # User David Demelier # Date 1322647684 -3600 # Node ID 1dcf1b92fc46fdd6194433154d864cae680e2382 # Parent 6a9ff80949f5ccd16dac93544f515bd3ba561aee Remove abandonned module diff -r 6a9ff80949f5 -r 1dcf1b92fc46 module.c --- a/module.c Wed Nov 30 11:04:29 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * module.c -- portable functions to manipulate dynamic libraries - * - * Copyright (c) 2011, David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include "module.h" - -struct module * -module_load(const char *path, int flags) -{ - struct module *mod; - - if ((mod = malloc(sizeof (struct module))) == NULL) - return NULL; - - /* Flags are not supported on Windows */ -#if defined(_WIN32) || defined(__WIN32__) - (void) flags; - mod->handler = LoadLibrary(path); -#else - mod->handler = dlopen(path, flags); -#endif - - if (!(mod->handler)) { - module_free(mod); - return NULL; - } - - return mod; -} - -int -module_find(struct module *mod, const char *sym) -{ -#if defined(_WIN32) || defined(__WIN32__) - mod->sym = GetProcAddress(mod->handler, sym); -#else - mod->sym = dlsym(mod->handler, sym); -#endif - - if (!(mod->sym)) - return -1; - - return 0; -} - -void -module_free(struct module *mod) -{ -#if defined(_WIN32) || defined(__WIN32__) - FreeLibrary(mod->handler); -#else - dlclose(mod->handler); -#endif - - free(mod); -} diff -r 6a9ff80949f5 -r 1dcf1b92fc46 module.h --- a/module.h Wed Nov 30 11:04:29 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * module.h -- portable functions to manipulate dynamic libraries - * - * Copyright (c) 2011, David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MODULE_H_ -#define _MODULE_H_ - -#if defined(_WIN32) || defined(__WIN32__) -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Unsupported on windows */ -#if defined(_WIN32) || defined(__WIN32__) -#define MOD_LAZY 1 -#define MOD_NOW 1 -#else -#define MOD_LAZY RTLD_LAZY -#define MOD_NOW RTLD_NOW -#endif - -struct module { -#if defined(_WIN32) || defined(__WIN32__) - HMODULE handler; - FARPROC sym; -#else - void *handler; - void *sym; -#endif -}; - -struct module *module_load(const char *, int); -int module_find(struct module *, const char *); -void module_free(struct module *); - -#ifdef __cplusplus -} -#endif - -#endif /* _MODULE_H_ */