Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

mime.c File Reference

Shared MIME database functions for ROX-CLib. More...

#include "rox-clib.h"
#include <stdlib.h>
#include <time.h>
#include <sys/param.h>
#include <fnmatch.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
#include <libxml/parser.h>
#include "rox.h"
#include "basedir.h"
#include "mime.h"

Data Structures

struct  pattern

Defines

#define TYPE_NS   "http://www.freedesktop.org/standards/shared-mime-info"
#define UNKNOWN   text_plain

Typedefs

typedef pattern Pattern

Functions

void rox_mime_init (void)
void mime_init (void)
ROXMIMETyperox_mime_lookup (const char *path)
ROXMIMETypemime_lookup (const char *path)
ROXMIMETyperox_mime_lookup_by_name (const char *name)
ROXMIMETypemime_lookup_by_name (const char *name)
char * rox_mime_type_name (const ROXMIMEType *type)
char * mime_type_name (const ROXMIMEType *type)
const char * rox_mime_type_comment (ROXMIMEType *type)
const char * mime_type_comment (ROXMIMEType *type)
void rox_mime_set_ignore_exec_bit (int ignore)
void mime_set_ignore_exec_bit (int ignore)
int rox_mime_get_ignore_exec_bit (void)
int mime_get_ignore_exec_bit (void)
void rox_mime_set_by_content (int content)
void mime_set_by_content (int content)
int rox_mime_get_by_content (void)
int mime_get_by_content (void)
GdkPixbuf * rox_mime_get_icon (const ROXMIMEType *type, int msize)

Variables

ROXMIMETypetext_plain
ROXMIMETypeapplication_executable
ROXMIMETypeapplication_octet_stream
ROXMIMETypeinode_directory
ROXMIMETypeinode_mountpoint
ROXMIMETypeinode_pipe
ROXMIMETypeinode_socket
ROXMIMETypeinode_block
ROXMIMETypeinode_char
ROXMIMETypeinode_door
ROXMIMETypeinode_unknown


Detailed Description

Shared MIME database functions for ROX-CLib.

Author:
Thomas Leonard, Stephen Watson
Version:
Id
mime.c,v 1.6 2005/10/22 10:42:28 stephen Exp

Define Documentation

#define TYPE_NS   "http://www.freedesktop.org/standards/shared-mime-info"
 

XML name space of the MIME definitions.

#define UNKNOWN   text_plain
 

Normal files of undefined type default to text/plain


Typedef Documentation

typedef struct pattern Pattern
 

The first pattern in the list which matches is used


Function Documentation

int mime_get_by_content void   ) 
 

Return how the MIME system deals with the content of files, see mime_set_by_content().

Deprecated:
Use rox_mime_get_by_content()

int mime_get_ignore_exec_bit void   ) 
 

Return how the MIME system treats executable files, see mime_set_ignore_exec_bit().

Deprecated:
Use rox_mime_get_ignore_exec_bit().

void mime_init void   ) 
 

Initialize the MIME type system.

Deprecated:
Use rox_mime_init() instead.

ROXMIMEType* mime_lookup const char *  path  ) 
 

Return the MIME type of the named object.

Deprecated:
Use rox_mime_lookup().

ROXMIMEType* mime_lookup_by_name const char *  name  ) 
 

Return the type of a file based purely on the name. The file need not exist or be readable.

Deprecated:
use rox_mime_lookup_by_name()

void mime_set_by_content int  content  ) 
 

Set how the MIME system deals with the content of files. If content is FALSE then the content of the files will never be read to identify the type.

Deprecated:
Use rox_mime_set_by_content()

void mime_set_ignore_exec_bit int  ignore  ) 
 

Set how the MIME system treats executable files. If ignore is FALSE then all executable files will be identified as application/executable

Deprecated:
Use rox_mime_set_ignore_exec_bit().

const char* mime_type_comment ROXMIMEType type  ) 
 

Return the comment of a MIME type (the long form of a name, e.g. " Text document")

Deprecated:
use rox_mime_type_comment().

