1 /******************************************************************************\ 2 * * 3 * UniPKG (c) iSteve <isteve@bofh.cz>, 2005 * 4 * * 5 * Universal PacKaGer. * 6 * Licensed under GNU/GPL - if you don't like the software, fix it! * 7 * * 8 \******************************************************************************/ 9 10 typedef struct { 11 char *name; 12 char *linktarget; 13 mode_t mode; 14 time_t time; 15 int ftype; 16 uid_t uid; 17 gid_t gid; 18 19 off_t filesize; // size of the given file 20 off_t upfilesize; // unpacked filesize, because we do it per partes 21 22 unsigned long dmajor; 23 unsigned long dminor; 24 off_t nextblock; 25 26 void *internal; // pointer to internal archive description 27 int stage; // internal data; info about stage progress 28 int atype; // internal data; type of archive 29 int longheader; // it has taken more than one block; do not clear 30 } comarchive; 31 32 #define AF_UNDEFINED -1 33 #define AF_REGULAR 0 34 #define AF_DIRECTORY 1 35 #define AF_DEVNODE 2 36 #define AF_FIFOBUF 3 37 #define AF_SOCKET 4 38 #define AF_SYMLINK 5 39 40 #define AT_AR 0 41 #define AT_TAR 1 42 #define AT_CPIO 2 43 44 #define AS_HEADER 0 // Need headers to continue 45 #define AS_MOREHEAD 1 // More headers necessary 46 #define AS_DATA 2 // File data is in the archive next... 47 #define AS_NEWFILE 3 // New file freshly parsed from headers 48 49 #define TARPAD(x) ((512 - (x % 512)) == 512 ? 0 : (512 - (x % 512))) 50 #define CPIOPAD(x) ((4 - ((x) & 3)) & 3) 51 52 comarchive *init_archive(int atype); 53 void deinit_archive(comarchive *carchive); 54 void clear_archive_member(comarchive *carchive); 55 56 void update_nextblock(comarchive *carchive); 57 void update_stage(comarchive *carchive); 58 void update_upfilesize(comarchive *carchive); 59 60 int parse_block(comarchive *carchive, char *block);