Asterisk - The Open Source Telephony Project  18.5.0
app_db.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  * Copyright (C) 2003, Jefferson Noxon
6  *
7  * Mark Spencer <[email protected]>
8  * Jefferson Noxon <[email protected]>
9  *
10  * See http://www.asterisk.org for more information about
11  * the Asterisk project. Please do not directly contact
12  * any of the maintainers of this project for assistance;
13  * the project provides a web site, mailing lists and IRC
14  * channels for your use.
15  *
16  * This program is free software, distributed under the terms of
17  * the GNU General Public License Version 2. See the LICENSE file
18  * at the top of the source tree.
19  */
20 
21 /*! \file
22  *
23  * \brief Database access functions
24  *
25  * \author Mark Spencer <[email protected]>
26  * \author Jefferson Noxon <[email protected]>
27  *
28  * \ingroup applications
29  */
30 
31 /*** MODULEINFO
32  <support_level>core</support_level>
33  ***/
34 
35 #include "asterisk.h"
36 
37 #include "asterisk/file.h"
38 #include "asterisk/channel.h"
39 #include "asterisk/pbx.h"
40 #include "asterisk/module.h"
41 #include "asterisk/astdb.h"
42 #include "asterisk/lock.h"
43 
44 /*** DOCUMENTATION
45  <application name="DBdeltree" language="en_US">
46  <synopsis>
47  Delete a family or keytree from the asterisk database.
48  </synopsis>
49  <syntax argsep="/">
50  <parameter name="family" required="true" />
51  <parameter name="keytree" />
52  </syntax>
53  <description>
54  <para>This application will delete a <replaceable>family</replaceable> or <replaceable>keytree</replaceable>
55  from the Asterisk database.</para>
56  </description>
57  <see-also>
58  <ref type="function">DB_DELETE</ref>
59  <ref type="function">DB</ref>
60  </see-also>
61  </application>
62  ***/
63 
64 static const char dt_app[] = "DBdeltree";
65 
66 static int deltree_exec(struct ast_channel *chan, const char *data)
67 {
68  char *argv, *family, *keytree;
69 
70  argv = ast_strdupa(data);
71 
72  if (strchr(argv, '/')) {
73  family = strsep(&argv, "/");
74  keytree = strsep(&argv, "\0");
75  if (!family || !keytree) {
76  ast_debug(1, "Ignoring; Syntax error in argument\n");
77  return 0;
78  }
79  if (ast_strlen_zero(keytree))
80  keytree = 0;
81  } else {
82  family = argv;
83  keytree = 0;
84  }
85 
86  if (keytree) {
87  ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
88  } else {
89  ast_verb(3, "DBdeltree: family=%s\n", family);
90  }
91 
92  if (ast_db_deltree(family, keytree) < 0) {
93  ast_verb(3, "DBdeltree: Error deleting key from database.\n");
94  }
95 
96  return 0;
97 }
98 
99 static int unload_module(void)
100 {
102 }
103 
104 static int load_module(void)
105 {
107 }
108 
109 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Database Access Functions");
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:567
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static int load_module(void)
Definition: app_db.c:104
static int unload_module(void)
Definition: app_db.c:99
static const char dt_app[]
Definition: app_db.c:64
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
#define ast_verb(level,...)
Definition: logger.h:463
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
Core PBX routines and definitions.
char * strsep(char **str, const char *delims)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.
static int deltree_exec(struct ast_channel *chan, const char *data)
Definition: app_db.c:66
Persistant data storage (akin to *doze registry)
int ast_db_deltree(const char *family, const char *keytree)
Delete one or more entries in astdb.
Definition: main/db.c:457
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626