NetSurf
Data Structures | Enumerations | Functions | Variables
filetype.c File Reference
#include "amiga/os3support.h"
#include <stdlib.h>
#include <string.h>
#include <proto/icon.h>
#include <proto/dos.h>
#include <proto/datatypes.h>
#include <proto/exec.h>
#include <workbench/icon.h>
#include "netsurf/content.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "amiga/filetype.h"
#include "amiga/object.h"
Include dependency graph for filetype.c:

Go to the source code of this file.

Data Structures

struct  ami_mime_entry
 

Enumerations

enum  { AMI_MIME_MIMETYPE , AMI_MIME_DATATYPE , AMI_MIME_FILETYPE , AMI_MIME_PLUGINCMD }
 

Functions

const char * fetch_filetype (const char *unix_path)
 Determine the MIME type of a local file. More...
 
const char * ami_content_type_to_file_type (content_type type)
 
static void ami_mime_entry_free (void *nso)
 
nserror ami_mime_init (const char *mimefile)
 
void ami_mime_free (void)
 
static struct ami_mime_entryami_mime_entry_locate (lwc_string *search, int type, struct Node **start_node)
 Return next matching MIME entry. More...
 
static APTR ami_mime_guess_add_datatype (struct DataType *dt, lwc_string **lwc_mimetype)
 
struct Node * ami_mime_from_datatype (struct DataType *dt, lwc_string **mimetype, struct Node *start_node)
 Return a MIME Type matching a DataType. More...
 
struct Node * ami_mime_to_filetype (lwc_string *mimetype, lwc_string **filetype, struct Node *start_node)
 Return the DefIcons type matching a MIME type. More...
 
const char * ami_mime_content_to_filetype (struct hlcache_handle *c)
 
struct Node * ami_mime_has_cmd (lwc_string **mimetype, struct Node *start_node)
 Return all MIME types containing a plugincmd. More...
 
static struct Node * ami_mime_to_plugincmd (lwc_string *mimetype, lwc_string **plugincmd, struct Node *start_node)
 Return the plugincmd matching a MIME type. More...
 
lwc_string * ami_mime_content_to_cmd (struct hlcache_handle *c)
 
bool ami_mime_compare (struct hlcache_handle *c, const char *type)
 Compare the MIME type of an hlcache_handle to a DefIcons type. More...
 
void ami_mime_dump (void)
 

Variables

static struct MinList * ami_mime_list = NULL
 filetype – determine the MIME type of a local file More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
AMI_MIME_MIMETYPE 
AMI_MIME_DATATYPE 
AMI_MIME_FILETYPE 
AMI_MIME_PLUGINCMD 

Definition at line 50 of file filetype.c.

Function Documentation

◆ ami_content_type_to_file_type()

const char * ami_content_type_to_file_type ( content_type  type)

Definition at line 141 of file filetype.c.

References CONTENT_CSS, CONTENT_HTML, CONTENT_IMAGE, CONTENT_TEXTPLAIN, and type.

Referenced by ami_mime_content_to_filetype().

Here is the caller graph for this function:

◆ ami_mime_compare()

bool ami_mime_compare ( struct hlcache_handle c,
const char *  type 
)

Compare the MIME type of an hlcache_handle to a DefIcons type.

Definition at line 614 of file filetype.c.

References ami_mime_to_filetype(), content_get_mime_type(), and type.

Referenced by ami_file_save(), ami_gui_menu_update_disabled(), and HOOKF().

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

◆ ami_mime_content_to_cmd()

lwc_string * ami_mime_content_to_cmd ( struct hlcache_handle c)

Definition at line 595 of file filetype.c.

References ami_mime_to_plugincmd(), and content_get_mime_type().

Referenced by amiga_plugin_hack_execute().

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

◆ ami_mime_content_to_filetype()

const char * ami_mime_content_to_filetype ( struct hlcache_handle c)

Definition at line 523 of file filetype.c.

References ami_content_type_to_file_type(), ami_mime_to_filetype(), content_get_mime_type(), and content_get_type().

Here is the call graph for this function:

◆ ami_mime_dump()

void ami_mime_dump ( void  )

Definition at line 639 of file filetype.c.

References ami_mime_entry_locate(), AMI_MIME_MIMETYPE, ami_mime_entry::datatype, ami_mime_entry::filetype, ami_mime_entry::mimetype, NSLOG, and ami_mime_entry::plugincmd.

Referenced by ami_mime_free().

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

◆ ami_mime_entry_free()

static void ami_mime_entry_free ( void *  nso)
static

Definition at line 167 of file filetype.c.

References ami_mime_entry::datatype, ami_mime_entry::filetype, ami_mime_entry::mimetype, and ami_mime_entry::plugincmd.

Referenced by ami_mime_guess_add_datatype(), and ami_mime_init().

Here is the caller graph for this function:

◆ ami_mime_entry_locate()

static struct ami_mime_entry * ami_mime_entry_locate ( lwc_string *  search,
int  type,
struct Node **  start_node 
)
static

Return next matching MIME entry.

