mime.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper/***********************************************************************
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* This software is part of the ast package *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* Copyright (c) 1985-2011 AT&T Intellectual Property *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* and is licensed under the *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* Eclipse Public License, Version 1.0 *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* by AT&T Intellectual Property *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* A copy of the License is available at *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* http://www.eclipse.org/org/documents/epl-v10.html *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* Information and Software Systems Research *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* AT&T Research *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* Florham Park NJ *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* Glenn Fowler <gsf@research.att.com> *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* David Korn <dgk@research.att.com> *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper* Phong Vo <kpv@research.att.com> *
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper***********************************************************************/
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper * Glenn Fowler
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper * AT&T Research
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper * mime/mailcap support library
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeperstatic const char id[] = "\n@(#)$Id: mime library (AT&T Research) 2002-10-29 $\0\n";
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reepertypedef struct Att_s
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reepertypedef struct Cap_s
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper unsigned long flags;
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reepertypedef struct
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reepertypedef struct
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reepertypedef struct
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reepertypedef struct
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper * convert c to lower case
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeperlower(register int c)
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper * Ent_t case insensitive comparf
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeperorder(Dt_t* dt, void* a, void* b, Dtdisc_t* disc)
de47fb992b4c3414ac5b445d5cab364b0b8b8b43Mark de Reeper * Ent_t freef
for (; isspace(*s); s++);
cap = 0;
for (; isspace(*v); v++);
if (cap)
for (k = t; isspace(*t); t++);
while (isspace(*++t));
if (t <= v && (!cap || !k))
if (!cap)
if (cap)
if (ent)
if (pud)
if (!(s = (char*)file))
s = MIME_FILES;
if ((strneq(s, "~/", n = 2) || strneq(s, "$HOME/", n = 6) || strneq(s, "${HOME}/", n = 8)) && (t = getenv("HOME")))
if (!wp->pattern || !strncasecmp(ent->name, wp->pattern, wp->prefix) && (!ent->name[wp->prefix] || ent->name[wp->prefix] == '/'))
static Ent_t*
register char* lp;
register char* rp;
register char* rb;
register char* rv;
register int rc;
return ent;
*rp++ = 0;
return ent;
if (rc)
*rv = 0;
return ent;
} while (*rp);
} while (*lp);
if (first < 0 || x > 0)
if (first >= 0 || !q)
v = (char*)name;
v = (char*)type;
n = strlen(v);
goto lose;
if (a1.name.size == 6 && strneq(a1.name.data, "strcmp", 6) || a1.name.size == 10 && strneq(a1.name.data, "strcasecmp", 10))
goto lose;
goto lose;
else c ^= (a1.name.size == 6 ? strncmp : strncasecmp)(a2.name.data, a3.name.data, a2.name.size) == 0;
goto skip;
goto lose;
if (!arg(&a2, -1) || a2.name.size > 2 || a2.name.size == 1 && *a2.name.data != '=' || a2.name.size == 2 && (!strneq(a1.name.data, "!=", 2) || !strneq(a2.name.data, "==", 2)))
goto lose;
goto lose;
goto lose;
goto lose;
goto skip;
lose:
if (!system(s))
skip:
mimecmp(register const char* s, register const char* v, char** e)
return mp;
if (mp)