Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:05 2009

## Asterisk developer's documentation

# module.h File Reference

Asterisk module definitions. More...

Go to the source code of this file.

## Defines

#define | AST_FORCE_FIRM 1
| Firmly unload a module.
#define | AST_FORCE_HARD 2
| Unconditionally unload a module.
#define | AST_FORCE_SOFT 0
| Softly unload a module.
#define | AST_MODULE_CONFIG "modules.conf"
| Module configuration file.
#define | ASTERISK_GPL_KEY "This paragraph is Copyright (C) 2000, Linux Support Services, Inc. \In order for your module to load, it must return this key via a function \called \"key\". Any code which includes this paragraph must be licensed under \the GNU General Public License version 2 or later (at your option). Linux \Support Services, Inc. reserves the right to allow other parties to license \this paragraph under other terms as well."
| The text the key() function should return.
#define | LOCAL_USER_ACF_ADD(u)
#define | LOCAL_USER_ADD(u)
| Add a localuser.
#define | LOCAL_USER_DECL
| The localuser declaration.
#define | LOCAL_USER_REMOVE(u)
| Remove a localuser.
#define | STANDARD_DECREMENT_USECOUNT
#define | STANDARD_HANGUP_LOCALUSERS
| Hangup all localusers.
#define | STANDARD_INCREMENT_USECOUNT
#define | STANDARD_LOCAL_USER
| Standard localuser struct definition.
#define | STANDARD_USECOUNT(res)
| Set the specfied integer to the current usecount.

## Functions

int | ast_load_resource (const char *resource_name)
| Load a module.
int | ast_loader_register (int(*updater)(void))
| Add a procedure to be run when modules have been updated.
int | ast_loader_unregister (int(*updater)(void))
| Remove a procedure to be run when modules are updated.
char * | ast_module_helper (char *line, char *word, int pos, int state, int rpos, int needsreload)
| Match modules names for the Asterisk cli.
int | ast_module_reload (const char *name)
| Reload asterisk modules.
int | ast_register_atexit (void(*func)(void))
| Register a function to be executed before Asterisk exits.
int | ast_unload_resource (const char *resource_name, int force)
| Unloads a module.
void | ast_unregister_atexit (void(*func)(void))
| Unregister a function registered with ast_register_atexit().
int | ast_update_module_list (int(*modentry)(const char *module, const char *description, int usecnt, const char *like), const char *like)
| Ask for a list of modules, descriptions, and use counts.
void | ast_update_use_count (void)
| Notify when usecount has been changed.
char * | description (void)
| Provides a description of the module.
char * | key (void)
| Returns the ASTERISK_GPL_KEY.
int | load_module (void)
| Initialize the module.
int | reload (void)
| Reload stuff.
int | unload_module (void)
| Cleanup all module structures, sockets, etc.
int | usecount (void)
| Provides a usecount.

## Detailed Description

Asterisk module definitions.

This file contains the definitons for functions Asterisk modules should provide and some other module related functions.

Definition in file module.h.

## Define Documentation

#define AST_FORCE_FIRM 1

Firmly unload a module.

This flag signals ast_unload_resource() to attempt to unload a module even if it is in use. It will attempt to use the module's unload_module function.

Definition at line 130 of file module.h.

Referenced by ast_unload_resource(), and handle_unload().

#define AST_FORCE_HARD 2

Unconditionally unload a module.

This flag signals ast_unload_resource() to first attempt to unload a module using the module's unload_module function, then if that fails to unload the module using dlclose. The module will be unloaded even if it is still in use. Use of this flag is not recommended.

Definition at line 140 of file module.h.

Referenced by handle_unload().

#define AST_FORCE_SOFT 0

Softly unload a module.

This flag signals ast_unload_resource() to unload a module only if it is not in use, according to the module's usecount.

Definition at line 121 of file module.h.

Referenced by handle_unload().

#define AST_MODULE_CONFIG "modules.conf"

Module configuration file.

Definition at line 113 of file module.h.

Referenced by ast_load_resource(), and load_modules().

#define ASTERISK_GPL_KEY "This paragraph is Copyright (C) 2000, Linux Support Services, Inc. \In order for your module to load, it must return this key via a function \called \"key\". Any code which includes this paragraph must be licensed under \the GNU General Public License version 2 or later (at your option). Linux \Support Services, Inc. reserves the right to allow other parties to license \this paragraph under other terms as well."

The text the key() function should return.

Definition at line 105 of file module.h.

Referenced by key().

#define LOCAL_USER_ACF_ADD | ( | u |  | ) |

Definition at line 331 of file module.h.

Referenced by acf_curl_exec(), acf_cut_exec(), acf_sort_exec(), acf_vmcount_exec(), dundifunc_read(), function_enum(), function_txtcidname(), and queue_function_qac().

#define LOCAL_USER_ADD | ( | u |  | ) |

Add a localuser.

Parameters:

  | u | a pointer to a localuser struct

This macro adds a localuser to the list of users and increments the usecount. It expects a variable named `chan` of type `ast_channel` in the current scope.

Note:
  This function dynamically allocates memory. If this operation fails it will cause your function to return -1 to the caller.

Definition at line 316 of file module.h.

Referenced by __login_exec(), _while_exec(), admin_exec(), adsi_exec(), agi_exec_full(), alarmreceiver_exec(), app_exec(), appendcdruserfield_exec(), aqm_exec(), auth_exec(), background_detect_exec(), chanavail_exec(), chanspy_exec(), conf_exec(), controlplayback_exec(), count_exec(), cpeid_exec(), curl_exec(), cut_exec(), datetime_exec(), del_exec(), deltree_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), dumpchan_exec(), dundi_lookup_exec(), echo_exec(), enumlookup_exec(), eval_exec(), exec_exec(), execif_exec(), festival_exec(), flash_exec(), forkcdr_exec(), get_exec(), gosub_exec(), gosubif_exec(), group_check_exec(), group_count_exec(), group_match_count_exec(), group_set_exec(), hasvoicemail_exec(), ices_exec(), lookupblacklist_exec(), lookupcidname_exec(), macro_exec(), macroif_exec(), math_exec(), md5_exec(), md5check_exec(), milliwatt_exec(), mixmonitor_exec(), mp3_exec(), NBScat_exec(), nocdr_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_call_exec(), park_exec(), parkandannounce_exec(), PGSQL_exec(), pickup_exec(), playback_exec(), pqm_exec(), privacy_exec(), put_exec(), queue_exec(), random_exec(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), retrydial_exec(), rpt_exec(), rqm_exec(), sayunixtime_exec(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), setrdnis_exec(), settransfercapability_exec(), skel_exec(), sms_exec(), softhangup_exec(), sort_exec(), system_exec_helper(), testclient_exec(), testserver_exec(), transfer_exec(), txtcidname_exec(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), waitforring_exec(), waitforsilence_exec(), zapateller_exec(), and zapras_exec().

