/** * libretrodb_cursor_open: * @db : Handle to database. * @cursor : Handle to database cursor. * @q : Query to execute. * * Opens cursor to database based on query @q. * * Returns: 0 if successful, otherwise negative. **/ int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor, libretrodb_query_t *q) { cursor->fd = dup(db->fd); if (cursor->fd == -1) return -errno; cursor->db = db; cursor->is_valid = 1; libretrodb_cursor_reset(cursor); cursor->query = q; if (q) libretrodb_query_inc_ref(q); return 0; }
/** * libretrodb_cursor_open: * @db : Handle to database. * @cursor : Handle to database cursor. * @q : Query to execute. * * Opens cursor to database based on query @q. * * Returns: 0 if successful, otherwise negative. **/ int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor, libretrodb_query_t *q) { cursor->fd = filestream_open(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1); if (!cursor->fd) return -errno; cursor->db = db; cursor->is_valid = 1; libretrodb_cursor_reset(cursor); cursor->query = q; if (q) libretrodb_query_inc_ref(q); return 0; }