Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:01:29 2007

Asterisk developer's documentation :: Codename Pineapple


db.c File Reference


Detailed Description

ASTdb Management.

Author:
Mark Spencer <markster@digium.com>
Note:
DB3 is licensed under Sleepycat Public License and is thus incompatible with GPL. To avoid having to make another exception (and complicate licensing even further) we elect to use DB1 which is BSD licensed

Definition in file db.c.

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/astdb.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/manager.h"
#include "db1-ast/include/db.h"

Include dependency graph for db.c:

Go to the source code of this file.

Functions

int ast_db_del (const char *family, const char *keys)
int ast_db_deltree (const char *family, const char *keytree)
void ast_db_freetree (struct ast_db_entry *dbe)
int ast_db_get (const char *family, const char *keys, char *value, int valuelen)
ast_db_entryast_db_gettree (const char *family, const char *keytree)
int ast_db_put (const char *family, const char *keys, const char *value)
 AST_MUTEX_DEFINE_STATIC (dblock)
int astdb_init (void)
static int database_del (int fd, int argc, char *argv[])
static int database_deltree (int fd, int argc, char *argv[])
static int database_get (int fd, int argc, char *argv[])
static int database_put (int fd, int argc, char *argv[])
static int database_show (int fd, int argc, char *argv[])
static int database_showkey (int fd, int argc, char *argv[])
static int dbinit (void)
static int keymatch (const char *key, const char *prefix)
static int manager_dbdel (struct mansession *s, const struct message *m)
static int manager_dbdeltree (struct mansession *s, const struct message *m)
static int manager_dbget (struct mansession *s, const struct message *m)
static int manager_dbput (struct mansession *s, const struct message *m)
static int subkeymatch (const char *key, const char *suffix)

Variables

static DB * astdb
ast_cli_entry cli_database []
static const char database_del_usage []
static const char database_deltree_usage []
static const char database_get_usage []
static const char database_put_usage []
static const char database_show_usage []
static const char database_showkey_usage []


Function Documentation

int ast_db_del const char *  family,
const char *  keys
 

Definition at line 214 of file db.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dbinit(), key(), LOG_DEBUG, and option_debug.

Referenced by __expire_registry(), ast_privacy_set(), cache_lookup_internal(), database_del(), destroy_association(), dump_agents(), handle_dbdel(), manager_dbdel(), reload_agents(), and update_registry().

00215 {
00216    char fullkey[256];
00217    DBT key;
00218    int res, fullkeylen;
00219 
00220    ast_mutex_lock(&dblock);
00221    if (dbinit()) {
00222       ast_mutex_unlock(&dblock);
00223       return -1;
00224    }
00225    
00226    fullkeylen = snprintf(fullkey, sizeof(fullkey), "/%s/%s", family, keys);
00227    memset(&key, 0, sizeof(key));
00228    key.data = fullkey;
00229    key.size = fullkeylen + 1;
00230    
00231    res = astdb->del(astdb, &key, 0);
00232    astdb->sync(astdb, 0);
00233    
00234    ast_mutex_unlock(&dblock);
00235 
00236    if (res) {
00237       if (option_debug)
00238          ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
00239    }
00240    return res;
00241 }

int ast_db_deltree const char *  family,
const char *  keytree
 

Definition at line 100 of file db.c.

References ast_mutex_lock(), ast_mutex_unlock(), dbinit(), key(), keymatch(), keys, and prefix.

Referenced by ast_privacy_reset(), database_deltree(), handle_dbdeltree(), iax_provision_reload(), and manager_dbdeltree().

