GRASS Programmer's Manual 6.4.1(2011)
d_opendb.c
Go to the documentation of this file.
00001 
00015 #include <stdlib.h>
00016 #include <grass/dbmi.h>
00017 #include "macros.h"
00018 #include "dbstubs.h"
00019 
00026 int db_d_open_database(void)
00027 {
00028     dbHandle handle;
00029     int stat;
00030 
00031     /* get the arg(s) */
00032     db_init_handle(&handle);
00033     DB_RECV_HANDLE(&handle);
00034 
00035     /* see if there is a database already open */
00036     if (db__test_database_open()) {
00037         db_error("Multiple open databases not allowed");
00038         DB_SEND_FAILURE();
00039         return DB_OK;
00040     }
00041 
00042     /* call the procedure */
00043     stat = db_driver_open_database(&handle);
00044 
00045     /* send the return code */
00046     if (stat != DB_OK) {
00047         db_free_handle(&handle);
00048         DB_SEND_FAILURE();
00049         return DB_OK;
00050     }
00051     DB_SEND_SUCCESS();
00052 
00053     /* record the open in the driver state */
00054     db__mark_database_open(db_get_handle_dbname(&handle),
00055                            db_get_handle_dbschema(&handle));
00056     /* DO NOT free the handle since we saved the pointers to the name,path */
00057 
00058     /* no results */
00059     return DB_OK;
00060 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines