NetSurf
Data Structures | Typedefs | Functions | Variables
content_factory.c File Reference

Content factory implementation. More...

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "utils/http.h"
#include "content/content.h"
#include "content/content_factory.h"
#include "content/content_protected.h"
#include "content/llcache.h"
Include dependency graph for content_factory.c:

Go to the source code of this file.

Data Structures

struct  content_handler_entry
 Entry in list of content handlers. More...
 

Typedefs

typedef struct content_handler_entry content_handler_entry
 Entry in list of content handlers. More...
 

Functions

void content_factory_fini (void)
 Clean up after the content factory. More...
 
nserror content_factory_register_handler (const char *mime_type, const content_handler *handler)
 Register a handler with the content factory. More...
 
static const content_handlercontent_lookup (lwc_string *mime_type)
 Find a handler for a MIME type. More...
 
content_type content_factory_type_from_mime_type (lwc_string *mime_type)
 Compute the generic content type for a MIME type. More...
 
struct contentcontent_factory_create_content (llcache_handle *llcache, const char *fallback_charset, bool quirks, lwc_string *effective_type)
 Create a content object. More...
 

Variables

static content_handler_entrycontent_handlers
 

Detailed Description

Content factory implementation.

Definition in file content_factory.c.

Typedef Documentation

◆ content_handler_entry

Entry in list of content handlers.

Function Documentation

◆ content_factory_create_content()

struct content * content_factory_create_content ( llcache_handle llcache,
const char *  fallback_charset,
bool  quirks,
lwc_string *  effective_type 
)

Create a content object.

Parameters
llcacheUnderlying source data handle
fallback_charsetCharacter set to fall back to if none specified
quirksQuirkiness of containing document
effective_typeEffective MIME type of content
Returns
Pointer to content object, or NULL on failure

Definition at line 169 of file content_factory.c.

References content_lookup(), content_handler::create, content::fallback_charset, content::handler, http_content_type_destroy(), http_parse_content_type(), llcache, llcache_handle_get_header(), NSERROR_OK, http_content_type::parameters, and content::quirks.

Referenced by hlcache_find_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_factory_fini()

void content_factory_fini ( void  )

Clean up after the content factory.

Definition at line 53 of file content_factory.c.

References content_handlers, content_handler::fini, content_handler_entry::handler, content_handler_entry::mime_type, and content_handler_entry::next.

Referenced by netsurf_exit().

Here is the caller graph for this function:

◆ content_factory_register_handler()

nserror content_factory_register_handler ( const char *  mime_type,
const content_handler handler 
)

Register a handler with the content factory.

Parameters
mime_typeMIME type to handle
handlerContent handler for MIME type
Returns
NSERROR_OK on success, appropriate error otherwise
Note
Latest registration for a MIME type wins

Definition at line 80 of file content_factory.c.

References content_handlers, content_handler_entry::handler, content_handler_entry::mime_type, content_handler_entry::next, NSERROR_NOMEM, and NSERROR_OK.

Referenced by amiga_plugin_hack_init(), html_init(), nscss_init(), and textplain_init().

Here is the caller graph for this function:

◆ content_factory_type_from_mime_type()

content_type content_factory_type_from_mime_type ( lwc_string *  mime_type)

Compute the generic content type for a MIME type.

Parameters
mime_typeMIME type to consider
Returns
Generic content type

Definition at line 147 of file content_factory.c.

References content_lookup(), CONTENT_NONE, content_handler_entry::handler, content_handler_entry::mime_type, content_handler::type, and type.

Referenced by ami_file_set_type(), box_object(), exec_inline_script(), hlcache_type_is_acceptable(), HOOKF(), and mimesniff_compute_effective_type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_lookup()

static const content_handler * content_lookup ( lwc_string *  mime_type)
static

Find a handler for a MIME type.

Parameters
mime_typeMIME type to search for
Returns
Associated handler, or NULL if none

Definition at line 122 of file content_factory.c.

References content_handlers, content_handler_entry::handler, content_handler_entry::mime_type, and content_handler_entry::next.

Referenced by content_factory_create_content(), and content_factory_type_from_mime_type().

Here is the caller graph for this function:

Variable Documentation

◆ content_handlers

content_handler_entry* content_handlers
static