Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Copyright 2011 John-Mark Bell <jmb@netsurf-browser.org>
  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. /** \file
  20.  * MIME type sniffer (interface)
  21.  */
  22.  
  23. #ifndef NETSURF_CONTENT_MIMESNIFF_H_
  24. #define NETSURF_CONTENT_MIMESNIFF_H_
  25.  
  26. #include <stdbool.h>
  27.  
  28. #include <libwapcaplet/libwapcaplet.h>
  29. #include "utils/errors.h"
  30.  
  31. struct llcache_handle;
  32.  
  33. /**
  34.  * Compute the effective MIME type for an object using the sniffing
  35.  * algorithm described in http://mimesniff.spec.whatwg.org/
  36.  *
  37.  * \param handle          Source data handle to sniff
  38.  * \param data            First data chunk, or NULL
  39.  * \param len             Length of \a data, in bytes
  40.  * \param sniff_allowed   Whether MIME type sniffing is allowed
  41.  * \param image_only      Sniff image types only
  42.  * \param effective_type  Location to receive computed type
  43.  * \return NSERROR_OK on success,
  44.  *         NSERROR_NEED_DATA iff \a data is NULL and data is needed
  45.  *         NSERROR_NOT_FOUND if sniffing is prohibited and no
  46.  *                           Content-Type header was found
  47.  */
  48. nserror mimesniff_compute_effective_type(struct llcache_handle *handle,
  49.                 const uint8_t *data, size_t len, bool sniff_allowed,
  50.                 bool image_only, lwc_string **effective_type);
  51.  
  52. nserror mimesniff_init(void);
  53. void mimesniff_fini(void);
  54.  
  55. #endif
  56.