Commit 9b633f70 authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

implement zathura_db_get_fileinfo

parent 320063f6
......@@ -200,3 +200,35 @@ zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int p
sqlite3_finalize(stmt);
return res == SQLITE_OK;
}
bool
zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned int* page, int* offset, float* scale)
{
g_return_val_if_fail(db && file && page && ofset && scale, false);
static const char SQL_FILEINFO_GET[] =
"SELECT page, offset, scale FROM fileinfo WHERE file = ?;";
sqlite3_stmt* stmt = prepare_statement(db->session, SQL_FILEINFO_GET);
if (stmt == NULL) {
return false;
}
if (sqlite3_bind_text(stmt, 1, file, -1, NULL) != SQLITE_OK)
sqlite3_finalize(stmt);
girara_error("Failed to bind arguments.");
return false;
}
if (sqlite3_step(stmt) != SQLITE_ROW) {
sqlite3_finalize(stmt);
girara_info("No info for file %s available.", file);
return false;
}
*page = sqlite3_column_int(stmt, 0);
*offset = sqlite3_column_int(stmt, 1);
*scale = sqlite3_column_double(stmt, 2);
sqlite3_finalize(stmt);
return true;
}
......@@ -59,4 +59,14 @@ girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char* fil
*/
bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int page, int offset, float scale);
/* Get file info (last site, ...) from the database.
* @param db The database instance
* @param file The file to which the file info belongs to.
* @param page The last page.
* @param offset The last offset.
* @param scale The last scale.
* @return true on success, false otherwise.
*/
bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned int* page, int* offset, float* scale);
#endif // DATABASE_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment