OpenDNSSEC-enforcer  1.4.5
dd_string.c
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 /*+
28  * dd_string.c - Database DELETE String
29  *
30  * Description:
31  * Holds miscellaneous utility functions used when constructing SQL DELETE
32  * commands in the KSM database.
33 -*/
34 
35 #include <stdio.h>
36 
37 #include "ksm/database_statement.h"
38 #include "ksm/string_util.h"
39 #include "ksm/string_util2.h"
40 
41 
42 
43 /*+
44  * DdsInit - Create Basic Query
45  *
46  * Description:
47  * Creates the basic query string comprising:
48  *
49  * DELETE FROM <table>
50  *
51  * Arguments:
52  * const char* table
53  * Name of the table from where the data is retrieved.
54  *
55  * Returns:
56  * char*
57  * Query string. This must be freed via a call to DdsEnd
58 -*/
59 
60 char* DdsInit(const char* table)
61 {
62  char* query;
63 
64  query = StrStrdup("DELETE FROM ");
65  StrAppend(&query, table);
66 
67  return query;
68 }
69 
70 
71 /*+
72  * DdsConditionInt - Append Integer Condition to Query
73  * DdsConditionString - Append String Condition to Query
74  * DdsConditionKeyword - Append Keyword Condition to Query
75  * DdsEnd - End Query String Creation
76  * DdsFree - Free Query Resources
77  *
78  * Description:
79  * Add conditions to the deletion statement and free up resources.
80  *
81  * Because the operations are the same as the corresponding "query"
82  * functions, this are no more than wrappers for those functions.
83  *
84  * Arguments:
85  * See corresponding query functions.
86 -*/
87 
88 void DdsConditionInt(char** query, const char* field, DQS_COMPARISON compare,
89  int value, int index)
90 {
91  DqsConditionInt(query, field, compare, value, index);
92  return;
93 }
94 
95 void DdsConditionString(char** query, const char* field, DQS_COMPARISON compare,
96  const char* value, int index)
97 {
98  DqsConditionString(query, field, compare, value, index);
99  return;
100 }
101 
102 void DdsConditionKeyword(char** query, const char* field,
103  DQS_COMPARISON compare, const char* value, int index)
104 {
105  DqsConditionKeyword(query, field, compare, value, index);
106  return;
107 }
108 
109 void DdsEnd(char** query)
110 {
111  DqsEnd(query);
112  return;
113 }
114 
115 void DdsFree(char* query)
116 {
117  DqsFree(query);
118  return;
119 }