Index: libabac/abac_xml.c
===================================================================
--- libabac/abac_xml.c	(revision 8164e709d8a3bf2b8dcd15ac0a7e74618d221836)
+++ libabac/abac_xml.c	(revision 756011efe7136368215ad60236f4b9d0fed71b38)
@@ -8,4 +8,5 @@
 #include <string.h>
 #include <time.h>
+#include <ctype.h>
 
 #include <libxml/tree.h>
@@ -189,13 +190,4 @@
 
 
-/* Hex dump the contents of buf (length len) to stderr.  For debugging */
-static void dump_it(xmlChar *buf, int len) {
-    int i;
-
-    for (i=0; i < len; i++ ) 
-	fprintf(stderr, "%02x ", buf[i] & 0xff);
-    fprintf(stderr, "\n");
-}
-
 /* Convert a SHA1 hash to text for printing or use in strings.  keyid is the
  * hash (SHA_DIGEST_LENGTH bytes long) and text is the output string (at least
@@ -564,5 +556,4 @@
     xmlNodePtr node = NULL;         /* Scratch XML node */
     xmlNodePtr x509ptr = NULL;      /* XML X509Certificate node */
-    int rv = 0;                     /* Return value */
     xmlChar *pem=NULL;
 
@@ -580,5 +571,6 @@
 
     /* Find the X509Certificate from KeyInfo section */
