Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include "content/fetch.h"
  22. #include "utils/log.h"
  23. #include "utils/utils.h"
  24.  
  25. /**
  26.  * filetype -- determine the MIME type of a local file
  27.  */
  28.  
  29. const char *fetch_filetype(const char *unix_path)
  30. {
  31.         int l;
  32.         LOG(("unix path %s", unix_path));
  33.         l = strlen(unix_path);
  34.         if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
  35.                 return "text/css";
  36.         if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
  37.                 return "text/css";
  38.         if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
  39.                 return "image/jpeg";
  40.         if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
  41.                 return "image/jpeg";
  42.         if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
  43.                 return "image/gif";
  44.         if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
  45.                 return "image/png";
  46.         if (2 < l && strcasecmp(unix_path + l - 3, "b60") == 0)
  47.                 return "image/png";
  48.         if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
  49.                 return "image/jng";
  50.         if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
  51.                 return "image/svg";
  52.         return "text/html";
  53. }
  54.  
  55.  
  56. char *fetch_mimetype(const char *ro_path)
  57. {
  58.         return strdup("text/plain");
  59. }
  60.