2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-06-21 17:18:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2005-01-13 23:29:24 +03:00
|
|
|
#include <string.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "content/fetch.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
2003-06-21 17:18:00 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* filetype -- determine the MIME type of a local file
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char *fetch_filetype(const char *unix_path)
|
|
|
|
{
|
2003-09-28 03:36:34 +04:00
|
|
|
int l;
|
2003-06-21 17:18:00 +04:00
|
|
|
LOG(("unix path %s", unix_path));
|
2003-09-28 03:36:34 +04:00
|
|
|
l = strlen(unix_path);
|
|
|
|
if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
|
2003-06-21 17:18:00 +04:00
|
|
|
return "text/css";
|
2004-03-27 03:54:03 +03:00
|
|
|
if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
|
|
|
|
return "image/jpeg";
|
|
|
|
if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
|
|
|
|
return "image/jpeg";
|
2004-06-03 01:00:10 +04:00
|
|
|
if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
|
|
|
|
return "image/gif";
|
|
|
|
if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
|
|
|
|
return "image/png";
|
2005-01-02 14:46:29 +03:00
|
|
|
if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
|
|
|
|
return "image/jng";
|
2008-05-26 03:28:06 +04:00
|
|
|
if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
|
|
|
|
return "image/svg";
|
2003-06-21 17:18:00 +04:00
|
|
|
return "text/html";
|
|
|
|
}
|
|
|
|
|
2004-03-22 03:38:08 +03:00
|
|
|
|
|
|
|
char *fetch_mimetype(const char *ro_path)
|
|
|
|
{
|
|
|
|
return strdup("text/plain");
|
|
|
|
}
|