<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2176/18/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Modules">Modules</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~lathama">Andrew Latham</a>
</h4>
<div id="versionComment">
<b>Comment:</b>
Add AST_MODULE_INFO<br />
</div>
<br/>
<h4>Changes (3)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >{code} <br>AST_MODULE_INFO_STANDARD(keystr, desc); <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">... or ... <br>AST_MODULE_INFO(keystr, flags_to_set, desc, load_func, unload_func, reload_func, load_pri); <br></td></tr>
<tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">*AST_MODULE_INFO_STANDARD* <br></td></tr>
<tr><td class="diff-unchanged" >* keystr - Applicable license for module. In most cases this is ASTERISK_GPL_KEY. <br>* desc - Description of module. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>*AST_MODULE_INFO* <br>* keystr <br>* flags_to_set <br>* desc <br>* load_func <br>* unload_func <br>* reload_func <br>* load_pri <br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<p>All modules must have at least the following:</p>
<h2><a name="Modules-LoadModule"></a>Load Module</h2>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">static int load_module():</pre>
</div></div>
<p>Module loading including tests for configuration or dependencies. This function can return <b>AST_MODULE_LOAD_FAILURE</b>, <b>AST_MODULE_LOAD_DECLINE</b>, or <b>AST_MODULE_LOAD_SUCCESS</b>. If a dependency or environment variable fails tests return <b>AST_MODULE_LOAD_FAILURE</b>. If the module can not load the configuration file or other non-critical problem retrun <b>AST_MODULE_LOAD_DECLINE</b>. On success return <b>AST_MODULE_LOAD_SUCCESS</b>.</p>
<p>Example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">/*!
* \brief Load Module
*/
static int load_module(void)
{
if (dependency_does_not_exist) {
return AST_MODULE_LOAD_FAILURE;
}
if (configuration_file_does_not_exist) {
return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}</pre>
</div></div>
<h2><a name="Modules-UnloadModule"></a>Unload Module</h2>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">static int unload_module():</pre>
</div></div>
<p>The module will soon be unloaded. If any channels are using your features, you should give them a softhangup in an effort to keep the program from crashing. Generally, unload_module is only called when the usecount is 0 or less, but the user can force unloading at their discretion, and thus a module should do its best to comply (although in some cases there may be no way to avoid a crash). This function should return 0 on success and non-zero on failure (i.e. it cannot yet be unloaded).</p>
<p>Example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">/*!
* \brief Unload Module
*/
static int unload_module(void)
{
if (active_use) {
return 1;
}
return 0;
}</pre>
</div></div>
<h2><a name="Modules-ModuleInformation"></a>Module Information</h2>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">AST_MODULE_INFO_STANDARD(keystr, desc);
... or ...
AST_MODULE_INFO(keystr, flags_to_set, desc, load_func, unload_func, reload_func, load_pri);</pre>
</div></div>
<p><b>AST_MODULE_INFO_STANDARD</b></p>
<ul>
        <li>keystr - Applicable license for module. In most cases this is ASTERISK_GPL_KEY.</li>
        <li>desc - Description of module.</li>
</ul>
<p><b>AST_MODULE_INFO</b></p>
<ul>
        <li>keystr</li>
        <li>flags_to_set</li>
        <li>desc</li>
        <li>load_func</li>
        <li>unload_func</li>
        <li>reload_func</li>
        <li>load_pri</li>
</ul>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Modules">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4260026&revisedVersion=4&originalVersion=3">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Modules?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>