-/* $Id: yaz-proxy-config.cpp,v 1.11 2004-12-03 14:28:18 adam Exp $
+/* $Id: yaz-proxy-config.cpp,v 1.14 2005-02-10 08:09:42 oleg Exp $
Copyright (c) 1998-2004, Index Data.
This file is part of the yaz-proxy.
*/
#include <ctype.h>
-#include <yaz/ylog.h>
+#include <yaz/log.h>
#include "proxyp.h"
class Yaz_ProxyConfigP {
int *target_idletime, int *client_idletime,
int *keepalive_limit_bw, int *keepalive_limit_pdu,
int *pre_init, const char **cql2rpn,
- const char **authentication);
+ const char **authentication,
+ const char **negotiation_charset,
+ const char **negotiation_lang);
void return_limit(xmlNodePtr ptr,
int *limit_bw, int *limit_pdu, int *limit_req);
int check_type_1(ODR odr, xmlNodePtr ptr, Z_RPNQuery *query,
int *keepalive_limit_pdu,
int *pre_init,
const char **cql2rpn,
- const char **authentication)
+ const char **authentication,
+ const char **negotiation_charset,
+ const char **negotiation_lang)
{
*pre_init = 0;
int no_url = 0;
if (t)
*authentication = t;
}
+ if (ptr->type == XML_ELEMENT_NODE
+ && !strcmp((const char *) ptr->name, "negotiation-charset"))
+ {
+ const char *t = get_text(ptr);
+ if (t)
+ *negotiation_charset = t;
+ }
+ if (ptr->type == XML_ELEMENT_NODE
+ && !strcmp((const char *) ptr->name, "negotiation-lang"))
+ {
+ const char *t = get_text(ptr);
+ if (t)
+ *negotiation_lang = t;
+ }
}
}
#endif
}
#endif
+const char *Yaz_ProxyConfig::check_mime_type(const char *path)
+{
+ struct {
+ const char *mask;
+ const char *type;
+ } types[] = {
+ {".xml", "text/xml"},
+ {".xsl", "text/xml"},
+ {".tkl", "text/xml"},
+ {".xsd", "text/xml"},
+ {".html", "text/html"},
+ {".jpg", "image/jpeg"},
+ {".png", "image/png"},
+ {".gif", "image/gif"},
+ {0, "text/plain"},
+ {0, 0},
+ };
+ int i;
+ size_t plen = strlen (path);
+ for (i = 0; types[i].type; i++)
+ if (types[i].mask == 0)
+ return types[i].type;
+ else
+ {
+ size_t mlen = strlen(types[i].mask);
+ if (plen > mlen && !memcmp(path+plen-mlen, types[i].mask, mlen))
+ return types[i].type;
+ }
+ return "application/octet-stream";
+}
+
+
int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
Odr_oid *syntax, Z_RecordComposition *comp,
char **addinfo,
int *keepalive_limit_pdu,
int *pre_init,
const char **cql2rpn,
- const char **authentication)
+ const char **authentication,
+ const char **negotiation_charset,
+ const char **negotiation_lang)
{
#if HAVE_XSLT
xmlNodePtr ptr;
limit_bw, limit_pdu, limit_req,
target_idletime, client_idletime,
keepalive_limit_bw, keepalive_limit_pdu,
- pre_init, cql2rpn, authentication);
+ pre_init, cql2rpn, authentication,
+ negotiation_charset, negotiation_lang);
return 1;
}
i++;
int *keepalive_limit_pdu,
int *pre_init,
const char **cql2rpn,
- const char **authentication)
+ const char **authentication,
+ const char **negotiation_charset,
+ const char **negotiation_lang)
{
#if HAVE_XSLT
xmlNodePtr ptr;
m_cp->return_target_info(ptr, url, limit_bw, limit_pdu, limit_req,
target_idletime, client_idletime,
keepalive_limit_bw, keepalive_limit_pdu,
- pre_init, cql2rpn, authentication);
+ pre_init, cql2rpn, authentication,
+ negotiation_charset, negotiation_lang);
}
#else
*url = name;