summaryrefslogtreecommitdiffstats
path: root/database/sqlite
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-05-06 20:30:48 +0200
committerDavid Sommerseth <davids@redhat.com>2009-05-06 20:30:48 +0200
commit5611c22c92cefb2e9c86d20a98ed4680e5b813ed (patch)
tree9bf9f81898b288e5396953bb9c2e5ea72409853c /database/sqlite
parent75f1e6f6b12f9fe461e4afa5bf3c998d21d48394 (diff)
downloadeurephia-5611c22c92cefb2e9c86d20a98ed4680e5b813ed.tar.gz
eurephia-5611c22c92cefb2e9c86d20a98ed4680e5b813ed.tar.xz
eurephia-5611c22c92cefb2e9c86d20a98ed4680e5b813ed.zip
Renamed fieldmapping for 'attempts' to 'attemptslog'
Also made the result XML from eDBadminAttemptsLog(...) more efficient by not adding the username/certificate/ipaddress group tags if the information is not present.
Diffstat (limited to 'database/sqlite')
-rw-r--r--database/sqlite/administration.c6
-rw-r--r--database/sqlite/attempts.c19
2 files changed, 16 insertions, 9 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c
index 6def2e8..e75dccd 100644
--- a/database/sqlite/administration.c
+++ b/database/sqlite/administration.c
@@ -1565,11 +1565,11 @@ xmlDoc *eDBadminGetLastlog(eurephiaCTX *ctx, xmlDoc *srch, const char *sortkeys)
// The search XML document format is:
// <eurephia format="1">
-// <attempts mode="{search|add|delete}">
+// <attemptslog mode="{search|add|delete}">
// <fieldMapping table="attempts">
// <{field name}>{field value}</{field field}>
// </fieldMapping>
-// </attempts>
+// </attemptslog>
// </eurehpia>
//
// It can be several search field tags to limit the search even more.
@@ -1593,7 +1593,7 @@ xmlDoc *eDBadminAttemptsLog(eurephiaCTX *ctx, xmlDoc *qryxml) {
return NULL;
}
- root_n = eurephiaXML_getRoot(ctx, qryxml, "attempts", 1);
+ root_n = eurephiaXML_getRoot(ctx, qryxml, "attemptslog", 1);
if( root_n == NULL ) {
eurephia_log(ctx, LOG_CRITICAL, 0, "Invalid XML input.");
return NULL;
diff --git a/database/sqlite/attempts.c b/database/sqlite/attempts.c
index 7e8e95b..4afd981 100644
--- a/database/sqlite/attempts.c
+++ b/database/sqlite/attempts.c
@@ -65,24 +65,31 @@ xmlDoc *attempts_list(eurephiaCTX *ctx, eDBfieldMap *fmap) {
return 0;
}
- eurephiaXML_CreateDoc(ctx, 1, "attempts", &doc, &root_n);
+ eurephiaXML_CreateDoc(ctx, 1, "attemptslog", &doc, &root_n);
xmlNewProp(root_n, (xmlChar *) "mode", (xmlChar *) "list");
- uname_n = xmlNewChild(root_n, NULL, (xmlChar *) "username", NULL);
- cert_n = xmlNewChild(root_n, NULL, (xmlChar *) "certificate", NULL);
- remip_n = xmlNewChild(root_n, NULL, (xmlChar *) "ipaddress", NULL);
- assert( (uname_n != NULL) && (cert_n != NULL) && (remip_n != NULL) );
-
for( i = 0; i < sqlite_get_numtuples(res); i++ ) {
xmlNode *atmpt_n = NULL;
if( sqlite_get_value(res, i, 0) != NULL ) { // Username
+ if( uname_n == NULL ) {
+ uname_n = xmlNewChild(root_n, NULL, (xmlChar *) "username", NULL);
+ assert( uname_n != NULL );
+ }
atmpt_n = xmlNewChild(uname_n, NULL, (xmlChar *) "attempt", NULL);
sqlite_xml_value(atmpt_n, XML_NODE, "username", res, i, 0);
} else if( sqlite_get_value(res, i, 1) != NULL ) { // Digest
+ if( cert_n == NULL ) {
+ cert_n = xmlNewChild(root_n, NULL, (xmlChar *) "certificate", NULL);
+ assert( cert_n != NULL );
+ }
atmpt_n = xmlNewChild(cert_n, NULL, (xmlChar *) "attempt", NULL);
sqlite_xml_value(atmpt_n, XML_NODE, "certificate", res, i, 1);
} else if( sqlite_get_value(res, i, 2) != NULL ) { // IP address
+ if( remip_n == NULL ) {
+ remip_n = xmlNewChild(root_n, NULL, (xmlChar *) "ipaddress", NULL);
+ assert( remip_n != NULL );
+ }
atmpt_n = xmlNewChild(remip_n, NULL, (xmlChar *) "attempt", NULL);
sqlite_xml_value(atmpt_n, XML_NODE, "ipaddress", res, i, 2);
} else {