#define LOCAL_USER_DECL

Value:

    AST_MUTEX_DEFINE_STATIC(localuser_lock); \
                      static struct localuser *localusers = NULL; \
                      static int localusecnt = 0;

The localuser declaration.

This macro should be used in combination with STANDARD_LOCAL_USER. It creates a localuser mutex and several other variables used for keeping the use count.

Sample Usage:

     STANDARD_LOCAL_USER;
     LOCAL_USER_DECL;

Definition at line 289 of file module.h.

#define LOCAL_USER_REMOVE | ( | u |  | ) |

Remove a localuser.

Parameters:

  | u | the user to add, should be of type struct localuser

This macro removes a localuser from the list of users and decrements the usecount.

Definition at line 353 of file module.h.

Referenced by __login_exec(), acf_curl_exec(), acf_cut_exec(), acf_sort_exec(), acf_vmcount_exec(), admin_exec(), adsi_exec(), agi_exec_full(), alarmreceiver_exec(), app_exec(), appendcdruserfield_exec(), aqm_exec(), auth_exec(), background_detect_exec(), chanavail_exec(), chanspy_exec(), conf_exec(), controlplayback_exec(), count_exec(), cpeid_exec(), curl_exec(), cut_exec(), datetime_exec(), del_exec(), deltree_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), dumpchan_exec(), dundi_lookup_exec(), dundifunc_read(), echo_exec(), enumlookup_exec(), eval_exec(), exec_exec(), execif_exec(), festival_exec(), flash_exec(), forkcdr_exec(), function_enum(), function_txtcidname(), get_exec(), gosub_exec(), gosubif_exec(), group_check_exec(), group_count_exec(), group_match_count_exec(), group_set_exec(), hasvoicemail_exec(), ices_exec(), lookupblacklist_exec(), lookupcidname_exec(), macro_exec(), macroif_exec(), math_exec(), md5_exec(), md5check_exec(), milliwatt_exec(), mixmonitor_exec(), mp3_exec(), NBScat_exec(), nocdr_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_call_exec(), park_exec(), parkandannounce_exec(), PGSQL_exec(), pickup_exec(), playback_exec(), pqm_exec(), privacy_exec(), put_exec(), queue_exec(), queue_function_qac(), random_exec(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), retrydial_exec(), rpt_exec(), rqm_exec(), sayunixtime_exec(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), setrdnis_exec(), settransfercapability_exec(), skel_exec(), sms_exec(), softhangup_exec(), sort_exec(), system_exec_helper(), testclient_exec(), testserver_exec(), transfer_exec(), txtcidname_exec(), upqm_exec(), userevent_exec(), verbose_exec(), vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), waitforring_exec(), waitforsilence_exec(), zapateller_exec(), and zapras_exec().

#define STANDARD_DECREMENT_USECOUNT

Value:

    ast_mutex_lock(&localuser_lock); \
       localusecnt--; \
       ast_mutex_unlock(&localuser_lock); \
       ast_update_use_count();

Definition at line 299 of file module.h.

Referenced by mixmonitor_thread().

#define STANDARD_HANGUP_LOCALUSERS

Hangup all localusers.

This macro hangs up on all current localusers and sets the usecount to zero when finished.

Definition at line 380 of file module.h.

Referenced by unload_module().

#define STANDARD_INCREMENT_USECOUNT

Value:

    ast_mutex_lock(&localuser_lock); \
       localusecnt++; \
       ast_mutex_unlock(&localuser_lock); \
       ast_update_use_count();

Definition at line 293 of file module.h.

Referenced by mixmonitor_thread().

#define STANDARD_LOCAL_USER

Value:

    struct localuser { \
                      struct ast_channel *chan; \
                      struct localuser *next; \
                        }

Standard localuser struct definition.

This macro defines a localuser struct. The channel.h file must be included to use this macro because it refrences ast_channel.

Definition at line 271 of file module.h.

#define STANDARD_USECOUNT | ( | res |  | ) |

Value:

    { \
       res = localusecnt; \
    }

Set the specfied integer to the current usecount.

Parameters:

  | res | the integer variable to set.

This macro sets the specfied integer variable to the local usecount.

Sample Usage:

     int usecount(void)
     {
        int res;
        STANDARD_USECOUNT(res);
        return res;
     }

Definition at line 411 of file module.h.

Referenced by usecount().

## Function Documentation

int ast_load_resource | ( | const char * | resource_name | ) |

Load a module.

Parameters:

  | resource_name | The filename of the module to load.

This function is run by the PBX to load the modules. It performs all loading and initilization tasks. Basically, to load a module, just give it the name of the module and it will do the rest.

Returns:
  Zero on success, -1 on error.

Definition at line 423 of file loader.c.

References __load_resource(), ast_config_destroy(), ast_config_load(), AST_MODULE_CONFIG, cfg, and option_verbose.

Referenced by file_ok_sel(), handle_load(), load_module(), and reload_module().

    00424 {
    00425    int o;
    00426    struct ast_config *cfg = NULL;
    00427    int res;
    00428
    00429    /* Keep the module file parsing silent */
    00430    o = option_verbose;
    00431    option_verbose = 0;
    00432    cfg = ast_config_load(AST_MODULE_CONFIG);
    00433    option_verbose = o;
    00434    res = __load_resource(resource_name, cfg);
    00435    if (cfg)
    00436       ast_config_destroy(cfg);
    00437    return res;
    00438 }

