A kernel mime_table module, so not every fs will bundle its own.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10580 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
SubDir OBOS_TOP src add-ons kernel generic mime_table ;
|
||||
|
||||
R5KernelAddon mime_table : kernel generic :
|
||||
mime_table.c
|
||||
module.c
|
||||
;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
## BeOS Generic Makefile v2.2 ##
|
||||
|
||||
## Fill in this file to specify the project being created, and the referenced
|
||||
## makefile-engine will do all of the hard work for you. This handles both
|
||||
## Intel and PowerPC builds of the BeOS.
|
||||
|
||||
## Application Specific Settings ---------------------------------------------
|
||||
|
||||
# specify the name of the binary
|
||||
NAME= mime_table
|
||||
|
||||
# specify the type of binary
|
||||
# APP: Application
|
||||
# SHARED: Shared library or add-on
|
||||
# STATIC: Static library archive
|
||||
# DRIVER: Kernel Driver
|
||||
TYPE= DRIVER
|
||||
|
||||
# add support for new Pe and Eddie features
|
||||
# to fill in generic makefile
|
||||
|
||||
#%{
|
||||
# @src->@
|
||||
|
||||
# specify the source files to use
|
||||
# full paths or paths relative to the makefile can be included
|
||||
# all files, regardless of directory, will have their object
|
||||
# files created in the common object directory.
|
||||
# Note that this means this makefile will not work correctly
|
||||
# if two source files with the same name (source.c or source.cpp)
|
||||
# are included from different directories. Also note that spaces
|
||||
# in folder names do not work well with this makefile.
|
||||
SRCS= mime_table.c module.c
|
||||
|
||||
# specify the resource files to use
|
||||
# full path or a relative path to the resource file can be used.
|
||||
RSRCS=
|
||||
|
||||
# @<-src@
|
||||
#%}
|
||||
|
||||
# end support for Pe and Eddie
|
||||
|
||||
# specify additional libraries to link against
|
||||
# there are two acceptable forms of library specifications
|
||||
# - if your library follows the naming pattern of:
|
||||
# libXXX.so or libXXX.a you can simply specify XXX
|
||||
# library: libbe.so entry: be
|
||||
#
|
||||
# - if your library does not follow the standard library
|
||||
# naming scheme you need to specify the path to the library
|
||||
# and it's name
|
||||
# library: my_lib.a entry: my_lib.a or path/my_lib.a
|
||||
LIBS=
|
||||
|
||||
# specify additional paths to directories following the standard
|
||||
# libXXX.so or libXXX.a naming scheme. You can specify full paths
|
||||
# or paths relative to the makefile. The paths included may not
|
||||
# be recursive, so include all of the paths where libraries can
|
||||
# be found. Directories where source files are found are
|
||||
# automatically included.
|
||||
LIBPATHS=
|
||||
|
||||
# additional paths to look for system headers
|
||||
# thes use the form: #include <header>
|
||||
# source file directories are NOT auto-included here
|
||||
SYSTEM_INCLUDE_PATHS = ../../../../../headers/os/drivers/
|
||||
|
||||
# additional paths to look for local headers
|
||||
# thes use the form: #include "header"
|
||||
# source file directories are automatically included
|
||||
LOCAL_INCLUDE_PATHS =
|
||||
|
||||
# specify the level of optimization that you desire
|
||||
# NONE, SOME, FULL
|
||||
OPTIMIZE=
|
||||
|
||||
# specify any preprocessor symbols to be defined. The symbols will not
|
||||
# have their values set automatically; you must supply the value (if any)
|
||||
# to use. For example, setting DEFINES to "DEBUG=1" will cause the
|
||||
# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG"
|
||||
# would pass "-DDEBUG" on the compiler's command line.
|
||||
DEFINES=
|
||||
|
||||
# specify special warning levels
|
||||
# if unspecified default warnings will be used
|
||||
# NONE = supress all warnings
|
||||
# ALL = enable all warnings
|
||||
WARNINGS =
|
||||
|
||||
# specify whether image symbols will be created
|
||||
# so that stack crawls in the debugger are meaningful
|
||||
# if TRUE symbols will be created
|
||||
SYMBOLS =
|
||||
|
||||
# specify debug settings
|
||||
# if TRUE will allow application to be run from a source-level
|
||||
# debugger. Note that this will disable all optimzation.
|
||||
DEBUGGER =
|
||||
|
||||
# specify additional compiler flags for all files
|
||||
COMPILER_FLAGS =
|
||||
|
||||
# specify additional linker flags
|
||||
LINKER_FLAGS =
|
||||
|
||||
# specify the version of this particular item
|
||||
# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL")
|
||||
# This may also be specified in a resource.
|
||||
APP_VERSION =
|
||||
|
||||
# (for TYPE == DRIVER only) Specify desired location of driver in the /dev
|
||||
# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will
|
||||
# instruct the driverinstall rule to place a symlink to your driver's binary in
|
||||
# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at
|
||||
# /dev/video/usb when loaded. Default is "misc".
|
||||
DRIVER_PATH =
|
||||
|
||||
## include the makefile-engine
|
||||
include $(BUILDHOME)/etc/makefile-engine
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright 1999-2001, Be Incorporated. All Rights Reserved.
|
||||
This file may be used under the terms of the Be Sample Code License.
|
||||
|
||||
extended: 2001-12-11 by Marcus Overhagen
|
||||
*/
|
||||
|
||||
#include <mime_table.h>
|
||||
|
||||
struct ext_mime mimes[] = {
|
||||
{ "gz", "application/x-gzip" },
|
||||
{ "hqx", "application/x-binhex40" },
|
||||
{ "lha", "application/x-lharc" },
|
||||
{ "lzh", "application/x-lharc" },
|
||||
{ "pcl", "application/x-pcl" },
|
||||
{ "pdf", "application/pdf" },
|
||||
{ "ps", "application/postscript" },
|
||||
{ "sit", "application/x-stuff-it" },
|
||||
{ "tar", "application/x-tar" },
|
||||
{ "tgz", "application/x-gzip" },
|
||||
{ "uue", "application/x-uuencode" },
|
||||
{ "z", "application/x-compress" },
|
||||
{ "zip", "application/zip" },
|
||||
{ "zoo", "application/x-zoo" },
|
||||
{ "pkg", "application/x-scode-UPkg" },
|
||||
{ "vdwn", "application/x-scode-UPkg" },
|
||||
{ "proj", "application/x-mw-project" },
|
||||
{ "swf", "application/x-shockwave-flash" },
|
||||
{ "clp", "application/x-codeliege-project" },
|
||||
|
||||
{ "aif", "audio/x-aiff" },
|
||||
{ "aifc", "audio/x-aifc" },
|
||||
{ "aiff", "audio/x-aiff" },
|
||||
{ "au", "audio/basic" },
|
||||
{ "mid", "audio/x-midi" },
|
||||
{ "midi", "audio/x-midi" },
|
||||
{ "mod", "audio/mod" },
|
||||
{ "ra", "audio/x-real-audio" },
|
||||
{ "wav", "audio/x-wav" },
|
||||
{ "mp2", "audio/x-mpeg" },
|
||||
{ "mp3", "audio/x-mpeg" },
|
||||
{ "ogg", "audio/x-vorbis" },
|
||||
{ "mpc", "audio/x-mpc" },
|
||||
{ "asf", "application/x-asf" },
|
||||
{ "riff", "application/x-riff" },
|
||||
{ "wma", "audio/x-ms-wma" },
|
||||
|
||||
{ "bmp", "image/x-bmp" },
|
||||
{ "fax", "image/g3fax" },
|
||||
{ "gif", "image/gif" },
|
||||
{ "iff", "image/x-iff" },
|
||||
{ "jpg", "image/jpeg" },
|
||||
{ "jpeg", "image/jpeg" },
|
||||
{ "pbm", "image/x-portable-bitmap" },
|
||||
{ "pcx", "image/x-pcx" },
|
||||
{ "pgm", "image/x-portable-graymap" },
|
||||
{ "png", "image/png" },
|
||||
{ "ppm", "image/x-portable-pixmap" },
|
||||
{ "rgb", "image/x-rgb" },
|
||||
{ "tga", "image/x-targa" },
|
||||
{ "tif", "image/tiff" },
|
||||
{ "tiff", "image/tiff" },
|
||||
{ "xbm", "image/x-xbitmap" },
|
||||
|
||||
{ "txt", "text/plain" },
|
||||
{ "ini", "text/plain" },
|
||||
{ "log", "text/plain" },
|
||||
{ "bat", "text/plain" },
|
||||
{ "doc", "text/plain" },
|
||||
{ "cfg", "text/plain" },
|
||||
{ "inf", "text/plain" },
|
||||
{ "htm", "text/html" },
|
||||
{ "html", "text/html" },
|
||||
{ "rtf", "text/rtf" },
|
||||
{ "c", "text/x-source-code" },
|
||||
{ "cc", "text/x-source-code" },
|
||||
{ "c++", "text/x-source-code" },
|
||||
{ "h", "text/x-source-code" },
|
||||
{ "h++", "text/x-source-code" },
|
||||
{ "hh", "text/x-source-code" },
|
||||
{ "hpp", "text/x-source-code" },
|
||||
{ "pl", "text/x-source-code" },
|
||||
{ "py", "text/x-source-code" },
|
||||
{ "cxx", "text/x-source-code" },
|
||||
{ "cpp", "text/x-source-code" },
|
||||
{ "S", "text/x-source-code" },
|
||||
{ "asm", "text/x-source-code" },
|
||||
{ "bas", "text/x-source-code" },
|
||||
{ "pas", "text/x-source-code" },
|
||||
{ "java", "text/x-source-code" },
|
||||
|
||||
{ "avi", "video/x-msvideo" },
|
||||
{ "mov", "video/quicktime" },
|
||||
{ "mpg", "video/mpeg" },
|
||||
{ "mpeg", "video/mpeg" },
|
||||
{ "ogm", "video/x-ogm" },
|
||||
{ "wmv", "video/x-ms-wmv" },
|
||||
{ "rm", "application/vnd.rn-realmedia" },
|
||||
{ "rn", "application/vnd.rn-realmedia" },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: mime_table.c
|
||||
/
|
||||
/ Description: Kernel module implementing kernel-space mime_table API
|
||||
/
|
||||
/ Copyright 1999, Be Incorporated, All Rights Reserved.
|
||||
/ This file may be used under the terms of the Be Sample Code License.
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
#include <Drivers.h>
|
||||
#include <KernelExport.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mime_table.h>
|
||||
extern struct ext_mime mimes[];
|
||||
|
||||
#if DEBUG > 0
|
||||
#define ddprintf(x) dprintf x
|
||||
#else
|
||||
#define ddprintf(x)
|
||||
#endif
|
||||
|
||||
/* Module static data */
|
||||
const char mime_table_module_name[] = B_MIME_TABLE_MODULE_NAME;
|
||||
|
||||
static status_t
|
||||
std_ops(int32 op, ...)
|
||||
{
|
||||
switch(op) {
|
||||
case B_MODULE_INIT:
|
||||
return B_OK;
|
||||
case B_MODULE_UNINIT:
|
||||
return B_OK;
|
||||
default:
|
||||
/* do nothing */
|
||||
;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
status_t get_table(struct ext_mime **table)
|
||||
{
|
||||
if (!table)
|
||||
return EINVAL;
|
||||
/* no need to malloc & copy yet */
|
||||
*table = mimes;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void free_table(struct ext_mime *table)
|
||||
{
|
||||
/* do nothing yet */
|
||||
}
|
||||
|
||||
const char *mime_for_ext(const char *ext)
|
||||
{
|
||||
int i;
|
||||
/* should probably be optimized */
|
||||
for (i = 0; mimes[i].extension; i++) {
|
||||
if (!strcmp(ext, mimes[i].extension))
|
||||
return mimes[i].mime;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *ext_for_mime(const char *mime)
|
||||
{
|
||||
int i;
|
||||
/* should probably be optimized */
|
||||
for (i = 0; mimes[i].mime; i++) {
|
||||
if (!strcmp(mime, mimes[i].mime))
|
||||
return mimes[i].extension;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static mime_table_module_info mime_table = {
|
||||
{
|
||||
mime_table_module_name,
|
||||
0,
|
||||
std_ops
|
||||
},
|
||||
get_table,
|
||||
free_table,
|
||||
mime_for_ext,
|
||||
ext_for_mime
|
||||
};
|
||||
|
||||
_EXPORT mime_table_module_info *modules[] = {
|
||||
&mime_table,
|
||||
NULL
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user