-    if ( x509ptr = xmlSecFindNode(node, xmlSecNodeX509Certificate, xmlSecDSigNs)) {
+    if ( (x509ptr = xmlSecFindNode(node, xmlSecNodeX509Certificate, 
+		    xmlSecDSigNs))) {
         pem=get_element_content(x509ptr);
         } else {
@@ -704,5 +696,6 @@
     if(ncred !=1) {
         /* load  issuer_ptr */ 
-        if(issuer_ptr && abac_verifier_load_id_chars(ctxt_id_certs, issuer_ptr, NULL) != 0 /*ABAC_CERT_SUCCESS*/)
+        if(issuer_ptr && abac_verifier_load_id_chars(ctxt_id_certs, 
+		    (char *) issuer_ptr, NULL) != 0 /*ABAC_CERT_SUCCESS*/)
             goto fail;
     }
@@ -789,5 +782,5 @@
 	    continue;
 	if ( !strcmp((char *) c->name, "ABACprincipal")) {
-	    xmlNodePtr k = get_direct_child(c, "keyid");
+	    xmlNodePtr k = get_direct_child(c, (xmlChar *)"keyid");
 	    if ( !k ) return -1;
 	    len += role_len(get_element_content(k));
@@ -825,27 +818,27 @@
  */
 static xmlChar *term_copy(xmlNodePtr n, xmlChar *dest, abac_keyid_map_t *km) {
-    xmlNodePtr p = get_direct_child(n, "ABACprincipal");
+    xmlNodePtr p = get_direct_child(n, (xmlChar *)"ABACprincipal");
     xmlNodePtr k = NULL;
     xmlNodePtr m = NULL;
-    char *ks = NULL;
-    char *ms = NULL;
+    xmlChar *ks = NULL;
+    xmlChar *ms = NULL;
 
     if ( !p ) return NULL;
-    if ( !(k = get_direct_child(p, "keyid"))) return NULL;
+    if ( !(k = get_direct_child(p, (xmlChar *)"keyid"))) return NULL;
     if ( !(ks = get_element_content(k))) return NULL;
     if ( !(dest = role_copy(ks, dest))) return NULL;
     /* If there's a mnemonic string, add the mapping from keyid to mnemonic to
      * the keymap */
-    if ( (m = get_direct_child(p, "mnemonic"))) {
+    if ( (m = get_direct_child(p, (xmlChar *)"mnemonic"))) {
 	if ( (ms = get_element_content(m))) {
-	    abac_keyid_map_remove_keyid(km, ks);
-	    abac_keyid_map_add_nickname(km, ks, ms);
+	    abac_keyid_map_remove_keyid(km, (char *) ks);
+	    abac_keyid_map_add_nickname(km, (char *) ks, (char *) ms);
 	}
     }
-    if ( (p = get_direct_child(n, "linking_role"))) {
+    if ( (p = get_direct_child(n, (xmlChar *)"linking_role"))) {
 	*dest++ = '.';
 	if ( !(dest = role_copy(get_element_content(p), dest))) return NULL;
     }
-    if ( (p = get_direct_child(n, "role"))) {
+    if ( (p = get_direct_child(n, (xmlChar *)"role"))) {
 	*dest++ = '.';
 	if ( !(dest = role_copy(get_element_content(p), dest))) return NULL;
@@ -864,11 +857,4 @@
     return d;
 }
-
-static void partial_string_dump(char *s, char *e) {
-    for (; s!= e; s++) 
-	fprintf(stderr, "%c", *s);
-    fprintf(stderr, "\n");
-}
-
 
 /*
@@ -928,7 +914,7 @@
     /* Translate term by term */
     d = rv[0];
-    if ( !( c = get_direct_child(n, "head"))) goto fail;
+    if ( !( c = get_direct_child(n, (xmlChar *)"head"))) goto fail;
     if ( !(d = term_copy(c, d, km))) goto fail;
-    d = append_and_move(d, "<-", 2);
+    d = append_and_move(d, (xmlChar *)"<-", 2);
     tails = 0;
     for (c = n->children; c; c = c->next) {
@@ -938,5 +924,5 @@
 	    /* if more than one tail, add " & " */
 	    if ( tails++) 
-		d = append_and_move(d, " & ", 3);
+		d = append_and_move(d, (xmlChar *)" & ", 3);
 	    if ( !(d = term_copy(c, d, km))) goto fail;
 	}
@@ -967,5 +953,4 @@
     xmlChar keyid[SHA_DIGEST_LENGTH];/* issuer SHA1 hash */
     xmlChar text_keyid[2*SHA_DIGEST_LENGTH+1];/* Issuer keyid in text */
-    xmlChar *txt;		/* rt0 content */
     xmlChar **rv = NULL;	/* return value */
     xmlChar *issuer_ptr=NULL;	/* Issuer certificate to add to ctxt_id_certs */
@@ -1007,5 +992,5 @@
     /* Pick parsing specialization based on the version.  If we can't resolve a
      * processor, this is an unknown version. */
-    if ( !(proc = get_xml_processing(get_element_content(version))))
+    if ( !(proc = get_xml_processing((char *) get_element_content(version))))
 	goto fail;
 
@@ -1017,6 +1002,6 @@
     issuer_ptr=get_issuer(doc);
     if( issuer_ptr && 
-	    abac_verifier_load_id_chars(ctxt_id_certs,issuer_ptr, NULL) != 
-	    ABAC_CERT_SUCCESS) {
+	    abac_verifier_load_id_chars(ctxt_id_certs, (char *)issuer_ptr, 
+		NULL) != ABAC_CERT_SUCCESS) {
         goto fail;
     }
@@ -1139,5 +1124,5 @@
 
 xmlChar *encode_rt0_xml_v10(abac_attribute_t *a) {
-    return minimal_xml_escaping(abac_attribute_role_string(a));
+    return minimal_xml_escaping((xmlChar *)abac_attribute_role_string(a));
 }
 
@@ -1200,10 +1185,10 @@
 static int encode_principal_role(abac_role_t *r, char *tmp,  int sz,
 	abac_keyid_map_t *km) {
-    char *p = minimal_xml_escaping(abac_role_principal(r));
+    xmlChar *p = minimal_xml_escaping((xmlChar *) abac_role_principal(r));
     char *nick = NULL;
     int ts = 0;
 
     if ( km ) 
-	nick = abac_keyid_map_key_to_nickname(km, p);
+	nick = abac_keyid_map_key_to_nickname(km, (char *)p);
 
     if (nick) {
@@ -1221,11 +1206,11 @@
 static int encode_single_role(abac_role_t *r, char *tmp,  int sz,
 	abac_keyid_map_t *km) {
-    char *p = minimal_xml_escaping(abac_role_principal(r));
-    char *ro = minimal_xml_escaping(abac_role_role_name(r));
+    xmlChar *p = minimal_xml_escaping((xmlChar*)abac_role_principal(r));
+    xmlChar *ro = minimal_xml_escaping((xmlChar *)abac_role_role_name(r));
     char *nick = NULL;
     int ts = 0;
 
     if ( km ) 
-	nick = abac_keyid_map_key_to_nickname(km, p);
+	nick = abac_keyid_map_key_to_nickname(km, (char *)p);
 
     if (nick) {
@@ -1245,12 +1230,12 @@
 static int encode_linking_role(abac_role_t *r, char *tmp,  int sz,
 	abac_keyid_map_t *km) {
-    char *p = minimal_xml_escaping(abac_role_principal(r));
-    char *ro = minimal_xml_escaping(abac_role_role_name(r));
-    char *li = minimal_xml_escaping(abac_role_linking_role(r));
+    xmlChar *p = minimal_xml_escaping((xmlChar *)abac_role_principal(r));
+    xmlChar *ro = minimal_xml_escaping((xmlChar*)abac_role_role_name(r));
+    xmlChar *li = minimal_xml_escaping((xmlChar*)abac_role_linking_role(r));
     char *nick = NULL;	    
     int ts = 0;
 
     if ( km ) 
-	nick = abac_keyid_map_key_to_nickname(km, p);
+	nick = abac_keyid_map_key_to_nickname(km, (char *) p);
 
     if (nick) {
@@ -1324,5 +1309,5 @@
         tail=abac_attribute_get_tail_n(a,i);
 	abac_role_t *r = abac_role_from_string(tail);
-	int ts;
+	int ts = -1;
 
 	if ( !r )
@@ -1436,49 +1421,4 @@
 }
 
-#define CERTSIZE 4096
-/* Read a file into a the dynamically allocated array buf.  Whatever was in buf
- * is discarded w/o freeing so it should initially be NULL and len 0. On return
- * buf contains as much of the contents of filename as possible and len is the
- * length of it.  The caller must free() buf. buf is zero terminated.*/
-static void read_cert(char *filename, char **buf, int *len) {
-    FILE *cert = NULL;
-    char *nbuf = NULL;
-    int cap = CERTSIZE;
-    int r = 0;
-
-    *len = 0; 
-    if (!(*buf = malloc(CERTSIZE))) return;
-
-    if ( !(cert = fopen(filename, "r"))) 
-	goto fail;
-
-    /* Read cert, expanding buf as necessary */
-    while ( (r = fread(*buf + *len, 1, cap - *len, cert)) != 0) {
-	*len += r;
-	if ( *len == cap ) {
-	    if ( !(nbuf = realloc(*buf, cap + CERTSIZE)) ) 
-		goto fail;
-	    memcpy(nbuf, *buf, cap);
-	    cap += CERTSIZE;
-	    *buf = nbuf;
-	}
-    }
-    /* Extend if we read exactly cap bytes so we can terminate the string */
-    if ( *len == cap ) {
-	if ( !(nbuf = realloc(*buf, cap + CERTSIZE)) ) 
-	    goto fail;
-	memcpy(nbuf, *buf, cap);
-	cap += CERTSIZE;
-	*buf = nbuf;
-    }
-    (*buf)[*len] = '\0';
-    return;
-fail:
-    if ( *buf) free(*buf);
-    *buf = NULL;
-    *len = 0;
-    return;
-}
-
 
 /******** helper functions used by libabac **********************/
