Example #1
0
/**
 * open the gdbm database
 *
 * @param pe error buffer
 * @param parameters db-specific parameter.  In this case,
 *                   the path to use
 * @returns DB_E_SUCCESS on success, DB_E_* otherwise.
 */
int db_gdbm_open(char **pe, char *parameters) {
    char db_path[PATH_MAX + 1];
    int result = DB_E_SUCCESS;

    snprintf(db_path,sizeof(db_path),"%s/%s",parameters,"songs.gdb");

    //    reload = reload ? GDBM_NEWDB : GDBM_WRCREAT;
    _gdbm_lock();
    _gdbm_songs = gdbm_open(db_path, 0, GDBM_WRCREAT | GDBM_SYNC | GDBM_NOLOCK,
                           0600,NULL);

    if(!_gdbm_songs) {
        /* let's try creating it! */
        _gdbm_songs = gdbm_open(db_path,0,GDBM_NEWDB | GDBM_SYNC | GDBM_NOLOCK,
                                0600,NULL);
    }

    if(!_gdbm_songs) {
        DPRINTF(E_FATAL,L_DB,"Could not open songs database (%s): %s\n",
                db_path,strerror(errno));
        db_get_error(pe,DB_E_DB_ERROR,gdbm_strerror(gdbm_errno));
        result = DB_E_DB_ERROR;
    }
    _gdbm_unlock();
    return result;
}
Example #2
0
void db_print_error()
{
	fprintf(stderr, "MYSQL_ERROR: %s\n", db_get_error());
}