GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
xdrtable.c
Go to the documentation of this file.
1 /*!
2  \file lib/db/dbmi_base/xdrtable.c
3 
4  \brief DBMI Library (base) - external data representation (table)
5 
6  (C) 1999-2009, 2011 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Joel Jones (CERL/UIUC), Radim Blazek, Brad Douglas, Markus Neteler
12  \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
13 */
14 
15 #include <grass/dbmi.h>
16 #include <grass/glocale.h>
17 #include "macros.h"
18 
19 /*!
20  \brief Send table definition
21 
22  \param table pointer to dbTable
23 
24  \return
25 */
27 {
28  int i;
29 
30  DB_SEND_INT(table->numColumns);
31 
32  for (i = 0; i < table->numColumns; i++) {
34  }
35  DB_SEND_STRING(&table->tableName);
36  DB_SEND_STRING(&table->description);
37 
38  DB_SEND_INT(table->priv_insert);
39  DB_SEND_INT(table->priv_delete);
40 
41  return DB_OK;
42 }
43 
44 /*!
45  \brief Receive table definition
46 
47  \param[out] table
48 
49  \return
50 */
52 {
53  int i, ncols;
54  dbTable *t;
55 
56  DB_RECV_INT(&ncols);
57 
58  *table = t = db_alloc_table(ncols);
59  if (t == NULL)
60  return db_get_error_code();
61 
62  for (i = 0; i < t->numColumns; i++) {
64  }
67 
70 
71  return DB_OK;
72 }
73 
74 /*!
75  \brief Send table data
76 
77  \param table
78 
79  \return
80 */
82 {
83  int i, ncols;
84 
85  ncols = table->numColumns;
86  DB_SEND_INT(ncols);
87  for (i = 0; i < ncols; i++) {
89  }
90 
91  return DB_OK;
92 }
93 
94 /*!
95  \brief Receive table data
96 
97  \param table
98 
99  \return
100 */
102 {
103  int i, ncols;
104 
105  ncols = table->numColumns;
106  DB_RECV_INT(&i);
107 
108  if (i != ncols) {
109  db_error(_("fetch: table has wrong number of columns"));
110  return DB_FAILED;
111  }
112  for (i = 0; i < ncols; i++) {
114  }
115 
116  return DB_OK;
117 }
int db__recv_table_definition(dbTable **table)
Receive table definition.
Definition: xdrtable.c:51
#define DB_RECV_COLUMN_DEFINITION(x)
Definition: macros.h:84
int db__recv_table_data(dbTable *table)
Receive table data.
Definition: xdrtable.c:101
#define DB_SEND_INT(x)
Definition: macros.h:37
#define DB_RECV_INT(x)
Definition: macros.h:39
dbColumn * columns
Definition: dbmi.h:225
int priv_delete
Definition: dbmi.h:227
dbString description
Definition: dbmi.h:223
dbString tableName
Definition: dbmi.h:222
#define NULL
Definition: ccmath.h:32
int numColumns
Definition: dbmi.h:224
double t
Definition: r_raster.c:39
int db_get_error_code(void)
Get error code.
#define DB_SEND_COLUMN_VALUE(x)
Definition: macros.h:87
#define DB_SEND_STRING(x)
Definition: macros.h:12
dbTable * db_alloc_table(int)
Allocate a table with a specific number of columns.
int db__send_table_definition(dbTable *table)
Send table definition.
Definition: xdrtable.c:26
int db__send_table_data(dbTable *table)
Send table data.
Definition: xdrtable.c:81
void db_error(const char *)
Report error message.
#define DB_SEND_COLUMN_DEFINITION(x)
Definition: macros.h:82
#define DB_FAILED
Definition: dbmi.h:72
dbColumn * db_get_table_column(dbTable *, int)
Returns column structure for given table and column number.
#define _(str)
Definition: glocale.h:10
int priv_insert
Definition: dbmi.h:226
#define DB_RECV_COLUMN_VALUE(x)
Definition: macros.h:89
#define DB_RECV_STRING(x)
Definition: macros.h:18
#define DB_OK
Definition: dbmi.h:71