OpenDNSSEC-enforcer
1.3.4
|
00001 /* 00002 * $Id: dd_string.c 731 2009-05-18 08:24:19Z sion $ 00003 * 00004 * Copyright (c) 2008-2009 Nominet UK. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00017 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00018 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00019 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00020 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00021 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00023 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00025 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 */ 00028 00029 /*+ 00030 * dd_string.c - Database DELETE String 00031 * 00032 * Description: 00033 * Holds miscellaneous utility functions used when constructing SQL DELETE 00034 * commands in the KSM database. 00035 -*/ 00036 00037 #include <stdio.h> 00038 00039 #include "ksm/database_statement.h" 00040 #include "ksm/string_util.h" 00041 #include "ksm/string_util2.h" 00042 00043 00044 00045 /*+ 00046 * DdsInit - Create Basic Query 00047 * 00048 * Description: 00049 * Creates the basic query string comprising: 00050 * 00051 * DELETE FROM <table> 00052 * 00053 * Arguments: 00054 * const char* table 00055 * Name of the table from where the data is retrieved. 00056 * 00057 * Returns: 00058 * char* 00059 * Query string. This must be freed via a call to DdsEnd 00060 -*/ 00061 00062 char* DdsInit(const char* table) 00063 { 00064 char* query; 00065 00066 query = StrStrdup("DELETE FROM "); 00067 StrAppend(&query, table); 00068 00069 return query; 00070 } 00071 00072 00073 /*+ 00074 * DdsConditionInt - Append Integer Condition to Query 00075 * DdsConditionString - Append String Condition to Query 00076 * DdsConditionKeyword - Append Keyword Condition to Query 00077 * DdsEnd - End Query String Creation 00078 * DdsFree - Free Query Resources 00079 * 00080 * Description: 00081 * Add conditions to the deletion statement and free up resources. 00082 * 00083 * Because the operations are the same as the corresponding "query" 00084 * functions, this are no more than wrappers for those functions. 00085 * 00086 * Arguments: 00087 * See corresponding query functions. 00088 -*/ 00089 00090 void DdsConditionInt(char** query, const char* field, DQS_COMPARISON compare, 00091 int value, int index) 00092 { 00093 DqsConditionInt(query, field, compare, value, index); 00094 return; 00095 } 00096 00097 void DdsConditionString(char** query, const char* field, DQS_COMPARISON compare, 00098 const char* value, int index) 00099 { 00100 DqsConditionString(query, field, compare, value, index); 00101 return; 00102 } 00103 00104 void DdsConditionKeyword(char** query, const char* field, 00105 DQS_COMPARISON compare, const char* value, int index) 00106 { 00107 DqsConditionKeyword(query, field, compare, value, index); 00108 return; 00109 } 00110 00111 void DdsEnd(char** query) 00112 { 00113 DqsEnd(query); 00114 return; 00115 } 00116 00117 void DdsFree(char* query) 00118 { 00119 DqsFree(query); 00120 return; 00121 }