-/* $Id: yaz-proxy-config.cpp,v 1.11 2004-12-03 14:28:18 adam Exp $
+/* $Id: yaz-proxy-config.cpp,v 1.13 2005-01-18 10:49:22 adam 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 {
}
#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,