00001 #include <stdlib.h> 00002 #include <grass/dbmi.h> 00003 #include "macros.h" 00004 #include "dbstubs.h" 00005 00012 int 00013 db_d_open_database() 00014 { 00015 dbHandle handle; 00016 int stat; 00017 00018 /* get the arg(s) */ 00019 db_init_handle (&handle); 00020 DB_RECV_HANDLE(&handle); 00021 00022 /* see if there is a database already open */ 00023 if (db__test_database_open()) 00024 { 00025 db_error ("Multiple open databases not allowed"); 00026 DB_SEND_FAILURE(); 00027 return DB_OK; 00028 } 00029 00030 /* call the procedure */ 00031 stat = db_driver_open_database (&handle); 00032 00033 /* send the return code */ 00034 if (stat != DB_OK) 00035 { 00036 db_free_handle (&handle); 00037 DB_SEND_FAILURE(); 00038 return DB_OK; 00039 } 00040 DB_SEND_SUCCESS(); 00041 00042 /* record the open in the driver state */ 00043 db__mark_database_open ( 00044 db_get_handle_dbname (&handle), 00045 db_get_handle_dbschema (&handle)); 00046 /* DO NOT free the handle since we saved the pointers to the name,path */ 00047 00048 /* no results */ 00049 return DB_OK; 00050 }