GRASS Programmer's Manual
6.4.2(2012)
|
00001 00015 #include <stdlib.h> 00016 #include <grass/dbmi.h> 00017 #include "macros.h" 00018 00029 int db_find_database(dbDriver * driver, dbHandle * handle, int *found) 00030 { 00031 int ret_code; 00032 int stat; 00033 dbHandle temp; 00034 00035 /* start the procedure call */ 00036 db__set_protocol_fds(driver->send, driver->recv); 00037 DB_START_PROCEDURE_CALL(DB_PROC_FIND_DATABASE); 00038 00039 /* send the arguments to the procedure */ 00040 DB_SEND_HANDLE(handle); 00041 00042 /* get the return code for the procedure call */ 00043 DB_RECV_RETURN_CODE(&ret_code); 00044 00045 if (ret_code != DB_OK) 00046 return ret_code; /* ret_code SHOULD == DB_FAILED */ 00047 00048 /* get results */ 00049 DB_RECV_INT(found); 00050 00051 stat = DB_OK; 00052 if (*found) { 00053 DB_RECV_HANDLE(&temp); 00054 stat = db_set_handle(handle, 00055 db_get_handle_dbname(&temp), 00056 db_get_handle_dbschema(&temp) 00057 ); 00058 db_free_handle(&temp); 00059 } 00060 return stat; 00061 }