GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
d_openinsert.c
Go to the documentation of this file.
1/*!
2 * \file db/dbmi_driver/d_openinsert.c
3 *
4 * \brief DBMI Library (driver) - open insert cursor
5 *
6 * SPDX-FileCopyrightText: 1999-2008 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Joel Jones (CERL/UIUC), Radim Blazek
10 */
11
12#include <grass/dbmi.h>
13#include "macros.h"
14#include "dbstubs.h"
15
16/*!
17 \brief Open insert cursor
18
19 \return DB_OK on success
20 \return DB_FAILED on failure
21 */
23{
25 dbTable *table;
26 int stat;
27 dbToken token;
28
29 /* get the arg(s) */
31
32 /* create a cursor */
33 cursor = (dbCursor *)db_malloc(sizeof(dbCursor));
34 if (cursor == NULL)
35 return db_get_error_code();
37 if (token < 0)
38 return db_get_error_code();
41
42 /* call the procedure */
44
45 /* send the return code */
46 if (stat != DB_OK) {
48 return DB_OK;
49 }
51
52 /* mark this as an insert cursor */
54
55 /* add this cursor to the cursors managed by the driver state */
57
58 /* results */
59 DB_SEND_TOKEN(&token);
60 DB_SEND_INT(cursor->type);
61 DB_SEND_INT(cursor->mode);
62 return DB_OK;
63}
#define NULL
Definition ccmath.h:32
int db_d_open_insert_cursor(void)
Open insert cursor.
Main header of GRASS DataBase Management Interface.
int dbToken
Definition dbmi.h:143
#define DB_OK
Definition dbmi.h:69
void * dbAddress
Definition dbmi.h:142
int(* db_driver_open_insert_cursor)(dbCursor *)
dbToken db_new_token(dbAddress)
Add new token.
void db_init_cursor(dbCursor *)
Initialize dbCursor.
Definition cursor.c:20
void db_set_cursor_type_insert(dbCursor *)
Set cursor to be writable (insert)
Definition cursor.c:128
int db_get_error_code(void)
Get error code.
void db__add_cursor_to_driver_state(dbCursor *)
Add cursor do driver state.
void db_set_cursor_table(dbCursor *, dbTable *)
Set table for given cursor.
Definition cursor.c:75
void * db_malloc(int)
Allocate memory.
#define DB_SEND_INT(x)
Definition macros.h:82
#define DB_RECV_TABLE_DEFINITION(x)
Definition macros.h:142
#define DB_SEND_SUCCESS()
Definition macros.h:13
#define DB_SEND_TOKEN(x)
Definition macros.h:214
#define DB_SEND_FAILURE()
Definition macros.h:18