/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2010 Index Data
* See the file LICENSE for details.
*/
/**
*/
#include <stdlib.h>
+#include <assert.h>
#include <yaz/srw.h>
#include <yaz/matchstr.h>
#include <yaz/yaz-iconv.h>
+static char *yaz_decode_sru_dbpath_odr(ODR n, const char *uri, size_t len)
+{
+ return odr_strdupn(n, uri, len);
+}
+
+void yaz_encode_sru_dbpath_buf(char *dst, const char *db)
+{
+ assert(db);
+ *dst = '/';
+ strcpy(dst+1, db);
+}
+
+char *yaz_encode_sru_dbpath_odr(ODR out, const char *db)
+{
+ char *dst = odr_malloc(out, 3 * strlen(db) + 2);
+ yaz_encode_sru_dbpath_buf(dst, db);
+ return dst;
+}
+
#if YAZ_HAVE_XML2
static int yaz_base64decode(const char *in, char *out)
{
if (!p1)
p1 = p0 + strlen(p0);
if (p1 != p0)
- {
- db = (char*) odr_malloc(decode, p1 - p0 + 1);
- memcpy (db, p0, p1 - p0);
- db[p1 - p0] = '\0';
- }
-
+ db = yaz_decode_sru_dbpath_odr(decode, p0, p1 - p0);
grab_charset(decode, content_type, charset);
ret = z_soap_codec(decode, soap_package,
if (!p1)
p1 = p0 + strlen(p0);
if (p1 != p0)
- {
- db = (char*) odr_malloc(decode, p1 - p0 + 1);
- memcpy (db, p0, p1 - p0);
- db[p1 - p0] = '\0';
- }
+ db = yaz_decode_sru_dbpath_odr(decode, p0, p1 - p0);
if (!strcmp(hreq->method, "POST"))
p1 = hreq->content_buf;
yaz_uri_to_array(p1, decode, &uri_name, &uri_val);
}
-
/*
* Local variables:
* c-basic-offset: 4