home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2003 May / VPR0305.ISO / OLS / TAR32223 / tar32223.lzh / tar32_2 / src / tar.h < prev    next >
C/C++ Source or Header  |  2003-01-17  |  2KB  |  95 lines

  1. #ifndef __TAR_H
  2. #define __TAR_H
  3.  
  4. /*
  5.  * tar header block definition
  6.  *
  7.  * From IEEE Std 1003.1-1988, pp.156
  8.  */
  9.  
  10.  
  11. #define    TMAGIC        "ustar"
  12. #define    TMAGLEN        6
  13.  
  14. #define    TOMAGIC        "ustar  "
  15. #define    TOMAGLEN    8
  16.  
  17. #define    TVERSION    "00"
  18. #define    TVERSLEN    2
  19.  
  20. #define    REGTYPE        '0'    /* Regular file */
  21. #define    AREGTYPE    '\0'    /* Regular file; old V7 format */
  22. #define    LNKTYPE        '1'    /* Link */
  23. #define    SYMTYPE        '2'    /* Symbolic link */
  24. #define    CHRTYPE        '3'    /* Character special */
  25. #define    BLKTYPE        '4'    /* Block special */
  26. #define    DIRTYPE        '5'    /* Directory */
  27. #define    FIFOTYPE    '6'    /* FIFO special */
  28. #define    CONTTYPE    '7'    /* Continguous file */
  29. #define LONGLINK    'L' /* Long name Link by tantan*/
  30.  
  31.  
  32. #define    MULTYPE        'M'    /* Added by GNUtar, not POSIX */
  33. #define    VOLTYPE        'V'    /* Added by GNUtar, not POSIX */
  34.  
  35.  
  36. #define    TSUID        04000    /* Set UID on execution */
  37. #define    TSGID        02000    /* Set GID on execution */
  38. #define    TSVTX        01000    /* Reserved */
  39.                 /* File permissions */
  40. #define    TUREAD        00400    /* read by owner */
  41. #define    TUWRITE        00200    /* write by owner */
  42. #define    TUEXEC        00100    /* execute/search by owner */
  43. #define    TGREAD        00040    /* read by group */
  44. #define    TGWRITE        00020    /* write by group */
  45. #define    TGEXEC        00010    /* execute/search by group */
  46. #define    TOREAD        00004    /* read by other */
  47. #define    TOWRITE        00002    /* write by other */
  48. #define    TOEXEC        00001    /* execute/search by other */
  49.  
  50.  
  51. #define    TBLOCK    512
  52. #define    NAMSIZ    100
  53.  
  54. typedef    union    hblock    {
  55.     char    dummy[TBLOCK];
  56.     struct    {
  57.         char    name[NAMSIZ];
  58.         char    mode[8];
  59.         char    uid[8];
  60.         char    gid[8];
  61.         char    size[12];
  62.         char    mtime[12];
  63.         char    chksum[8];
  64.         char    typeflag;
  65.         char    linkname[NAMSIZ];
  66.         char    magic[6];
  67.         char    version[2];
  68.         char    uname[32];
  69.         char    gname[32];
  70.         char    devmajor[8];
  71.         char    devminor[8];
  72.     /* Following fields were added by GNUtar */
  73.         char    atime[12];
  74.         char    ctime[12];
  75.         char    offset[12];
  76.     } dbuf;
  77.     unsigned int compsum(){
  78.         unsigned int sum = 0;
  79.         int i;
  80.         for(i=0;i<TBLOCK;i++){
  81.             sum += (unsigned char)dummy[i];
  82.         }
  83.         /* calc without checksum field */
  84.         for(i=0;i<sizeof(dbuf.chksum);i++){
  85.             sum -= dbuf.chksum[i];
  86.             sum += ' ';
  87.         }
  88.         return sum;
  89.     }
  90. } HEADER;
  91.  
  92.  
  93.  
  94. #endif    /* __TAR_H */
  95.