32 #include <sys/types.h> 48 if (columns != 2 || strcmp(column_names[0],
"key") || strcmp(column_names[1],
"value")) {
49 fprintf(stderr,
"Unknown row type\n");
54 key.
size = strlen(values[0]) + 1;
55 value.data = values[1];
56 value.size = strlen(values[1]) + 1;
58 if (bdb->put(bdb, &key, &
value, 0)) {
71 fprintf(stderr,
"Could not add row to Berkeley DB: %s\n", errmsg);
80 if (sqlite3_open(dbname, &
sql3db) != SQLITE_OK) {
81 fprintf(stderr,
"Unable to open Asterisk database '%s': %s\n", dbname, sqlite3_errmsg(
sql3db));
92 fprintf(stderr,
"Unable to create astdb: %s\n", strerror(
errno));
98 int main(
int argc,
char *argv[])
100 struct stat dont_care;
103 fprintf(stderr,
"%s takes the path of SQLite3 astdb as its only argument\n", basename(argv[0]));
104 fprintf(stderr,
"and will produce a file 'astdb' in the current directory\n" 105 "Make a backup of any existing Berkeley DB astdb you have and copy\n" 106 "the new astdb to its location: often /var/lib/asterisk/astdb\n");
110 if (stat(argv[1], &dont_care)) {
111 fprintf(stderr,
"Unable to open %s: %s\n", argv[1], strerror(
errno));
124 fprintf(stderr,
"Database conversion failed!\n");
129 printf(
"Created ./astdb. Back up any existing astdb and copy the created\n");
130 printf(
"astdb file to the original's location. Often /var/lib/asterisk/astdb.\n");
static int db_open_sqlite3(const char *dbname)
Asterisk main include file. File version handling, generic pbx functions.
int main(int argc, char *argv[])
static int create_bdb_astdb(void)
static struct ast_str * dbname
static int add_row_to_bdb(void *arg, int columns, char **values, char **column_names)
DB * dbopen(char *fname, int flags, int mode, DBTYPE type, const void *openinfo) const
static int convert_bdb_to_sqlite3(void)