00001 #include <stdlib.h> 00002 #include <grass/dbmi.h> 00003 #include "macros.h" 00004 00011 int 00012 db_find_database (dbDriver *driver, dbHandle *handle, int *found) 00013 { 00014 int ret_code; 00015 int stat; 00016 dbHandle temp; 00017 00018 /* start the procedure call */ 00019 db__set_protocol_fds (driver->send, driver->recv); 00020 DB_START_PROCEDURE_CALL(DB_PROC_FIND_DATABASE); 00021 00022 /* send the arguments to the procedure */ 00023 DB_SEND_HANDLE (handle); 00024 00025 /* get the return code for the procedure call */ 00026 DB_RECV_RETURN_CODE(&ret_code); 00027 00028 if (ret_code != DB_OK) 00029 return ret_code; /* ret_code SHOULD == DB_FAILED */ 00030 00031 /* get results */ 00032 DB_RECV_INT(found); 00033 00034 stat = DB_OK; 00035 if (*found) 00036 { 00037 DB_RECV_HANDLE (&temp); 00038 stat = db_set_handle (handle, 00039 db_get_handle_dbname(&temp), 00040 db_get_handle_dbschema(&temp) 00041 ); 00042 db_free_handle (&temp); 00043 } 00044 return stat; 00045 }