GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_finddb.c
Go to the documentation of this file.
1 
15 #include <stdlib.h>
16 #include <grass/dbmi.h>
17 #include "macros.h"
18 
29 int db_find_database(dbDriver * driver, dbHandle * handle, int *found)
30 {
31  int ret_code;
32  int stat;
33  dbHandle temp;
34 
35  /* start the procedure call */
36  db__set_protocol_fds(driver->send, driver->recv);
37  DB_START_PROCEDURE_CALL(DB_PROC_FIND_DATABASE);
38 
39  /* send the arguments to the procedure */
40  DB_SEND_HANDLE(handle);
41 
42  /* get the return code for the procedure call */
43  DB_RECV_RETURN_CODE(&ret_code);
44 
45  if (ret_code != DB_OK)
46  return ret_code; /* ret_code SHOULD == DB_FAILED */
47 
48  /* get results */
49  DB_RECV_INT(found);
50 
51  stat = DB_OK;
52  if (*found) {
53  DB_RECV_HANDLE(&temp);
54  stat = db_set_handle(handle,
55  db_get_handle_dbname(&temp),
57  );
58  db_free_handle(&temp);
59  }
60  return stat;
61 }
#define DB_SEND_HANDLE(x)
Definition: macros.h:57
void db__set_protocol_fds(FILE *send, FILE *recv)
Definition: xdr.c:71
void db_free_handle(dbHandle *handle)
Definition: handle.c:61
#define DB_RECV_INT(x)
Definition: macros.h:39
#define DB_RECV_HANDLE(x)
Definition: macros.h:59
const char * db_get_handle_dbschema(dbHandle *handle)
Definition: handle.c:50
int db_find_database(dbDriver *driver, dbHandle *handle, int *found)
Find database.
Definition: c_finddb.c:29
int stat
Definition: g3dcolor.c:369
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition: macros.h:4
int db_set_handle(dbHandle *handle, const char *dbName, const char *dbSchema)
Definition: handle.c:22
Definition: driver.h:25
const char * db_get_handle_dbname(dbHandle *handle)
Definition: handle.c:39