ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/plugin.h
(Generate patch)

Comparing deliantra/server/include/plugin.h (file contents):
Revision 1.14 by root, Tue Aug 29 05:03:55 2006 UTC vs.
Revision 1.17 by root, Sun Jul 1 05:00:18 2007 UTC

1/*****************************************************************************/ 1/*
2/* Crossfire plugin support - (C) 2001 by Yann Chachkoff. */ 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3/* This code is placed under the GPL. */ 3 *
4/*****************************************************************************/ 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22 */
5 23
6/*****************************************************************************/ 24/*****************************************************************************/
7/* Headers needed. */ 25/* Headers needed. */
8/*****************************************************************************/ 26/*****************************************************************************/
9 27
11#define PLUGIN_H_ 29#define PLUGIN_H_
12 30
13/*****************************************************************************/ 31/*****************************************************************************/
14/* This one does not exist under Win32. */ 32/* This one does not exist under Win32. */
15/*****************************************************************************/ 33/*****************************************************************************/
16#ifndef WIN32
17#include <dlfcn.h> 34#include <dlfcn.h>
18#endif
19 35
20#undef MODULEAPI
21#ifdef WIN32
22#ifdef PYTHON_PLUGIN_EXPORTS
23#define MODULEAPI __declspec(dllexport)
24#else
25#define MODULEAPI __declspec(dllimport)
26#endif
27#else
28#define MODULEAPI 36#define MODULEAPI
29#endif
30 37
31#include <global.h> 38#include <global.h>
32#include <object.h> 39#include <object.h>
33 40
34#ifdef HAVE_TIME_H 41#ifdef HAVE_TIME_H
39 46
40 47
41/*****************************************************************************/ 48/*****************************************************************************/
42/* This one does not exist under Win32. */ 49/* This one does not exist under Win32. */
43/*****************************************************************************/ 50/*****************************************************************************/
44#ifndef WIN32
45#include <dirent.h> 51#include <dirent.h>
46#endif
47 52
48#define NR_EVENTS 42 53#define NR_EVENTS 42
49 54
50#include <stdarg.h> 55#include <stdarg.h>
51 56
67 72
68typedef void* (*f_plug_api) (int* type, ...); 73typedef void* (*f_plug_api) (int* type, ...);
69typedef int (*f_plug_postinit) (void); 74typedef int (*f_plug_postinit) (void);
70typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr); 75typedef int (*f_plug_init)(const char* iversion, f_plug_api gethooksptr);
71 76
72#ifndef WIN32
73#define LIBPTRTYPE void* 77#define LIBPTRTYPE void*
74#else
75#define LIBPTRTYPE HMODULE
76#endif
77 78
78typedef struct _crossfire_plugin 79typedef struct _crossfire_plugin
79{ 80{
80 f_plug_api eventfunc; /* Event Handler function */ 81 f_plug_api eventfunc; /* Event Handler function */
81 f_plug_api propfunc; /* Plugin getProperty function */ 82 f_plug_api propfunc; /* Plugin getProperty function */
89} crossfire_plugin; 90} crossfire_plugin;
90 91
91extern int plugin_number; 92extern int plugin_number;
92extern crossfire_plugin* plugins_list; 93extern crossfire_plugin* plugins_list;
93 94
94#ifdef WIN32
95
96#define plugins_dlopen(fname) LoadLibrary(fname)
97#define plugins_dlclose(lib) FreeLibrary(lib)
98#define plugins_dlsym(lib,name) GetProcAddress(lib,name)
99
100#else /*WIN32 */
101
102#define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL) 95#define plugins_dlopen(fname) dlopen(fname,RTLD_NOW|RTLD_GLOBAL)
103#define plugins_dlclose(lib) dlclose(lib) 96#define plugins_dlclose(lib) dlclose(lib)
104#define plugins_dlsym(lib,name) dlsym(lib,name) 97#define plugins_dlsym(lib,name) dlsym(lib,name)
105#define plugins_dlerror() dlerror() 98#define plugins_dlerror() dlerror()
106#endif /* WIN32 */
107 99
108 100
109/* OBJECT-RELATED HOOKS */ 101/* OBJECT-RELATED HOOKS */
110 102
111#define CFAPI_OBJECT_PROP_OB_ABOVE 1 103#define CFAPI_OBJECT_PROP_OB_ABOVE 1

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines