Rizin
unix-like reverse engineering framework and cli tools
file.h
Go to the documentation of this file.
1 /* $OpenBSD: file.h,v 1.22 2009/10/27 23:59:37 deraadt Exp $ */
2 /*
3  * Copyright (c) Ian F. Darwin 1986-1995.
4  * Software written by Ian F. Darwin and others;
5  * maintained 1995-present by Christos Zoulas and others.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice immediately at the beginning of the file, without modification,
12  * this list of conditions, and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 /*
30  * file.h - definitions for file(1) program
31  * @(#)$Id: file.h,v 1.22 2009/10/27 23:59:37 deraadt Exp $
32  */
33 
34 #ifndef __file_h__
35 #define __file_h__
36 
37 #include "mconfig.h"
38 #include <rz_magic.h>
39 
40 #include <stdio.h> /* Include that here, to make sure __P gets defined */
41 #include <errno.h>
42 #include <fcntl.h> /* For open and flags */
43 #include <inttypes.h> // TODO: use utX
44 #include <rz_regex.h>
45 #include <sys/types.h>
46 /* Do this here and now, because struct stat gets re-defined on solaris */
47 #include <sys/stat.h>
48 #include <stdarg.h>
49 
50 /* Type for Unicode characters */
51 typedef unsigned long unichar;
52 
53 struct stat;
54 const char *file_fmttime(unsigned int, int, char *);
55 int file_buffer(struct rz_magic_set *, int, const char *, const void *, size_t);
56 int file_fsmagic(struct rz_magic_set *, const char *, struct stat *);
57 int file_pipe2file(struct rz_magic_set *, int, const void *, size_t);
58 int file_printf(struct rz_magic_set *, const char *, ...);
59 int file_reset(struct rz_magic_set *);
60 int file_tryelf(struct rz_magic_set *, int, const unsigned char *, size_t);
61 int file_zmagic(struct rz_magic_set *, int, const char *, const ut8 *, size_t);
62 int file_ascmagic(struct rz_magic_set *, const unsigned char *, size_t);
63 int file_is_tar(struct rz_magic_set *, const unsigned char *, size_t);
64 int file_softmagic(struct rz_magic_set *, const unsigned char *, size_t, int);
65 struct mlist *file_apprentice(struct rz_magic_set *, const char *, int);
66 ut64 file_signextend(RzMagic *, struct rz_magic *, ut64);
67 void file_delmagic(struct rz_magic *, int type, size_t entries);
68 void file_badread(struct rz_magic_set *);
69 void file_badseek(struct rz_magic_set *);
70 void file_oomem(struct rz_magic_set *, size_t);
71 void file_error(struct rz_magic_set *, int, const char *, ...);
72 void file_magerror(struct rz_magic_set *, const char *, ...);
73 void file_magwarn(struct rz_magic_set *, const char *, ...);
74 void file_mdump(struct rz_magic *);
75 void file_showstr(FILE *, const char *, size_t);
76 size_t file_mbswidth(const char *);
77 const char *file_getbuffer(struct rz_magic_set *);
78 ssize_t sread(int, void *, size_t, int);
79 int file_check_mem(struct rz_magic_set *, unsigned int);
80 int file_looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
81 
82 #ifndef HAVE_VASPRINTF
83 int vasprintf(char **ptr, const char *format_string, va_list vargs);
84 #endif
85 #ifndef HAVE_ASPRINTF
86 int asprintf(char **ptr, const char *format_string, ...);
87 #endif
88 
89 #ifndef O_BINARY
90 #define O_BINARY 0
91 #endif
92 
93 #endif /* __file_h__ */
RzList * entries(RzBinFile *bf)
Definition: bin_ne.c:98
void file_showstr(FILE *, const char *, size_t)
Definition: apprentice.c:1778
ut64 file_signextend(RzMagic *, struct rz_magic *, ut64)
Definition: apprentice.c:757
int file_reset(struct rz_magic_set *)
void file_badread(struct rz_magic_set *)
const char * file_getbuffer(struct rz_magic_set *)
struct mlist * file_apprentice(struct rz_magic_set *, const char *, int)
int file_ascmagic(struct rz_magic_set *, const unsigned char *, size_t)
size_t file_mbswidth(const char *)
int file_pipe2file(struct rz_magic_set *, int, const void *, size_t)
void file_oomem(struct rz_magic_set *, size_t)
void file_error(struct rz_magic_set *, int, const char *,...)
int vasprintf(char **ptr, const char *format_string, va_list vargs)
int file_buffer(struct rz_magic_set *, int, const char *, const void *, size_t)
int file_tryelf(struct rz_magic_set *, int, const unsigned char *, size_t)
int file_fsmagic(struct rz_magic_set *, const char *, struct stat *)
Definition: fsmagic.c:76
void file_delmagic(struct rz_magic *, int type, size_t entries)
Definition: apprentice.c:255
void file_magerror(struct rz_magic_set *, const char *,...)
void file_mdump(struct rz_magic *)
Definition: mdump.c:47
void file_badseek(struct rz_magic_set *)
int asprintf(char **ptr, const char *format_string,...)
int file_printf(struct rz_magic_set *, const char *,...)
int file_looks_utf8(const unsigned char *, size_t, unichar *, size_t *)
Definition: ascmagic.c:605
ssize_t sread(int, void *, size_t, int)
void file_magwarn(struct rz_magic_set *, const char *,...)
Definition: mdump.c:172
int file_is_tar(struct rz_magic_set *, const unsigned char *, size_t)
int file_zmagic(struct rz_magic_set *, int, const char *, const ut8 *, size_t)
int file_check_mem(struct rz_magic_set *, unsigned int)
const char * file_fmttime(unsigned int, int, char *)
Definition: mdump.c:188
int file_softmagic(struct rz_magic_set *, const unsigned char *, size_t, int)
unsigned long unichar
Definition: file.h:51
uint8_t ut8
Definition: lh5801.h:11
int type
Definition: mipsasm.c:17
string FILE
Definition: benchmark.py:21
int ssize_t
Definition: sftypes.h:39
Definition: sftypes.h:80
ut64(WINAPI *w32_GetEnabledXStateFeatures)()