int seaf_db_get_int (SeafDB *db, const char *sql) { int ret = -1; Connection_T conn; ResultSet_T result; SeafDBRow seaf_row; conn = get_db_connection (db); if (!conn) return -1; TRY result = Connection_executeQuery (conn, "%s", sql); CATCH (SQLException) g_warning ("Error exec query %s: %s.\n", sql, Exception_frame.message); Connection_close (conn); return -1; END_TRY; seaf_row.res = result; TRY if (ResultSet_next (result)) ret = seaf_db_row_get_column_int (&seaf_row, 0); CATCH (SQLException) g_warning ("Error exec query %s: %s.\n", sql, Exception_frame.message); Connection_close (conn); return -1; END_TRY; Connection_close (conn); return ret; }
static gboolean get_limit (SeafDBRow *row, void *vdays) { int *days = vdays; *days = seaf_db_row_get_column_int (row, 0); return FALSE; }
static gboolean collect_repo_shared_group (SeafDBRow *row, void *data) { GList **shared_group = data; int group_id = seaf_db_row_get_column_int (row, 0); const char *perm = seaf_db_row_get_column_text (row, 1); const char *repo_id = seaf_db_row_get_column_text (row, 2); SeafileSharedGroup *gobj = g_object_new (SEAFILE_TYPE_SHARED_GROUP, "repo_id", repo_id, "group_id", group_id, "perm", perm, NULL); *shared_group = g_list_prepend (*shared_group, gobj); return TRUE; }