Sat Aug 6 00:39:34 2011

Asterisk developer's documentation


app_db.c File Reference

Database access functions. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "asterisk/options.h"
#include "asterisk/file.h"
#include "asterisk/logger.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, void *data)
static int deltree_exec (struct ast_channel *chan, void *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_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
static const struct ast_module_infoast_module_info = &__mod_info
static char * d_app = "DBdel"
static char * d_descrip
static char * d_synopsis = "Delete a key from the database"
static char * dt_app = "DBdeltree"
static char * dt_descrip
static char * dt_synopsis = "Delete a family or keytree from the database"


Detailed Description

Database access functions.

Author:
Mark Spencer <markster@digium.com>

Jefferson Noxon <jeff@debian.org>

Definition in file app_db.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 167 of file app_db.c.

static void __unreg_module ( void   )  [static]

Definition at line 167 of file app_db.c.

static int del_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 109 of file app_db.c.

References ast_db_del(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_verbose(), ast_module_user::chan, LOG_DEBUG, LOG_WARNING, option_verbose, and VERBOSE_PREFIX_3.

Referenced by load_module().

00110 {
00111    char *argv, *family, *key;
00112    struct ast_module_user *u;
00113    static int deprecation_warning = 0;
00114 
00115    u = ast_module_user_add(chan);
00116 
00117    if (!deprecation_warning) {
00118       deprecation_warning = 1;
00119       ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
00120    }
00121 
00122    argv = ast_strdupa(data);
00123 
00124    if (strchr(argv, '/')) {
00125       family = strsep(&argv, "/");
00126       key = strsep(&argv, "\0");
00127       if (!family || !key) {
00128          ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
00129          ast_module_user_remove(u);
00130          return 0;
00131       }
00132       if (option_verbose > 2)
00133          ast_verbose(VERBOSE_PREFIX_3 "DBdel: family=%s, key=%s\n", family, key);
00134       if (ast_db_del(family, key)) {
00135          if (option_verbose > 2)
00136             ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n");
00137       }
00138    } else {
00139       ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
00140    }
00141 
00142    ast_module_user_remove(u);
00143    
00144    return 0;
00145 }

static int deltree_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 68 of file app_db.c.

References ast_db_deltree(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_strlen_zero(), ast_verbose(), ast_module_user::chan, LOG_DEBUG, option_verbose, and VERBOSE_PREFIX_3.

Referenced by load_module().

00069 {
00070    char *argv, *family, *keytree;
00071    struct ast_module_user *u;
00072 
00073    u = ast_module_user_add(chan);
00074 
00075    argv = ast_strdupa(data);
00076 
00077    if (strchr(argv, '/')) {
00078       family = strsep(&argv, "/");
00079       keytree = strsep(&argv, "\0");
00080          if (!family || !keytree) {
00081             ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
00082             ast_module_user_remove(u);
00083             return 0;
00084          }
00085       if (ast_strlen_zero(keytree))
00086          keytree = 0;
00087    } else {
00088       family = argv;
00089       keytree = 0;
00090    }
00091 
00092    if (option_verbose > 2) {
00093       if (keytree)
00094          ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: family=%s, keytree=%s\n", family, keytree);
00095       else
00096          ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: family=%s\n", family);
00097    }
00098 
00099    if (ast_db_deltree(family, keytree)) {
00100       if (option_verbose > 2)
00101          ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: Error deleting key from database.\n");
00102    }
00103 
00104    ast_module_user_remove(u);
00105 
00106    return 0;
00107 }

static int load_module ( void   )  [static]

Definition at line 157 of file app_db.c.

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

00158 {
00159    int retval;
00160 
00161    retval = ast_register_application(d_app, del_exec, d_synopsis, d_descrip);
00162    retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip);
00163    
00164    return retval;
00165 }

static int unload_module ( void   )  [static]

Definition at line 147 of file app_db.c.

References ast_unregister_application().

00148 {
00149    int retval;
00150 
00151    retval = ast_unregister_application(dt_app);
00152    retval |= ast_unregister_application(d_app);
00153 
00154    return retval;
00155 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 167 of file app_db.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 167 of file app_db.c.

char* d_app = "DBdel" [static]

Definition at line 61 of file app_db.c.

char* d_descrip [static]

Initial value:

"  DBdel(family/key): This application will delete a key from the Asterisk\n"
"database.\n"
"  This application has been DEPRECATED in favor of the DB_DELETE function.\n"
Todo:
XXX Remove this application after 1.4 is relased

Definition at line 52 of file app_db.c.

char* d_synopsis = "Delete a key from the database" [static]

Definition at line 64 of file app_db.c.

char* dt_app = "DBdeltree" [static]

Definition at line 62 of file app_db.c.

char* dt_descrip [static]

Initial value:

"  DBdeltree(family[/keytree]): This application will delete a family or keytree\n"
"from the Asterisk database\n"

Definition at line 57 of file app_db.c.

char* dt_synopsis = "Delete a family or keytree from the database" [static]

Definition at line 65 of file app_db.c.


Generated on Sat Aug 6 00:39:34 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7