diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-13 21:26:16 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-13 21:26:16 +0100 |
commit | 29f820906aaf5dbd81f3a6203d72a08ccd364be0 (patch) | |
tree | cde0913c7212142be7b00c29b1654c4c81244019 /database | |
parent | 7a015bdf45d739ca3e6a4ac7d7e9fdb8daa7ab70 (diff) | |
download | eurephia-29f820906aaf5dbd81f3a6203d72a08ccd364be0.tar.gz eurephia-29f820906aaf5dbd81f3a6203d72a08ccd364be0.tar.xz eurephia-29f820906aaf5dbd81f3a6203d72a08ccd364be0.zip |
Completed rewriting eDBadminGetUserInfo(...) function for XML
This rewrite utilities the XML interface instead of the more static
eurephiaUSERINFO struct.
Diffstat (limited to 'database')
-rw-r--r-- | database/eurephiadb_driver.h | 8 | ||||
-rw-r--r-- | database/sqlite/administration.c | 25 |
2 files changed, 19 insertions, 14 deletions
diff --git a/database/eurephiadb_driver.h b/database/eurephiadb_driver.h index 387e312..f636ac0 100644 --- a/database/eurephiadb_driver.h +++ b/database/eurephiadb_driver.h @@ -22,6 +22,10 @@ #include <eurephia_values_struct.h> #include <eurephia_admin_struct.h> +#ifdef HAVE_LIBXML2 +#include <libxml/tree.h> +#endif + #ifndef EUREPHIADB_DRIVER_H_ #define EUREPHIADB_DRIVER_H_ @@ -100,8 +104,10 @@ int (*eDBadminLogout) (eurephiaCTX *ctx, const char *session); int (*eDBadminConfigSet) (eurephiaCTX *ctx, const char *key, const char *val); int (*eDBadminConfigDelete) (eurephiaCTX *ctx, const char *key); +#ifdef HAVE_LIBXML2 eurephiaUSERLIST *(*eDBadminGetUserList) (eurephiaCTX *ctx, const char *sortkeys); -int (*eDBadminGetUserInfo) (eurephiaCTX *ctx, int infoType, eurephiaUSERINFO *user); +xmlDoc *(*eDBadminGetUserInfo) (eurephiaCTX *ctx, int infoType, xmlDoc *srch); +#endif int (*eDBadminAddUser) (eurephiaCTX *ctx, eurephiaUSERINFO *userinfo); int (*eDBadminUpdateUser) (eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *userinfo); int (*eDBadminDeleteUser) (eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *userinfo); diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index ab6cdd3..2462fc8 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -411,25 +411,26 @@ eurephiaUSERLIST *eDBadminGetUserList(eurephiaCTX *ctx, const char *sortkeys) { return ret; } -inline int xml_set_flag(xmlNodePtr node, char *flagname, int flagged) { +inline int xml_set_flag(xmlNode *node, char *flagname, int flagged) { if( flagged ) { xmlNewChild(node, NULL, (xmlChar *) "flag", (xmlChar *) flagname); } return flagged; } + // This function will read out all info from eurephiaINFO *user which is not NULL and create a query based // on these values. If a user is found, the *user struct will be updated with the user found. On success // the function returns 1. -int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { +xmlDoc *eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, xmlDoc *srch) { dbresult *uinf = NULL, *certinf = NULL; eDBfieldMap *uinfo_map = NULL; int flag = 0, uid = 0; - xmlDocPtr doc = NULL; - xmlNodePtr root_n = NULL, info_n = NULL; + xmlDoc *doc = NULL; + xmlNode *root_n = NULL, *info_n = NULL; - uinfo_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, "u", user); + uinfo_map = eDBxmlMapping(ctx, tbl_sqlite_users, "u", srch); // Query the database, find the user defined in the user map uinf = sqlite_query_mapped(ctx, SQL_SELECT, @@ -463,6 +464,7 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { case 1: uid = atoi_nullsafe(sqlite_get_value(uinf, 0, 4)); + doc = xmlNewDoc((xmlChar *) "1.0"); root_n = xmlNewNode(NULL, (xmlChar *) "user"); sqlite_xml_value(root_n, XML_ATTR, "uid", uinf, 0, 4); @@ -518,7 +520,7 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { info_n = xmlNewChild(root_n, NULL, (xmlChar *) "certificates", NULL); if( (certinf != NULL) && (sqlite_get_numtuples(certinf) > 0) ) { int i; - xmlNodePtr cert, acpr; + xmlNode *cert, *acpr; for( i = 0; i < sqlite_get_numtuples(certinf); i++ ) { cert = xmlNewChild(info_n, NULL, (xmlChar *) "certificate", NULL); @@ -542,16 +544,11 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { } } - // Just for debug purpose, until everything is ported over to XML - xmlSaveFormatFileEnc("-", doc, "UTF-8", 1); - xmlFreeDoc(doc); - xmlCleanupParser(); - return 1; - + return doc; default: sqlite_free_results(uinf); eurephia_log(ctx, LOG_ERROR, 0, "Too many user records was found."); - return 0; + return NULL; } } @@ -560,6 +557,7 @@ int eDBadminAddUser(eurephiaCTX *ctx, eurephiaUSERINFO *usrinf) { } int eDBadminUpdateUser(eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *usrinf) { + /* dbresult *uinf = NULL; eurephiaUSERINFO *srch = NULL; eDBfieldMap *data_map = NULL, *srch_map = NULL; @@ -584,6 +582,7 @@ int eDBadminUpdateUser(eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *usrinf eAdminFreeUSERINFO(srch); eDBfreeMapping(data_map); + */ return 1; } |