int ast_loader_register | ( | int(*)(void) | updater | ) |

Add a procedure to be run when modules have been updated.

Parameters:

  | updater | The function to run when modules have been updated.

This function adds the given function to a linked list of functions to be run when the modules are updated.

Returns:
  Zero on success and -1 on failure.

Definition at line 609 of file loader.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), LOG_WARNING, malloc, loadupdate::next, loadupdate::updater, and updaters.

Referenced by show_console().

    00610 {
    00611    struct loadupdate *tmp;
    00612    /* XXX Should be more flexible here, taking > 1 verboser XXX */
    00613    if ((tmp = malloc(sizeof (struct loadupdate)))) {
    00614       tmp->updater = v;
    00615       if (ast_mutex_lock(&modlock))
    00616          ast_log(LOG_WARNING, "Failed to lock\n");
    00617       tmp->next = updaters;
    00618       updaters = tmp;
    00619       ast_mutex_unlock(&modlock);
    00620       return 0;
    00621    }
    00622    return -1;
    00623 }

int ast_loader_unregister | ( | int(*)(void) | updater | ) |

Remove a procedure to be run when modules are updated.

Parameters:

  | updater | The updater function to unregister.

This removes the given function from the updater list.

Returns:
  Zero on success, -1 on failure.

Definition at line 625 of file loader.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), LOG_WARNING, loadupdate::next, loadupdate::updater, and updaters.

Referenced by exit_now().

    00626 {
    00627    int res = -1;
    00628    struct loadupdate *tmp, *tmpl=NULL;
    00629    if (ast_mutex_lock(&modlock))
    00630       ast_log(LOG_WARNING, "Failed to lock\n");
    00631    tmp = updaters;
    00632    while(tmp) {
    00633       if (tmp->updater == v)  {
    00634          if (tmpl)
    00635             tmpl->next = tmp->next;
    00636          else
    00637             updaters = tmp->next;
    00638          break;
    00639       }
    00640       tmpl = tmp;
    00641       tmp = tmp->next;
    00642    }
    00643    if (tmp)
    00644       res = 0;
    00645    ast_mutex_unlock(&modlock);
    00646    return res;
    00647 }

char* ast_module_helper | ( | char * | line,
|  | char * | word,
|  | int | pos,
|  | int | state,
|  | int | rpos,
|  | int | needsreload |
| ) |  |  |

Match modules names for the Asterisk cli.

Parameters:

  | line | Unused by this function, but this should be the line we are matching.
  | word | The partial name to match.
  | pos | The position the word we are completing is in.
  | state | The possible match to return.
  | rpos | The position we should be matching. This should be the same as pos.
  | needsreload | This should be 1 if we need to reload this module and 0 otherwise. This function will only return modules that are reloadble if this is 1.

Returns:
  A possible completion of the partial match, or NULL if no matches were found.

Definition at line 166 of file loader.c.

References ast_mutex_lock(), ast_mutex_unlock(), module::next, module::reload, module::resource, and strdup.

Referenced by complete_mod_2(), and complete_mod_4().

    00167 {
    00168    struct module *m;
    00169    int which=0;
    00170    char *ret;
    00171
    00172    if (pos != rpos)
    00173       return NULL;
    00174    ast_mutex_lock(&modlock);
    00175    m = module_list;
    00176    while(m) {
    00177       if (!strncasecmp(word, m->resource, strlen(word)) && (m->reload || !needsreload)) {
    00178          if (++which > state)
    00179             break;
    00180       }
    00181       m = m->next;
    00182    }
    00183    if (m) {
    00184       ret = strdup(m->resource);
    00185    } else {
    00186       ret = NULL;
    00187       if (!strncasecmp(word, "extconfig", strlen(word))) {
    00188          if (++which > state)
    00189             ret = strdup("extconfig");
    00190       } else if (!strncasecmp(word, "manager", strlen(word))) {
    00191          if (++which > state)
    00192             ret = strdup("manager");
    00193       } else if (!strncasecmp(word, "enum", strlen(word))) {
    00194          if (++which > state)
    00195             ret = strdup("enum");
    00196       } else if (!strncasecmp(word, "rtp", strlen(word))) {
    00197          if (++which > state)
    00198             ret = strdup("rtp");
    00199       }
    00200
    00201    }
    00202    ast_mutex_unlock(&modlock);
    00203    return ret;
    00204 }

int ast_module_reload | ( | const char * | name | ) |

Reload asterisk modules.

Parameters:

  | name | the name of the module to reload

This function reloads the specified module, or if no modules are specified, it will reload all loaded modules.

Note:
  Modules are reloaded using their reload() functions, not unloading them and loading them again.

Returns:
  Zero if the specified module was not found, 1 if the module was found but cannot be reloaded, -1 if a reload operation is already in progress, and 2 if the specfied module was found and reloaded.

Definition at line 206 of file loader.c.

References ast_cdr_engine_reload(), ast_enum_reload(), ast_lastreloadtime, ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_rtp_reload(), ast_verbose(), module::description, dnsmgr_reload(), module::next, option_verbose, read_config_maps(), module::reload, reload(), reload_manager(), module::resource, and VERBOSE_PREFIX_3.

