Wed Jan 27 20:02:19 2016

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), OPTION_WAIT = (1 << 0),
  OPTION_PATTERNS_DISABLED = (1 << 0)
}

Functions

static int app_exec (struct ast_channel *chan, const char *data)
 AST_APP_OPTIONS (app_opts,{AST_APP_OPTION('a', OPTION_A), AST_APP_OPTION_ARG('b', OPTION_B, OPTION_ARG_B), AST_APP_OPTION_ARG('c', OPTION_C, OPTION_ARG_C),})
 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Skeleton (sample) Application")
static int load_module (void)
static int unload_module (void)

Variables

static char * app = "Skel"

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

Enumerator:
OPTION_ARG_B 
OPTION_ARG_C 
OPTION_ARG_ARRAY_SIZE 

Definition at line 84 of file app_skel.c.

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

Enumerator:
OPTION_A 
OPTION_B 
OPTION_C 
OPTION_WAIT 
OPTION_PATTERNS_DISABLED 

Definition at line 78 of file app_skel.c.

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


Function Documentation

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

Definition at line 98 of file app_skel.c.

References 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(), LOG_NOTICE, LOG_WARNING, OPTION_A, OPTION_ARG_ARRAY_SIZE, OPTION_ARG_B, OPTION_ARG_C, OPTION_B, OPTION_C, and parse().

Referenced by load_module().

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

AST_APP_OPTIONS ( app_opts   ) 
AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Skeleton (sample) Application"   
)
static int load_module ( void   )  [static]
static int unload_module ( void   )  [static]

Definition at line 143 of file app_skel.c.

References ast_unregister_application().

00144 {
00145    return ast_unregister_application(app);
00146 }


Variable Documentation

char* app = "Skel" [static]

Definition at line 76 of file app_skel.c.


Generated on 27 Jan 2016 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1