file/src/ascmagic.c File Reference

#include "file.h"
#include "magic.h"
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <ctype.h>
#include <stdlib.h>
#include "names.h"

Go to the source code of this file.

Defines

#define MAXLINELEN   300
#define ISSPC(x)
#define F   0
#define T   1
#define I   2
#define X   3

Typedefs

typedef unsigned long unichar

Functions

static const char * rcsid (const char *p)
static int looks_ascii (const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
static int looks_utf8 (const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
static int looks_unicode (const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
static int looks_latin1 (const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
static int looks_extended (const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
static void from_ebcdic (const unsigned char *buf, size_t nbytes, unsigned char *out)
static int ascmatch (const unsigned char *s, const unichar *us, size_t ulen)
int file_ascmagic (struct magic_set *ms, const unsigned char *buf, size_t nbytes)

Variables

static char text_chars [256]
static unsigned char ebcdic_to_ascii []


Define Documentation

#define F   0

Definition at line 435 of file ascmagic.c.

#define I   2

Definition at line 437 of file ascmagic.c.

#define ISSPC (  ) 

Value:

((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
                  || (x) == 0x85 || (x) == '\f')

Definition at line 58 of file ascmagic.c.

Referenced by file_ascmagic().

#define MAXLINELEN   300

Definition at line 57 of file ascmagic.c.

#define T   1

Definition at line 436 of file ascmagic.c.

Referenced by looks_ascii(), looks_extended(), looks_latin1(), looks_unicode(), and looks_utf8().

#define X   3

Definition at line 438 of file ascmagic.c.

Referenced by looks_extended().


Typedef Documentation

typedef unsigned long unichar

Definition at line 55 of file ascmagic.c.


Function Documentation

static int ascmatch ( const unsigned char *  s,
const unichar us,
size_t  ulen 
) [static]

Definition at line 368 of file ascmagic.c.

Referenced by file_ascmagic().

int file_ascmagic ( struct magic_set ms,
const unsigned char *  buf,
size_t  nbytes 
)

Definition at line 78 of file ascmagic.c.

References ascmatch(), from_ebcdic(), ISSPC, looks_ascii(), looks_extended(), looks_latin1(), looks_unicode(), looks_utf8(), names::name, NNAMES, names::type, and types.

static void from_ebcdic ( const unsigned char *  buf,
size_t  nbytes,
unsigned char *  out 
) [static]

Definition at line 708 of file ascmagic.c.

Referenced by file_ascmagic().

static int looks_ascii ( const unsigned char *  buf,
size_t  nbytes,
unichar ubuf,
size_t *  ulen 
) [static]

Definition at line 464 of file ascmagic.c.

References T.

Referenced by file_ascmagic().

static int looks_extended ( const unsigned char *  buf,
size_t  nbytes,
unichar ubuf,
size_t *  ulen 
) [static]

Definition at line 503 of file ascmagic.c.

References T, and X.

Referenced by file_ascmagic().

static int looks_latin1 ( const unsigned char *  buf,
size_t  nbytes,
unichar ubuf,
size_t *  ulen 
) [static]

Definition at line 484 of file ascmagic.c.

References T.

Referenced by file_ascmagic().

static int looks_unicode ( const unsigned char *  buf,
size_t  nbytes,
unichar ubuf,
size_t *  ulen 
) [static]

Definition at line 585 of file ascmagic.c.

References T.

Referenced by file_ascmagic().

static int looks_utf8 ( const unsigned char *  buf,
size_t  nbytes,
unichar ubuf,
size_t *  ulen 
) [static]

Definition at line 523 of file ascmagic.c.

References T.

Referenced by file_ascmagic().

static const char* rcsid ( const char *  p  )  [static]

Definition at line 52 of file ascmagic.c.


Variable Documentation

unsigned char ebcdic_to_ascii[] [static]

Initial value:

 {
  0,   1,   2,   3, 156,   9, 134, 127, 151, 141, 142,  11,  12,  13,  14,  15,
 16,  17,  18,  19, 157, 133,   8, 135,  24,  25, 146, 143,  28,  29,  30,  31,
128, 129, 130, 131, 132,  10,  23,  27, 136, 137, 138, 139, 140,   5,   6,   7,
144, 145,  22, 147, 148, 149, 150,   4, 152, 153, 154, 155,  20,  21, 158,  26,
' ', 160, 161, 162, 163, 164, 165, 166, 167, 168, 213, '.', '<', '(', '+', '|',
'&', 169, 170, 171, 172, 173, 174, 175, 176, 177, '!', '$', '*', ')', ';', '~',
'-', '/', 178, 179, 180, 181, 182, 183, 184, 185, 203, ',', '%', '_', '>', '?',
186, 187, 188, 189, 190, 191, 192, 193, 194, '`', ':', '#', '@', '\'','=', '"',
195, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 196, 197, 198, 199, 200, 201,
202, 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', '^', 204, 205, 206, 207, 208,
209, 229, 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 210, 211, 212, '[', 214, 215,
216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, ']', 230, 231,
'{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 232, 233, 234, 235, 236, 237,
'}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 238, 239, 240, 241, 242, 243,
'\\',159, 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 244, 245, 246, 247, 248, 249,
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 250, 251, 252, 253, 254, 255
}

Definition at line 649 of file ascmagic.c.

char text_chars[256] [static]

Initial value:

 {
        
         0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  1  ,  1  ,  1  ,  1  ,  0  ,  1  ,  1  ,  0  ,  0  ,  
        
         0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  0  ,  1  ,  0  ,  0  ,  0  ,  0  ,  
         1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  
         1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  
         1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  
         1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  
         1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  
         1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  1  ,  0  ,  
        
         3  ,  3  ,  3  ,  3  ,  3  ,  1  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  
         3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  3  ,  
         2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  
         2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  
         2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  
         2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  
         2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  
         2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2  ,  2     
}

Definition at line 441 of file ascmagic.c.


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2