GRASS 8 Programmer's Manual 8.6.0dev(2026)-f6f2c534ea
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 * (C) 1999-2008 by the GRASS Development Team
7 *
8 * This program is free software under the GNU General Public
9 * License (>=v2). Read the file COPYING that comes with GRASS
10 * for details.
11 *
12 * \author Joel Jones (CERL/UIUC), Radim Blazek
13 */
14
15#include <grass/dbmi.h>
16#include "macros.h"
17#include "dbstubs.h"
18
19/*!
20 \brief Open insert cursor
21
22 \return DB_OK on success
23 \return DB_FAILED on failure
24 */
26{
28 dbTable *table;
29 int stat;
30 dbToken token;
31
32 /* get the arg(s) */
34
35 /* create a cursor */
36 cursor = (dbCursor *)db_malloc(sizeof(dbCursor));
37 if (cursor == NULL)
38 return db_get_error_code();
40 if (token < 0)
41 return db_get_error_code();
44
45 /* call the procedure */
47
48 /* send the return code */
49 if (stat != DB_OK) {
51 return DB_OK;
52 }
54
55 /* mark this as an insert cursor */
57
58 /* add this cursor to the cursors managed by the driver state */
60
61 /* results */
62 DB_SEND_TOKEN(&token);
63 DB_SEND_INT(cursor->type);
64 DB_SEND_INT(cursor->mode);
65 return DB_OK;
66}
#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:145
#define DB_OK
Definition dbmi.h:71
void * dbAddress
Definition dbmi.h:144
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:23
void db_set_cursor_type_insert(dbCursor *)
Set cursor to be writable (insert)
Definition cursor.c:131
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:78
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