GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
handle.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <grass/dbmi.h>
3 
10 void db_init_handle(dbHandle * handle)
11 {
12  db_init_string(&handle->dbName);
13  db_init_string(&handle->dbSchema);
14 }
15 
22 int db_set_handle(dbHandle * handle, const char *dbName, const char *dbSchema)
23 {
24  int stat;
25 
26  stat = db_set_string(&handle->dbName, dbName);
27  if (stat != DB_OK)
28  return stat;
29  stat = db_set_string(&handle->dbSchema, dbSchema);
30  return stat;
31 }
32 
39 const char *db_get_handle_dbname(dbHandle * handle)
40 {
41  return db_get_string(&handle->dbName);
42 }
43 
50 const char *db_get_handle_dbschema(dbHandle * handle)
51 {
52  return db_get_string(&handle->dbSchema);
53 }
54 
61 void db_free_handle(dbHandle * handle)
62 {
63  db_free_string(&handle->dbName);
64  db_free_string(&handle->dbSchema);
65 }
66 
73 void db_free_handle_array(dbHandle * handle, int count)
74 {
75  int i;
76 
77  if (handle) {
78  for (i = 0; i < count; i++)
79  db_free_handle(&handle[i]);
80  db_free(handle);
81  }
82 }
83 
91 {
92  int i;
93  dbHandle *handle;
94 
95  handle = (dbHandle *) db_calloc(count, sizeof(dbHandle));
96  if (handle)
97  for (i = 0; i < count; i++)
98  db_init_handle(&handle[i]);
99  return handle;
100 }
void db_free_handle(dbHandle *handle)
Definition: handle.c:61
void * db_calloc(int n, int m)
int count
void db_free_handle_array(dbHandle *handle, int count)
Definition: handle.c:73
const char * db_get_handle_dbschema(dbHandle *handle)
Definition: handle.c:50
dbHandle * db_alloc_handle_array(int count)
Definition: handle.c:90
int stat
Definition: g3dcolor.c:369
int db_set_handle(dbHandle *handle, const char *dbName, const char *dbSchema)
Definition: handle.c:22
char * db_get_string(dbString *x)
Definition: string.c:131
void db_init_handle(dbHandle *handle)
Definition: handle.c:10
int db_set_string(dbString *x, const char *s)
Definition: string.c:33
void db_free_string(dbString *x)
Definition: string.c:142
const char * db_get_handle_dbname(dbHandle *handle)
Definition: handle.c:39
void db_init_string(dbString *x)
Definition: string.c:11
void db_free(void *s)