Mon Jun 27 16:51:00 2011

Asterisk developer's documentation


app_skel.c File Reference

Skeleton application. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"

Go to the source code of this file.

Enumerations

enum  option_args { OPTION_ARG_B = 0, OPTION_ARG_C = 1, OPTION_ARG_ARRAY_SIZE = 2 }
enum  option_flags { OPTION_A = (1 << 0), OPTION_B = (1 << 1), OPTION_C = (1 << 2) }

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int app_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Skeleton (sample) Application" , .key = "This paragraph is copyright (c) 2006 by Digium, 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). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static char * app = "Skel"
static struct ast_app_option app_opts [128] = { [ 'a' ] = { .flag = OPTION_A }, [ 'b' ] = { .flag = OPTION_B , .arg_index = OPTION_ARG_B + 1 }, [ 'c' ] = { .flag = OPTION_C , .arg_index = OPTION_ARG_C + 1 },}
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

Skeleton application.

Author:
<Your Name Here> <<Your Email Here>> 
This is a skeleton for development of an Asterisk application

Definition in file app_skel.c.


Enumeration Type Documentation

enum option_args

Enumerator:
OPTION_ARG_B 
OPTION_ARG_C 
OPTION_ARG_ARRAY_SIZE 

Definition at line 83 of file app_skel.c.

00083                  {
00084    OPTION_ARG_B = 0,
00085    OPTION_ARG_C = 1,
00086    /* This *must* be the last value in this enum! */
00087    OPTION_ARG_ARRAY_SIZE = 2,
00088 };

enum option_flags

Enumerator:
OPTION_A 
OPTION_B 
OPTION_C 

Definition at line 77 of file app_skel.c.

00077                   {
00078    OPTION_A = (1 << 0),
00079    OPTION_B = (1 << 1),
00080    OPTION_C = (1 << 2),
00081 };


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 153 of file app_skel.c.

static void __unreg_module ( void   )  [static]

Definition at line 153 of file app_skel.c.

static int app_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 97 of file app_skel.c.

References app_opts, args, AST_APP_ARG, ast_app_parse_options(), AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, dummy(), ast_flags::flags, LOG_NOTICE, LOG_WARNING, OPTION_A, OPTION_ARG_ARRAY_SIZE, OPTION_ARG_B, OPTION_ARG_C, OPTION_B, OPTION_C, and parse().

00098 {
00099    int res = 0;
00100    struct ast_flags flags;
00101    char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
00102    AST_DECLARE_APP_ARGS(args,
00103       AST_APP_ARG(dummy);
00104       AST_APP_ARG(options);
00105    );
00106 
00107    if (ast_strlen_zero(data)) {
00108       ast_log(LOG_WARNING, "%s requires an argument (dummy[,options])\n", app);
00109       return -1;
00110    }
00111 
00112    /* Do our thing here */
00113 
00114    /* We need to make a copy of the input string if we are going to modify it! */
00115    parse = ast_strdupa(data);
00116 
00117    AST_STANDARD_APP_ARGS(args, parse);
00118 
00119    if (args.argc == 2) {
00120       ast_app_parse_options(app_opts, &flags, opts, args.options);
00121    }
00122 
00123    if (!ast_strlen_zero(args.dummy)) {
00124       ast_log(LOG_NOTICE, "Dummy value is : %s\n", args.dummy);
00125    }
00126 
00127    if (ast_test_flag(&flags, OPTION_A)) {
00128       ast_log(LOG_NOTICE, "Option A is set\n");
00129    }
00130 
00131    if (ast_test_flag(&flags, OPTION_B)) {
00132       ast_log(LOG_NOTICE, "Option B is set with : %s\n", opts[OPTION_ARG_B] ? opts[OPTION_ARG_B] : "<unspecified>");
00133    }
00134 
00135    if (ast_test_flag(&flags, OPTION_C)) {
00136       ast_log(LOG_NOTICE, "Option C is set with : %s\n", opts[OPTION_ARG_C] ? opts[OPTION_ARG_C] : "<unspecified>");
00137    }
00138 
00139    return res;
00140 }

static int load_module ( void   )  [static]

Definition at line 147 of file app_skel.c.

References app_exec, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and ast_register_application_xml.

static int unload_module ( void   )  [static]

Definition at line 142 of file app_skel.c.

References ast_unregister_application().

00143 {
00144    return ast_unregister_application(app);
00145 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Skeleton (sample) Application" , .key = "This paragraph is copyright (c) 2006 by Digium, 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). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 153 of file app_skel.c.

char* app = "Skel" [static]

Definition at line 75 of file app_skel.c.

struct ast_app_option app_opts[128] = { [ 'a' ] = { .flag = OPTION_A }, [ 'b' ] = { .flag = OPTION_B , .arg_index = OPTION_ARG_B + 1 }, [ 'c' ] = { .flag = OPTION_C , .arg_index = OPTION_ARG_C + 1 },} [static]

Definition at line 94 of file app_skel.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 153 of file app_skel.c.


Generated on Mon Jun 27 16:51:00 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7