00001 /* module.h: header for module.c 00002 * 00003 * Copyright (C) 2003, 2004 Eggheads Development Team 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 * 00019 * $Id: module.h,v 1.49 2007-09-13 22:20:55 sven Exp $ 00020 */ 00021 00022 #ifndef _EGG_MODULE_H_ 00023 #define _EGG_MODULE_H_ 00024 00025 /* Values for 'why' in module_unload() */ 00026 #define MODULE_USER 0 /* User is manually unloading a module. */ 00027 #define MODULE_SHUTDOWN 1 /* Bot is exiting. Can't be ignored. */ 00028 #define MODULE_RESTART 2 /* Bot is restarting. */ 00029 00030 /* Bind table names for modules events */ 00031 #define BTN_LOAD_MODULE "load" 00032 #define BTN_UNLOAD_MODULE "unload" 00033 00034 struct egg_module; 00035 typedef struct egg_module egg_module_t; 00036 00037 typedef int (*egg_start_func_t)(egg_module_t *modinfo); 00038 typedef int (*egg_close_func_t)(int why); 00039 typedef void (*egg_unload_func_t)(void); 00040 typedef void (*egg_cleanup_hook_t)(egg_module_t *mod); 00041 00042 struct egg_module { 00043 const char *name; 00044 const char *author; 00045 const char *version; 00046 const char *description; 00047 00048 egg_close_func_t close_func; 00049 egg_unload_func_t unload_func; 00050 egg_cleanup_hook_t event_cleanup; 00051 void *module_data; 00052 00053 /* API and versioning info. */ 00054 int major, minor; 00055 void *module_api; 00056 }; 00057 00058 int module_init(void); 00059 int module_shutdown(void); 00060 00061 int module_add_dir(const char *moddir); 00062 int module_load(const char *name); 00063 int module_loaded(const char *name); 00064 int module_unload(const char *name, int why); 00065 egg_module_t *module_lookup(const char *name); 00066 void *module_get_api(const char *name, int major, int minor); 00067 int module_addref(const char *name); 00068 int module_decref(const char *name); 00069 int module_list(const char ***names); 00070 00071 /* Windows hack to export functions from dlls. */ 00072 #if defined (__CYGWIN__) 00073 # define EXPORT_SCOPE __declspec(dllexport) 00074 #else 00075 # define EXPORT_SCOPE 00076 #endif 00077 00078 #endif /* !_EGG_MODULE_H_ */