| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * Asterisk -- An open source telephony toolkit. | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-01-21 07:06:25 +00:00
										 |  |  |  * Copyright (C) 1999 - 2005, Digium, Inc. | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  |  * Copyright (C) 2003, Jefferson Noxon | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2004-10-02 00:58:31 +00:00
										 |  |  |  * Mark Spencer <markster@digium.com> | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  |  * Jefferson Noxon <jeff@debian.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * See http://www.asterisk.org for more information about
 | 
					
						
							|  |  |  |  * the Asterisk project. Please do not directly contact | 
					
						
							|  |  |  |  * any of the maintainers of this project for assistance; | 
					
						
							|  |  |  |  * the project provides a web site, mailing lists and IRC | 
					
						
							|  |  |  |  * channels for your use. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  |  * This program is free software, distributed under the terms of | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * the GNU General Public License Version 2. See the LICENSE file | 
					
						
							|  |  |  |  * at the top of the source tree. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  | /*! \file
 | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  |  * \brief Database access functions | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-12-30 21:18:06 +00:00
										 |  |  |  * \author Mark Spencer <markster@digium.com> | 
					
						
							|  |  |  |  * \author Jefferson Noxon <jeff@debian.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-11-06 15:09:47 +00:00
										 |  |  |  * \ingroup applications | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-14 20:28:54 +00:00
										 |  |  | /*** MODULEINFO
 | 
					
						
							|  |  |  | 	<support_level>core</support_level> | 
					
						
							|  |  |  |  ***/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-07 18:54:56 +00:00
										 |  |  | #include "asterisk.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-21 06:02:45 +00:00
										 |  |  | #include "asterisk/file.h"
 | 
					
						
							|  |  |  | #include "asterisk/channel.h"
 | 
					
						
							|  |  |  | #include "asterisk/pbx.h"
 | 
					
						
							|  |  |  | #include "asterisk/module.h"
 | 
					
						
							|  |  |  | #include "asterisk/astdb.h"
 | 
					
						
							|  |  |  | #include "asterisk/lock.h"
 | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-03 01:01:25 +00:00
										 |  |  | /*** DOCUMENTATION
 | 
					
						
							|  |  |  | 	<application name="DBdeltree" language="en_US"> | 
					
						
							|  |  |  | 		<synopsis> | 
					
						
							|  |  |  | 			Delete a family or keytree from the asterisk database. | 
					
						
							|  |  |  | 		</synopsis> | 
					
						
							|  |  |  | 		<syntax argsep="/"> | 
					
						
							|  |  |  | 			<parameter name="family" required="true" /> | 
					
						
							|  |  |  | 			<parameter name="keytree" /> | 
					
						
							|  |  |  | 		</syntax> | 
					
						
							|  |  |  | 		<description> | 
					
						
							|  |  |  | 			<para>This application will delete a <replaceable>family</replaceable> or <replaceable>keytree</replaceable> | 
					
						
							|  |  |  | 			from the Asterisk database.</para> | 
					
						
							|  |  |  | 		</description> | 
					
						
							| 
									
										
										
										
											2008-11-05 12:13:57 +00:00
										 |  |  | 		<see-also> | 
					
						
							|  |  |  | 			<ref type="function">DB_DELETE</ref> | 
					
						
							|  |  |  | 			<ref type="function">DB</ref> | 
					
						
							|  |  |  | 		</see-also> | 
					
						
							| 
									
										
										
										
											2008-11-03 01:01:25 +00:00
										 |  |  | 	</application> | 
					
						
							|  |  |  |  ***/ | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-07 14:55:51 +00:00
										 |  |  | static const char dt_app[] = "DBdeltree"; | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-21 21:13:09 +00:00
										 |  |  | static int deltree_exec(struct ast_channel *chan, const char *data) | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-07-09 16:19:00 +00:00
										 |  |  | 	char *argv, *family, *keytree; | 
					
						
							| 
									
										
										
										
											2008-02-09 11:27:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-10 13:22:15 +00:00
										 |  |  | 	argv = ast_strdupa(data); | 
					
						
							| 
									
										
										
										
											2008-02-09 11:27:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-05 03:16:07 +00:00
										 |  |  | 	if (strchr(argv, '/')) { | 
					
						
							|  |  |  | 		family = strsep(&argv, "/"); | 
					
						
							|  |  |  | 		keytree = strsep(&argv, "\0"); | 
					
						
							| 
									
										
										
										
											2007-09-19 17:22:42 +00:00
										 |  |  | 		if (!family || !keytree) { | 
					
						
							|  |  |  | 			ast_debug(1, "Ignoring; Syntax error in argument\n"); | 
					
						
							|  |  |  | 			return 0; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2005-10-26 19:48:14 +00:00
										 |  |  | 		if (ast_strlen_zero(keytree)) | 
					
						
							| 
									
										
										
										
											2004-07-09 16:19:00 +00:00
										 |  |  | 			keytree = 0; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		family = argv; | 
					
						
							|  |  |  | 		keytree = 0; | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-02-09 11:27:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-14 03:49:52 +00:00
										 |  |  | 	if (keytree) { | 
					
						
							| 
									
										
										
										
											2007-07-26 15:49:18 +00:00
										 |  |  | 		ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree); | 
					
						
							| 
									
										
										
										
											2013-02-14 03:49:52 +00:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2007-07-26 15:49:18 +00:00
										 |  |  | 		ast_verb(3, "DBdeltree: family=%s\n", family); | 
					
						
							| 
									
										
										
										
											2013-02-14 03:49:52 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-02-09 11:27:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-14 03:49:52 +00:00
										 |  |  | 	if (ast_db_deltree(family, keytree) < 0) { | 
					
						
							| 
									
										
										
										
											2007-07-26 15:49:18 +00:00
										 |  |  | 		ast_verb(3, "DBdeltree: Error deleting key from database.\n"); | 
					
						
							| 
									
										
										
										
											2013-02-14 03:49:52 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-09 16:19:00 +00:00
										 |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int unload_module(void) | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-17 10:24:02 +00:00
										 |  |  | 	return ast_unregister_application(dt_app); | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int load_module(void) | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-17 10:24:02 +00:00
										 |  |  | 	return ast_register_application_xml(dt_app, deltree_exec); | 
					
						
							| 
									
										
										
										
											2003-03-07 06:00:13 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Database Access Functions"); |