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