GRASS 8 Programmer's Manual 8.6.0dev(2026)-8843f13794
Loading...
Searching...
No Matches
c_list_tabs.c
Go to the documentation of this file.
1/*!
2 * \file db/dbmi_client/c_list_tabs.c
3 *
4 * \brief DBMI Library (client) - list tables
5 *
6 * SPDX-FileCopyrightText: 1999-2008 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Joel Jones (CERL/UIUC), Radim Blazek
10 */
11
12#include <stdlib.h>
13#include <string.h>
14#include <grass/dbmi.h>
15#include "macros.h"
16
17static int cmp_dbstr(const void *pa, const void *pb)
18{
19 const char *a = db_get_string((dbString *)pa);
20 const char *b = db_get_string((dbString *)pb);
21
22 return strcmp(a, b);
23}
24
25/*!
26 \brief List available tables for given connection
27
28 \param driver db driver
29 \param[out] names list of table names
30 \param[out] count number of items in the list
31 \param system ?
32
33 \return DB_OK on success
34 \return DB_FAILED on failure
35 */
36int db_list_tables(dbDriver *driver, dbString **names, int *count, int system)
37{
38 int ret_code;
39
40 /* start the procedure call */
43
44 /* arguments */
46
47 /* get the return code for the procedure call */
49
50 if (ret_code != DB_OK)
51 return ret_code; /* ret_code SHOULD == DB_FAILED */
52
53 /* results */
55
56 qsort(*names, *count, sizeof(dbString), cmp_dbstr);
57
58 return DB_OK;
59}
int db_list_tables(dbDriver *driver, dbString **names, int *count, int system)
List available tables for given connection.
Definition c_list_tabs.c:36
Main header of GRASS DataBase Management Interface.
#define DB_PROC_LIST_TABLES
Definition dbmi.h:54
#define DB_OK
Definition dbmi.h:69
char * db_get_string(const dbString *)
Get string.
Definition string.c:138
void db__set_protocol_fds(FILE *, FILE *)
?
int count
#define DB_SEND_INT(x)
Definition macros.h:82
#define DB_RECV_STRING_ARRAY(x, n)
Definition macros.h:44
#define DB_START_PROCEDURE_CALL(x)
Definition macros.h:2
#define DB_RECV_RETURN_CODE(x)
Definition macros.h:7
double b
Definition r_raster.c:37