Referenced by handle_reload(), and monitor_sig_flags().

    00207 {
    00208    struct module *m;
    00209    int reloaded = 0;
    00210    int oldversion;
    00211    int (*reload)(void);
    00212    /* We'll do the logger and manager the favor of calling its reload here first */
    00213
    00214    if (ast_mutex_trylock(&reloadlock)) {
    00215       ast_verbose("The previous reload command didn't finish yet\n");
    00216       return -1;
    00217    }
    00218    time(&ast_lastreloadtime);
    00219
    00220    if (!name || !strcasecmp(name, "extconfig")) {
    00221       read_config_maps();
    00222       reloaded = 2;
    00223    }
    00224    if (!name || !strcasecmp(name, "manager")) {
    00225       reload_manager();
    00226       reloaded = 2;
    00227    }
    00228    if (!name || !strcasecmp(name, "cdr")) {
    00229       ast_cdr_engine_reload();
    00230       reloaded = 2;
    00231    }
    00232    if (!name || !strcasecmp(name, "enum")) {
    00233       ast_enum_reload();
    00234       reloaded = 2;
    00235    }
    00236    if (!name || !strcasecmp(name, "rtp")) {
    00237       ast_rtp_reload();
    00238       reloaded = 2;
    00239    }
    00240    if (!name || !strcasecmp(name, "dnsmgr")) {
    00241       dnsmgr_reload();
    00242       reloaded = 2;
    00243    }
    00244
    00245    ast_mutex_lock(&modlock);
    00246    oldversion = modlistver;
    00247    m = module_list;
    00248    while(m) {
    00249       if (!name || !strcasecmp(name, m->resource)) {
    00250          if (reloaded < 1)
    00251             reloaded = 1;
    00252          reload = m->reload;
    00253          ast_mutex_unlock(&modlock);
    00254          if (reload) {
    00255             reloaded = 2;
    00256             if (option_verbose > 2)
    00257                ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", m->resource, m->description());
    00258             reload();
    00259          }
    00260          ast_mutex_lock(&modlock);
    00261          if (oldversion != modlistver)
    00262             break;
    00263       }
    00264       m = m->next;
    00265    }
    00266    ast_mutex_unlock(&modlock);
    00267    ast_mutex_unlock(&reloadlock);
    00268    return reloaded;
    00269 }

int ast_register_atexit | ( | void(*)(void) | func | ) |

Register a function to be executed before Asterisk exits.

Parameters:

  | func | The callback function to use.

Returns:
  Zero on success, -1 on error.

Definition at line 376 of file asterisk.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_unregister_atexit(), atexits, ast_atexit::func, malloc, and ast_atexit::next.

Referenced by do_reload(), and load_module().

    00377 {
    00378    int res = -1;
    00379    struct ast_atexit *ae;
    00380    ast_unregister_atexit(func);
    00381    ae = malloc(sizeof(struct ast_atexit));
    00382    ast_mutex_lock(&atexitslock);
    00383    if (ae) {
    00384       memset(ae, 0, sizeof(struct ast_atexit));
    00385       ae->next = atexits;
    00386       ae->func = func;
    00387       atexits = ae;
    00388       res = 0;
    00389    }
    00390    ast_mutex_unlock(&atexitslock);
    00391    return res;
    00392 }

int ast_unload_resource | ( | const char * | resource_name,
|  | int | force |
| ) |  |  |

Unloads a module.

Parameters:

  | resource_name | The name of the module to unload.
  | force | The force flag. This should be set using one of the AST_FORCE* flags.

This function unloads a module. It will only unload modules that are not in use (usecount not zero), unless AST_FORCE_FIRM or AST_FORCE_HARD is specified. Setting AST_FORCE_FIRM or AST_FORCE_HARD will unload the module regardless of consequences (NOT_RECOMMENDED).

Returns:
  Zero on success, -1 on error.

Definition at line 122 of file loader.c.

References AST_FORCE_FIRM, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_update_use_count(), dlclose(), free, module::lib, LOG_WARNING, module::next, module::resource, module::unload_module, and module::usecount.

Referenced by __load_resource(), exit_now(), handle_unload(), reload_module(), and remove_module().

    00123 {
    00124    struct module *m, *ml = NULL;
    00125    int res = -1;
    00126    if (ast_mutex_lock(&modlock))
    00127       ast_log(LOG_WARNING, "Failed to lock\n");
    00128    m = module_list;
    00129    while(m) {
    00130       if (!strcasecmp(m->resource, resource_name)) {
    00131          if ((res = m->usecount()) > 0)  {
    00132             if (force)
    00133                ast_log(LOG_WARNING, "Warning:  Forcing removal of module %s with use count %d\n", resource_name, res);
    00134             else {
    00135                ast_log(LOG_WARNING, "Soft unload failed, '%s' has use count %d\n", resource_name, res);
    00136                ast_mutex_unlock(&modlock);
    00137                return -1;
    00138             }
    00139          }
    00140          res = m->unload_module();
    00141          if (res) {
    00142             ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name);
    00143             if (force <= AST_FORCE_FIRM) {
    00144                ast_mutex_unlock(&modlock);
    00145                return -1;
    00146             } else
    00147                ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n");
    00148          }
    00149          if (ml)
    00150             ml->next = m->next;
    00151          else
    00152             module_list = m->next;
    00153          dlclose(m->lib);
    00154          free(m);
    00155          break;
    00156       }
    00157       ml = m;
    00158       m = m->next;
    00159    }
    00160    modlistver = rand();
    00161    ast_mutex_unlock(&modlock);
    00162    ast_update_use_count();
    00163    return res;
    00164 }

void ast_unregister_atexit | ( | void(*)(void) | func | ) |

Unregister a function registered with ast_register_atexit().

Parameters:

  | func | The callback function to unregister.

Definition at line 394 of file asterisk.c.

References ast_mutex_lock(), ast_mutex_unlock(), atexits, ast_atexit::func, and ast_atexit::next.

Referenced by ast_register_atexit(), and do_reload().

    00395 {
    00396    struct ast_atexit *ae, *prev = NULL;
    00397    ast_mutex_lock(&atexitslock);
    00398    ae = atexits;
    00399    while(ae) {
    00400       if (ae->func == func) {
    00401          if (prev)
    00402             prev->next = ae->next;
    00403          else
    00404             atexits = ae->next;
    00405          break;
    00406       }
    00407       prev = ae;
    00408       ae = ae->next;
    00409    }
    00410    ast_mutex_unlock(&atexitslock);
    00411 }

int ast_update_module_list | ( | int(*)(const char *module, const char *description, int usecnt, const char *like) | modentry,
|  | const char * | like |
| ) |  |  |

Ask for a list of modules, descriptions, and use counts.

Parameters:

  | modentry | A callback to an updater function.
  | like | For each of the modules loaded, modentry will be executed with the resource, description, and usecount values of each particular module.

Returns:
  the number of modules loaded

Definition at line 589 of file loader.c.

