GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
xdrtable.c
Go to the documentation of this file.
1 #include <grass/dbmi.h>
2 #include "macros.h"
3 
4 
5 int db__send_table_definition(dbTable * table)
6 {
7  int i;
8 
9  DB_SEND_INT(table->numColumns);
10 
11  for (i = 0; i < table->numColumns; i++) {
12  DB_SEND_COLUMN_DEFINITION(&table->columns[i]);
13  }
14  DB_SEND_STRING(&table->tableName);
15  DB_SEND_STRING(&table->description);
16 
17  DB_SEND_INT(table->priv_insert);
18  DB_SEND_INT(table->priv_delete);
19 
20  return DB_OK;
21 }
22 
23 int db__recv_table_definition(dbTable ** table)
24 {
25  int i, ncols;
26  dbTable *t;
27 
28  DB_RECV_INT(&ncols);
29 
30  *table = t = db_alloc_table(ncols);
31  if (t == NULL)
32  return db_get_error_code();
33 
34  for (i = 0; i < t->numColumns; i++) {
35  DB_RECV_COLUMN_DEFINITION(&t->columns[i]);
36  }
37  DB_RECV_STRING(&t->tableName);
38  DB_RECV_STRING(&t->description);
39 
40  DB_RECV_INT(&t->priv_insert);
41  DB_RECV_INT(&t->priv_delete);
42 
43  return DB_OK;
44 }
45 
46 int db__send_table_data(dbTable * table)
47 {
48  int i, ncols;
49 
50  ncols = table->numColumns;
51  DB_SEND_INT(ncols);
52  for (i = 0; i < ncols; i++) {
54  }
55 
56  return DB_OK;
57 }
58 
59 int db__recv_table_data(dbTable * table)
60 {
61  int i, ncols;
62 
63  ncols = table->numColumns;
64  DB_RECV_INT(&i);
65 
66  if (i != ncols) {
67  db_error("fetch: table has wrong number of columns");
68  return DB_FAILED;
69  }
70  for (i = 0; i < ncols; i++) {
72  }
73 
74  return DB_OK;
75 }
dbColumn * db_get_table_column(dbTable *table, int n)
returns column structure for given table and column number
int db__recv_table_definition(dbTable **table)
Definition: xdrtable.c:23
#define DB_RECV_COLUMN_DEFINITION(x)
Definition: macros.h:84
int db__recv_table_data(dbTable *table)
Definition: xdrtable.c:59
#define DB_SEND_INT(x)
Definition: macros.h:37
dbTable * db_alloc_table(int ncols)
#define DB_RECV_INT(x)
Definition: macros.h:39
void db_error(const char *s)
int db_get_error_code(void)
#define DB_SEND_COLUMN_VALUE(x)
Definition: macros.h:87
#define DB_SEND_STRING(x)
Definition: macros.h:12
int db__send_table_definition(dbTable *table)
Definition: xdrtable.c:5
int db__send_table_data(dbTable *table)
Definition: xdrtable.c:46
#define DB_SEND_COLUMN_DEFINITION(x)
Definition: macros.h:82
return NULL
Definition: dbfopen.c:1394
#define DB_RECV_COLUMN_VALUE(x)
Definition: macros.h:89
#define DB_RECV_STRING(x)
Definition: macros.h:18