Parameters
searchlwc_string to search for (or NULL for all)
typeof value being searched for (AMI_MIME_#?)
start_nodenode to continue search (updated on exit)
Returns
entry or NULL if no match

Definition at line 279 of file filetype.c.

References AMI_MIME_DATATYPE, AMI_MIME_FILETYPE, ami_mime_list, AMI_MIME_MIMETYPE, AMI_MIME_PLUGINCMD, ami_mime_entry::datatype, ami_mime_entry::filetype, GetHead(), GetSucc(), IsMinListEmpty, ami_mime_entry::mimetype, nsObject::objstruct, ami_mime_entry::plugincmd, and type.

Referenced by ami_mime_dump(), ami_mime_from_datatype(), ami_mime_has_cmd(), ami_mime_to_filetype(), and ami_mime_to_plugincmd().

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

◆ ami_mime_free()

void ami_mime_free ( void  )

Definition at line 264 of file filetype.c.

References ami_mime_dump(), ami_mime_list, and FreeObjList().

Referenced by main().

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

◆ ami_mime_from_datatype()

struct Node * ami_mime_from_datatype ( struct DataType *  dt,
lwc_string **  mimetype,
struct Node *  start_node 
)

Return a MIME Type matching a DataType.

Parameters
dta DataType structure
mimetypelwc_string to hold the MIME type
start_nodenode to feed back in to continue search
Returns
node or NULL if no match

Definition at line 455 of file filetype.c.

References AMI_MIME_DATATYPE, ami_mime_entry_locate(), ami_mime_guess_add_datatype(), and ami_mime_entry::mimetype.

Referenced by fetch_filetype().

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

◆ ami_mime_guess_add_datatype()

static APTR ami_mime_guess_add_datatype ( struct DataType *  dt,
lwc_string **  lwc_mimetype 
)
static

Definition at line 350 of file filetype.c.

References AddObject(), ami_mime_entry_free(), ami_mime_list, AMINS_MIME, ami_mime_entry::datatype, ami_mime_entry::filetype, ami_mime_entry::mimetype, ObjectCallback(), nsObject::objstruct, and strlwr().

Referenced by ami_mime_from_datatype().

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

◆ ami_mime_has_cmd()

struct Node * ami_mime_has_cmd ( lwc_string **  mimetype,
struct Node *  start_node 
)

Return all MIME types containing a plugincmd.

Parameters
mimetypeptr to lwc_string MIME type
start_nodenode to feed back in to continue search
Returns
node or NULL if no match

Definition at line 547 of file filetype.c.

References ami_mime_entry_locate(), AMI_MIME_PLUGINCMD, and ami_mime_entry::mimetype.

Referenced by amiga_plugin_hack_init().

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

◆ ami_mime_init()

nserror ami_mime_init ( const char *  mimefile)

Definition at line 177 of file filetype.c.

References AddObject(), AMI_MIME_DATATYPE, ami_mime_entry_free(), AMI_MIME_FILETYPE, ami_mime_list, AMI_MIME_MIMETYPE, AMI_MIME_PLUGINCMD, AMINS_MIME, buffer, ami_mime_entry::datatype, FClose, ami_mime_entry::filetype, FOpen, ami_mime_entry::mimetype, NewObjList(), NSERROR_NOMEM, NSERROR_OK, NSLOG, ObjectCallback(), nsObject::objstruct, and ami_mime_entry::plugincmd.

Referenced by main().

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

◆ ami_mime_to_filetype()

struct Node * ami_mime_to_filetype ( lwc_string *  mimetype,
lwc_string **  filetype,
struct Node *  start_node 
)

Return the DefIcons type matching a MIME type.

Parameters
mimetypelwc_string MIME type
filetypeptr to lwc_string to hold DefIcons type
start_nodenode to feed back in to continue search
Returns
node or NULL if no match

Definition at line 503 of file filetype.c.

References ami_mime_entry_locate(), AMI_MIME_MIMETYPE, and ami_mime_entry::filetype.

Referenced by ami_mime_compare(), and ami_mime_content_to_filetype().

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

◆ ami_mime_to_plugincmd()

static struct Node * ami_mime_to_plugincmd ( lwc_string *  mimetype,
lwc_string **  plugincmd,
struct Node *  start_node 
)
static

Return the plugincmd matching a MIME type.

Parameters
mimetypelwc_string MIME type
plugincmdptr to lwc_string to hold plugincmd
start_nodenode to feed back in to continue search
Returns
node or NULL if no match

Definition at line 575 of file filetype.c.

References ami_mime_entry_locate(), AMI_MIME_MIMETYPE, and ami_mime_entry::plugincmd.

Referenced by ami_mime_content_to_cmd().

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

◆ fetch_filetype()

const char * fetch_filetype ( const char *  unix_path)

Determine the MIME type of a local file.

Parameters
unix_pathUnix style path to file on disk
Returns
Pointer to MIME type string (should not be freed) - invalidated on next call to fetch_filetype.

Definition at line 58 of file filetype.c.

References ami_mime_from_datatype().

Referenced by fetch_rsrc_process(), and HOOKF().

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

Variable Documentation

◆ ami_mime_list

struct MinList* ami_mime_list = NULL
static

filetype – determine the MIME type of a local file

Definition at line 40 of file filetype.c.

Referenced by ami_mime_entry_locate(), ami_mime_free(), ami_mime_guess_add_datatype(), and ami_mime_init().