|
Asterisk - The Open Source Telephony Project GIT-master-27fb039
|
Skeleton application. More...
#include "asterisk.h"#include <math.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"#include "asterisk/config.h"#include "asterisk/config_options.h"#include "asterisk/say.h"#include "asterisk/astobj2.h"#include "asterisk/acl.h"#include "asterisk/netsock2.h"#include "asterisk/strings.h"#include "asterisk/cli.h"
Go to the source code of this file.
Data Structures | |
| struct | skel_config |
| A container that holds all config-related information. More... | |
| struct | skel_current_game |
| Information about a currently running set of games. More... | |
| struct | skel_global_config |
| A structure to hold global configuration-related options. More... | |
| struct | skel_level |
| Object to hold level config information. More... | |
| struct | skel_level_state |
| A structure to maintain level state across reloads. More... | |
Macros | |
| #define | LEVEL_BUCKETS 1 |
| #define | SKEL_FORMAT "%-15.15s %-15.15s %-15.15s\n" |
| #define | SKEL_FORMAT "%-15.15s %-11.11s %-12.12s %-8.8s %-8.8s %-12.12s\n" |
| #define | SKEL_FORMAT1 "%-15.15s %-15u %-15u\n" |
| #define | SKEL_FORMAT1 "%-15.15s %-11u %-12u %-8u %-8u %-8f\n" |
Enumerations | |
| enum | option_args { OPTION_ARG_NUMGAMES , OPTION_ARG_ARRAY_SIZE } |
| enum | option_flags { OPTION_CHEAT = (1 << 0) , OPTION_NUMGAMES = (1 << 1) } |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static | AO2_GLOBAL_OBJ_STATIC (globals) |
| A global object container that will contain the skel_config that gets swapped out on reloads. | |
| static int | app_exec (struct ast_channel *chan, const char *data) |
| struct ast_module * | AST_MODULE_SELF_SYM (void) |
| CONFIG_INFO_STANDARD (cfg_info, globals, skel_config_alloc,.files=ACO_FILES(&app_skel_conf),) | |
| Register information about the configs being processed by this module. | |
| static int | custom_bitfield_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
| A custom bitfield handler. | |
| static char * | handle_skel_show_config (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_skel_show_games (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_skel_show_levels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | load_module (void) |
| Load the module. | |
| static void | play_files_helper (struct ast_channel *chan, const char *prompts) |
| static int | reload_module (void) |
| static void * | skel_config_alloc (void) |
| Allocate a skel_config to hold a snapshot of the complete results of parsing a config. | |
| static void | skel_config_destructor (void *obj) |
| static void * | skel_find_or_create_state (const char *category) |
| Look up an existing state object, or create a new one. | |
| static struct skel_current_game * | skel_game_alloc (struct skel_level *level) |
| static void | skel_game_destructor (void *obj) |
| static void | skel_global_config_destructor (void *obj) |
| static void * | skel_level_alloc (const char *cat) |
| Allocate a skel_level based on a category in a configuration file. | |
| static int | skel_level_cmp (void *obj, void *arg, int flags) |
| static void | skel_level_destructor (void *obj) |
| static void * | skel_level_find (struct ao2_container *tmp_container, const char *category) |
| Find a skel level in the specified container. | |
| static int | skel_level_hash (const void *obj, const int flags) |
| static struct skel_level * | skel_state_alloc (const char *name) |
| static void | skel_state_destructor (void *obj) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Skeleton (sample) Application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, } |
| static char * | app = "SkelGuessNumber" |
| static const struct ast_app_option | app_opts [128] = { [ 'c' ] = { .flag = OPTION_CHEAT }, [ 'n' ] = { .flag = OPTION_NUMGAMES , .arg_index = OPTION_ARG_NUMGAMES + 1 }, } |
| struct aco_file | app_skel_conf |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ao2_container * | games |
| The container of active games. | |
| static struct aco_type | global_option |
| An aco_type structure to link the "general" category to the skel_global_config type. | |
| struct aco_type * | global_options [] = ACO_TYPES(&global_option) |
| static const char * | level_categories [] |
| static struct aco_type | level_option |
| An aco_type structure to link the everything but the "general" and "sounds" categories to the skel_level type. | |
| struct aco_type * | level_options [] = ACO_TYPES(&level_option) |
| static struct ast_cli_entry | skel_cli [] |
| static struct aco_type | sound_option |
| An aco_type structure to link the "sounds" category to the skel_global_config type. | |
| struct aco_type * | sound_options [] = ACO_TYPES(&sound_option) |
Skeleton application.
This is a skeleton for development of an Asterisk application
Definition in file app_skel.c.
| #define LEVEL_BUCKETS 1 |
Definition at line 244 of file app_skel.c.
| #define SKEL_FORMAT "%-15.15s %-15.15s %-15.15s\n" |
| #define SKEL_FORMAT "%-15.15s %-11.11s %-12.12s %-8.8s %-8.8s %-12.12s\n" |
| #define SKEL_FORMAT1 "%-15.15s %-15u %-15u\n" |
| #define SKEL_FORMAT1 "%-15.15s %-11u %-12u %-8u %-8u %-8f\n" |
| enum option_args |
| Enumerator | |
|---|---|
| OPTION_ARG_NUMGAMES | |
| OPTION_ARG_ARRAY_SIZE | |
Definition at line 184 of file app_skel.c.
| enum option_flags |
| Enumerator | |
|---|---|
| OPTION_CHEAT | |
| OPTION_NUMGAMES | |
Definition at line 179 of file app_skel.c.
|
static |
Definition at line 817 of file app_skel.c.
|
static |
Definition at line 817 of file app_skel.c.
|
static |
A global object container that will contain the skel_config that gets swapped out on reloads.
|
static |
Definition at line 423 of file app_skel.c.
References ao2_cleanup, ao2_find, ao2_global_obj_ref, ao2_link, ao2_lock, ao2_unlink, ao2_unlock, app, app_opts, args, AST_APP_ARG, ast_app_parse_options(), ast_channel_language(), ast_debug, AST_DECLARE_APP_ARGS, ast_log, ast_parse_arg(), ast_random(), ast_readstring(), ast_say_number(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, buf, ast_flags::flags, games, globals, LOG_ERROR, LOG_WARNING, NULL, OBJ_KEY, OPTION_ARG_ARRAY_SIZE, OPTION_ARG_NUMGAMES, OPTION_CHEAT, OPTION_NUMGAMES, options, PARSE_IN_RANGE, PARSE_INT32, PARSE_UINT32, play_files_helper(), RAII_VAR, and skel_game_alloc().
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 817 of file app_skel.c.
| CONFIG_INFO_STANDARD | ( | cfg_info | , |
| globals | , | ||
| skel_config_alloc | , | ||
| . | files = ACO_FILES(&app_skel_conf) |
||
| ) |
Register information about the configs being processed by this module.
|
static |
A custom bitfield handler.
Definition at line 399 of file app_skel.c.
References ast_true(), global, and var.
Referenced by load_module().
|
static |
Definition at line 639 of file app_skel.c.
References a, ao2_cleanup, ao2_global_obj_ref, ast_cli(), AST_CLI_YESNO, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, globals, NULL, RAII_VAR, and ast_cli_entry::usage.
|
static |
Definition at line 669 of file app_skel.c.
References a, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, games, skel_current_game::games_left, skel_current_game::level_info, skel_level::name, NULL, SKEL_FORMAT, SKEL_FORMAT1, skel_current_game::total_games, and ast_cli_entry::usage.
|
static |
Definition at line 699 of file app_skel.c.
References a, ao2_cleanup, ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli(), skel_level_state::avg_guesses, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, globals, skel_level_state::losses, skel_level::max_guesses, skel_level::max_num, skel_level::name, NULL, RAII_VAR, SKEL_FORMAT, SKEL_FORMAT1, skel_level::state, ast_cli_entry::usage, and skel_level_state::wins.
|
static |
Load the module.
Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
Definition at line 769 of file app_skel.c.
References ACO_EXACT, aco_info_destroy(), aco_info_init(), aco_option_register, aco_option_register_custom, aco_process_config(), ACO_PROCESS_ERROR, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_cleanup, ao2_container_alloc_list, app, app_exec, ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, custom_bitfield_handler(), error(), FLDSET, games, global_options, level_options, NULL, OPT_STRINGFIELD_T, OPT_UINT_T, prompt, skel_cli, sound_options, and STRFLDSET.
|
static |
Definition at line 412 of file app_skel.c.
References ast_stopstream(), ast_strdupa, ast_stream_and_wait(), ast_strsep(), AST_STRSEP_STRIP, AST_STRSEP_TRIM, and prompt.
Referenced by app_exec().
|
static |
Definition at line 741 of file app_skel.c.
References aco_process_config(), ACO_PROCESS_ERROR, and AST_MODULE_LOAD_DECLINE.
|
static |
Allocate a skel_config to hold a snapshot of the complete results of parsing a config.
Definition at line 610 of file app_skel.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ast_string_field_init, error(), skel_config::global, LEVEL_BUCKETS, skel_config::levels, NULL, skel_config_destructor(), skel_global_config_destructor(), skel_level_cmp(), and skel_level_hash().
|
static |
Definition at line 603 of file app_skel.c.
References ao2_cleanup, skel_config::global, and skel_config::levels.
Referenced by skel_config_alloc().
|
static |
Look up an existing state object, or create a new one.
Definition at line 565 of file app_skel.c.
References ao2_cleanup, ao2_find, ao2_global_obj_ref, ao2_ref, globals, NULL, OBJ_KEY, RAII_VAR, and skel_state_alloc().
Referenced by skel_level_alloc().
|
static |
Definition at line 357 of file app_skel.c.
References ao2_alloc, ao2_ref, skel_current_game::level_info, NULL, and skel_game_destructor().
Referenced by app_exec().
|
static |
Definition at line 346 of file app_skel.c.
References ao2_cleanup, and skel_current_game::level_info.
Referenced by skel_game_alloc().
|
static |
Definition at line 340 of file app_skel.c.
References ast_string_field_free_memory, and global.
Referenced by skel_config_alloc().
|
static |
Allocate a skel_level based on a category in a configuration file.
| cat | The category to base the level on |
Definition at line 576 of file app_skel.c.
References ao2_alloc, ao2_ref, ast_string_field_init, ast_string_field_set, name, NULL, skel_find_or_create_state(), skel_level_destructor(), and skel_level::state.
|
static |
Definition at line 382 of file app_skel.c.
References CMP_MATCH, CMP_STOP, match(), skel_level::name, and OBJ_KEY.
Referenced by skel_config_alloc().
|
static |
Definition at line 368 of file app_skel.c.
References ao2_cleanup, ast_string_field_free_memory, and skel_level::state.
Referenced by skel_level_alloc().
|
static |
Find a skel level in the specified container.
| tmp_container | A non-active container to search for a level |
| category | The category associated with the level to check for |
| non-NULL | The level from the container |
| NULL | The level does not exist in the container |
Definition at line 552 of file app_skel.c.
|
static |
Definition at line 375 of file app_skel.c.
References ast_str_case_hash(), name, skel_level::name, and OBJ_KEY.
Referenced by skel_config_alloc().
|
static |
Definition at line 541 of file app_skel.c.
References ao2_alloc, NULL, and skel_state_destructor().
Referenced by skel_find_or_create_state().
|
static |
Definition at line 352 of file app_skel.c.
Referenced by skel_state_alloc().
|
static |
Definition at line 750 of file app_skel.c.
References aco_info_destroy(), ao2_cleanup, ao2_global_obj_release, app, ARRAY_LEN, ast_cli_unregister_multiple(), ast_unregister_application(), games, globals, and skel_cli.
|
static |
Definition at line 817 of file app_skel.c.
|
static |
Definition at line 177 of file app_skel.c.
|
static |
Definition at line 193 of file app_skel.c.
| struct aco_file app_skel_conf |
Definition at line 324 of file app_skel.c.
|
static |
Definition at line 817 of file app_skel.c.
|
static |
The container of active games.
Definition at line 333 of file app_skel.c.
Referenced by app_exec(), handle_skel_show_games(), load_module(), and unload_module().
|
static |
An aco_type structure to link the "general" category to the skel_global_config type.
Definition at line 284 of file app_skel.c.
| struct aco_type* global_options[] = ACO_TYPES(&global_option) |
|
static |
Definition at line 305 of file app_skel.c.
|
static |
An aco_type structure to link the everything but the "general" and "sounds" categories to the skel_level type.
Definition at line 312 of file app_skel.c.
| struct aco_type* level_options[] = ACO_TYPES(&level_option) |
|
static |
Definition at line 735 of file app_skel.c.
Referenced by load_module(), and unload_module().
|
static |
An aco_type structure to link the "sounds" category to the skel_global_config type.
Definition at line 295 of file app_skel.c.
| struct aco_type* sound_options[] = ACO_TYPES(&sound_option) |