Sat Aug 6 00:39:37 2011

Asterisk developer's documentation


app_skel.c File Reference

Skeleton application. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk/file.h"
#include "asterisk/logger.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_A = (1 << 0), OPTION_B = (1 << 1), OPTION_C = (1 << 2) }
enum  { OPTION_ARG_B = 0, OPTION_ARG_C = 1, OPTION_ARG_ARRAY_SIZE = 2 }

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int app_exec (struct ast_channel *chan, void *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_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
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 const struct ast_module_infoast_module_info = &__mod_info
static char * descrip
enum { ... }  option_args
enum { ... }  option_flags
static char * synopsis


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

anonymous enum

Enumerator:
OPTION_A 
OPTION_B 
OPTION_C 

Definition at line 56 of file app_skel.c.

00056      {
00057    OPTION_A = (1 << 0),
00058    OPTION_B = (1 << 1),
00059    OPTION_C = (1 << 2),
00060 } option_flags;

anonymous enum

Enumerator:
OPTION_ARG_B 
OPTION_ARG_C 
OPTION_ARG_ARRAY_SIZE 

Definition at line 62 of file app_skel.c.

00062      {
00063    OPTION_ARG_B = 0,
00064    OPTION_ARG_C = 1,
00065    /* This *must* be the last value in this enum! */
00066    OPTION_ARG_ARRAY_SIZE = 2,
00067 } option_args;


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 133 of file app_skel.c.

static void __unreg_module ( void   )  [static]

Definition at line 133 of file app_skel.c.

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

Definition at line 76 of file app_skel.c.

References app_opts, AST_APP_ARG, ast_app_parse_options(), AST_DECLARE_APP_ARGS, ast_log(), ast_module_user_add, ast_module_user_remove, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_module_user::chan, 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().

00077 {
00078    int res = 0;
00079    struct ast_flags flags;
00080    struct ast_module_user *u;
00081    char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
00082    AST_DECLARE_APP_ARGS(args,
00083       AST_APP_ARG(dummy);
00084       AST_APP_ARG(options);
00085    );
00086 
00087    if (ast_strlen_zero(data)) {
00088       ast_log(LOG_WARNING, "%s requires an argument (dummy|[options])\n", app);
00089       return -1;
00090    }
00091 
00092    u = ast_module_user_add(chan);
00093 
00094    /* Do our thing here */
00095 
00096    /* We need to make a copy of the input string if we are going to modify it! */
00097    parse = ast_strdupa(data);
00098 
00099    AST_STANDARD_APP_ARGS(args, parse);
00100 
00101    if (args.argc == 2)
00102       ast_app_parse_options(app_opts, &flags, opts, args.options);
00103 
00104    if (!ast_strlen_zero(args.dummy)) 
00105       ast_log(LOG_NOTICE, "Dummy value is : %s\n", args.dummy);
00106 
00107    if (ast_test_flag(&flags, OPTION_A))
00108       ast_log(LOG_NOTICE, "Option A is set\n");
00109 
00110    if (ast_test_flag(&flags, OPTION_B))
00111       ast_log(LOG_NOTICE, "Option B is set with : %s\n", opts[OPTION_ARG_B] ? opts[OPTION_ARG_B] : "<unspecified>");
00112 
00113    if (ast_test_flag(&flags, OPTION_C))
00114       ast_log(LOG_NOTICE, "Option C is set with : %s\n", opts[OPTION_ARG_C] ? opts[OPTION_ARG_C] : "<unspecified>");
00115 
00116    ast_module_user_remove(u);
00117 
00118    return res;
00119 }

static int load_module ( void   )  [static]

Definition at line 128 of file app_skel.c.

References app_exec, and ast_register_application().

00129 {
00130    return ast_register_application(app, app_exec, synopsis, descrip);
00131 }

static int unload_module ( void   )  [static]

Definition at line 121 of file app_skel.c.

References ast_unregister_application().

00122 {
00123    int res;
00124    res = ast_unregister_application(app);
00125    return res; 
00126 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 133 of file app_skel.c.

char* app = "Skel" [static]

Definition at line 50 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 73 of file app_skel.c.

Referenced by app_exec().

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 133 of file app_skel.c.

char* descrip [static]

Initial value:

 "This application is a template to build other applications from.\n"
 " It shows you the basic structure to create your own Asterisk applications.\n"

Definition at line 53 of file app_skel.c.

enum { ... } option_args

enum { ... } option_flags

char* synopsis [static]

Initial value:

 
"Skeleton application."

Definition at line 51 of file app_skel.c.


Generated on Sat Aug 6 00:39:37 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7