summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-20 14:35:58 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-20 14:35:58 +0100
commit3d9bc3a1f5bbc5457da4a43ce240c30eea9dac74 (patch)
treefe7f5ba2c24d9d2f2a38f1e5ac245157dd14eb7b
parentd747ff97dcf12ea39f8836b85c608cce9a3720e5 (diff)
downloadeurephia-3d9bc3a1f5bbc5457da4a43ce240c30eea9dac74.tar.gz
eurephia-3d9bc3a1f5bbc5457da4a43ce240c30eea9dac74.tar.xz
eurephia-3d9bc3a1f5bbc5457da4a43ce240c30eea9dac74.zip
Moved xmlPrint_certs(...) into certificates.c where it really belongs
-rw-r--r--eurephiadm/commands/certificates.c69
-rw-r--r--eurephiadm/commands/users.c71
2 files changed, 72 insertions, 68 deletions
diff --git a/eurephiadm/commands/certificates.c b/eurephiadm/commands/certificates.c
index a3ae77c..e2eaf7c 100644
--- a/eurephiadm/commands/certificates.c
+++ b/eurephiadm/commands/certificates.c
@@ -55,6 +55,7 @@
#include "../argparser.h"
#include "../get_console_input.h"
+#include "../field_print.h"
void display_certs_help(int page) {
printf("Help page not implemented yet\n");
@@ -131,6 +132,74 @@ char *ExtractCertInfo(X509 *cert, const char *fieldname) {
}
#endif
+void xmlPrint_certs(xmlXPathContext *certsXP, const char *xpath) {
+ xmlXPathObject *certsObj = NULL;
+ xmlNode *certnode = NULL;
+ int i = 0;
+
+ // Find the certificates in the given XPath query
+ certsObj = xmlXPathEvalExpression((xmlChar *)xpath, certsXP);
+ if( certsObj == NULL ) {
+ fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpath);
+ return;
+ }
+
+ // If no certs were found, inform and exit
+ if( certsObj->nodesetval->nodeNr == 0 ) {
+ field_print_str("Associated certificates", "None");
+ printf("\n");
+ xmlXPathFreeObject(certsObj);
+ return;
+ }
+
+ // Parse all certificates found
+ printf("\n");
+ printf(" %3s (D) %-35.35s %33.33s\n %-49.49s %19.19s\n",
+ "ID", "Common name", "Organisation", "e-mail", "Registered");
+#ifdef FIREWALL
+ printf(" %-44.44s %24.24s\n", "Firewall access profile", "FW Destination");
+#endif
+ printf(" --------------------------------------------------------------------"
+ "----------\n");
+
+ for( i = 0; i < certsObj->nodesetval->nodeNr; i++ ) {
+ xmlNode *acpr = NULL;
+
+ certnode = certsObj->nodesetval->nodeTab[i];
+ if( certnode->type != XML_ELEMENT_NODE) {
+ // Skip nodes which is not element nodes
+ continue;
+ }
+ if( xmlStrcmp(certnode->name, (xmlChar *)"certificate") != 0 ) {
+ // Skip nodes which is not a certificate "collection"
+ continue;
+ }
+
+ acpr = xmlFindNode(certnode, "access_profile");
+
+ printf(" %3s (%1s) %-35.35s %33.33s\n %-49.49s %19.19s\n",
+ xmlGetAttrValue(certnode->properties, "certid"),
+ xmlGetAttrValue(certnode->properties, "depth"),
+ xmlGetNodeContent(certnode, "common_name"),
+ xmlGetNodeContent(certnode, "organisation"),
+ xmlGetNodeContent(certnode, "email"),
+ xmlGetAttrValue(certnode->properties, "registered"));
+#ifdef FIREWALL
+ printf(" %-44.44s %24.24s\n",
+ defaultValue(xmlExtractContent(acpr), "(not set)"),
+ defaultValue(xmlGetAttrValue(acpr->properties, "fwdestination"), "-"));
+#endif
+ if( (i+1) < certsObj->nodesetval->nodeNr ) {
+ printf("\n");
+ }
+ }
+ printf(" --------------------------------------------------------------------"
+ "----------\n");
+
+ xmlXPathFreeObject(certsObj);
+}
+
+
void replace_char(char *str, char s, char r) {
if( str != NULL ) {
char *ptr = str;
diff --git a/eurephiadm/commands/users.c b/eurephiadm/commands/users.c
index 21c8486..7b84df5 100644
--- a/eurephiadm/commands/users.c
+++ b/eurephiadm/commands/users.c
@@ -48,6 +48,9 @@
#include "../get_console_input.h"
#include "../field_print.h"
+// Reuse code which is in certificats.c
+void xmlPrint_certs(xmlXPathContext *certsXP, const char *xpath);
+
void display_users_help(int page) {
printf("\n%s -- Administer user accounts\n\n", MODULE);
@@ -243,74 +246,6 @@ char *xmlFlags2str(xmlXPathContext *xpathCTX, const char *xpath) {
return flagstr;
}
-void xmlPrint_certs(xmlXPathContext *certsXP, const char *xpath) {
- xmlXPathObject *certsObj = NULL;
- xmlNode *certnode = NULL;
- int i = 0;
-
- // Find the certificates in the given XPath query
- certsObj = xmlXPathEvalExpression((xmlChar *)xpath, certsXP);
- if( certsObj == NULL ) {
- fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpath);
- return;
- }
-
- // If no certs were found, inform and exit
- if( certsObj->nodesetval->nodeNr == 0 ) {
- field_print_str("Associated certificates", "None");
- printf("\n");
- xmlXPathFreeObject(certsObj);
- return;
- }
-
- // Parse all certificates found
- field_print_int("Associated certificates", certsObj->nodesetval->nodeNr);
- printf("\n");
- printf(" %3s (D) %-35.35s %33.33s\n %-49.49s %19.19s\n",
- "ID", "Common name", "Organisation", "e-mail", "Registered");
-#ifdef FIREWALL
- printf(" %-44.44s %24.24s\n", "Firewall access profile", "FW Destination");
-#endif
- printf(" --------------------------------------------------------------------"
- "----------\n");
-
- for( i = 0; i < certsObj->nodesetval->nodeNr; i++ ) {
- xmlNode *acpr = NULL;
-
- certnode = certsObj->nodesetval->nodeTab[i];
- if( certnode->type != XML_ELEMENT_NODE) {
- // Skip nodes which is not element nodes
- continue;
- }
- if( xmlStrcmp(certnode->name, (xmlChar *)"certificate") != 0 ) {
- // Skip nodes which is not a certificate "collection"
- continue;
- }
-
- acpr = xmlFindNode(certnode, "access_profile");
-
- printf(" %3s (%1s) %-35.35s %33.33s\n %-49.49s %19.19s\n",
- xmlGetAttrValue(certnode->properties, "certid"),
- xmlGetAttrValue(certnode->properties, "depth"),
- xmlGetNodeContent(certnode, "common_name"),
- xmlGetNodeContent(certnode, "organisation"),
- xmlGetNodeContent(certnode, "email"),
- xmlGetAttrValue(certnode->properties, "registered"));
-#ifdef FIREWALL
- printf(" %-44.44s %24.24s\n",
- defaultValue(xmlExtractContent(acpr), "(not set)"),
- defaultValue(xmlGetAttrValue(acpr->properties, "fwdestination"), "-"));
-#endif
- if( (i+1) < certsObj->nodesetval->nodeNr ) {
- printf("\n");
- }
- }
- printf(" --------------------------------------------------------------------"
- "----------\n");
-
- xmlXPathFreeObject(certsObj);
-}
-
void xmlPrint_lastlog(xmlXPathContext *xpathCTX, int verb, const char *xpath) {
xmlXPathObject *lastlogObj = NULL;
int i = 0;