-
Notifications
You must be signed in to change notification settings - Fork 6
/
dcfldd.h
167 lines (128 loc) · 4.18 KB
/
dcfldd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* $Id: dcfldd.h,v 1.7 2005/05/19 21:00:07 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
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 Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef DCFLDD_H
#define DCFLDD_H
#define _FILE_OFFSET_BITS 64
#define LARGEFILE_SOURCE
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
#include <ctype.h>
#include <time.h>
#include <stdio.h>
#include "config.h"
#include "system.h"
#include "hash.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "dcfldd"
#define AUTHORS "dcfldd by Nicholas Harbour, GNU dd by Paul Rubin, David MacKenzie and Stuart Kemp"
#define SWAB_ALIGN_OFFSET 2
#ifndef SIGINFO
# define SIGINFO SIGUSR1
#endif
#ifndef S_TYPEISSHM
# define S_TYPEISSHM(Stat_ptr) 0
#endif
#define ROUND_UP_OFFSET(X, M) ((M) - 1 - (((X) + (M) - 1) % (M)))
#define PTR_ALIGN(Ptr, M) ((Ptr) \
+ ROUND_UP_OFFSET ((char *)(Ptr) - (char *)0, (M)))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define output_char(c) \
do \
{ \
obuf[oc++] = (c); \
if (oc >= output_blocksize) \
write_output (); \
} \
while (0)
/* Default input and output blocksize. */
/* #define DEFAULT_BLOCKSIZE 512 */
#ifndef DEFAULT_BLOCKSIZE
#define DEFAULT_BLOCKSIZE 32768 /* 32k blocksize is HUGELY more efficient
* for large device IO than 512 */
#endif /* DEFAULT_BLOCKSIZE */
#ifndef DEFAULT_SPLIT_FORMAT
#define DEFAULT_SPLIT_FORMAT "nnn"
#endif /* DEFAULT_SPLIT_FORMAT */
#ifndef DEFAULT_HASHWINDOW_FORMAT
#define DEFAULT_HASHWINDOW_FORMAT "#window_start# - #window_end#: #hash#"
#endif /* DEFAULT_HASHWINDOW_FORMAT */
#ifndef DEFAULT_TOTALHASH_FORMAT
#define DEFAULT_TOTALHASH_FORMAT "\nTotal (#algorithm#): #hash#"
#endif /* DEFAULT_TOTALHASH_FORMAT */
#ifndef DEFAULT_HASHCONV
#define DEFAULT_HASHCONV HASHCONV_BEFORE
#endif /* DEFAULT_HASHCONV */
/* Conversions bit masks. */
#define C_ASCII 01
#define C_EBCDIC 02
#define C_IBM 04
#define C_BLOCK 010
#define C_UNBLOCK 020
#define C_LCASE 040
#define C_UCASE 0100
#define C_SWAB 0200
#define C_NOERROR 0400
#define C_NOTRUNC 01000
#define C_SYNC 02000
/* Use separate input and output buffers, and combine partial input blocks. */
#define C_TWOBUFS 04000
typedef enum {
HASHCONV_BEFORE,
HASHCONV_AFTER
} hashconv_t;
extern hashconv_t hashconv;
extern char *program_name;
extern char *input_file;
extern char *output_file;
extern size_t input_blocksize;
extern size_t output_blocksize;
extern size_t conversion_blocksize;
extern uintmax_t skip_records;
extern uintmax_t seek_records;
extern uintmax_t max_records;
extern int conversions_mask;
extern int translation_needed;
extern uintmax_t w_partial;
extern uintmax_t w_full;
extern uintmax_t r_partial;
extern uintmax_t r_full;
extern uintmax_t r_partial;
extern uintmax_t r_truncate;
extern int do_hash;
extern int do_verify;
extern int do_status;
extern int char_is_saved;
extern unsigned char saved_char;
extern time_t start_time;
extern ssize_t update_thresh;
struct conversion
{
char *convname;
int conversion;
};
/* FIXME: Figure out where usage() is getting called from and delete this if needed */
extern void usage(int);
extern void print_stats(void);
extern void cleanup(void);
extern inline void quit(int);
extern void parse_conversion(char *);
extern int hex2char(char *);
#endif /* DCFLDD_H */