00101 {
00102    char prefix[256];
00103    DBT key, data;
00104    char *keys;
00105    int res;
00106    int pass;
00107    
00108    if (family) {
00109       if (keytree) {
00110          snprintf(prefix, sizeof(prefix), "/%s/%s", family, keytree);
00111       } else {
00112          snprintf(prefix, sizeof(prefix), "/%s", family);
00113       }
00114    } else if (keytree) {
00115       return -1;
00116    } else {
00117       prefix[0] = '\0';
00118    }
00119    
00120    ast_mutex_lock(&dblock);
00121    if (dbinit()) {
00122       ast_mutex_unlock(&dblock);
00123       return -1;
00124    }
00125    
00126    memset(&key, 0, sizeof(key));
00127    memset(&data, 0, sizeof(data));
00128    pass = 0;
00129    while (!(res = astdb->seq(astdb, &key, &data, pass++ ? R_NEXT : R_FIRST))) {
00130       if (key.size) {
00131          keys = key.data;
00132          keys[key.size - 1] = '\0';
00133       } else {
00134          keys = "<bad key>";
00135       }
00136       if (keymatch(keys, prefix)) {
00137          astdb->del(astdb, &key, 0);
00138       }
00139    }
00140    astdb->sync(astdb, 0);
00141    ast_mutex_unlock(&dblock);
00142    return 0;
00143 }

void ast_db_freetree struct ast_db_entry dbe  ) 
 

Definition at line 460 of file db.c.

References free, last, and ast_db_entry::next.

00461 {
00462    struct ast_db_entry *last;
00463    while (dbe) {
00464       last = dbe;
00465       dbe = dbe->next;
00466       free(last);
00467    }
00468 }

int ast_db_get const char *  family,
const char *  keys,
char *  value,
int  valuelen
 

Definition at line 172 of file db.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dbinit(), key(), LOG_DEBUG, LOG_NOTICE, and option_debug.

Referenced by ast_privacy_check(), cache_lookup_internal(), check_access(), create_addr(), database_get(), handle_dbget(), iax_provision_version(), load_password(), manager_dbget(), populate_addr(), reg_source_db(), and reload_agents().

00173 {
00174    char fullkey[256] = "";
00175    DBT key, data;
00176    int res, fullkeylen;
00177 
00178    ast_mutex_lock(&dblock);
00179    if (dbinit()) {
00180       ast_mutex_unlock(&dblock);
00181       return -1;
00182    }
00183 
00184    fullkeylen = snprintf(fullkey, sizeof(fullkey), "/%s/%s", family, keys);
00185    memset(&key, 0, sizeof(key));
00186    memset(&data, 0, sizeof(data));
00187    memset(value, 0, valuelen);
00188    key.data = fullkey;
00189    key.size = fullkeylen + 1;
00190    
00191    res = astdb->get(astdb, &key, &data, 0);
00192    
00193    ast_mutex_unlock(&dblock);
00194 
00195    /* Be sure to NULL terminate our data either way */
00196    if (res) {
00197       if (option_debug)
00198          ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
00199    } else {
00200 #if 0
00201       printf("Got value of size %d\n", data.size);
00202 #endif
00203       if (data.size) {
00204          ((char *)data.data)[data.size - 1] = '\0';
00205          /* Make sure that we don't write too much to the dst pointer or we don't read too much from the source pointer */
00206          ast_copy_string(value, data.data, (valuelen > data.size) ? data.size : valuelen);
00207       } else {
00208          ast_log(LOG_NOTICE, "Strange, empty value for /%s/%s\n", family, keys);
00209       }
00210    }
00211    return res;
00212 }

struct ast_db_entry* ast_db_gettree const char *  family,
const char *  keytree
 

Definition at line 398 of file db.c.

References ast_log(), ast_malloc, ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), astdb, ast_db_entry::data, dbinit(), key(), keymatch(), keys, last, LOG_WARNING, and prefix.

Referenced by reload_agents().

