#include "file.h"
#include "magic.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <limits.h>
#include <netinet/in.h>
#include "patchlevel.h"
Include dependency graph for magic.c:
Go to the source code of this file.
Defines | |
#define | STDIN_FILENO 0 |
#define | SLOP (1 + sizeof(union VALUETYPE)) |
Functions | |
static const char * | rcsid (const char *p) |
static void | free_mlist (struct mlist *mlist) |
static void | close_and_restore (const struct magic_set *ms, const char *name, int fd, const struct stat *sb) |
static int | info_from_stat (struct magic_set *ms, mode_t md) |
magic_set * | magic_open (int flags) |
void | magic_close (struct magic_set *ms) |
int | magic_load (struct magic_set *ms, const char *magicfile) |
int | magic_compile (struct magic_set *ms, const char *magicfile) |
int | magic_check (struct magic_set *ms, const char *magicfile) |
const char * | magic_file (struct magic_set *ms, const char *inname) |
const char * | magic_buffer (struct magic_set *ms, const void *buf, size_t nb) |
const char * | magic_error (struct magic_set *ms) |
int | magic_errno (struct magic_set *ms) |
int | magic_setflags (struct magic_set *ms, int flags) |
#define SLOP (1 + sizeof(union VALUETYPE)) |
Referenced by magic_file().
#define STDIN_FILENO 0 |
Definition at line 86 of file magic.c.
Referenced by checkPassPhrase(), close_and_restore(), getOutputFrom(), magic_file(), main(), readRPM(), runScript(), sread(), and ufdOpen().
static void close_and_restore | ( | const struct magic_set * | ms, | |
const char * | name, | |||
int | fd, | |||
const struct stat * | sb | |||
) | [static] |
Definition at line 207 of file magic.c.
References magic_set::flags, MAGIC_PRESERVE_ATIME, and STDIN_FILENO.
Referenced by magic_file().
static void free_mlist | ( | struct mlist * | mlist | ) | [static] |
Definition at line 130 of file magic.c.
References file_delmagic(), mlist::magic, mlist::mapped, next, mlist::next, and mlist::nmagic.
Referenced by magic_check(), magic_close(), magic_compile(), and magic_load().
static int info_from_stat | ( | struct magic_set * | ms, | |
mode_t | md | |||
) | [static] |
const char* magic_buffer | ( | struct magic_set * | ms, | |
const void * | buf, | |||
size_t | nb | |||
) |
Definition at line 355 of file magic.c.
References file_buffer(), file_getbuffer(), and file_reset().
int magic_check | ( | struct magic_set * | ms, | |
const char * | magicfile | |||
) |
Definition at line 199 of file magic.c.
References file_apprentice(), FILE_CHECK, and free_mlist().
Referenced by main().
void magic_close | ( | struct magic_set * | ms | ) |
Definition at line 166 of file magic.c.
References magic_set::out::buf, magic_set::c, free_mlist(), magic_set::cont::li, magic_set::mlist, magic_set::o, and magic_set::out::pbuf.
Referenced by main(), and rpmfcClassify().
int magic_compile | ( | struct magic_set * | ms, | |
const char * | magicfile | |||
) |
Definition at line 191 of file magic.c.
References file_apprentice(), FILE_COMPILE, and free_mlist().
Referenced by main().
int magic_errno | ( | struct magic_set * | ms | ) |
const char* magic_error | ( | struct magic_set * | ms | ) |
Definition at line 371 of file magic.c.
References magic_set::out::buf, magic_set::haderr, and magic_set::o.
Referenced by load(), main(), process(), and rpmfcClassify().
const char* magic_file | ( | struct magic_set * | ms, | |
const char * | inname | |||
) |
Definition at line 242 of file magic.c.
References alloca(), close_and_restore(), errno, file_buffer(), file_error(), file_fsmagic(), file_getbuffer(), file_printf(), file_reset(), magic_set::flags, HOWMANY, info_from_stat(), MAGIC_MIME, O_BINARY, SLOP, sread(), and STDIN_FILENO.
Referenced by file_fsmagic(), process(), and rpmfcClassify().
int magic_load | ( | struct magic_set * | ms, | |
const char * | magicfile | |||
) |
Definition at line 179 of file magic.c.
References file_apprentice(), FILE_LOAD, free_mlist(), and magic_set::mlist.
Referenced by load(), and rpmfcClassify().
struct magic_set* magic_open | ( | int | flags | ) |
Definition at line 90 of file magic.c.
References magic_set::out::buf, magic_set::c, errno, magic_set::error, magic_set::file, magic_set::haderr, magic_set::out::left, magic_set::cont::len, magic_set::cont::li, magic_set::line, magic_setflags(), magic_set::mlist, magic_set::o, magic_set::out::pbuf, magic_set::out::psize, magic_set::out::ptr, and magic_set::out::size.
Referenced by load(), main(), and rpmfcClassify().
int magic_setflags | ( | struct magic_set * | ms, | |
int | flags | |||
) |
Definition at line 383 of file magic.c.
References magic_set::flags, and MAGIC_PRESERVE_ATIME.
Referenced by magic_open().