Wed Jan 8 2020 09:49:55

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 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 = "ac1f6a56484a8820659555499174e588" , .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

Enumerator
OPTION_ARG_B 
OPTION_ARG_C 
OPTION_ARG_ARRAY_SIZE 

Definition at line 84 of file app_skel.c.

84  {
85  OPTION_ARG_B = 0,
86  OPTION_ARG_C = 1,
87  /* This *must* be the last value in this enum! */
89 };
Enumerator
OPTION_A 
OPTION_B 
OPTION_C 
OPTION_WAIT 
OPTION_PATTERNS_DISABLED 

Definition at line 78 of file app_skel.c.

78  {
79  OPTION_A = (1 << 0),
80  OPTION_B = (1 << 1),
81  OPTION_C = (1 << 2),
82 };

Function Documentation

static void __reg_module ( void  )
static

Definition at line 154 of file app_skel.c.

static void __unreg_module ( void  )
static

Definition at line 154 of file app_skel.c.

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

Definition at line 98 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(), 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().

99 {
100  int res = 0;
101  struct ast_flags flags;
102  char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
105  AST_APP_ARG(options);
106  );
107 
108  if (ast_strlen_zero(data)) {
109  ast_log(LOG_WARNING, "%s requires an argument (dummy[,options])\n", app);
110  return -1;
111  }
112 
113  /* Do our thing here */
114 
115  /* We need to make a copy of the input string if we are going to modify it! */
116  parse = ast_strdupa(data);
117 
118  AST_STANDARD_APP_ARGS(args, parse);
119 
120  if (args.argc == 2) {
121  ast_app_parse_options(app_opts, &flags, opts, args.options);
122  }
123 
124  if (!ast_strlen_zero(args.dummy)) {
125  ast_log(LOG_NOTICE, "Dummy value is : %s\n", args.dummy);
126  }
127 
128  if (ast_test_flag(&flags, OPTION_A)) {
129  ast_log(LOG_NOTICE, "Option A is set\n");
130  }
131 
132  if (ast_test_flag(&flags, OPTION_B)) {
133  ast_log(LOG_NOTICE, "Option B is set with : %s\n", opts[OPTION_ARG_B] ? opts[OPTION_ARG_B] : "<unspecified>");
134  }
135 
136  if (ast_test_flag(&flags, OPTION_C)) {
137  ast_log(LOG_NOTICE, "Option C is set with : %s\n", opts[OPTION_ARG_C] ? opts[OPTION_ARG_C] : "<unspecified>");
138  }
139 
140  return res;
141 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
static struct ast_app_option app_opts[128]
Definition: app_skel.c:95
#define LOG_WARNING
Definition: logger.h:144
static void dummy(char *unused,...)
Definition: chan_unistim.c:188
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: app.c:2101
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
unsigned int flags
Definition: utils.h:201
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
static char * app
Definition: app_skel.c:76
Structure used to handle boolean flags.
Definition: utils.h:200
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static int load_module ( void  )
static

Definition at line 148 of file app_skel.c.

References app_exec(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and ast_register_application_xml.

149 {
152 }
static int app_exec(struct ast_channel *chan, const char *data)
Definition: app_skel.c:98
static char * app
Definition: app_skel.c:76
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int unload_module ( void  )
static

Definition at line 143 of file app_skel.c.

References ast_unregister_application().

144 {
146 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static char * app
Definition: app_skel.c:76

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 154 of file app_skel.c.

char* app = "Skel"
static

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

Referenced by app_exec().

Definition at line 154 of file app_skel.c.