00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _ASTERISK_MODULE_H
00029 #define _ASTERISK_MODULE_H
00030
00031 #include "asterisk/utils.h"
00032
00033 #if defined(__cplusplus) || defined(c_plusplus)
00034 extern "C" {
00035 #endif
00036
00037
00038 #define ASTERISK_GPL_KEY \
00039 "This paragraph is copyright (c) 2006 by Digium, Inc. \
00040 In order for your module to load, it must return this \
00041 key via a function called \"key\". Any code which \
00042 includes this paragraph must be licensed under the GNU \
00043 General Public License version 2 or later (at your \
00044 option). In addition to Digium's general reservations \
00045 of rights, Digium expressly reserves the right to \
00046 allow other parties to license this paragraph under \
00047 different terms. Any use of Digium, Inc. trademarks or \
00048 logos (including \"Asterisk\" or \"Digium\") without \
00049 express written permission of Digium, Inc. is prohibited.\n"
00050
00051 #define AST_MODULE_CONFIG "modules.conf"
00052
00053 enum ast_module_unload_mode {
00054 AST_FORCE_SOFT = 0,
00055 AST_FORCE_FIRM = 1,
00056 AST_FORCE_HARD = 2,
00057
00058 };
00059
00060 enum ast_module_load_result {
00061 AST_MODULE_LOAD_SUCCESS = 0,
00062 AST_MODULE_LOAD_DECLINE = 1,
00063 AST_MODULE_LOAD_SKIP = 2,
00064 AST_MODULE_LOAD_FAILURE = -1,
00065 };
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 enum ast_module_load_result ast_load_resource(const char *resource_name);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode);
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 void ast_update_use_count(void);
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 int ast_update_module_list(int (*modentry)(const char *module, const char *description, int usecnt, const char *like),
00114 const char *like);
00115
00116
00117
00118
00119
00120
00121 int ast_module_check(char *name);
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 int ast_loader_register(int (*updater)(void));
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 int ast_loader_unregister(int (*updater)(void));
00143
00144
00145
00146
00147
00148
00149 void ast_module_shutdown(void);
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload);
00168
00169
00170
00171 struct ast_module;
00172
00173
00174
00175
00176
00177 struct ast_module_user;
00178 struct ast_module_user_list;
00179
00180
00181
00182
00183
00184
00185
00186 enum ast_module_flags {
00187 AST_MODFLAG_DEFAULT = 0,
00188 AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0),
00189 AST_MODFLAG_BUILDSUM = (1 << 1),
00190 };
00191
00192 struct ast_module_info {
00193
00194
00195
00196
00197
00198
00199
00200 struct ast_module *self;
00201 enum ast_module_load_result (*load)(void);
00202 int (*reload)(void);
00203 int (*unload)(void);
00204 const char *name;
00205 const char *description;
00206
00207
00208
00209
00210
00211
00212
00213 const char *key;
00214 unsigned int flags;
00215
00216
00217 const char buildopt_sum[33];
00218 };
00219
00220 void ast_module_register(const struct ast_module_info *);
00221 void ast_module_unregister(const struct ast_module_info *);
00222
00223 struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_channel *);
00224 void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
00225 void __ast_module_user_hangup_all(struct ast_module *);
00226
00227 #define ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan)
00228 #define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user)
00229 #define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self)
00230
00231 struct ast_module *ast_module_ref(struct ast_module *);
00232 void ast_module_unref(struct ast_module *);
00233
00234 #if defined(__cplusplus) || defined(c_plusplus)
00235 #define AST_MODULE_INFO(keystr, flags_to_set, desc, load_func, unload_func, reload_func) \
00236 static struct ast_module_info __mod_info = { \
00237 NULL, \
00238 load_func, \
00239 reload_func, \
00240 unload_func, \
00241 AST_MODULE, \
00242 desc, \
00243 keystr, \
00244 flags_to_set | AST_MODFLAG_BUILDSUM, \
00245 AST_BUILDOPT_SUM, \
00246 }; \
00247 static void __attribute__ ((constructor)) __reg_module(void) \
00248 { \
00249 ast_module_register(&__mod_info); \
00250 } \
00251 static void __attribute__ ((destructor)) __unreg_module(void) \
00252 { \
00253 ast_module_unregister(&__mod_info); \
00254 } \
00255 const static __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info
00256
00257 #define AST_MODULE_INFO_STANDARD(keystr, desc) \
00258 AST_MODULE_INFO(keystr, AST_MODFLAG_DEFAULT, desc, \
00259 load_module, \
00260 unload_module, \
00261 NULL \
00262 )
00263 #else
00264
00265
00266
00267 const static __attribute__((unused)) struct ast_module_info *ast_module_info;
00268
00269 #define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) \
00270 static struct ast_module_info __mod_info = { \
00271 .name = AST_MODULE, \
00272 .flags = flags_to_set | AST_MODFLAG_BUILDSUM, \
00273 .description = desc, \
00274 .key = keystr, \
00275 .buildopt_sum = AST_BUILDOPT_SUM, \
00276 fields \
00277 }; \
00278 static void __attribute__ ((constructor)) __reg_module(void) \
00279 { \
00280 ast_module_register(&__mod_info); \
00281 } \
00282 static void __attribute__ ((destructor)) __unreg_module(void) \
00283 { \
00284 ast_module_unregister(&__mod_info); \
00285 } \
00286 const static struct ast_module_info *ast_module_info = &__mod_info
00287
00288 #define AST_MODULE_INFO_STANDARD(keystr, desc) \
00289 AST_MODULE_INFO(keystr, AST_MODFLAG_DEFAULT, desc, \
00290 .load = load_module, \
00291 .unload = unload_module, \
00292 )
00293 #endif
00294
00295 #if defined(__cplusplus) || defined(c_plusplus)
00296 }
00297 #endif
00298
00299 #endif