Wed Jan 27 20:02:17 2016

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

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Database Access Functions")
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 const char d_app [] = "DBdel"
static const char dt_app [] = "DBdeltree"

Detailed Description

Database access functions.

Author:
Mark Spencer <markster@digium.com>
Jefferson Noxon <jeff@debian.org>

Definition in file app_db.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Database Access Functions"   
)
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, and LOG_WARNING.

Referenced by load_module().

00123 {
00124    char *argv, *family, *key;
00125    static int deprecation_warning = 0;
00126 
00127    if (!deprecation_warning) {
00128       deprecation_warning = 1;
00129       ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
00130    }
00131 
00132    argv = ast_strdupa(data);
00133 
00134    if (strchr(argv, '/')) {
00135       family = strsep(&argv, "/");
00136       key = strsep(&argv, "\0");
00137       if (!family || !key) {
00138          ast_debug(1, "Ignoring; Syntax error in argument\n");
00139          return 0;
00140       }
00141       ast_verb(3, "DBdel: family=%s, key=%s\n", family, key);
00142       if (ast_db_del(family, key))
00143          ast_verb(3, "DBdel: Error deleting key from database.\n");
00144    } else {
00145       ast_debug(1, "Ignoring, no parameters\n");
00146    }
00147 
00148    return 0;
00149 }

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(), and ast_verb.

Referenced by load_module().

00090 {
00091    char *argv, *family, *keytree;
00092 
00093    argv = ast_strdupa(data);
00094 
00095    if (strchr(argv, '/')) {
00096       family = strsep(&argv, "/");
00097       keytree = strsep(&argv, "\0");
00098       if (!family || !keytree) {
00099          ast_debug(1, "Ignoring; Syntax error in argument\n");
00100          return 0;
00101       }
00102       if (ast_strlen_zero(keytree))
00103          keytree = 0;
00104    } else {
00105       family = argv;
00106       keytree = 0;
00107    }
00108 
00109    if (keytree) {
00110       ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
00111    } else {
00112       ast_verb(3, "DBdeltree: family=%s\n", family);
00113    }
00114 
00115    if (ast_db_deltree(family, keytree) < 0) {
00116       ast_verb(3, "DBdeltree: Error deleting key from database.\n");
00117    }
00118 
00119    return 0;
00120 }

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().

00162 {
00163    int retval;
00164 
00165    retval = ast_register_application_xml(d_app, del_exec);
00166    retval |= ast_register_application_xml(dt_app, deltree_exec);
00167 
00168    return retval;
00169 }

static int unload_module ( void   )  [static]

Definition at line 151 of file app_db.c.

References ast_unregister_application().

00152 {
00153    int retval;
00154 
00155    retval = ast_unregister_application(dt_app);
00156    retval |= ast_unregister_application(d_app);
00157 
00158    return retval;
00159 }


Variable Documentation

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.


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