Esempio n. 1
0
int init() {
    int ret;

/*
    ret = sqlite3_exec(db, "DROP TABLE IF EXISTS songs", NULL, 0, NULL);
    if (ret != SQLITE_OK) {
        fprintf(stderr, "%s\n", sqlite3_errmsg(db));
        exit(-1);
    }
*/

    ret = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS songs (\
            id INTEGER PRIMARY KEY, file TEXT, artist TEXT, album TEXT, title TEXT, year INTEGER, genre TEXT, track TEXT, type TEXT, lastupdate NUMBER, \
            UNIQUE (artist, album, title));", NULL, 0, NULL);
    if (ret != SQLITE_OK) {
        fprintf(stderr, "%s\n", sqlite3_errmsg(db));
        exit(-1);
    }

    ret = sqlite3_exec(db, "CREATE VIEW IF NOT EXISTS albums AS\
            SELECT artist, album, count(*) songs, year, genre FROM songs GROUP BY album", NULL, 0, NULL);
    if (ret != SQLITE_OK) {
        fprintf(stderr, "%s\n", sqlite3_errmsg(db));
        exit(-1);
    }

    reg_num = pcre_compile("^[0-9]+$", 0, &error, &erroffset, NULL);
    if (reg_num == NULL) {
        fprintf(stderr, "%s at %d\n", error, erroffset);
        return -1;
    }

    return 0;
}
Esempio n. 2
0
#if 0
INSERT INTO version (table_name, table_version) values ('uacreg','1');
CREATE TABLE uacreg (
    id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
    l_uuid VARCHAR(64) NOT NULL,
    l_username VARCHAR(64) NOT NULL,
    l_domain VARCHAR(128) DEFAULT '' NOT NULL,
    r_username VARCHAR(64) NOT NULL,
    r_domain VARCHAR(128) NOT NULL,
    realm VARCHAR(64) NOT NULL,
    auth_username VARCHAR(64) NOT NULL,
    auth_password VARCHAR(64) NOT NULL,
    auth_proxy VARCHAR(128) DEFAULT '' NOT NULL,
    expires INT(10) UNSIGNED DEFAULT 0 NOT NULL,
    CONSTRAINT l_uuid_idx UNIQUE (l_uuid)
) ENGINE=MyISAM;
#endif


extern struct tm_binds uac_tmb;
extern pv_spec_t auth_username_spec;
extern pv_spec_t auth_realm_spec;
extern pv_spec_t auth_password_spec;

counter_handle_t regtotal;         /* Total number of registrations in memory */
counter_handle_t regactive;        /* Active registrations - 200 OK */
counter_handle_t regdisabled;      /* Disabled registrations */

/* Init counters */
static void uac_reg_counter_init()
Esempio n. 3
0
#define NR_KEYS			3

int mt_fetch_rows = 1000;

/** database connection */
static db1_con_t *db_con = NULL;
static db_func_t mt_dbf;

#if 0
INSERT INTO version (table_name, table_version) values ('mtree','1');
CREATE TABLE mtree (
		id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
		tprefix VARCHAR(32) NOT NULL,
		tvalue VARCHAR(128) DEFAULT '' NOT NULL,
		CONSTRAINT tprefix_idx UNIQUE (tprefix)
		) ENGINE=MyISAM;
INSERT INTO version (table_name, table_version) values ('mtrees','1');
CREATE TABLE mtrees (
		id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
		tname VARCHAR(128) NOT NULL,
		tprefix VARCHAR(32) NOT NULL,
		tvalue VARCHAR(128) DEFAULT '' NOT NULL,
		CONSTRAINT tname_tprefix_idx UNIQUE (tname, tprefix)
		) ENGINE=MyISAM;
#endif

/** parameters */
static str db_url = str_init(DEFAULT_DB_URL);
static str db_table = str_init("mtrees");
static str tname_column   = str_init("tname");