kio
kmimemagic.cpp File Reference
#include "kmimemagic.h"
#include <kdebug.h>
#include <kapplication.h>
#include <qfile.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kstaticdeleter.h>
#include <klargefile.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <stdarg.h>
#include <qregexp.h>
#include <qstring.h>
Go to the source code of this file.
Defines | |
#define | BEDATE 9 |
#define | BELONG 8 |
#define | BESHORT 7 |
#define | BYTE 1 |
#define | DATE 6 |
#define | EATAB |
#define | FLAG_STRONG 0x1000 |
#define | HOWMANY 4000 |
#define | INDIR 1 |
#define | isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) |
#define | L_C 0x002 |
#define | L_CPP 0x080 |
#define | L_DIFF 0x400 |
#define | L_HTML 0x001 |
#define | L_JAVA 0x040 |
#define | L_MACH 0x010 |
#define | L_MAIL 0x100 |
#define | L_MAKE 0x004 |
#define | L_NEWS 0x200 |
#define | L_OBJC 0x800 |
#define | L_PAS 0x020 |
#define | L_PLI 0x008 |
#define | LEDATE 12 |
#define | LELONG 11 |
#define | LESHORT 10 |
#define | LONG 4 |
#define | MAXDESC 50 |
#define | MAXMIMESTRING 256 |
#define | MAXstring 64 |
#define | MIME_APPL_TAR "application/x-tar" |
#define | MIME_APPL_TROFF "application/x-troff" |
#define | MIME_BINARY_UNKNOWN "application/octet-stream" |
#define | MIME_BINARY_UNREADABLE "application/x-unreadable" |
#define | MIME_BINARY_ZEROSIZE "application/x-zerosize" |
#define | MIME_INODE_BDEV "inode/blockdevice" |
#define | MIME_INODE_CDEV "inode/chardevice" |
#define | MIME_INODE_DIR "inode/directory" |
#define | MIME_INODE_FIFO "inode/fifo" |
#define | MIME_INODE_LINK "inode/link" |
#define | MIME_INODE_SOCK "inode/socket" |
#define | MIME_TEXT_FORTRAN "text/x-fortran" |
#define | MIME_TEXT_PLAIN "text/plain" |
#define | MIME_TEXT_UNKNOWN "text/plain" |
#define | NAMSIZ 100 |
#define | NBEDATE 6 |
#define | NBELONG 6 |
#define | NBESHORT 7 |
#define | NBYTE 4 |
#define | NDATE 4 |
#define | NLEDATE 6 |
#define | NLELONG 6 |
#define | NLESHORT 7 |
#define | NLONG 4 |
#define | NSHORT 5 |
#define | NSTRING 6 |
#define | NTYPES (sizeof(types)/sizeof(asc_type)) |
#define | P_C 1 |
#define | P_CPP 7 |
#define | P_DIFF 10 |
#define | P_HTML 0 |
#define | P_JAVA 6 |
#define | P_MACH 4 |
#define | P_MAIL 8 |
#define | P_MAKE 2 |
#define | P_NEWS 9 |
#define | P_OBJC 11 |
#define | P_PAS 5 |
#define | P_PLI 3 |
#define | RECORDSIZE 512 |
#define | SHORT 2 |
#define | STRING 5 |
#define | TEXT_MAXLINELEN 300 |
#define | TGNMLEN 32 |
#define | TMAGIC "ustar " |
#define | TUNMLEN 32 |
#define | UNSIGNED 2 |
Functions | |
static int | ascmagic (struct config_rec *conf, unsigned char *buf, int nbytes) |
static long | from_oct (int, char *) |
static int | fsmagic (struct config_rec *conf, const char *fn, KDE_struct_stat *sb) |
static char * | getstr (register char *s, register char *p, int plen, int *slen) |
static char * | getstr (char *, char *, int, int *) |
static int | getvalue (struct magic *, char **) |
static int | hextoint (int) |
static int | is_tar (unsigned char *, int) |
static int | match (struct config_rec *conf, unsigned char *, int) |
static int | mcheck (union VALUETYPE *, struct magic *) |
static int | mconvert (union VALUETYPE *, struct magic *) |
static int | mget (union VALUETYPE *, unsigned char *, struct magic *, int) |
static void | process (struct config_rec *conf, const QString &) |
static void | refineResult (KMimeMagicResult *r, const QString &_filename) |
static unsigned long | signextend (struct magic *, unsigned long) |
static bool | STREQ (const Token *token, const char *b) |
static int | tagmagic (unsigned char *buf, int nbytes) |
static int | textmagic (struct config_rec *conf, unsigned char *, int) |
static void | tryit (struct config_rec *conf, unsigned char *buf, int nb) |
Variables | |
static KStaticDeleter< KMimeMagic > | kmimemagicsd |
static const asc_type | types [] |
Define Documentation
#define BEDATE 9 |
Definition at line 139 of file kmimemagic.cpp.
#define BELONG 8 |
Definition at line 138 of file kmimemagic.cpp.
#define BESHORT 7 |
Definition at line 137 of file kmimemagic.cpp.
#define BYTE 1 |
Definition at line 132 of file kmimemagic.cpp.
#define DATE 6 |
Definition at line 136 of file kmimemagic.cpp.
#define EATAB |
Value:
{while (isascii((unsigned char) *l) && \ isspace((unsigned char) *l)) ++l;}
Definition at line 614 of file kmimemagic.cpp.
#define FLAG_STRONG 0x1000 |
Definition at line 234 of file kmimemagic.cpp.
#define HOWMANY 4000 |
Definition at line 101 of file kmimemagic.cpp.
#define INDIR 1 |
Definition at line 121 of file kmimemagic.cpp.
#define isodigit | ( | c | ) | ( ((c) >= '0') && ((c) <= '7') ) |
Definition at line 2045 of file kmimemagic.cpp.
#define L_C 0x002 |
Definition at line 221 of file kmimemagic.cpp.
#define L_CPP 0x080 |
Definition at line 227 of file kmimemagic.cpp.
#define L_DIFF 0x400 |
Definition at line 230 of file kmimemagic.cpp.
#define L_HTML 0x001 |
Definition at line 220 of file kmimemagic.cpp.
#define L_JAVA 0x040 |
Definition at line 226 of file kmimemagic.cpp.
#define L_MACH 0x010 |
Definition at line 224 of file kmimemagic.cpp.
#define L_MAIL 0x100 |
Definition at line 228 of file kmimemagic.cpp.
#define L_MAKE 0x004 |
Definition at line 222 of file kmimemagic.cpp.
#define L_NEWS 0x200 |
Definition at line 229 of file kmimemagic.cpp.
#define L_OBJC 0x800 |
Definition at line 231 of file kmimemagic.cpp.
#define L_PAS 0x020 |
Definition at line 225 of file kmimemagic.cpp.
#define L_PLI 0x008 |
Definition at line 223 of file kmimemagic.cpp.
#define LEDATE 12 |
Definition at line 142 of file kmimemagic.cpp.
#define LELONG 11 |
Definition at line 141 of file kmimemagic.cpp.
#define LESHORT 10 |
Definition at line 140 of file kmimemagic.cpp.
#define LONG 4 |
Definition at line 134 of file kmimemagic.cpp.
#define MAXDESC 50 |
Definition at line 102 of file kmimemagic.cpp.
#define MAXMIMESTRING 256 |
Definition at line 99 of file kmimemagic.cpp.
#define MAXstring 64 |
Definition at line 103 of file kmimemagic.cpp.
#define MIME_APPL_TAR "application/x-tar" |
Definition at line 96 of file kmimemagic.cpp.
#define MIME_APPL_TROFF "application/x-troff" |
Definition at line 95 of file kmimemagic.cpp.
#define MIME_BINARY_UNKNOWN "application/octet-stream" |
Definition at line 83 of file kmimemagic.cpp.
#define MIME_BINARY_UNREADABLE "application/x-unreadable" |
Definition at line 84 of file kmimemagic.cpp.
#define MIME_BINARY_ZEROSIZE "application/x-zerosize" |
Definition at line 85 of file kmimemagic.cpp.
#define MIME_INODE_BDEV "inode/blockdevice" |
Definition at line 90 of file kmimemagic.cpp.
#define MIME_INODE_CDEV "inode/chardevice" |
Definition at line 89 of file kmimemagic.cpp.
#define MIME_INODE_DIR "inode/directory" |
Definition at line 88 of file kmimemagic.cpp.
#define MIME_INODE_FIFO "inode/fifo" |
Definition at line 91 of file kmimemagic.cpp.
#define MIME_INODE_LINK "inode/link" |
Definition at line 92 of file kmimemagic.cpp.
#define MIME_INODE_SOCK "inode/socket" |
Definition at line 93 of file kmimemagic.cpp.
#define MIME_TEXT_FORTRAN "text/x-fortran" |
Definition at line 97 of file kmimemagic.cpp.
#define MIME_TEXT_PLAIN "text/plain" |
Definition at line 87 of file kmimemagic.cpp.
#define MIME_TEXT_UNKNOWN "text/plain" |
Definition at line 86 of file kmimemagic.cpp.
#define NAMSIZ 100 |
Definition at line 166 of file kmimemagic.cpp.
#define NBEDATE 6 |
#define NBELONG 6 |
#define NBESHORT 7 |
#define NBYTE 4 |
#define NDATE 4 |
#define NLEDATE 6 |
#define NLELONG 6 |
#define NLESHORT 7 |
#define NLONG 4 |
#define NSHORT 5 |
#define NSTRING 6 |
#define NTYPES (sizeof(types)/sizeof(asc_type)) |
Definition at line 270 of file kmimemagic.cpp.
#define P_C 1 |
Definition at line 237 of file kmimemagic.cpp.
#define P_CPP 7 |
Definition at line 243 of file kmimemagic.cpp.
#define P_DIFF 10 |
Definition at line 246 of file kmimemagic.cpp.
#define P_HTML 0 |
Definition at line 236 of file kmimemagic.cpp.
#define P_JAVA 6 |
Definition at line 242 of file kmimemagic.cpp.
#define P_MACH 4 |
Definition at line 240 of file kmimemagic.cpp.
#define P_MAIL 8 |
Definition at line 244 of file kmimemagic.cpp.
#define P_MAKE 2 |
Definition at line 238 of file kmimemagic.cpp.
#define P_NEWS 9 |
Definition at line 245 of file kmimemagic.cpp.
#define P_OBJC 11 |
Definition at line 247 of file kmimemagic.cpp.
#define P_PAS 5 |
Definition at line 241 of file kmimemagic.cpp.
#define P_PLI 3 |
Definition at line 239 of file kmimemagic.cpp.
#define RECORDSIZE 512 |
Definition at line 165 of file kmimemagic.cpp.
#define SHORT 2 |
Definition at line 133 of file kmimemagic.cpp.
#define STRING 5 |
Definition at line 135 of file kmimemagic.cpp.
#define TEXT_MAXLINELEN 300 |
Definition at line 1992 of file kmimemagic.cpp.
#define TGNMLEN 32 |
Definition at line 168 of file kmimemagic.cpp.
#define TMAGIC "ustar " |
Definition at line 191 of file kmimemagic.cpp.
#define TUNMLEN 32 |
Definition at line 167 of file kmimemagic.cpp.
#define UNSIGNED 2 |
Definition at line 122 of file kmimemagic.cpp.
Function Documentation
static int ascmagic | ( | struct config_rec * | conf, | |
unsigned char * | buf, | |||
int | nbytes | |||
) | [static] |
Definition at line 1780 of file kmimemagic.cpp.
static long from_oct | ( | int | digs, | |
char * | where | |||
) | [static] |
Definition at line 2097 of file kmimemagic.cpp.
static int fsmagic | ( | struct config_rec * | conf, | |
const char * | fn, | |||
KDE_struct_stat * | sb | |||
) | [static] |
Definition at line 1442 of file kmimemagic.cpp.
static char* getstr | ( | register char * | s, | |
register char * | p, | |||
int | plen, | |||
int * | slen | |||
) | [static] |
Definition at line 1003 of file kmimemagic.cpp.
static char* getstr | ( | char * | , | |
char * | , | |||
int | , | |||
int * | ||||
) | [static] |
static int getvalue | ( | struct magic * | m, | |
char ** | p | |||
) | [static] |
Definition at line 985 of file kmimemagic.cpp.
static int hextoint | ( | int | c | ) | [static] |
Definition at line 1110 of file kmimemagic.cpp.
static int is_tar | ( | unsigned char * | buf, | |
int | nbytes | |||
) | [static] |
Definition at line 2053 of file kmimemagic.cpp.
static int match | ( | struct config_rec * | conf, | |
unsigned char * | s, | |||
int | nbytes | |||
) | [static] |
Definition at line 1579 of file kmimemagic.cpp.
static int mcheck | ( | union VALUETYPE * | p, | |
struct magic * | m | |||
) | [static] |
Definition at line 1244 of file kmimemagic.cpp.
static int mconvert | ( | union VALUETYPE * | p, | |
struct magic * | m | |||
) | [static] |
Definition at line 1127 of file kmimemagic.cpp.
static int mget | ( | union VALUETYPE * | p, | |
unsigned char * | s, | |||
struct magic * | m, | |||
int | nbytes | |||
) | [static] |
Definition at line 1174 of file kmimemagic.cpp.
void process | ( | struct config_rec * | conf, | |
const QString & | fn | |||
) | [static] |
Definition at line 1354 of file kmimemagic.cpp.
static void refineResult | ( | KMimeMagicResult * | r, | |
const QString & | _filename | |||
) | [static] |
Definition at line 2245 of file kmimemagic.cpp.
static unsigned long signextend | ( | struct magic * | m, | |
unsigned long | v | |||
) | [static] |
Definition at line 730 of file kmimemagic.cpp.
static bool STREQ | ( | const Token * | token, | |
const char * | b | |||
) | [inline, static] |
Definition at line 1769 of file kmimemagic.cpp.
static int tagmagic | ( | unsigned char * | buf, | |
int | nbytes | |||
) | [static] |
Definition at line 1692 of file kmimemagic.cpp.
static int textmagic | ( | struct config_rec * | conf, | |
unsigned char * | buf, | |||
int | nbytes | |||
) | [static] |
Definition at line 1998 of file kmimemagic.cpp.
static void tryit | ( | struct config_rec * | conf, | |
unsigned char * | buf, | |||
int | nb | |||
) | [static] |
Definition at line 1422 of file kmimemagic.cpp.
Variable Documentation
KStaticDeleter<KMimeMagic> kmimemagicsd [static] |
Definition at line 39 of file kmimemagic.cpp.
const asc_type types[] [static] |
Initial value:
{ { "text/html", 19, 2 }, { "text/x-c", 13, 1 }, { "text/x-makefile", 4, 1.9 }, { "text/x-pli", 1, 3 }, { "text/x-assembler", 6, 2.1 }, { "text/x-pascal", 1, 1 }, { "text/x-java", 12, 1 }, { "text/x-c++", 19, 1 }, { "message/rfc822", 4, 1.9 }, { "message/news", 3, 2 }, { "text/x-diff", 4, 2 }, { "text/x-objc", 10, 1 } }
Definition at line 255 of file kmimemagic.cpp.