1 /*\ 2 |*| Parity Archive - A way to restore missing files in a set. 3 |*| 4 |*| Copyright (C) 2001 Willem Monsuwe (willem@stack.nl) 5 |*| 6 |*| File format by Stefan Wehlus - 7 |*| initial idea by Tobias Rieper, further suggestions by Kilroy Balore 8 \*/ 9 #ifndef PAR_H 10 #define PAR_H 11 12 #include "types.h" 13 14 #define PAR_FIX_HEAD_SIZE 0x60 15 #define FILE_ENTRY_FIX_SIZE 0x38 16 17 struct par_s { 18 i64 magic; 19 u32 version; 20 u32 client; 21 md5 control_hash; 22 md5 set_hash; 23 i64 vol_number; 24 i64 num_files; 25 i64 file_list; 26 i64 file_list_size; 27 i64 data; 28 i64 data_size; 29 30 i64 control_hash_offset; 31 pfile_t *files; 32 pfile_t *volumes; 33 u16 *filename; 34 u16 *comment; 35 file_t f; 36 }; 37 38 struct pfile_entr_s { 39 i64 size; 40 i64 status; 41 i64 file_size; 42 md5 hash; 43 md5 hash_16k; 44 u16 filename[1]; 45 }; 46 47 struct pfile_s { 48 pfile_t *next; 49 i64 status; 50 i64 file_size; 51 md5 hash_16k; 52 md5 hash; 53 i64 vol_number; 54 u16 *filename; 55 file_t f; 56 hfile_t *match; 57 u16 *fnrs; 58 }; 59 60 extern struct cmdline { 61 int action; 62 int loglevel; 63 int volumes; /*\ Number of volumes to create \*/ 64 65 int pervol : 1; /*\ volumes is actually files per volume \*/ 66 int plus :1; /*\ Turn on or off options (with + or -) \*/ 67 int move :1; /*\ Move away files that are in the way \*/ 68 int fix :1; /*\ Fix files with bad filenames \*/ 69 int usecase :1; /*\ Compare filenames without case \*/ 70 int dupl :1; /*\ Check for duplicate files \*/ 71 int add :1; /*\ Don't add files to PXX volumes \*/ 72 int pxx :1; /*\ Create PXX volumes \*/ 73 int ctrl :1; /*\ Check/create control hash \*/ 74 int keep :1; /*\ Keep broken files \*/ 75 int smart :1; /*\ Try to be smart about filenames \*/ 76 int dash :1; /*\ End of cmdline switches \*/ 77 } cmd; 78 79 #define ACTION_CHECK 01 /*\ Check PAR files \*/ 80 #define ACTION_RESTORE 02 /*\ Restore missing files \*/ 81 #define ACTION_MIX 03 /*\ Try to use a mix of all PAR files \*/ 82 #define ACTION_ADD 11 /*\ Create a PAR archive ... \*/ 83 #define ACTION_ADDING 12 /*\ ... and add files to it. \*/ 84 #define ACTION_TEXT_UI 20 /*\ Interactive text interface \*/ 85 86 #define PAR_MAGIC (*((i64 *)"PAR\0\0\0\0\0")) 87 #define IS_PAR(x) (((x).magic) == PAR_MAGIC) 88 89 #define CMP_MD5(a,b) (!memcmp((a), (b), sizeof(md5))) 90 91 #define USE_FILE(p) ((p)->status & 0x1) 92 93 #endif /* PAR_H */ 94