GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
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 SPDX-FileCopyrightText: 1999-2009, 2011 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Joel Jones (CERL/UIUC), Radim Blazek, Brad Douglas, Markus Neteler
10 \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
11 */
12
13#include <grass/dbmi.h>
14#include <grass/glocale.h>
15#include "macros.h"
16
17/*!
18 \brief Send table definition
19
20 \param table pointer to dbTable
21
22 \return
23 */
25{
26 int i;
27
28 DB_SEND_INT(table->numColumns);
29
30 for (i = 0; i < table->numColumns; i++) {
32 }
35
38
39 return DB_OK;
40}
41
42/*!
43 \brief Receive table definition
44
45 \param[out] table
46
47 \return
48 */
50{
51 int i, ncols;
52 dbTable *t;
53
54 DB_RECV_INT(&ncols);
55
56 *table = t = db_alloc_table(ncols);
57 if (t == NULL)
58 return db_get_error_code();
59
60 for (i = 0; i < t->numColumns; i++) {
61 DB_RECV_COLUMN_DEFINITION(&t->columns[i]);
62 }
63 DB_RECV_STRING(&t->tableName);
64 DB_RECV_STRING(&t->description);
65
66 DB_RECV_INT(&t->priv_insert);
67 DB_RECV_INT(&t->priv_delete);
68
69 return DB_OK;
70}
71
72/*!
73 \brief Send table data
74
75 \param table
76
77 \return
78 */
80{
81 int i, ncols;
82
83 ncols = table->numColumns;
84 DB_SEND_INT(ncols);
85 for (i = 0; i < ncols; i++) {
87 }
88
89 return DB_OK;
90}
91
92/*!
93 \brief Receive table data
94
95 \param table
96
97 \return
98 */
100{
101 int i, ncols;
102
103 ncols = table->numColumns;
104 DB_RECV_INT(&i);
105
106 if (i != ncols) {
107 db_error(_("fetch: table has wrong number of columns"));
108 return DB_FAILED;
109 }
110 for (i = 0; i < ncols; i++) {
112 }
113
114 return DB_OK;
115}
#define NULL
Definition ccmath.h:32
Main header of GRASS DataBase Management Interface.
#define DB_FAILED
Definition dbmi.h:70
#define DB_OK
Definition dbmi.h:69
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:37
dbString tableName
Definition dbmi.h:211
int priv_insert
Definition dbmi.h:215
int priv_delete
Definition dbmi.h:216
int numColumns
Definition dbmi.h:213
dbString description
Definition dbmi.h:212
dbColumn * columns
Definition dbmi.h:214
int db__recv_table_definition(dbTable **table)
Receive table definition.
Definition xdrtable.c:49
int db__recv_table_data(dbTable *table)
Receive table data.
Definition xdrtable.c:99
int db__send_table_data(dbTable *table)
Send table data.
Definition xdrtable.c:79
int db__send_table_definition(dbTable *table)
Send table definition.
Definition xdrtable.c:24