view module.h @ 66:f773c76b1f3c

Added extern C tests
author David Demelier <markand@malikania.fr>
date Wed, 09 Nov 2011 21:08:43 +0100
parents 23a3ebcbf08e
children
line wrap: on
line source

/*
 * module.h -- portable functions to manipulate dynamic libraries
 *
 * Copyright (c) 2011, David Demelier <markand@malikania.fr>
 *
 * 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 <windows.h>
#else
#include <dlfcn.h>
#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_ */