Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <assert.h>
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 #include <string.h>
00037 #include <time.h>
00038
00039 #include "ksm/database.h"
00040 #include "ksm/database_statement.h"
00041 #include "ksm/datetime.h"
00042 #include "ksm/db_fields.h"
00043 #include "ksm/debug.h"
00044 #include "ksm/ksmdef.h"
00045 #include "ksm/ksm.h"
00046 #include "ksm/ksm_internal.h"
00047 #include "ksm/message.h"
00048 #include "ksm/string_util.h"
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 int KsmDNSSECKeysInSMCountInit(DB_RESULT* result, int id)
00069 {
00070 int where = 0;
00071 char* sql = NULL;
00072 int status = 0;
00073
00074
00075
00076 sql = DqsCountInit("dnsseckeys");
00077 if (id >= 0) {
00078 DqsConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, id, where++);
00079 }
00080
00081
00082
00083
00084 status = DbExecuteSql(DbHandle(), sql, result);
00085
00086 DqsFree(sql);
00087
00088 return status;
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 int KsmDNSSECKeysStateCountInit(DB_RESULT* result, int policy_id, KSM_KEY_POLICY *key_policy, int state)
00116 {
00117 int where = 0;
00118 char* sql = NULL;
00119 int status = 0;
00120
00121
00122 if (key_policy == NULL) {
00123 return MsgLog(KSM_INVARG, "NULL key_policy");
00124 }
00125
00126
00127
00128 sql = DqsCountInit("dnsseckeys");
00129
00130 DqsConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, key_policy->sm, where++);
00131 DqsConditionInt(&sql, "policy_id", DQS_COMPARE_EQ, policy_id, where++);
00132 DqsConditionInt(&sql, "size", DQS_COMPARE_EQ, key_policy->bits, where++);
00133 DqsConditionInt(&sql, "algorithm", DQS_COMPARE_EQ, key_policy->algorithm, where++);
00134 DqsConditionInt(&sql, "keytype", DQS_COMPARE_EQ, key_policy->type, where++);
00135 DqsConditionInt(&sql, "state", DQS_COMPARE_EQ, state, where++);
00136
00137
00138
00139
00140 status = DbExecuteSql(DbHandle(), sql, result);
00141
00142 DqsFree(sql);
00143
00144 return status;
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 int KsmDNSSECKeysInSMCount(DB_RESULT result, int* count)
00168 {
00169 int status = 0;
00170 DB_ROW row = NULL;
00171
00172
00173
00174 status = DbFetchRow(result, &row);
00175 if (status == 0) {
00176
00177
00178
00179 status = DbInt(row, DB_COUNT, count);
00180 }
00181 else if (status == -1) {}
00182
00183 else {
00184 status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
00185 }
00186
00187 DbFreeRow(row);
00188
00189 return status;
00190 }