Reformat
[yaz-moved-to-github.git] / src / srwutil.c
index b906ec9..40c8039 100644 (file)
@@ -14,6 +14,7 @@
 #include <assert.h>
 #include <yaz/srw.h>
 #include <yaz/matchstr.h>
+#include <yaz/base64.h>
 #include <yaz/yaz-iconv.h>
 #include "sru-p.h"
 
@@ -45,7 +46,7 @@ Z_AttributeList *yaz_use_attribute_create(ODR o, const char *name)
     Z_AttributeElement ** elements;
     attributes->num_attributes = 1;
     elements = (Z_AttributeElement**)
-        odr_malloc (o, attributes->num_attributes * sizeof(*elements));
+        odr_malloc(o, attributes->num_attributes * sizeof(*elements));
     elements[0] = (Z_AttributeElement*) odr_malloc(o,sizeof(**elements));
     elements[0]->attributeType = odr_intdup(o, 1);
     elements[0]->attributeSet = odr_nullval();
@@ -85,52 +86,6 @@ const char *yaz_element_attribute_value_get(xmlNodePtr ptr,
 }
 #endif
 
-static int yaz_base64decode(const char *in, char *out)
-{
-    const char *map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz0123456789+/";
-    int olen = 0;
-    int len = strlen(in);
-
-    while (len >= 4)
-    {
-       char i0, i1, i2, i3;
-       char *p;
-
-       if (!(p = strchr(map, in[0])))
-           return 0;
-       i0 = p - map;
-       len--;
-       if (!(p = strchr(map, in[1])))
-           return 0;
-       i1 = p - map;
-       len--;
-       *(out++) = i0 << 2 | i1 >> 4;
-       olen++;
-       if (in[2] == '=')
-           break;
-       if (!(p = strchr(map, in[2])))
-           return 0;
-       i2 = p - map;
-       len--;
-       *(out++) = i1 << 4 | i2 >> 2;
-       olen++;
-       if (in[3] == '=')
-           break;
-       if (!(p = strchr(map, in[3])))
-           return 0;
-       i3 = p - map;
-       len--;
-       *(out++) = i2 << 6 | i3;
-       olen++;
-
-       in += 4;
-    }
-
-    *out = '\0';
-    return olen;
-}
-
 int yaz_srw_check_content_type(Z_HTTP_Response *hres)
 {
     const char *content_type = z_HTTP_header_lookup(hres->headers,
@@ -222,9 +177,9 @@ void yaz_add_srw_diagnostic_uri(ODR o, Z_SRW_diagnostic **d,
                                 const char *message, const char *details)
 {
     Z_SRW_diagnostic *d_new;
-    d_new = (Z_SRW_diagnostic *) odr_malloc (o, (*num + 1)* sizeof(**d));
+    d_new = (Z_SRW_diagnostic *) odr_malloc(o, (*num + 1)* sizeof(**d));
     if (*num)
-        memcpy (d_new, *d, *num *sizeof(**d));
+        memcpy(d_new, *d, *num *sizeof(**d));
     *d = d_new;
 
     yaz_mk_srw_diagnostic(o, *d + *num, uri, message, details);