예제 #1
0
파일: seaf-db.c 프로젝트: WeiY/seafile
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;
}
예제 #2
0
파일: repo-mgr.c 프로젝트: hram908/seafile
static gboolean
get_limit (SeafDBRow *row, void *vdays)
{
    int *days = vdays;

    *days = seaf_db_row_get_column_int (row, 0);

    return FALSE;
}
예제 #3
0
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;
}