00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _ASTERISK_MODULE_H
00015 #define _ASTERISK_MODULE_H
00016
00017 #if defined(__cplusplus) || defined(c_plusplus)
00018 extern "C" {
00019 #endif
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 int load_module(void);
00030
00031
00032
00033
00034
00035
00036
00037 int unload_module(void);
00038
00039
00040
00041
00042
00043
00044
00045 int usecount(void);
00046
00047
00048
00049
00050
00051 char *description(void);
00052
00053
00054
00055
00056
00057
00058
00059 char *key(void);
00060
00061
00062
00063
00064
00065
00066
00067 int reload(void);
00068
00069 #define ASTERISK_GPL_KEY \
00070 "This paragraph is Copyright (C) 2000, Linux Support Services, Inc. \
00071 In order for your module to load, it must return this key via a function \
00072 called \"key\". Any code which includes this paragraph must be licensed under \
00073 the GNU General Public License version 2 or later (at your option). Linux \
00074 Support Services, Inc. reserves the right to allow other parties to license \
00075 this paragraph under other terms as well."
00076
00077 #define AST_MODULE_CONFIG "modules.conf"
00078
00079 #define AST_FORCE_SOFT 0
00080 #define AST_FORCE_FIRM 1
00081 #define AST_FORCE_HARD 2
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 int ast_load_resource(char *resource_name);
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 int ast_unload_resource(char *resource_name, int force);
00103
00104
00105
00106
00107
00108
00109 void ast_update_use_count(void);
00110
00111
00112
00113
00114
00115
00116
00117 int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt));
00118
00119
00120
00121
00122
00123
00124
00125
00126 int ast_loader_register(int (*updater)(void));
00127
00128
00129
00130
00131
00132
00133
00134 int ast_loader_unregister(int (*updater)(void));
00135
00136
00137
00138
00139
00140
00141 void ast_module_reload(const char *name);
00142
00143 int ast_register_atexit(void (*func)(void));
00144 void ast_unregister_atexit(void (*func)(void));
00145
00146
00147
00148
00149
00150 #define STANDARD_LOCAL_USER struct localuser { \
00151 struct ast_channel *chan; \
00152 struct localuser *next; \
00153 }
00154
00155 #define LOCAL_USER_DECL AST_MUTEX_DEFINE_STATIC(localuser_lock); \
00156 static struct localuser *localusers = NULL; \
00157 static int localusecnt = 0;
00158
00159 #define LOCAL_USER_ADD(u) { \
00160 \
00161 if (!(u=(struct localuser *)malloc(sizeof(struct localuser)))) { \
00162 ast_log(LOG_WARNING, "Out of memory\n"); \
00163 return -1; \
00164 } \
00165 ast_mutex_lock(&localuser_lock); \
00166 u->chan = chan; \
00167 u->next = localusers; \
00168 localusers = u; \
00169 localusecnt++; \
00170 ast_mutex_unlock(&localuser_lock); \
00171 ast_update_use_count(); \
00172 }
00173
00174 #define LOCAL_USER_REMOVE(u) { \
00175 struct localuser *uc, *ul = NULL; \
00176 ast_mutex_lock(&localuser_lock); \
00177 uc = localusers; \
00178 while (uc) { \
00179 if (uc == u) { \
00180 if (ul) \
00181 ul->next = uc->next; \
00182 else \
00183 localusers = uc->next; \
00184 break; \
00185 } \
00186 ul = uc; \
00187 uc = uc->next; \
00188 }\
00189 free(u); \
00190 localusecnt--; \
00191 ast_mutex_unlock(&localuser_lock); \
00192 ast_update_use_count(); \
00193 }
00194
00195 #define STANDARD_HANGUP_LOCALUSERS { \
00196 struct localuser *u, *ul; \
00197 ast_mutex_lock(&localuser_lock); \
00198 u = localusers; \
00199 while(u) { \
00200 ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD); \
00201 ul = u; \
00202 u = u->next; \
00203 free(ul); \
00204 } \
00205 ast_mutex_unlock(&localuser_lock); \
00206 localusecnt=0; \
00207 }
00208
00209 #define STANDARD_USECOUNT(res) { \
00210 ast_mutex_lock(&localuser_lock); \
00211 res = localusecnt; \
00212 ast_mutex_unlock(&localuser_lock); \
00213 }
00214
00215
00216
00217 #if defined(__cplusplus) || defined(c_plusplus)
00218 }
00219 #endif
00220 #endif