diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-16 22:11:32 +0100 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-16 22:11:32 +0100 |
| commit | 4789e394a7e695a55ca7c7df87d8ccb7010bb971 (patch) | |
| tree | d6e7fb148fff0ffb694a13d5962dfc223176192d /database/sqlite | |
| parent | 937eb70d21e4231d210915dce1e9ac02aef47567 (diff) | |
| download | eurephia-4789e394a7e695a55ca7c7df87d8ccb7010bb971.tar.gz eurephia-4789e394a7e695a55ca7c7df87d8ccb7010bb971.tar.xz eurephia-4789e394a7e695a55ca7c7df87d8ccb7010bb971.zip | |
Rewrote eDBadminGetUserList(...) to use XML
Diffstat (limited to 'database/sqlite')
| -rw-r--r-- | database/sqlite/administration.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 2462fc8..a538adf 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -358,11 +358,11 @@ int eDBadminConfigDelete(eurephiaCTX *ctx, const char *key) { return 1; } -eurephiaUSERLIST *eDBadminGetUserList(eurephiaCTX *ctx, const char *sortkeys) { - eurephiaUSERINFO *rec = NULL, *last = NULL; - eurephiaUSERLIST *ret = NULL; +xmlDoc *eDBadminGetUserList(eurephiaCTX *ctx, const char *sortkeys) { + xmlDoc *userlist = NULL; + xmlNode *root_n = NULL, *user_n = NULL; dbresult *res = NULL; - char *dbsort = NULL; + char *dbsort = NULL, tmp[34]; int i = 0; assert((ctx != NULL) && (ctx->dbc != 0)); @@ -381,34 +381,26 @@ eurephiaUSERLIST *eDBadminGetUserList(eurephiaCTX *ctx, const char *sortkeys) { } // Prepare a list with all users - ret = (eurephiaUSERLIST *) malloc(sizeof(eurephiaUSERLIST)+2); - assert(ret != NULL); - memset(ret, 0, sizeof(eurephiaUSERLIST)+2); - - ret->num_users = sqlite_get_numtuples(res); + memset(&tmp, 0, 34); + userlist = xmlNewDoc((xmlChar *)"1.0"); + root_n = xmlNewNode(NULL, (xmlChar *)"userlist"); + snprintf(tmp, 32, "%i", sqlite_get_numtuples(res)); + xmlNewProp(root_n, (xmlChar *)"usercount", (xmlChar *)tmp); + xmlDocSetRootElement(userlist, root_n); // Register all records - for( i = 0; i < ret->num_users; i++ ) { - rec = eAdminPopulateUSERINFO( - atoi_nullsafe(sqlite_get_value(res, i, 4)), // uid - sqlite_get_value(res, i, 0), // username - NULL, // passwd - sqlite_get_value(res, i, 1), // activated - sqlite_get_value(res, i, 2), // deactivated - sqlite_get_value(res, i, 3) // last accessed - ); - if( ret->users == NULL ) { - ret->users = rec; - last = ret->users; - } else { - last->next = rec; - last = rec; - } + for( i = 0; i < sqlite_get_numtuples(res); i++ ) { + user_n = xmlNewChild(root_n, NULL, (xmlChar *)"user", NULL); + sqlite_xml_value(user_n, XML_ATTR, "uid", res, i, 4); + sqlite_xml_value(user_n, XML_NODE, "username", res, i, 0); + sqlite_xml_value(user_n, XML_NODE, "activated", res, i, 1); + sqlite_xml_value(user_n, XML_NODE, "deactivated", res, i, 2); + sqlite_xml_value(user_n, XML_NODE, "last_accessed", res, i, 3); } sqlite_free_results(res); // Return a user list - return ret; + return userlist; } inline int xml_set_flag(xmlNode *node, char *flagname, int flagged) { |
