GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_openselect.c
Go to the documentation of this file.
1 
15 #include <grass/dbmi.h>
16 #include "macros.h"
17 
29 int db_open_select_cursor(dbDriver * driver, dbString * select, dbCursor * cursor,
30  int mode)
31 {
32  int ret_code;
33 
34  db_init_cursor(cursor);
35  cursor->driver = driver;
36 
37  /* start the procedure call */
38  db__set_protocol_fds(driver->send, driver->recv);
39  DB_START_PROCEDURE_CALL(DB_PROC_OPEN_SELECT_CURSOR);
40 
41  /* send the argument(s) to the procedure */
42  DB_SEND_STRING(select);
43  DB_SEND_INT(mode);
44 
45  /* get the return code for the procedure call */
46  DB_RECV_RETURN_CODE(&ret_code);
47 
48  if (ret_code != DB_OK)
49  return ret_code; /* ret_code SHOULD == DB_FAILED */
50 
51  /* get the results */
52  DB_RECV_TOKEN(&cursor->token);
53  DB_RECV_INT(&cursor->type);
54  DB_RECV_INT(&cursor->mode);
55  DB_RECV_TABLE_DEFINITION(&cursor->table);
56  return DB_OK;
57 }
struct driver * driver
Definition: driver/init.c:26
void db__set_protocol_fds(FILE *send, FILE *recv)
Definition: xdr.c:71
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_RECV_INT(x)
Definition: macros.h:39
#define DB_RECV_TOKEN(x)
Definition: macros.h:99
void db_init_cursor(dbCursor *cursor)
Definition: cursor.c:10
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_TABLE_DEFINITION(x)
Definition: macros.h:64
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:4
#define DB_SEND_STRING(x)
Definition: macros.h:12
Definition: driver.h:25
int db_open_select_cursor(dbDriver *driver, dbString *select, dbCursor *cursor, int mode)
Open select cursor.
Definition: c_openselect.c:29
tuple mode
Definition: tools.py:1481