GRASS Programmer's Manual  6.4.2(2012)
d_listdb.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_list_databases(void)
00027 {
00028     dbHandle *handles;
00029     dbString *path;
00030     int npaths;
00031     int i, count;
00032     int stat;
00033 
00034     /* arg(s) */
00035     DB_RECV_STRING_ARRAY(&path, &npaths);
00036 
00037     /* call the procedure */
00038     stat = db_driver_list_databases(path, npaths, &handles, &count);
00039     db_free_string_array(path, npaths);
00040 
00041     /* send the return code */
00042     if (stat != DB_OK) {
00043         DB_SEND_FAILURE();
00044         return DB_OK;
00045     }
00046     DB_SEND_SUCCESS();
00047 
00048     /* send results */
00049     DB_SEND_INT(count);
00050     for (i = 0; i < count; i++) {
00051         DB_SEND_HANDLE(&handles[i]);
00052     }
00053     db_free_handle_array(handles, count);
00054     return DB_OK;
00055 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines