diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 1999-10-28 15:30:50 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 1999-10-28 15:30:50 +0000 |
commit | f5d963d9cfc4aec49326b053e4929f4297b07b69 (patch) | |
tree | 1103c21673e3c099b7c258d86a1c3725d238a548 /include/asterisk | |
parent | 80d00a57bf387537b3f2508f54e9a452972dd893 (diff) |
Version 0.1.0 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@13 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk')
-rwxr-xr-x | include/asterisk/module.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/include/asterisk/module.h b/include/asterisk/module.h new file mode 100755 index 000000000..94a4f82b2 --- /dev/null +++ b/include/asterisk/module.h @@ -0,0 +1,127 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * Module definitions + * + * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC + * + * Mark Spencer <markster@linux-support.net> + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + +#ifndef _ASTERISK_MODULE_H +#define _ASTERISK_MODULE_H + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +/* Every module must provide these functions */ + +int load_module(void); /* Initialize the module */ +int unload_module(void); /* Cleanup all module structures, + sockets, etc */ +int usecount(void); /* How many channels provided by this module are in use? */ +char *description(void); /* Description of this module */ + +#define AST_MODULE_CONFIG "modules.conf" /* Module configuration file */ + +#define AST_FORCE_SOFT 0 +#define AST_FORCE_FIRM 1 +#define AST_FORCE_HARD 2 + +/* Load a module */ +int ast_load_resource(char *resource_name); + +/* Unload a module. Force unloading a module is not recommended. */ +int ast_unload_resource(char *resource_name, int force); + +/* Notify when usecount has been changed */ +void ast_update_use_count(void); + +/* Ask for a list of modules, descriptions, and use counts */ +int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt)); + +/* Ask this procedure to be run with modules have been updated */ +int ast_loader_register(int (*updater)(void)); + +/* No longer run me when modules are updated */ +int ast_loader_unregister(int (*updater)(void)); + +/* Local user routines keep track of which channels are using a given module resource. + They can help make removing modules safer, particularly if they're in use at the time + they have been requested to be removed */ + +#define STANDARD_LOCAL_USER struct localuser { \ + struct ast_channel *chan; \ + struct localuser *next; \ + } + +#define LOCAL_USER_DECL static pthread_mutex_t localuser_lock = PTHREAD_MUTEX_INITIALIZER; \ + static struct localuser *localusers = NULL; \ + static int localusecnt = 0; + +#define LOCAL_USER_ADD(u) { \ + \ + if (!(u=malloc(sizeof(struct localuser)))) { \ + ast_log(LOG_WARNING, "Out of memory\n"); \ + return -1; \ + } \ + pthread_mutex_lock(&localuser_lock); \ + u->chan = chan; \ + u->next = localusers; \ + localusers = u; \ + localusecnt++; \ + pthread_mutex_unlock(&localuser_lock); \ + ast_update_use_count(); \ +} + +#define LOCAL_USER_REMOVE(u) { \ + struct localuser *uc, *ul = NULL; \ + pthread_mutex_lock(&localuser_lock); \ + uc = localusers; \ + while (uc) { \ + if (uc == u) { \ + if (ul) \ + ul->next = uc->next; \ + else \ + localusers = uc->next; \ + break; \ + } \ + ul = uc; \ + uc = uc->next; \ + }\ + free(u); \ + localusecnt--; \ + pthread_mutex_unlock(&localuser_lock); \ + ast_update_use_count(); \ +} + +#define STANDARD_HANGUP_LOCALUSERS { \ + struct localuser *u, *ul; \ + pthread_mutex_lock(&localuser_lock); \ + u = localusers; \ + while(u) { \ + ast_softhangup(u->chan); \ + ul = u; \ + u = u->next; \ + free(ul); \ + } \ + pthread_mutex_unlock(&localuser_lock); \ + localusecnt=0; \ +} + +#define STANDARD_USECOUNT(res) { \ + pthread_mutex_lock(&localuser_lock); \ + res = localusecnt; \ + pthread_mutex_unlock(&localuser_lock); \ +} + + + +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif +#endif |