Debian Codegraph @

global.h

raw symbols SCIP
1 /*
2 * global.h
3 * Common header file.
4 *
5 * Copyright (c) 2003 Christoph Pfisterer
6 *
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use, copy,
11 * modify, merge, publish, distribute, sublicense, and/or sell copies
12 * of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
28 #define PROGNAME "disktype"
29
30
31 /* global includes */
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <unistd.h>
37 #include <errno.h>
38
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #include <sys/time.h>
42 #include <fcntl.h>
43
44
45 /* constants */
46
47 #define FLAG_IN_DISKLABEL (0x0001)
48
49 /* types */
50
51 typedef signed char s1;
52 typedef unsigned char u1;
53 typedef short int s2;
54 typedef unsigned short int u2;
55 typedef long int s4;
56 typedef unsigned long int u4;
57 typedef long long int s8;
58 typedef unsigned long long int u8;
59
60 typedef struct source {
61 u8 size;
62 int size_known;
63 void *cache_head;
64
65 int sequential;
66 u8 seq_pos;
67 int blocksize;
68 struct source *foundation;
69
70 int (*analyze)(struct source *s, int level);
71 u8 (*read_bytes)(struct source *s, u8 pos, u8 len, void *buf);
72 int (*read_block)(struct source *s, u8 pos, void *buf);
73 void (*close)(struct source *s);
74
75 /* private data may follow */
76 } SOURCE;
77
78 typedef struct section {
79 u8 pos, size;
80 int flags;
81 SOURCE *source;
82 } SECTION;
83
84 typedef void (*DETECTOR)(SECTION *section, int level);
85
86
87 /* detection dispatching functions */
88
89 void analyze_source(SOURCE *s, int level);
90 void analyze_source_special(SOURCE *s, int level, u8 pos, u8 size);
91 void analyze_recursive(SECTION *section, int level,
92 u8 rel_pos, u8 size, int flags);
93 void stop_detect(void);
94
95 /* file source functions */
96
97 SOURCE *init_file_source(int fd, int filekind);
98
99 int analyze_cdaccess(int fd, SOURCE *s, int level);
100
101 /* buffer functions */
102
103 u8 get_buffer(SECTION *section, u8 pos, u8 len, void **buf);
104 u8 get_buffer_real(SOURCE *s, u8 pos, u8 len, void *inbuf, void **outbuf);
105 void close_source(SOURCE *s);
106
107 /* output functions */
108
109 void print_line(int level, const char *fmt, ...);
110 void start_line(const char *fmt, ...);
111 void continue_line(const char *fmt, ...);
112 void finish_line(int level);
113
114 /* formatting functions */
115
116 void format_blocky_size(char *buf, u8 count, u4 blocksize,
117 const char *blockname, const char *append);
118 void format_size(char *buf, u8 size);
119 void format_size_verbose(char *buf, u8 size);
120
121 void format_ascii(void *from, char *to);
122 void format_utf16_be(void *from, u4 len, char *to);
123 void format_utf16_le(void *from, u4 len, char *to);
124
125 void format_uuid(void *from, char *to);
126 void format_uuid_lvm(void *uuid, char *to);
127 void format_guid(void *guid, char *to);
128
129 /* endian-aware data access */
130
131 u2 get_be_short(void *from);
132 u4 get_be_long(void *from);
133 u8 get_be_quad(void *from);
134
135 u2 get_le_short(void *from);
136 u4 get_le_long(void *from);
137 u8 get_le_quad(void *from);
138
139 u2 get_ve_short(int endianness, void *from);
140 u4 get_ve_long(int endianness, void *from);
141 u8 get_ve_quad(int endianness, void *from);
142
143 const char * get_ve_name(int endianness);
144
145 /* more data access */
146
147 void get_string(void *from, int len, char *to);
148 void get_pstring(void *from, char *to);
149 void get_padded_string(void *from, int len, char pad, char *to);
150
151 int find_memory(void *haystack, int haystack_len,
152 void *needle, int needle_len);
153
154 /* name table lookups */
155
156 char * get_name_for_mbrtype(int type);
157
158 /* error functions */
159
160 void error(const char *msg, ...);
161 void errore(const char *msg, ...);
162 void bailout(const char *msg, ...);
163 void bailoute(const char *msg, ...);
164
165 /* EOF */