2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: mime.c,v 1.1 2006-03-15 13:32:05 adam Exp $
12 #include <yaz/xmalloc.h>
16 struct yaz_mime_entry {
19 struct yaz_mime_entry *next;
22 struct yaz_mime_info {
23 struct yaz_mime_entry *table;
26 yaz_mime_types yaz_mime_types_create()
28 yaz_mime_types p = xmalloc(sizeof(*p));
33 void yaz_mime_types_add(yaz_mime_types t, const char *suffix,
34 const char *mime_type)
36 struct yaz_mime_entry *e = xmalloc(sizeof(*e));
37 e->mime_type = xstrdup(mime_type);
38 e->suffix = xstrdup(suffix);
43 const char *yaz_mime_lookup_suffix(yaz_mime_types t, const char *suffix)
45 struct yaz_mime_entry *e = t->table;
46 for (; e; e = e->next)
48 if (!strcmp(e->suffix, suffix))
54 const char *yaz_mime_lookup_fname(yaz_mime_types t, const char *fname)
56 const char *cp = strrchr(fname, '.');
57 if (!cp) /* if no . return now */
59 return yaz_mime_lookup_suffix(t, cp+1); /* skip . */
62 void yaz_mime_types_destroy(yaz_mime_types t)
64 struct yaz_mime_entry *e = t->table;
67 struct yaz_mime_entry *e_next = e->next;
79 * indent-tabs-mode: nil
81 * vim: shiftwidth=4 tabstop=8 expandtab