Created
October 19, 2012 18:07
-
-
Save leedm777/3919683 to your computer and use it in GitHub Desktop.
Asterisk's simplest module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Asterisk -- An open source telephony toolkit. | |
* | |
* Copyright (C) 2012, Digium, Inc. | |
* | |
* David M. Lee, II <[email protected]> | |
* | |
* See http://www.asterisk.org for more information about | |
* the Asterisk project. Please do not directly contact | |
* any of the maintainers of this project for assistance; | |
* the project provides a web site, mailing lists and IRC | |
* channels for your use. | |
* | |
* This program is free software, distributed under the terms of | |
* the GNU General Public License Version 2. See the LICENSE file | |
* at the top of the source tree. | |
*/ | |
/*! \file | |
* | |
* \brief Hello - Asterisk's simplest module. | |
* | |
* \author David M. Lee, II <[email protected]> | |
*/ | |
#include "asterisk.h" | |
#include "asterisk/module.h" | |
/* | |
* MODULEINFO block contains module metadata (support level, dependencies, etc.) | |
*/ | |
/*** MODULEINFO | |
<support_level>extended</support_level> | |
<defaulteanbled>no</defaulteanbled> | |
***/ | |
/*! | |
* \brief Load the res_hello.so module. | |
* | |
* There's no way for this module to fail to load, so it always returns | |
* AST_MODULE_LOAD_SUCCESS. | |
*/ | |
static int load_module(void) | |
{ | |
ast_log(AST_LOG_NOTICE, "Hello, Asterisk"); | |
/* AST_MODULE_LOAD_FAILURE would indicate a fatal error, such as a missing | |
* dependency. | |
*/ | |
/* AST_MODULE_LOAD_DECLINE would indicate failure to load due to bad | |
* or missing configuration. | |
*/ | |
return AST_MODULE_LOAD_SUCCESS; | |
} | |
/*! | |
* /brief Unloaad the res_hello.so module. | |
* | |
* Like loading, this is too simple to fail. | |
*/ | |
static int unload_module(void) | |
{ | |
ast_log(AST_LOG_NOTICE, "Goodbye, Asterisk\n"); | |
/* If modules resources are still in use, or cannot be unloaded, return -1 */ | |
return 0; | |
} | |
/* The following module information blob has the necessary module metadata to make the module | |
* usable by Asterisk. AST_MODULE_INFO allows more options to be set, but they're usually not | |
* necessary. | |
*/ | |
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Hello, Asterisk!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment