libclamav/filetypes.h
9b8e00a0
 /*
2023340a
  *  Copyright (C) 2007-2008 Sourcefire, Inc.
7021b545
  *
2023340a
  *  Authors: Tomasz Kojm
9b8e00a0
  *
  *  This program is free software; you can redistribute it and/or modify
bb34cb31
  *  it under the terms of the GNU General Public License version 2 as
  *  published by the Free Software Foundation.
9b8e00a0
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
48b7b4a7
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  *  MA 02110-1301, USA.
9b8e00a0
  */
 
888f5794
 #ifndef __FILETYPES_H
 #define __FILETYPES_H
 
994ae437
 #include <sys/types.h>
 
7021b545
 #include "clamav.h"
 #include "cltypes.h"
048d7677
 #include "fmap.h"
7021b545
 
6038397e
 #define MAGIC_BUFFER_SIZE 1024
888f5794
 #define CL_TYPENO 500
ee99255a
 #define MAX_EMBEDDED_OBJ 10
9b8e00a0
 
 typedef enum {
55094a9c
     CL_TYPE_ANY = 0,
c8f2d060
     CL_TYPE_TEXT_ASCII = CL_TYPENO, /* X3.4, ISO-8859, non-ISO ext. ASCII */
     CL_TYPE_TEXT_UTF8,
     CL_TYPE_TEXT_UTF16LE,
     CL_TYPE_TEXT_UTF16BE,
     CL_TYPE_BINARY_DATA,
     /* Please do not add any new types above this line */
7021b545
     CL_TYPE_ERROR,
3805ebcb
     CL_TYPE_MSEXE,
094116b2
     CL_TYPE_ELF,
89c14869
     CL_TYPE_MACHO,
3222a096
     CL_TYPE_MACHO_UNIBIN,
a7f5fd00
     CL_TYPE_POSIX_TAR,
     CL_TYPE_OLD_TAR,
75e46945
     CL_TYPE_CPIO_OLD,
     CL_TYPE_CPIO_ODC,
     CL_TYPE_CPIO_NEWC,
     CL_TYPE_CPIO_CRC,
3805ebcb
     CL_TYPE_GZ,
     CL_TYPE_ZIP,
     CL_TYPE_BZ,
     CL_TYPE_RAR,
9d96e4b6
     CL_TYPE_ARJ,
3805ebcb
     CL_TYPE_MSSZDD,
     CL_TYPE_MSOLE2,
     CL_TYPE_MSCAB,
     CL_TYPE_MSCHM,
bf45bf13
     CL_TYPE_SIS,
3805ebcb
     CL_TYPE_SCRENC,
7ec67e94
     CL_TYPE_GRAPHICS,
eb308794
     CL_TYPE_RIFF,
667ab9c6
     CL_TYPE_BINHEX,
846e4186
     CL_TYPE_TNEF,
2c6f9d57
     CL_TYPE_CRYPTFF,
f87214c3
     CL_TYPE_PDF,
3953039b
     CL_TYPE_UUENCODED,
015ce4a8
     CL_TYPE_SCRIPT,
bd988961
     CL_TYPE_HTML_UTF16,
52c2a8bd
     CL_TYPE_RTF,
81fded11
     CL_TYPE_7Z,
f7efc022
 
ece009c0
     /* bigger numbers have higher priority (in o-t-f detection) */
3805ebcb
     CL_TYPE_HTML, /* on the fly */
d1bccafe
     CL_TYPE_MAIL,  /* magic + on the fly */
a85bd2ac
     CL_TYPE_SFX, /* foo SFX marker */
4705a377
     CL_TYPE_ZIPSFX, /* on the fly */
d8a5c616
     CL_TYPE_RARSFX, /* on the fly */
faaf436a
     CL_TYPE_CABSFX,
9d96e4b6
     CL_TYPE_ARJSFX,
ed93f138
     CL_TYPE_NULSFT, /* on the fly */
6038397e
     CL_TYPE_AUTOIT,
cadaa703
     CL_TYPE_ISHIELD_MSI,
6038397e
     CL_TYPE_IGNORED /* please don't add anything below */
9b8e00a0
 } cli_file_t;
 
7021b545
 struct cli_ftype {
     cli_file_t type;
     uint32_t offset;
     unsigned char *magic;
     char *tname;
     struct cli_ftype *next;
9381324a
     uint16_t length;
7021b545
 };
 
a85bd2ac
 struct cli_matched_type {
9381324a
     struct cli_matched_type *next;
994ae437
     off_t offset;
9381324a
     cli_file_t type;
994ae437
     unsigned short cnt;
a85bd2ac
 };
 
7021b545
 cli_file_t cli_ftcode(const char *name);
0d9dbdef
 void cli_ftfree(const struct cl_engine *engine);
7021b545
 cli_file_t cli_filetype(const unsigned char *buf, size_t buflen, const struct cl_engine *engine);
49cc1e3c
 cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine);
5612732c
 int cli_addtypesigs(struct cl_engine *engine);
9b8e00a0
 
 #endif