GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
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 }
37
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++) {
63 DB_RECV_COLUMN_DEFINITION(&t->columns[i]);
64 }
65 DB_RECV_STRING(&t->tableName);
66 DB_RECV_STRING(&t->description);
67
68 DB_RECV_INT(&t->priv_insert);
69 DB_RECV_INT(&t->priv_delete);
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}
#define NULL
Definition ccmath.h:32
Main header of GRASS DataBase Management Interface.
#define DB_FAILED
Definition dbmi.h:72
#define DB_OK
Definition dbmi.h:71
dbColumn * db_get_table_column(dbTable *, int)
Returns column structure for given table and column number.
dbTable * db_alloc_table(int)
Allocate a table with a specific number of columns.
int db_get_error_code(void)
Get error code.
void db_error(const char *)
Report error message.
#define _(str)
Definition glocale.h:10
#define DB_SEND_STRING(x)
Definition macros.h:24
#define DB_SEND_INT(x)
Definition macros.h:82
#define DB_RECV_COLUMN_DEFINITION(x)
Definition macros.h:186
#define DB_RECV_INT(x)
Definition macros.h:87
#define DB_RECV_COLUMN_VALUE(x)
Definition macros.h:197
#define DB_RECV_STRING(x)
Definition macros.h:39
#define DB_SEND_COLUMN_DEFINITION(x)
Definition macros.h:181
#define DB_SEND_COLUMN_VALUE(x)
Definition macros.h:192
double t
Definition r_raster.c:39
dbString tableName
Definition dbmi.h:213
int priv_insert
Definition dbmi.h:217
int priv_delete
Definition dbmi.h:218
int numColumns
Definition dbmi.h:215
dbString description
Definition dbmi.h:214
dbColumn * columns
Definition dbmi.h:216
int db__recv_table_definition(dbTable **table)
Receive table definition.
Definition xdrtable.c:51
int db__recv_table_data(dbTable *table)
Receive table data.
Definition xdrtable.c:101
int db__send_table_data(dbTable *table)
Send table data.
Definition xdrtable.c:81
int db__send_table_definition(dbTable *table)
Send table definition.
Definition xdrtable.c:26