diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-25 13:52:48 +0200 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2009-09-25 13:52:48 +0200 |
commit | 73750bb6a385c6c1e87dc71b18caa32b31fb0029 (patch) | |
tree | 6c21753253b34018dbb83642d24d65eccf7ac9c5 /eurephiadm | |
parent | 63124ebf378c678b377e8bedbfcd676e1e753f04 (diff) | |
download | eurephia-73750bb6a385c6c1e87dc71b18caa32b31fb0029.tar.gz eurephia-73750bb6a385c6c1e87dc71b18caa32b31fb0029.tar.xz eurephia-73750bb6a385c6c1e87dc71b18caa32b31fb0029.zip |
Made eurephiadm users --list work with the new eDBadminUserAccess() API
Diffstat (limited to 'eurephiadm')
-rw-r--r-- | eurephiadm/commands/users.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c index e314dfe..657a6f2 100644 --- a/eurephiadm/commands/users.c +++ b/eurephiadm/commands/users.c @@ -56,6 +56,21 @@ #include "../xsltparser.h" +// TO BE REMOVED WHEN ALL FUNCTIONS ARE PORTED TO NEW eDBadminUserAccount() API +// These functions are here only to make eurephiadm compile. +static xmlDoc *eDBadminGetUserInfo(eurephiaCTX *ctx, int show_info, xmlDoc *srch_xml) { + return NULL; +} +static int eDBadminUpdateUser(eurephiaCTX *ctx, int uid, xmlDoc *update_xml) { + return 0; +} +static int eDBadminDeleteUser(eurephiaCTX *ctx, int uid, xmlDoc *update_xml) { + return 0; +} +static int eDBadminAddUser(eurephiaCTX *ctx, xmlDoc *user_xml) { + return -1; +} + /** * Forward declaration of a function already found in certificates.c */ @@ -199,8 +214,9 @@ void help_Users() { * @return returns 0 on success, otherwise 1. */ int list_users(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv) { - xmlDoc *userlist = NULL; - int i = 0; + xmlDoc *qrydoc = NULL, *userlist = NULL; + xmlNode *qry_n = NULL, *fmap_n = NULL; + int i = 0, rc = 0; char *sortkeys = NULL; const char *xsltparams[] = {"view", "'userlist'", NULL}; @@ -229,12 +245,37 @@ int list_users(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int } } + // Create a query document + eurephiaXML_CreateDoc(ctx, 1, "UserAccount", &qrydoc, &qry_n); + assert( (qrydoc != NULL) && (qry_n != NULL) ); + + xmlNewProp(qry_n, (xmlChar *) "mode", (xmlChar *) "view"); + xmlNewChild(qry_n, NULL, (xmlChar *) "sortkeys", (xmlChar *)sortkeys); + xmlNewChild(qry_n, NULL, (xmlChar *) "extractFlags", (xmlChar *) "1"); + + fmap_n = xmlNewChild(qry_n, NULL, (xmlChar *) "fieldMapping", NULL); + assert( fmap_n != NULL ); + xmlNewProp(fmap_n, (xmlChar *) "table", (xmlChar *) "users"); + // Retrieve the user list - and display it - userlist = eDBadminGetUserList(ctx, sortkeys); - xslt_print_xmldoc(stdout, cfg, userlist, "users.xsl", xsltparams); + userlist = eDBadminUserAccount(ctx, qrydoc); + if( eurephiaXML_IsResultMsg(ctx, userlist) ) { + eurephiaRESULT *res = eurephiaXML_ParseResultMsg(ctx, userlist); + if( res->resultType == exmlERROR ) { + fprintf(stderr, "%s: %s\n", MODULE, res->message); + rc = 1; + } else { + rc = 2; + } + free_nullsafe(ctx, res); + } else { + xslt_print_xmldoc(stdout, cfg, userlist, "users.xsl", xsltparams); + rc = 0; + } xmlFreeDoc(userlist); + xmlFreeDoc(qrydoc); - return 0; + return rc; } |