OpenDNSSEC-enforcer  1.4.9
database_statement.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2009 Nominet UK. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
27 #ifndef KSM_DATABASE_STATEMENT_H
28 #define KSM_DATABASE_STATEMENT_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*+
35  * database_statement.h - Database SQL Statement Construction
36  *
37  * Description:
38  * Prototypes for all the functions concerned with creating database
39  * query strings.
40 -*/
41 
42 /* Database comparison operators */
43 
44 typedef enum {
45  DQS_END_OF_LIST, /* Used to make the end of a list */
56 
57 /* General comparsion structure */
58 
59 typedef struct { /* Structure for a query */
60  int code; /* Code to query for */
61  DQS_COMPARISON compare; /* What comparison to use */
62  union { /* Data value to compare for */
63  int number;
64  const char* string;
65  void* binary;
66  struct tm* datetime;
67  } data;
69 
70 /* SELECT function prototypes */
71 
72 char* DqsInit(const char* table);
73 char* DqsCountInit(const char* table);
74 char* DqsSpecifyInit(const char* table, const char* fields);
75 void DqsConditionInt(char** query, const char* field, DQS_COMPARISON compare,
76  int value, int clause);
77 void DqsConditionString(char** query, const char* field, DQS_COMPARISON compare,
78  const char* value, int clause);
79 void DqsConditionKeyword(char** query, const char* field,
80  DQS_COMPARISON compare, const char* value, int clause);
81 void DqsOrderBy(char** query, const char* field);
82 void DqsEnd(char** query);
83 void DqsFree(char* query);
84 
85 /* INSERT helper functions */
86 
87 char* DisInit(const char* table);
88 char* DisSpecifyInit(const char* table, const char* cols);
89 void DisAppendInt(char** sql, int what);
90 void DisAppendString(char** sql, const char* what);
91 void DisEnd(char** sql);
92 void DisFree(char* sql);
93 
94 /* UPDATE helper functions */
95 
96 char* DusInit(const char* table);
97 void DusSetInt(char** sql, const char* field, int data, int clause);
98 void DusSetString(char** sql, const char* field, const char* data, int clause);
99 void DusConditionInt(char** query, const char* field, DQS_COMPARISON compare,
100  int value, int clause);
101 void DusConditionString(char** query, const char* field, DQS_COMPARISON compare,
102  const char* value, int clause);
103 void DusConditionKeyword(char** query, const char* field,
104  DQS_COMPARISON compare, const char* value, int clause);
105 void DusEnd(char** sql);
106 void DusFree(char* sql);
107 
108 /* DELETE function prototypes */
109 
110 char* DdsInit(const char* table);
111 void DdsConditionInt(char** query, const char* field, DQS_COMPARISON compare,
112  int value, int clause);
113 void DdsConditionString(char** query, const char* field, DQS_COMPARISON compare,
114  const char* value, int clause);
115 void DdsConditionKeyword(char** query, const char* field,
116  DQS_COMPARISON compare, const char* value, int clause);
117 void DdsEnd(char** query);
118 void DdsFree(char* query);
119 
120 #ifdef __cplusplus
121 };
122 #endif
123 
124 #endif /* KSM_DATABASE_STATEMENT_H */
void DdsConditionKeyword(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: dd_string.c:102
char * DisInit(const char *table)
Definition: di_string.c:65
void DisAppendInt(char **sql, int what)
Definition: di_string.c:131
void DqsConditionKeyword(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: dq_string.c:251
void DusConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: du_string.c:176
DQS_COMPARISON compare
char * DqsSpecifyInit(const char *table, const char *fields)
Definition: dq_string.c:117
DQS_COMPARISON
void DusEnd(char **sql)
Definition: du_string.c:202
void DdsConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: dd_string.c:95
char * DqsInit(const char *table)
Definition: dq_string.c:61
void DusConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int clause)
Definition: du_string.c:170
void DdsEnd(char **query)
Definition: dd_string.c:109
void DisFree(char *sql)
Definition: di_string.c:191
void DusSetString(char **sql, const char *field, const char *data, int clause)
Definition: du_string.c:113
char * DisSpecifyInit(const char *table, const char *cols)
Definition: di_string.c:99
void DqsConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int clause)
Definition: dq_string.c:224
void DusSetInt(char **sql, const char *field, int data, int clause)
Definition: du_string.c:97
void DdsConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int clause)
Definition: dd_string.c:88
char * DqsCountInit(const char *table)
Definition: dq_string.c:90
void DisEnd(char **sql)
Definition: di_string.c:170
void DusFree(char *sql)
Definition: du_string.c:223
void DusConditionKeyword(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: du_string.c:182
void DqsEnd(char **query)
Definition: dq_string.c:299
void DqsOrderBy(char **query, const char *field)
Definition: dq_string.c:277
char * DusInit(const char *table)
Definition: du_string.c:60
void DdsFree(char *query)
Definition: dd_string.c:115
void DqsConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: dq_string.c:238
void DqsFree(char *query)
Definition: dq_string.c:320
char * DdsInit(const char *table)
Definition: dd_string.c:60
void DisAppendString(char **sql, const char *what)
Definition: di_string.c:142