References ast_mutex_trylock(), ast_mutex_unlock(), module::description, module::next, module::resource, and module::usecount.

Referenced by handle_modlist(), and mod_update().

    00591 {
    00592    struct module *m;
    00593    int unlock = -1;
    00594    int total_mod_loaded = 0;
    00595
    00596    if (ast_mutex_trylock(&modlock))
    00597       unlock = 0;
    00598    m = module_list;
    00599    while (m) {
    00600       total_mod_loaded += modentry(m->resource, m->description(), m->usecount(), like);
    00601       m = m->next;
    00602    }
    00603    if (unlock)
    00604       ast_mutex_unlock(&modlock);
    00605
    00606    return total_mod_loaded;
    00607 }

void ast_update_use_count | ( | void |  | ) |

Notify when usecount has been changed.

This function calulates use counts and notifies anyone trying to keep track of them. It should be called whenever your module's usecount changes.

Note:
  The LOCAL_USER macros take care of calling this function for you.

Definition at line 573 of file loader.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), LOG_WARNING, loadupdate::next, loadupdate::updater, and updaters.

Referenced by __load_resource(), __oh323_new(), adpcm_destroy(), adpcmtolin_new(), agent_new(), alaw_destroy(), alawtolin_new(), alawtoulaw_new(), alsa_new(), aopen_decusecnt(), aopen_incusecnt(), ast_iax2_new(), ast_modem_new(), ast_unload_resource(), au_close(), au_open(), au_rewrite(), bestdata_decusecnt(), bestdata_incusecnt(), exit_now(), features_new(), g723_close(), g723_destroy(), g723_open(), g723_rewrite(), g723tolin_new(), g726_16_open(), g726_16_rewrite(), g726_24_open(), g726_24_rewrite(), g726_32_open(), g726_32_rewrite(), g726_40_open(), g726_40_rewrite(), g726_close(), g726_destroy(), g726tolin_new(), g729_close(), g729_open(), g729_rewrite(), gsm_close(), gsm_open(), gsm_rewrite(), h263_close(), h263_open(), h263_rewrite(), i4l_decusecnt(), i4l_incusecnt(), iax2_predestroy(), ilbc_close(), ilbc_open(), ilbc_rewrite(), lintoadpcm_new(), lintoalaw_new(), lintog723_new(), lintog726_new(), lintoulaw_new(), load_module(), local_new(), mgcp_hangup(), mgcp_new(), modem_hangup(), nbs_new(), ogg_vorbis_close(), ogg_vorbis_open(), ogg_vorbis_rewrite(), oh323_hangup(), oh323_request(), oss_new(), pcm_close(), pcm_open(), pcm_rewrite(), phone_check_exception(), phone_hangup(), phone_new(), sip_hangup(), sip_new(), sip_request_call(), sipsock_read(), skinny_new(), slinear_close(), slinear_open(), slinear_rewrite(), ulaw_destroy(), ulawtoalaw_new(), ulawtolin_new(), vox_close(), vox_open(), vox_rewrite(), vpb_hangup(), vpb_new(), wav_close(), wav_open(), wav_rewrite(), zt_hangup(), and zt_new().

    00574 {
    00575    /* Notify any module monitors that the use count for a
    00576       resource has changed */
    00577    struct loadupdate *m;
    00578    if (ast_mutex_lock(&modlock))
    00579       ast_log(LOG_WARNING, "Failed to lock\n");
    00580    m = updaters;
    00581    while(m) {
    00582       m->updater();
    00583       m = m->next;
    00584    }
    00585    ast_mutex_unlock(&modlock);
    00586
    00587 }

char* description | ( | void |  | ) |

Provides a description of the module.

Returns:
  a short description of your module

Definition at line 2530 of file chan_agent.c.

References desc, ast_channel_tech::description, and tdesc.

    02531 {
    02532    return (char *) desc;
    02533 }

char* key | ( | void |  | ) |

Returns the ASTERISK_GPL_KEY.

This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:

     char *key(void) {
             return ASTERISK_GPL_KEY;
     }

Returns:
  ASTERISK_GPL_KEY

Definition at line 2525 of file chan_agent.c.

References ASTERISK_GPL_KEY.

Referenced by __ast_key_get(), __load_resource(), ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_privacy_check(), ast_privacy_set(), authenticate(), authenticate_verify(), cache_lookup(), check_access(), check_key(), create_addr(), crypto_load(), database_show(), database_showkey(), del_exec(), function_db_exists(), function_db_read(), function_db_write(), get_exec(), init_keys(), manager_dbget(), manager_dbput(), misdn_set_opt_exec(), put_exec(), pw_cb(), register_verify(), reply_digest(), show_keys(), showkeys(), sort_internal(), try_load_key(), and update_key().

    02526 {
    02527    return ASTERISK_GPL_KEY;
    02528 }

int load_module | ( | void |  | ) |

Initialize the module.

This function is called at module load time. Put all code in here that needs to set up your module's hardware, software, registrations, etc.

Returns:
  This function should return 0 on success and non-zero on failure. If the module is not loaded successfully, Asterisk will call its unload_module() function.

Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.

Returns:
  int Always 0.

TE STUFF END

Definition at line 2453 of file chan_agent.c.

