GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
xdrindex.c
Go to the documentation of this file.
1 #include <grass/dbmi.h>
2 #include "macros.h"
3 
4 
5 int db__send_index(dbIndex * index)
6 {
7  int i;
8 
9  DB_SEND_STRING(&index->indexName);
10  DB_SEND_STRING(&index->tableName);
11  DB_SEND_CHAR(index->unique);
12 
13  DB_SEND_INT(index->numColumns);
14 
15  for (i = 0; i < index->numColumns; i++) {
16  DB_SEND_STRING(&index->columnNames[i]);
17  }
18 
19  return DB_OK;
20 }
21 
22 int db__send_index_array(dbIndex * list, int count)
23 {
24  int i;
25 
26  DB_SEND_INT(count);
27  for (i = 0; i < count; i++) {
28  DB_SEND_INDEX(&list[i]);
29  }
30  return DB_OK;
31 }
32 
33 int db__recv_index(dbIndex * index)
34 {
35  int i, ncols;
36 
37  db_init_index(index);
38  DB_RECV_STRING(&index->indexName);
39  DB_RECV_STRING(&index->tableName);
40  DB_RECV_CHAR(&index->unique);
41 
42  DB_RECV_INT(&ncols);
43 
44  if (db_alloc_index_columns(index, ncols) != DB_OK)
45  return db_get_error_code();
46 
47  for (i = 0; i < ncols; i++) {
48  DB_RECV_STRING(&index->columnNames[i]);
49  }
50 
51  return DB_OK;
52 }
53 
54 int db__recv_index_array(dbIndex ** list, int *count)
55 {
56  int i;
57 
58  DB_RECV_INT(count);
59 
60  *list = db_alloc_index_array(*count);
61  if (*list == NULL)
62  return db_get_error_code();
63 
64  for (i = 0; i < *count; i++) {
65  DB_RECV_INDEX(&((*list)[i]));
66  }
67 
68  return DB_OK;
69 }
#define DB_SEND_CHAR(x)
Definition: macros.h:23
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_RECV_INT(x)
Definition: macros.h:39
void db_init_index(dbIndex *index)
int db_alloc_index_columns(dbIndex *index, int ncols)
int count
int db__recv_index_array(dbIndex **list, int *count)
Definition: xdrindex.c:54
#define DB_SEND_INDEX(x)
Definition: macros.h:102
int db__send_index_array(dbIndex *list, int count)
Definition: xdrindex.c:22
int db__send_index(dbIndex *index)
Definition: xdrindex.c:5
int db_get_error_code(void)
#define DB_RECV_CHAR(x)
Definition: macros.h:25
#define DB_SEND_STRING(x)
Definition: macros.h:12
#define DB_RECV_INDEX(x)
Definition: macros.h:106
return NULL
Definition: dbfopen.c:1394
int db__recv_index(dbIndex *index)
Definition: xdrindex.c:33
dbIndex * db_alloc_index_array(int count)
#define DB_RECV_STRING(x)
Definition: macros.h:18