Wed Jan 8 2020 09:49:53

Asterisk developer's documentation


app_db.c File Reference

Database access functions. More...

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

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int del_exec (struct ast_channel *chan, const char *data)
 
static int deltree_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 = "Database Access Functions" , .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 struct ast_module_infoast_module_info = &__mod_info
 
static const char d_app [] = "DBdel"
 
static const char dt_app [] = "DBdeltree"
 

Detailed Description

Database access functions.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Jefferson Noxon jeff@.nosp@m.debi.nosp@m.an.or.nosp@m.g

Definition in file app_db.c.

Function Documentation

static void __reg_module ( void  )
static

Definition at line 171 of file app_db.c.

static void __unreg_module ( void  )
static

Definition at line 171 of file app_db.c.

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

Definition at line 122 of file app_db.c.

References ast_db_del(), ast_debug, ast_log(), ast_strdupa, ast_verb, LOG_WARNING, and strsep().

Referenced by load_module().

123 {
124  char *argv, *family, *key;
125  static int deprecation_warning = 0;
126 
127  if (!deprecation_warning) {
128  deprecation_warning = 1;
129  ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
130  }
131 
132  argv = ast_strdupa(data);
133 
134  if (strchr(argv, '/')) {
135  family = strsep(&argv, "/");
136  key = strsep(&argv, "\0");
137  if (!family || !key) {
138  ast_debug(1, "Ignoring; Syntax error in argument\n");
139  return 0;
140  }
141  ast_verb(3, "DBdel: family=%s, key=%s\n", family, key);
142  if (ast_db_del(family, key))
143  ast_verb(3, "DBdel: Error deleting key from database.\n");
144  } else {
145  ast_debug(1, "Ignoring, no parameters\n");
146  }
147 
148  return 0;
149 }
char * strsep(char **str, const char *delims)
#define LOG_WARNING
Definition: logger.h:144
#define ast_verb(level,...)
Definition: logger.h:243
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
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
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
Definition: db.c:365
static int deltree_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 89 of file app_db.c.

References ast_db_deltree(), ast_debug, ast_strdupa, ast_strlen_zero(), ast_verb, and strsep().

Referenced by load_module().

90 {
91  char *argv, *family, *keytree;
92 
93  argv = ast_strdupa(data);
94 
95  if (strchr(argv, '/')) {
96  family = strsep(&argv, "/");
97  keytree = strsep(&argv, "\0");
98  if (!family || !keytree) {
99  ast_debug(1, "Ignoring; Syntax error in argument\n");
100  return 0;
101  }
102  if (ast_strlen_zero(keytree))
103  keytree = 0;
104  } else {
105  family = argv;
106  keytree = 0;
107  }
108 
109  if (keytree) {
110  ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
111  } else {
112  ast_verb(3, "DBdeltree: family=%s\n", family);
113  }
114 
115  if (ast_db_deltree(family, keytree) < 0) {
116  ast_verb(3, "DBdeltree: Error deleting key from database.\n");
117  }
118 
119  return 0;
120 }
char * strsep(char **str, const char *delims)
#define ast_verb(level,...)
Definition: logger.h:243
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
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
int ast_db_deltree(const char *family, const char *keytree)
Delete one or more entries in astdb If both parameters are NULL, the entire database will be purged...
Definition: db.c:241
static int load_module ( void  )
static

Definition at line 161 of file app_db.c.

References ast_register_application_xml, del_exec(), and deltree_exec().

162 {
163  int retval;
164 
167 
168  return retval;
169 }
static const char dt_app[]
Definition: app_db.c:87
static const char d_app[]
Definition: app_db.c:86
static int deltree_exec(struct ast_channel *chan, const char *data)
Definition: app_db.c:89
static int del_exec(struct ast_channel *chan, const char *data)
Definition: app_db.c:122
#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 151 of file app_db.c.

References ast_unregister_application().

152 {
153  int retval;
154 
157 
158  return retval;
159 }
static const char dt_app[]
Definition: app_db.c:87
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static const char d_app[]
Definition: app_db.c:86

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Database Access Functions" , .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 171 of file app_db.c.

Definition at line 171 of file app_db.c.

const char d_app[] = "DBdel"
static

Definition at line 86 of file app_db.c.

const char dt_app[] = "DBdeltree"
static

Definition at line 87 of file app_db.c.