00399 {
00400    char prefix[256];
00401    DBT key, data;
00402    char *keys, *values;
00403    int values_len;
00404    int res;
00405    int pass;
00406    struct ast_db_entry *last = NULL;
00407    struct ast_db_entry *cur, *ret=NULL;
00408 
00409    if (!ast_strlen_zero(family)) {
00410       if (!ast_strlen_zero(keytree)) {
00411          /* Family and key tree */
00412          snprintf(prefix, sizeof(prefix), "/%s/%s", family, prefix);
00413       } else {
00414          /* Family only */
00415          snprintf(prefix, sizeof(prefix), "/%s", family);
00416       }
00417    } else {
00418       prefix[0] = '\0';
00419    }
00420    ast_mutex_lock(&dblock);
00421    if (dbinit()) {
00422       ast_mutex_unlock(&dblock);
00423       ast_log(LOG_WARNING, "Database unavailable\n");
00424       return NULL;   
00425    }
00426    memset(&key, 0, sizeof(key));
00427    memset(&data, 0, sizeof(data));
00428    pass = 0;
00429    while (!(res = astdb->seq(astdb, &key, &data, pass++ ? R_NEXT : R_FIRST))) {
00430       if (key.size) {
00431          keys = key.data;
00432          keys[key.size - 1] = '\0';
00433       } else {
00434          keys = "<bad key>";
00435       }
00436       if (data.size) {
00437          values = data.data;
00438          values[data.size - 1] = '\0';
00439       } else {
00440          values = "<bad value>";
00441       }
00442       values_len = strlen(values) + 1;
00443       if (keymatch(keys, prefix) && (cur = ast_malloc(sizeof(*cur) + strlen(keys) + 1 + values_len))) {
00444          cur->next = NULL;
00445          cur->key = cur->data + values_len;
00446          strcpy(cur->data, values);
00447          strcpy(cur->key, keys);
00448          if (last) {
00449             last->next = cur;
00450          } else {
00451             ret = cur;
00452          }
00453          last = cur;
00454       }
00455    }
00456    ast_mutex_unlock(&dblock);
00457    return ret; 
00458 }

int ast_db_put const char *  family,
const char *  keys,
const char *  value
 

Definition at line 145 of file db.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dbinit(), key(), and LOG_WARNING.

Referenced by ast_privacy_set(), cache_save_hint(), database_put(), dump_agents(), handle_command_response(), handle_dbput(), iax_provision_build(), manager_dbput(), mgcp_ss(), parse_register_contact(), save_secret(), ss_thread(), and update_registry().

00146 {
00147    char fullkey[256];
00148    DBT key, data;
00149    int res, fullkeylen;
00150 
00151    ast_mutex_lock(&dblock);
00152    if (dbinit()) {
00153       ast_mutex_unlock(&dblock);
00154       return -1;
00155    }
00156 
00157    fullkeylen = snprintf(fullkey, sizeof(fullkey), "/%s/%s", family, keys);
00158    memset(&key, 0, sizeof(key));
00159    memset(&data, 0, sizeof(data));
00160    key.data = fullkey;
00161    key.size = fullkeylen + 1;
00162    data.data = (char *) value;
00163    data.size = strlen(value) + 1;
00164    res = astdb->put(astdb, &key, &data, 0);
00165    astdb->sync(astdb, 0);
00166    ast_mutex_unlock(&dblock);
00167    if (res)
00168       ast_log(LOG_WARNING, "Unable to put value '%s' for key '%s' in family '%s'\n", value, keys, family);
00169    return res;
00170 }

AST_MUTEX_DEFINE_STATIC dblock   ) 
 

int astdb_init void   ) 
 

Provided by db.c

Definition at line 640 of file db.c.

References ast_cli_register_multiple(), ast_manager_register, cli_database, dbinit(), EVENT_FLAG_SYSTEM, manager_dbdel(), manager_dbdeltree(), manager_dbget(), and manager_dbput().

00641 {
00642    dbinit();
00643    ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry));
00644    ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry");
00645    ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry");
00646    ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry");
00647    ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree");
00648    return 0;
00649 }

static int database_del int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 272 of file db.c.

