]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/myingres.sh
Revert "First attempt at making things multi-threaded and make it possible to"
[bacula/bacula] / bacula / src / cats / myingres.sh
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2009-2010 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 #ifndef _MYINGRES_SH
29 #define _MYINGRES_SH
30
31 EXEC SQL INCLUDE SQLDA;
32
33 /* ---typedefs--- */
34
35 typedef struct ing_field {
36    char          name[34];
37    int           max_length;
38    unsigned int  type;
39    unsigned int  flags;       // 1 == not null
40 } INGRES_FIELD;
41
42 typedef struct ing_row {
43     IISQLVAR *sqlvar;           /* ptr to sqlvar[sqld] for one row */
44     struct ing_row *next;
45     int row_number;
46 } ING_ROW;
47
48 typedef enum ing_status {
49     ING_COMMAND_OK,
50     ING_TUPLES_OK,
51     ING_NO_RESULT,
52     ING_NO_ROWS_PROCESSED,
53     ING_EMPTY_RESULT,
54     ING_ERROR
55 } ING_STATUS;
56
57 typedef struct ing_varchar {
58     short len;
59     char* value;
60 } ING_VARCHAR;
61
62 /* It seems, Bacula needs the complete query result stored in one data structure */
63 typedef struct ing_result {
64     IISQLDA *sqlda;             /* descriptor */
65     INGRES_FIELD *fields;
66     int num_rows;
67     int num_fields;
68     ING_STATUS status;
69     ING_ROW *first_row;
70     ING_ROW *act_row;           /* just for iterating */
71     char numrowstring[10];
72     
73 } INGresult;
74
75 typedef struct ing_conn {
76     char dbname[24];
77     char user[32];
78     char password[32];
79     char connection_name[32];
80     int session_id;
81     char *msg;
82 } INGconn;
83
84
85 /* ---Prototypes--- */
86 int INGcheck(void);
87 short INGgetCols(const char *stmt);
88 char *INGgetvalue(INGresult *res, int row_number, int column_number);
89 bool INGgetisnull(INGresult *res, int row_number, int column_number);
90 int INGntuples(const INGresult *res);
91 int INGnfields(const INGresult *res);
92 char *INGfname(const INGresult *res, int column_number);
93 short INGftype(const INGresult *res, int column_number);
94 int INGexec(INGconn *db, const char *query);
95 INGresult *INGquery(INGconn *db, const char *query);
96 void INGclear(INGresult *res);
97 INGconn *INGconnectDB(char *dbname, char *user, char *passwd);
98 void INGdisconnectDB(INGconn *dbconn);
99 char *INGerrorMessage(const INGconn *conn);
100 char *INGcmdTuples(INGresult *res);
101
102 #endif /* _MYINGRES_SH */