References __unload_module(), action_agent_callback_login(), action_agent_logoff(), action_agents(), action_setcdruserfield(), action_transfer(), action_transferhangup(), action_zapdialoffhook(), action_zapdndoff(), action_zapdndon(), action_zapshowchannels(), admin_exec(), adsi_exec(), adsi_load(), agentmonitoroutgoing_exec(), agi_exec(), alarmreceiver_exec(), aliasl, answer_call(), app, app_exec, app_gosub, app_gosubif, app_pop, app_return, appendcdruserfield_exec(), aqm_exec(), AST_ALAW, ast_callerid_split(), ast_category_browse(), ast_cdr_register(), ast_channel_register(), ast_cli_register(), ast_cli_register_multiple(), ast_config_AST_LOG_DIR, ast_config_AST_SPOOL_DIR, ast_config_destroy(), ast_config_engine_register(), ast_config_load(), ast_custom_function_register(), ast_devstate_add(), AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H263, AST_FORMAT_ILBC, ast_format_register(), AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, ast_get_group(), ast_image_register(), ast_inet_ntoa(), ast_install_music_functions(), ast_install_vm_functions(), AST_LIN2A, AST_LIN2MU, ast_load_resource(), ast_log(), ast_manager_register, ast_manager_register2(), ast_moh_destroy(), AST_MULAW, ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), ast_netsock_init(), ast_netsock_list_alloc(), ast_netsock_release(), ast_pthread_create, AST_PTHREADT_NULL, ast_register_application(), ast_register_atexit(), ast_register_modem_driver(), ast_register_switch(), ast_register_translator(), ast_rtp_proto_register(), ast_true(), ast_unregister_translator(), ast_update_use_count(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose(), ASTOBJ_CONTAINER_INIT, au_close(), au_getcomment(), au_open(), au_read(), au_rewrite(), au_seek(), au_tell(), au_trunc(), au_write(), auth_exec(), background_detect_exec(), bindaddr, break_for_dtmf, builtins, callback_exec(), vpb_pvt::callerid, vpb_pvt::callgroup, calloc, ast_channel_tech::capabilities, cb_events(), cfg, chan_misdn_jb_empty(), chan_misdn_log(), chan_ringing(), chanavail_exec(), change_monitor_action(), change_monitor_exec(), chanspy_exec(), checksipdomain_function, cl_te_lock, cleanup_connection(), cli_add_queue_member, cli_conf, cli_remove_queue_member, cli_show_confs, cli_show_queue, cli_show_queues, conf_exec(), config, config_load(), connection_made(), context, controlplayback_exec(), count_exec(), cpeid_exec(), crypto_init(), crypto_load(), csv_log(), curl_exec(), custom_log(), cut_exec(), datetime_exec(), deadagi_exec(), DEFAULT_ECHO_CANCEL, DEFAULT_GAIN, del_exec(), deltree_exec(), descrip, dial_exec(), dictate_exec(), directory_exec(), disa_exec(), do_parking_thread(), dtmf_idd, dumpchan_exec(), dundi_debug_output(), dundi_error_output(), dundi_lookup_exec(), DUNDI_PORT, dundi_set_error(), dundi_set_output(), eagi_exec(), ec_supp_threshold, echo_exec(), enumlookup_exec(), error(), eval_exec(), EVENT_FLAG_AGENT, EVENT_FLAG_CALL, EVENT_FLAG_SYSTEM, exec_exec(), execif_exec(), external_rtp_create(), festival_exec(), find_desc(), find_transcoders(), flash_exec(), forkcdr_exec(), free, g723_close(), g723_getcomment(), g723_open(), g723_read(), g723_rewrite(), g723_seek(), g723_tell(), g723_trunc(), g723_write(), g726_16_open(), g726_16_rewrite(), g726_24_open(), g726_24_rewrite(), g726_32_open(), g726_32_rewrite(), g726_40_open(), g726_40_rewrite(), g726_close(), g726_getcomment(), g726_read(), g726_seek(), g726_tell(), g726_trunc(), g726_write(), g729_close(), g729_getcomment(), g729_open(), g729_read(), g729_rewrite(), g729_seek(), g729_tell(), g729_trunc(), g729_write(), g_config_initialized, get_exec(), get_group(), global_tracefile, gosub_descrip, gosub_exec(), gosub_synopsis, gosubif_descrip, gosubif_exec(), gosubif_synopsis, group, group_check_exec(), group_count_exec(), group_match_count_exec(), group_set_exec(), gruntdetect_timeout, gsm_close(), gsm_getcomment(), gsm_open(), gsm_read(), gsm_rewrite(), gsm_seek(), gsm_tell(), gsm_trunc(), gsm_write(), h263_close(), h263_getcomment(), h263_open(), h263_read(), h263_rewrite(), h263_seek(), h263_tell(), h263_trunc(), h263_write(), handle_playtones(), handle_stopplaytones(), hangup_connection(), has_voicemail(), hasvoicemail_exec(), htolel, iax2_do_register(), iax2_poke_peer(), iax2_prov_app(), iax_debug_output(), iax_error_output(), IAX_MAX_CALLS, iax_provision_reload(), iax_set_error(), iax_set_output(), iaxq, ices_exec(), iflist, ilbc_close(), ilbc_getcomment(), ilbc_open(), ilbc_read(), ilbc_rewrite(), ilbc_seek(), ilbc_tell(), ilbc_trunc(), ilbc_write(), ind_load_module(), init_classes(), io_context_create(), jb_error_output(), jb_setoutput(), jb_warning_output(), language, load_config(), load_objects(), load_odbc_config(), loadconfigurationfile(), local_ast_moh_cleanup(), local_ast_moh_start(), local_ast_moh_stop(), lock, ast_firmware_list::lock, ast_iax2_queue::lock, ast_alias_list::lock, ast_peer_list::lock, ast_user_list::lock, LOG_DEBUG, LOG_ERROR, log_file, LOG_NOTICE, LOG_WARNING, login_exec(), lookupblacklist_exec(), lookupcidname_exec(), macro_exec(), macro_exit_exec(), macroif_exec(), malloc, manager_add_queue_member(), manager_iax2_show_netstats(), manager_iax2_show_peers(), manager_log(), manager_parking_status(), manager_pause_queue_member(), manager_queues_show(), manager_queues_status(), manager_remove_queue_member(), manager_sip_show_peer(), manager_sip_show_peers(), mandescr_show_peer, mandescr_show_peers, math_exec(), max_ports, md5_exec(), md5check_exec(), messagecount(), milliwatt_exec(), misdn_cfg_get(), misdn_cfg_get_ports_string(), misdn_cfg_init(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_debug, misdn_debug_only, misdn_facility_exec(), misdn_set_opt_exec(), misdn_type, mixmonitor_exec(), mkbrd(), mkif(), vpb_pvt::mode, phone_pvt::mode, MODE_DIALTONE, MODE_FXO, MODE_FXS, MODE_IMMEDIATE, MODEM_DTMF_AST, MODEM_DTMF_I4L, MODEM_DTMF_NONE, MODEM_MODE_IMMEDIATE, MODEM_MODE_WAIT_ANSWER, MODEM_MODE_WAIT_RING, moh0_exec(), moh1_exec(), moh2_exec(), moh3_exec(), moh4_exec(), mp3_exec(), my_load_module(), ast_variable::name, NBScat_exec(), vpb_pvt::next, phone_pvt::next, ast_modem_pvt::next, iax2_peer::next, iax2_registry::next, ast_variable::next, nocdr_exec(), odbc_init(), odbc_load_module(), ogg_vorbis_close(), ogg_vorbis_getcomment(), ogg_vorbis_open(), ogg_vorbis_read(), ogg_vorbis_rewrite(), ogg_vorbis_seek(), ogg_vorbis_tell(), ogg_vorbis_trunc(), ogg_vorbis_write(), option_debug, option_initcrypto, option_verbose, ospfinished_exec(), osplookup_exec(), ospnext_exec(), page_exec(), park_call_exec(), park_exec(), parkandannounce_exec(), parse_config(), parse_gain_value(), pbx_load_module(), pcm_close(), pcm_getcomment(), pcm_open(), pcm_read(), pcm_rewrite(), pcm_seek(), pcm_tell(), pcm_trunc(), pcm_write(), peerl, ast_peer_list::peers, PGSQL_exec(), pickup_exec(), vpb_pvt::pickupgroup, playback_exec(), pop_descrip, pop_exec(), pop_synopsis, pqm_exec(), privacy_exec(), put_exec(), queue_exec(), queueagentcount_function, random_exec(), read_agent_config(), read_exec(), readfile_exec(), realtime_exec(), realtime_update_exec(), record_exec(), regl, relaxdtmf, release_lock, reload_agents(), reload_config(), reload_firmware(), reload_queue_members(), reload_queues(), restart_monitor(), retrydial_exec(), return_descrip, return_exec(), return_synopsis, rpt_exec(), rpt_master(), rqm_exec(), vpb_pvt::rxgain, phone_pvt::rxgain, vpb_pvt::rxswgain, sayunixtime_exec(), scan_thread(), sched_context_create(), send_digit(), senddtmf_exec(), sendimage_exec(), sendtext_exec(), sendurl_exec(), set_config(), set_dtmf_payload(), set_local_capabilities(), setcallerid_exec(), setcallerid_pres_exec(), setcdruserfield_exec(), setrdnis_exec(), settransfercapability_exec(), setup_incoming_call(), setup_outgoing_call(), setup_rtp_connection(), setup_zap(), show_console(), sip_addheader(), sip_dtmfmode(), sip_getheader(), sip_header_function, sip_poke_all_peers(), sip_send_all_registers(), sip_tech, sipchaninfo_function, sippeer_function, skel_exec(), slinear_close(), slinear_getcomment(), slinear_open(), slinear_read(), slinear_rewrite(), slinear_seek(), slinear_tell(), slinear_trunc(), slinear_write(), sms_exec(), iax2_peer::sockfd, softhangup_exec(), soft_key_template_definition::softKeyEvent, sort_exec(), sound_thread(), soundcard_init(), spool_dir, sqlite_log(), start_monitor_action(), start_monitor_exec(), start_network_thread(), statechange_queue(), stop_monitor_action(), stop_monitor_exec(), store_config(), strdup, synopsis, system_exec(), tds_load_module(), testclient_exec(), testserver_exec(), timer_period_ring, tracing, transfer_exec(), trysystem_exec(), vpb_pvt::txgain, phone_pvt::txgain, vpb_pvt::txswgain, txtcidname_exec(), type, chan_oss_pvt::type, unload_module(), upqm_exec(), use_ast_dtmf, use_ast_dtmfdet, use_ast_ind, UseLoopDrop, UseNativeBridge, UsePolarityCID, userevent_exec(), userl, ast_variable::value, verbose_exec(), VERBOSE_PREFIX_2, vm_box_exists(), vm_exec(), vm_execmain(), vmauthenticate(), VOICEMAIL_CONFIG, vox_close(), vox_getcomment(), vox_open(), vox_read(), vox_rewrite(), vox_seek(), vox_tell(), vox_trunc(), vox_write(), VPB_GOT_RXHWG, VPB_GOT_RXSWG, VPB_GOT_TXHWG, VPB_GOT_TXSWG, vpb_pvt::vpb_model, vpb_tech, vpb_tech_indicate, waitforring_exec(), waitforsilence_exec(), waresl, wav_close(), wav_getcomment(), wav_open(), wav_read(), wav_rewrite(), wav_seek(), wav_tell(), wav_trunc(), wav_write(), wave, while_end_exec(), while_start_exec(), zapateller_exec(), and zapras_exec().

    02454 {
    02455    /* Make sure we can register our agent channel type */
    02456    if (ast_channel_register(&agent_tech)) {
    02457       ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
    02458       return -1;
    02459    }
    02460    /* Dialplan applications */
    02461    ast_register_application(app, login_exec, synopsis, descrip);
    02462    ast_register_application(app2, callback_exec, synopsis2, descrip2);
    02463    ast_register_application(app3, agentmonitoroutgoing_exec, synopsis3, descrip3);
    02464    /* Manager commands */
    02465    ast_manager_register2("Agents", EVENT_FLAG_AGENT, action_agents, "Lists agents and their status", mandescr_agents);
    02466    ast_manager_register2("AgentLogoff", EVENT_FLAG_AGENT, action_agent_logoff, "Sets an agent as no longer logged in", mandescr_agent_logoff);
    02467    ast_manager_register2("AgentCallbackLogin", EVENT_FLAG_AGENT, action_agent_callback_login, "Sets an agent as logged in by callback", mandescr_agent_callback_login);
    02468    /* CLI Application */
    02469    ast_cli_register(&cli_show_agents);
    02470    ast_cli_register(&cli_agent_logoff);
    02471    /* Read in the config */
    02472    read_agent_config();
    02473    if (persistent_agents)
    02474       reload_agents();
    02475    return 0;
    02476 }

int reload | ( | void |  | ) |

Reload stuff.

This function is where any reload routines take place. Re-read config files, change signalling, whatever is appropriate on a reload.

Returns:
  The return value is not used.

Definition at line 2478 of file chan_agent.c.

References adsi_load(), ast_context_destroy(), ast_install_music_functions(), ast_log(), ast_unregister_indication_country(), config_load(), crypto_load(), delete_devices(), h323_reload(), ind_load_module(), init_classes(), load_config(), loadconfigurationfile(), local_ast_moh_cleanup(), local_ast_moh_start(), local_ast_moh_stop(), LOG_NOTICE, LOG_WARNING, mgcp_reload(), my_load_module(), my_unload_module(), odbc_load_module(), odbc_unload_module(), parse_config(), pbx_builtin_clear_globals(), pbx_load_module(), read_agent_config(), reload_agents(), reload_config(), reload_queues(), restart_monitor(), set_config(), setup_zap(), sip_reload(), tds_load_module(), and tds_unload_module().

Referenced by ast_module_reload().

    02479 {
    02480    read_agent_config();
    02481    if (persistent_agents)
    02482       reload_agents();
    02483    return 0;
    02484 }

int unload_module | ( | void |  | ) |

Cleanup all module structures, sockets, etc.

This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).

Returns:
  Zero on success, or non-zero on error.

Standard module functions ...

Definition at line 2486 of file chan_agent.c.

References __sip_destroy(), __unload_module(), aliasl, alsa, app, app_gosub, app_gosubif, app_pop, app_return, ast_cdr_unregister(), ast_channel_register(), ast_channel_unregister(), ast_cli_register(), ast_cli_unregister(), ast_cli_unregister_multiple(), ast_cond_destroy(), ast_config_engine_deregister(), ast_context_destroy(), ast_custom_function_unregister(), ast_devstate_del(), ast_format_unregister(), ast_free_ha(), ast_image_unregister(), ast_log(), ast_manager_unregister(), ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_rtp_proto_register(), ast_rtp_proto_unregister(), ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_uninstall_vm_functions(), ast_unregister_application(), ast_unregister_indication_country(), ast_unregister_modem_driver(), ast_unregister_switch(), ast_unregister_translator(), ast_verbose(), ASTOBJ_CONTAINER_DESTROY, ASTOBJ_CONTAINER_DESTROYALL, authl, bridges, builtins, checksipdomain_function, clear_and_free_interfaces(), clear_realm_authentication(), clear_sip_domains(), cli_add_queue_member, cli_conf, cli_remove_queue_member, cli_show_confs, cli_show_queue, cli_show_queues, delete_aliases(), delete_users(), mgcp_endpoint::delme, mgcp_gateway::delme, mgcp_gateway::endpoints, features, free, free_robin_list(), g_config_initialized, gateways, vpb_pvt::handle, chan_alsa_pvt::icard, iflist, io_context_destroy(), localaddr, locals, vpb_pvt::lock, ast_peer_list::lock, ast_user_list::lock, ast_alias_list::lock, oh323_pvt::lock, lock, LOG_NOTICE, LOG_VERBOSE, LOG_WARNING, max_bridges, mgcp_reload(), misdn_cfg_destroy(), misdn_debug, misdn_debug_only, misdn_tasks_destroy(), monitor_thread, mthreadactive, my_unload_module(), name, vpb_pvt::next, sip_pvt::next, chan_oss_pvt::next, mgcp_gateway::next, mgcp_endpoint::next, local_pvt::next, oh323_pvt::next, feature_pvt::next, agent_pvt::next, chan_alsa_pvt::ocard, odbc_destroy(), odbc_unload_module(), option_verbose, oss, vpb_pvt::owner, sip_pvt::owner, chan_oss_pvt::owner, local_pvt::owner, oh323_pvt::owner, feature_pvt::owner, chan_alsa_pvt::owner, agent_pvt::owner, vpb_pvt::owner_lock, peerl, vpb_pvt::play_dtmf_lock, vpb_pvt::play_lock, prune_gateways(), prune_peers(), queueagentcount_function, vpb_pvt::readthread, vpb_pvt::record_lock, regl, rpt_vars, sched_context_destroy(), sip_destroy_peer(), sip_destroy_user(), sip_header_function, sip_registry_destroy(), sip_tech, sipchaninfo_function, sippeer_function, sipsock, skinny_session(), chan_oss_pvt::sndcmd, chan_oss_pvt::sounddev, STANDARD_HANGUP_LOCALUSERS, statechange_queue(), tds_unload_module(), unregister_translators(), use_ast_ind, userl, vpb_tech, and vpb_tech_indicate.

Referenced by load_module().

    02487 {
    02488    struct agent_pvt *p;
    02489    /* First, take us out of the channel loop */
    02490    /* Unregister CLI application */
    02491    ast_cli_unregister(&cli_show_agents);
    02492    ast_cli_unregister(&cli_agent_logoff);
    02493    /* Unregister dialplan applications */
    02494    ast_unregister_application(app);
    02495    ast_unregister_application(app2);
    02496    ast_unregister_application(app3);
    02497    /* Unregister manager command */
    02498    ast_manager_unregister("Agents");
    02499    ast_manager_unregister("AgentLogoff");
    02500    ast_manager_unregister("AgentCallbackLogin");
    02501    /* Unregister channel */
    02502    ast_channel_unregister(&agent_tech);
    02503    if (!ast_mutex_lock(&agentlock)) {
    02504       /* Hangup all interfaces if they have an owner */
    02505       p = agents;
    02506       while(p) {
    02507          if (p->owner)
    02508             ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
    02509          p = p->next;
    02510       }
    02511       agents = NULL;
    02512       ast_mutex_unlock(&agentlock);
    02513    } else {
    02514       ast_log(LOG_WARNING, "Unable to lock the monitor\n");
    02515       return -1;
    02516    }
    02517    return 0;
    02518 }

int usecount | ( | void |  | ) |

Provides a usecount.

This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.

Returns:
  The module's usecount.

Definition at line 2520 of file chan_agent.c.

References ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), STANDARD_USECOUNT, usecnt, and usecnt_lock.

    02521 {
    02522    return usecnt;
    02523 }