home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / star / table.c < prev    next >
C/C++ Source or Header  |  1996-06-26  |  4KB  |  153 lines

  1. /* @(#)table.c    1.7 96/06/26 Copyright 1994 J. Schilling */
  2. #ifndef lint
  3. static    char sccsid[] =
  4.     "@(#)table.c    1.7 96/06/26 Copyright 1994 J. Schilling";
  5. #endif
  6. /*
  7.  *    Conversion tables for efficient conversion
  8.  *    of different file type representations
  9.  *
  10.  *    Copyright (c) 1994 J. Schilling
  11.  */
  12. /*
  13.  * This program is free software; you can redistribute it and/or modify
  14.  * it under the terms of the GNU General Public License as published by
  15.  * the Free Software Foundation; either version 2, or (at your option)
  16.  * any later version.
  17.  *
  18.  * This program is distributed in the hope that it will be useful,
  19.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  * GNU General Public License for more details.
  22.  *
  23.  * You should have received a copy of the GNU General Public License
  24.  * along with this program; see the file COPYING.  If not, write to
  25.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  */
  27.  
  28. #include "star.h"
  29. #include "table.h"
  30. #include <sys/stat.h>
  31.  
  32. #ifndef    S_IFIFO            /* If system knows no fifo's        */
  33. #define    S_IFIFO        S_IFREG    /* Map fifo's to regular files         */
  34. #endif
  35. #ifndef    S_IFNAM            /* If system knows no named files    */
  36. #define    S_IFNAM        S_IFREG    /* Map named files to regular files     */
  37. #endif
  38. #ifndef    S_IFCNT            /* If system knows no contiguous files    */
  39. #define    S_IFCNT        S_IFREG    /* Map contiguous file to regular files */
  40. #endif
  41. #ifndef    S_IFLNK            /* If system knows no symbolic links    */
  42. #define    S_IFLNK        S_IFREG    /* Map symbolic links to regular files */
  43. #endif
  44. #ifndef    S_IFSOCK        /* If system knows no fifo's        */
  45. #define    S_IFSOCK    S_IFREG    /* Map fifo's to regular files         */
  46. #endif
  47. #define    S_IFBAD    S_IFMT        /* XXX Have to use another val if someone */
  48.                 /* XXX starts to use S_IFMT for a */
  49.                 /* XXX useful file type */
  50. #define    XT_NAM    XT_BAD        /* XXX JS has not seen it yet */
  51.                 /* XXX if we use it, we have to change */
  52.                 /* XXX table.h and some of the tables below */
  53.  
  54. /*
  55.  * UNIX File type to XT_ table
  56.  */
  57. char    iftoxt_tab[] = {            
  58.             XT_NONE, XT_FIFO, XT_CHR,   XT_BAD,
  59.             XT_DIR,  XT_NAM,  XT_BLK,   XT_BAD,
  60.             XT_FILE, XT_CONT, XT_SLINK, XT_BAD,
  61.             XT_SOCK, XT_BAD,  XT_BAD,   XT_BAD,
  62.             };
  63.  
  64. /*
  65.  * Ustar File type to XT_ table
  66.  */
  67. char    ustoxt_tab[] = {
  68.             XT_FILE, XT_LINK, XT_SLINK, XT_CHR,
  69.             XT_BLK,  XT_DIR,  XT_FIFO,  XT_CONT,
  70. };
  71.  
  72. /*
  73.  * Gnutar File type to XT_ table
  74.  */
  75. char    gttoxt_tab[] = {
  76.         /* A */    XT_NONE,     XT_NONE,   XT_NONE,     XT_DUMPDIR,
  77.         /* E */    XT_NONE,     XT_NONE,   XT_NONE,     XT_NONE,
  78.         /* I */    XT_NONE,     XT_NONE,   XT_LONGLINK, XT_LONGNAME,
  79.         /* M */    XT_MULTIVOL, XT_NAMES,  XT_NONE,     XT_NONE,
  80.         /* Q */    XT_NONE,     XT_NONE,   XT_SPARSE,   XT_NONE,
  81.         /* U */    XT_NONE,     XT_VOLHDR, XT_NONE,     XT_NONE,
  82.         /* Y */    XT_NONE,     XT_NONE, 
  83. };
  84.  
  85. /*
  86.  * XT_ to UNIX File type table
  87.  */
  88. int    xttoif_tab[] = {
  89.             0,       S_IFREG,  S_IFCNT, S_IFREG,
  90.             S_IFLNK, S_IFDIR,  S_IFCHR, S_IFBLK,
  91.             S_IFIFO, S_IFSOCK, S_IFBAD, S_IFBAD,
  92.             S_IFBAD, S_IFBAD,  S_IFBAD, S_IFBAD,
  93.             S_IFBAD, S_IFBAD,  S_IFBAD, S_IFBAD,
  94.             S_IFDIR, S_IFBAD,  S_IFBAD, S_IFBAD,
  95.             S_IFBAD, S_IFBAD,  S_IFBAD, S_IFBAD,
  96.             S_IFBAD, S_IFBAD,  S_IFBAD, S_IFBAD,
  97.             };
  98.  
  99. /*
  100.  * XT_ to Star File type table
  101.  */
  102. char    xttost_tab[] = {
  103.         /* 0 */    0,       F_FILE, F_FILE, F_FILE,
  104.         /* 4 */    F_SLINK, F_DIR,  F_SPEC, F_SPEC,
  105.         /* 8 */    F_SPEC,  F_SPEC, F_SPEC, F_SPEC,
  106.         /*12 */    F_SPEC,  F_SPEC, F_SPEC, F_SPEC,
  107.         /*16 */    F_SPEC,  F_SPEC, F_SPEC, F_SPEC,
  108.         /*20 */    F_DIR,   F_FILE, F_FILE, F_FILE,
  109.         /*24 */    F_FILE,  F_FILE, F_SPEC, F_SPEC,
  110.         /*28 */    F_SPEC,  F_SPEC, F_SPEC, F_SPEC,
  111.             };
  112.  
  113. /*
  114.  * XT_ to Ustar File type table
  115.  *
  116.  * sockets cannot be handled in ansi tar, they are handled as regular files :-(
  117.  */
  118. char    xttous_tab[] = {
  119.             0,       REGTYPE, CONTTYPE, LNKTYPE,
  120.             SYMTYPE, DIRTYPE, CHRTYPE,  BLKTYPE,
  121.             FIFOTYPE,REGTYPE/* socket */, 0/* bad */, 0/* bad */,
  122.             0,       0,       0,        0,
  123.             0,       0,       0,        0,
  124.             LF_DUMPDIR, LF_LONGLINK, LF_LONGNAME, LF_MULTIVOL,
  125.             LF_NAMES,   LF_SPARSE,   LF_VOLHDR,   0,
  126.             0,       0,       0,        0,
  127.             };
  128.  
  129. /*
  130.  * XT_ to String table
  131.  */
  132. char    *xttostr_tab[] = {
  133. #define    XT_DEBUG
  134. #ifdef    XT_DEBUG
  135.             "U",    "-",    "C",    "H",
  136. #else
  137.             "-",    "-",    "-",    "-",
  138. #endif
  139.             "l",    "d",    "c",    "b",
  140.             "p",    "s",    "~",    "~",
  141.             "~",    "~",    "~",    "~",
  142.             "~",    "~",    "~",    "~",
  143.  
  144.             "D",    "K",    "L",    "M",
  145. #ifdef    XT_DEBUG
  146.             "N",    "S",    "V",    "~",
  147. #else
  148.             "N",    "-",    "V",    "~",
  149. #endif
  150.  
  151.             "~",    "~",    "~",    "~",
  152.             };
  153.