References ast_cli(), ast_db_del(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.

00273 {
00274    int res;
00275    if (argc != 4)
00276       return RESULT_SHOWUSAGE;
00277    res = ast_db_del(argv[2], argv[3]);
00278    if (res) {
00279       ast_cli(fd, "Database entry does not exist.\n");
00280    } else {
00281       ast_cli(fd, "Database entry removed.\n");
00282    }
00283    return RESULT_SUCCESS;
00284 }

static int database_deltree int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 286 of file db.c.

References ast_cli(), ast_db_deltree(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.

00287 {
00288    int res;
00289    if ((argc < 3) || (argc > 4))
00290       return RESULT_SHOWUSAGE;
00291    if (argc == 4) {
00292       res = ast_db_deltree(argv[2], argv[3]);
00293    } else {
00294       res = ast_db_deltree(argv[2], NULL);
00295    }
00296    if (res) {
00297       ast_cli(fd, "Database entries do not exist.\n");
00298    } else {
00299       ast_cli(fd, "Database entries removed.\n");
00300    }
00301    return RESULT_SUCCESS;
00302 }

static int database_get int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 257 of file db.c.

References ast_cli(), ast_db_get(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.

00258 {
00259    int res;
00260    char tmp[256];
00261    if (argc != 4)
00262       return RESULT_SHOWUSAGE;
00263    res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
00264    if (res) {
00265       ast_cli(fd, "Database entry not found.\n");
00266    } else {
00267       ast_cli(fd, "Value: %s\n", tmp);
00268    }
00269    return RESULT_SUCCESS;
00270 }

static int database_put int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 243 of file db.c.

References ast_cli(), ast_db_put(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.

00244 {
00245    int res;
00246    if (argc != 5)
00247       return RESULT_SHOWUSAGE;
00248    res = ast_db_put(argv[2], argv[3], argv[4]);
00249    if (res)  {
00250       ast_cli(fd, "Failed to update entry\n");
00251    } else {
00252       ast_cli(fd, "Updated database successfully\n");
00253    }
00254    return RESULT_SUCCESS;
00255 }

static int database_show int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 304 of file db.c.

References ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), dbinit(), key(), keymatch(), keys, prefix, RESULT_SHOWUSAGE, and RESULT_SUCCESS.

00305 {
00306    char prefix[256];
00307    DBT key, data;
00308    char *keys, *values;
00309    int res;
00310    int pass;
00311 
00312    if (argc == 4) {
00313       /* Family and key tree */
00314       snprintf(prefix, sizeof(prefix), "/%s/%s", argv[2], argv[3]);
00315    } else if (argc == 3) {
00316       /* Family only */
00317       snprintf(prefix, sizeof(prefix), "/%s", argv[2]);
00318    } else if (argc == 2) {
00319       /* Neither */
00320       prefix[0] = '\0';
00321    } else {
00322       return RESULT_SHOWUSAGE;
00323    }
00324    ast_mutex_lock(&dblock);
00325    if (dbinit()) {
00326       ast_mutex_unlock(&dblock);
00327       ast_cli(fd, "Database unavailable\n");
00328       return RESULT_SUCCESS;  
00329    }
00330    memset(&key, 0, sizeof(key));
00331    memset(&data, 0, sizeof(data));
00332    pass = 0;
00333    while (!(res = astdb->seq(astdb, &key, &data, pass++ ? R_NEXT : R_FIRST))) {
00334       if (key.size) {
00335          keys = key.data;
00336          keys[key.size - 1] = '\0';
00337       } else {
00338          keys = "<bad key>";
00339       }
00340       if (data.size) {
00341          values = data.data;
00342          values[data.size - 1]='\0';
00343       } else {
00344          values = "<bad value>";
00345       }
00346       if (keymatch(keys, prefix)) {
00347             ast_cli(fd, "%-50s: %-25s\n", keys, values);
00348       }
00349    }
00350    ast_mutex_unlock(&dblock);
00351    return RESULT_SUCCESS;  
00352 }

static int database_showkey int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 354 of file db.c.

References ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), astdb, dbinit(), key(), keys, RESULT_SHOWUSAGE, RESULT_SUCCESS, and subkeymatch().

00355 {
00356    char suffix[256];
00357    DBT key, data;
00358    char *keys, *values;
00359    int res;
00360    int pass;
00361 
00362    if (argc == 3) {
00363       /* Key only */
00364       snprintf(suffix, sizeof(suffix), "/%s", argv[2]);
00365    } else {
00366       return RESULT_SHOWUSAGE;
00367    }
00368    ast_mutex_lock(&dblock);
00369    if (dbinit()) {
00370       ast_mutex_unlock(&dblock);
00371       ast_cli(fd, "Database unavailable\n");
00372       return RESULT_SUCCESS;  
00373    }
00374    memset(&key, 0, sizeof(key));
00375    memset(&data, 0, sizeof(data));
00376    pass = 0;
00377    while (!(res = astdb->seq(astdb, &key, &data, pass++ ? R_NEXT : R_FIRST))) {
00378       if (key.size) {
00379          keys = key.data;
00380          keys[key.size - 1] = '\0';
00381       } else {
00382          keys = "<bad key>";
00383       }
00384       if (data.size) {
00385          values = data.data;
00386          values[data.size - 1]='\0';
00387       } else {
00388          values = "<bad value>";
00389       }
00390       if (subkeymatch(keys, suffix)) {
00391             ast_cli(fd, "%-50s: %-25s\n", keys, values);
00392       }
00393    }
00394    ast_mutex_unlock(&dblock);
00395    return RESULT_SUCCESS;  
00396 }

static int dbinit void   )  [static]
 

Definition at line 63 of file db.c.

References ast_config_AST_DB, AST_FILE_MODE, ast_log(), and LOG_WARNING.

Referenced by ast_db_del(), ast_db_deltree(), ast_db_get(), ast_db_gettree(), ast_db_put(), astdb_init(), database_show(), and database_showkey().

00064 {
00065    if (!astdb && !(astdb = dbopen((char *)ast_config_AST_DB, O_CREAT | O_RDWR, AST_FILE_MODE, DB_BTREE, NULL))) {
00066       ast_log(LOG_WARNING, "Unable to open Asterisk database\n");
00067       return -1;
00068    }
00069    return 0;
00070 }

static int keymatch const char *  key,
const char *  prefix
[inline, static]
 

Definition at line 73 of file db.c.

Referenced by ast_db_deltree(), ast_db_gettree(), and database_show().

00074 {
00075    int preflen = strlen(prefix);
00076    if (!preflen)
00077       return 1;
00078    if (!strcasecmp(key, prefix))
00079       return 1;
00080    if ((strlen(key) > preflen) && !strncasecmp(key, prefix, preflen)) {
00081       if (key[preflen] == '/')
00082          return 1;
00083    }
00084    return 0;
00085 }

static int manager_dbdel struct mansession s,
const struct message m
[static]
 

Definition at line 591 of file db.c.

References ast_db_del(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), key(), and s.

Referenced by astdb_init().

00592 {
00593    const char *family = astman_get_header(m, "Family");
00594    const char *key = astman_get_header(m, "Key");
00595    int res;
00596 
00597    if (ast_strlen_zero(family)) {
00598       astman_send_error(s, m, "No family specified.");
00599       return 0;
00600    }
00601 
00602    if (ast_strlen_zero(key)) {
00603       astman_send_error(s, m, "No key specified.");
00604       return 0;
00605    }
00606 
00607    res = ast_db_del(family, key);
00608    if (res)
00609       astman_send_error(s, m, "Database entry not found");
00610    else
00611       astman_send_ack(s, m, "Key deleted successfully");
00612 
00613    return 0;
00614 }

static int manager_dbdeltree struct mansession s,
const struct message m
[static]
 

Definition at line 616 of file db.c.

References ast_db_deltree(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), key(), and s.

Referenced by astdb_init().

00617 {
00618    const char *family = astman_get_header(m, "Family");
00619    const char *key = astman_get_header(m, "Key");
00620    int res;
00621 
00622    if (ast_strlen_zero(family)) {
00623       astman_send_error(s, m, "No family specified.");
00624       return 0;
00625    }
00626 
00627    if (!ast_strlen_zero(key))
00628       res = ast_db_deltree(family, key);
00629    else
00630       res = ast_db_deltree(family, NULL);
00631 
00632    if (res)
00633       astman_send_error(s, m, "Database entry not found");
00634    else
00635       astman_send_ack(s, m, "Key tree deleted successfully");
00636    
00637    return 0;
00638 }

static int manager_dbget struct mansession s,
const struct message m
[static]
 

Definition at line 554 of file db.c.

References ast_db_get(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_ack(), astman_send_error(), key(), and s.

Referenced by astdb_init().

00555 {
00556    const char *id = astman_get_header(m,"ActionID");
00557    char idText[256] = "";
00558    const char *family = astman_get_header(m, "Family");
00559    const char *key = astman_get_header(m, "Key");
00560    char tmp[256];
00561    int res;
00562 
00563    if (ast_strlen_zero(family)) {
00564       astman_send_error(s, m, "No family specified.");
00565       return 0;
00566    }
00567    if (ast_strlen_zero(key)) {
00568       astman_send_error(s, m, "No key specified.");
00569       return 0;
00570    }
00571 
00572    if (!ast_strlen_zero(id))
00573       snprintf(idText, sizeof(idText) ,"ActionID: %s\r\n", id);
00574 
00575    res = ast_db_get(family, key, tmp, sizeof(tmp));
00576    if (res) {
00577       astman_send_error(s, m, "Database entry not found");
00578    } else {
00579       astman_send_ack(s, m, "Result will follow");
00580       astman_append(s, "Event: DBGetResponse\r\n"
00581             "Family: %s\r\n"
00582             "Key: %s\r\n"
00583             "Val: %s\r\n"
00584             "%s"
00585             "\r\n",
00586             family, key, tmp, idText);
00587    }
00588    return 0;
00589 }

static int manager_dbput struct mansession s,
const struct message m
[static]
 

Definition at line 525 of file db.c.

References ast_db_put(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), key(), and s.

Referenced by astdb_init().

00526 {
00527    const char *family = astman_get_header(m, "Family");
00528    const char *key = astman_get_header(m, "Key");
00529    const char *val = astman_get_header(m, "Val");
00530    int res;
00531 
00532    if (ast_strlen_zero(family)) {
00533       astman_send_error(s, m, "No family specified");
00534       return 0;
00535    }
00536    if (ast_strlen_zero(key)) {
00537       astman_send_error(s, m, "No key specified");
00538       return 0;
00539    }
00540    if (ast_strlen_zero(val)) {
00541       astman_send_error(s, m, "No val specified");
00542       return 0;
00543    }
00544 
00545    res = ast_db_put(family, key, val);
00546    if (res) {
00547       astman_send_error(s, m, "Failed to update entry");
00548    } else {
00549       astman_send_ack(s, m, "Updated database successfully");
00550    }
00551    return 0;
00552 }

static int subkeymatch const char *  key,
const char *  suffix
[inline, static]
 

Definition at line 87 of file db.c.

Referenced by database_showkey().

00088 {
00089    int suffixlen = strlen(suffix);
00090    if (suffixlen) {
00091       const char *subkey = key + strlen(key) - suffixlen;
00092       if (subkey < key)
00093          return 0;
00094       if (!strcasecmp(subkey, suffix))
00095          return 1;
00096    }
00097    return 0;
00098 }


Variable Documentation

DB* astdb [static]
 

Definition at line 60 of file db.c.

Referenced by ast_db_gettree(), and database_showkey().

struct ast_cli_entry cli_database[]
 

Definition at line 499 of file db.c.

Referenced by astdb_init().

const char database_del_usage[] [static]
 

Initial value:

"Usage: database del <family> <key>\n"
"       Deletes an entry in the Asterisk database for a given\n"
"family and key.\n"

Definition at line 489 of file db.c.

const char database_deltree_usage[] [static]
 

Initial value:

"Usage: database deltree <family> [keytree]\n"
"       Deletes a family or specific keytree within a family\n"
"in the Asterisk database.\n"

Definition at line 494 of file db.c.

const char database_get_usage[] [static]
 

Initial value:

"Usage: database get <family> <key>\n"
"       Retrieves an entry in the Asterisk database for a given\n"
"family and key.\n"

Definition at line 484 of file db.c.

const char database_put_usage[] [static]
 

Initial value:

"Usage: database put <family> <key> <value>\n"
"       Adds or updates an entry in the Asterisk database for\n"
"a given family, key, and value.\n"

Definition at line 479 of file db.c.

const char database_show_usage[] [static]
 

Initial value:

"Usage: database show [family [keytree]]\n"
"       Shows Asterisk database contents, optionally restricted\n"
"to a given family, or family and keytree.\n"

Definition at line 470 of file db.c.

const char database_showkey_usage[] [static]
 

Initial value:

"Usage: database showkey <keytree>\n"
"       Shows Asterisk database contents, restricted to a given key.\n"

Definition at line 475 of file db.c.


Asterisk is a trademark for Digium, inc.. | Edvina.net | Asterisk.org | This documentation was generated with Doxygen