char* mime_type_name const ROXMIMEType type  ) 
 

Return the human readable name of the type, in the form media/sub-type

Deprecated:
use rox_mime_type_name().

int rox_mime_get_by_content void   ) 
 

Return how the MIME system deals with the content of files, see mime_set_by_content().

Currently this flag has no effect as identifying files by content is not yet supported.

Returns:
the value of the by_content flag.

GdkPixbuf* rox_mime_get_icon const ROXMIMEType type,
int  msize
 

Return the icon for the specified MIME type, scaled appropriately. This function checks the override icons for media/subtype, then the ROX theme icon for the same type. If neither works it tries again for the generic media icon in the same places. If nothing works, NULL is returned.

In the future this will detect the icon theme in use, but until then only the ROX theme is checked.

Parameters:
[in] type MIME type to look up
[in] msize maximum size in pixels of the icon to return. If 0 or less the default size of 48 is used.
Returns:
the icon, or NULL if not found.

int rox_mime_get_ignore_exec_bit void   ) 
 

Return how the MIME system treats executable files, see mime_set_ignore_exec_bit().

Returns:
the value of the ignore_exec flag.

void rox_mime_init void   ) 
 

Initialize the MIME type system. This must be called before the other functions.

ROXMIMEType* rox_mime_lookup const char *  path  ) 
 

Return the MIME type of the named object.

If the object does not exist, or is in an unsearchable directory, then the type returned is based purely on the name.

If the object does exist then the type of file is checked. If it is a non-file object (such as a directory) then the appropriate inode/* type is returned. If it is a file and is executable and the mime_get_ignore_exec_bit() value is FALSE then application/executable is returned.

If mime_get_by_content() is not FALSE and content checking is implemented (it currently is not) and a type is identified it is returned.

If the type can be identified by the name then that is returned.

Finally if the execute bit is set application/executable is returned, otherwise UNKNOWN.

Parameters:
[in] path path to object to check, or a name of a non-existant file
Returns:
the identified type.

ROXMIMEType* rox_mime_lookup_by_name const char *  name  ) 
 

Return the type of a file based purely on the name. The file need not exist or be readable.

Parameters:
[in] name name of file
Returns:
the identified type.

void rox_mime_set_by_content int  content  ) 
 

Set how the MIME system deals with the content of files. If content is FALSE then the content of the files will never be read to identify the type.

Currently this flag has no effect as identifying files by content is not yet supported.

Parameters:
[in] content the new value of the by_cotnent flag.

void rox_mime_set_ignore_exec_bit int  ignore  ) 
 

Set how the MIME system treats executable files. If ignore is FALSE then all executable files will be identified as application/executable

Parameters:
[in] ignore the new value of the ignore_exec flag.

const char* rox_mime_type_comment ROXMIMEType type  ) 
 

Return the comment of a MIME type (the long form of a name, e.g. " Text document")

Parameters:
[in] type the type
Returns:
the comment

char* rox_mime_type_name const ROXMIMEType type  ) 
 

Return the human readable name of the type, in the form media/sub-type

Parameters:
[in] type type to return name of.
Returns:
the name, pass to g_free() when done.


Variable Documentation

ROXMIMEType* application_executable
 

Default for executable file

ROXMIMEType* application_octet_stream
 

Default for binary file

ROXMIMEType* inode_block
 

Block device file

ROXMIMEType* inode_char
 

Character device file

ROXMIMEType* inode_directory
 

A directory

ROXMIMEType* inode_door
 

Door file, similar to sockets, not available on all operating systems

ROXMIMEType* inode_mountpoint
 

A directory used as a mount point

ROXMIMEType* inode_pipe
 

A named pipe

ROXMIMEType* inode_socket
 

UNIX domain socket

ROXMIMEType* inode_unknown
 

Unknown type, probably broken symbolic link

ROXMIMEType* text_plain
 

Default for plain file


Generated on Sat Oct 22 17:49:14 2005 for ROX-CLib by doxygen 1.3.8