diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-17 09:43:13 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-17 09:43:13 +0100 |
commit | 4f5bcdbd99fe9bfb3af5bdfa2a8bd973aa9a5bad (patch) | |
tree | effcb477ccbd429ec12951dda70b6ed03fe08242 /eurephiadm | |
parent | 58619e09c5d554e66cad768a9abd6b2fff7f5a62 (diff) | |
download | eurephia-4f5bcdbd99fe9bfb3af5bdfa2a8bd973aa9a5bad.tar.gz eurephia-4f5bcdbd99fe9bfb3af5bdfa2a8bd973aa9a5bad.tar.xz eurephia-4f5bcdbd99fe9bfb3af5bdfa2a8bd973aa9a5bad.zip |
Using the new eurephiaXML_* functions for creating and parsing XML
Also rebased the XML file to always have a document root which
is <eurephia/>. This tag must contain a "format" attribute, which
should be 1 for the moment.
When parsing the XML, the eurephiaXML_getRoot(...) function will
return a pointer to the requested XML node inside the <eurephia/>
document root. The format version in the root element will also
be checked automatically.
Diffstat (limited to 'eurephiadm')
-rw-r--r-- | eurephiadm/commands/users.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c index e2cf3f2..3a949d0 100644 --- a/eurephiadm/commands/users.c +++ b/eurephiadm/commands/users.c @@ -175,7 +175,12 @@ int list_users(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int "ID", "Username", "Activated","Deactivated","Last access"); fprintf(stdout, "---------------------------------------------------------------------------\n"); - users_n = xmlDocGetRootElement(userlist); + users_n = eurephiaXML_getRoot(ctx, userlist, "userlist", 1); + if( users_n == NULL ) { + fprintf(stderr, "Could not retrieve valid data\n"); + xmlFreeDoc(userlist); + return 1; + } users_n = users_n->children; for( ; users_n != NULL; users_n = users_n->next ) { @@ -288,7 +293,7 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int int i, crit_set = 0; long int show_info = USERINFO_user | USERINFO_certs; xmlDoc *user = NULL, *srch = NULL; - xmlNode *srch_root = NULL; + xmlNode *srch_root = NULL, *user_n = NULL; e_options activargs[] = { {"--uid", "-i", 1}, @@ -367,6 +372,13 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int } xmlFreeDoc(srch); + user_n = eurephiaXML_getRoot(ctx, user, "user", 1); + if( user_n == NULL ) { + fprintf(stderr, "Could not retrieve valid data\n"); + xmlFreeDoc(user); + return 1; + } + // Create a XPath context for functions which users XPath to locate info user_XP = xmlXPathNewContext(user); if( user_XP == NULL ) { @@ -374,9 +386,8 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int return 1; } - if( show_info & USERINFO_user ) { - xmlNode *lastacc = NULL, *user_n = xmlDocGetRootElement(user); + xmlNode *lastacc = NULL; lastacc = xmlFindNode(user_n, "last_accessed"); @@ -386,13 +397,13 @@ int show_user(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int field_print_str("Last accessed", xmlExtractContent(lastacc)); field_print_str("Activated", xmlGetNodeContent(user_n, "activated")); field_print_str("Dectivated", xmlGetNodeContent(user_n, "deactivated")); - field_print_str("Flags", xmlFlags2str(user_XP, "/user/flags/flag")); + field_print_str("Flags", xmlFlags2str(user_XP, "/eurephia/user/flags/flag")); printf("\n"); } // Show associated certificates if we was asked to show this info if( show_info & USERINFO_certs ) { - xmlPrint_certs(user_XP, "/user/certificates/certificate"); + xmlPrint_certs(user_XP, "/eurephia/user/certificates/certificate"); } // Clean up |