English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/freewrt_1_0/tools/paxmirabilis/src/options.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3815 by tg, Tue Jun 5 14:52:44 2007 UTC revision 3816 by tg, Wed Oct 29 17:58:40 2008 UTC
# Line 1  Line 1 
1  /**     $MirOS: src/bin/pax/options.c,v 1.24 2007/02/17 04:52:41 tg Exp $ */  /*      $OpenBSD: options.c,v 1.67 2007/02/24 09:50:55 jmc Exp $        */
 /*      $OpenBSD: options.c,v 1.64 2006/04/09 03:35:34 jaredy Exp $     */  
2  /*      $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $  */  /*      $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $  */
3    
4  /*-  /*-
# Line 57  Line 56 
56  #include "extern.h"  #include "extern.h"
57    
58  __SCCSID("@(#)options.c 8.2 (Berkeley) 4/18/94");  __SCCSID("@(#)options.c 8.2 (Berkeley) 4/18/94");
59  __RCSID("$MirOS: src/bin/pax/options.c,v 1.24 2007/02/17 04:52:41 tg Exp $");  __RCSID("$MirOS: src/bin/pax/options.c,v 1.27 2008/10/29 17:00:07 tg Exp $");
60    
61  #ifdef __GLIBC__  #ifdef __GLIBC__
62  char *fgetln(FILE *, size_t *);  char *fgetln(FILE *, size_t *);
# Line 174  int anonarch = 0; Line 173  int anonarch = 0;
173  int to_stdout = 0;  int to_stdout = 0;
174    
175  /*  /*
176     * Do we have -C anywhere?
177     */
178    int havechd = 0;
179    
180    /*
181   * options()   * options()
182   *      figure out if we are pax, tar or cpio. Call the appropriate options   *      figure out if we are pax, tar or cpio. Call the appropriate options
183   *      parser   *      parser
# Line 182  int to_stdout = 0; Line 186  int to_stdout = 0;
186  void  void
187  options(int argc, char **argv)  options(int argc, char **argv)
188  {  {
189            size_t n;
190    
191          /*          /*
192           * Are we acting like pax, tar or cpio (based on argv[0])           * Are we acting like pax, tar or cpio (based on argv[0])
193           */           */
194          if ((argv0 = strrchr(argv[0], '/')) != NULL)          if ((n = strlen(argv[0])) >= 3 && !strcmp(argv[0] + n - 3, NM_TAR)) {
195                  argv0++;                  argv0 = NM_TAR;
         else  
                 argv0 = argv[0];  
   
         if (strcmp(NM_TAR, argv0) == 0) {  
196                  tar_options(argc, argv);                  tar_options(argc, argv);
197                  return;          } else if (n >= 4 && !strcmp(argv[0] + n - 4, NM_CPIO)) {
198          } else if (strcmp(NM_CPIO, argv0) == 0) {                  argv0 = NM_CPIO;
199                  cpio_options(argc, argv);                  cpio_options(argc, argv);
200                  return;          } else {
201                    argv0 = NM_PAX;
202                    pax_options(argc, argv);
203          }          }
         /*  
          * assume pax as the default  
          */  
         argv0 = NM_PAX;  
         pax_options(argc, argv);  
204  }  }
205    
206  /*  /*
# Line 382  pax_options(int argc, char **argv) Line 380  pax_options(int argc, char **argv)
380                          /*                          /*
381                           * verbose operation mode                           * verbose operation mode
382                           */                           */
383                          vflag = 1;                          vflag++;
384                          flg |= VF;                          flg |= VF;
385                          break;                          break;
386                  case 'w':                  case 'w':
# Line 793  tar_options(int argc, char **argv) Line 791  tar_options(int argc, char **argv)
791                           */                           */
792                          break;                          break;
793                  case 'C':                  case 'C':
794                            havechd++;
795                          chdname = optarg;                          chdname = optarg;
796                          break;                          break;
797                  case 'H':                  case 'H':
# Line 940  tar_options(int argc, char **argv) Line 939  tar_options(int argc, char **argv)
939                                          if (*++argv == NULL)                                          if (*++argv == NULL)
940                                                  break;                                                  break;
941                                          chdname = *argv++;                                          chdname = *argv++;
942                                            havechd++;
943                                  } else if (pat_add(*argv++, chdname) < 0)                                  } else if (pat_add(*argv++, chdname) < 0)
944                                          tar_usage();                                          tar_usage();
945                                  else                                  else
# Line 1037  tar_options(int argc, char **argv) Line 1037  tar_options(int argc, char **argv)
1037                                          break;                                          break;
1038                                  if (ftree_add(*argv++, 1) < 0)                                  if (ftree_add(*argv++, 1) < 0)
1039                                          tar_usage();                                          tar_usage();
1040                                    havechd++;
1041                          } else if (ftree_add(*argv++, 0) < 0)                          } else if (ftree_add(*argv++, 0) < 0)
1042                                  tar_usage();                                  tar_usage();
1043                  }                  }
# Line 1217  cpio_options(int argc, char **argv) Line 1218  cpio_options(int argc, char **argv)
1218                                  /*                                  /*
1219                                   * verbose operation mode                                   * verbose operation mode
1220                                   */                                   */
1221                                  vflag = 1;                                  vflag++;
1222                                  break;                                  break;
1223                          case 'z':                          case 'z':
1224                                  /*                                  /*
# Line 1636  void Line 1637  void
1637  pax_usage(void)  pax_usage(void)
1638  {  {
1639          (void)fputs(          (void)fputs(
1640              "usage: pax [-0cdOnRSvz] [-E limit] [-f archive] [-G group] [-s replstr]\n"              "usage: pax [-0cdnOvz] [-E limit] [-f archive] [-G group] [-s replstr]\n"
1641              "\t  [-T [from_date][,to_date][/[c][m]]] [-U user] [pattern ...]\n"              "\t  [-T range] [-U user] [pattern ...]\n"
1642              "       pax -r [-0cDdikOnuvzYZz] [-E limit] [-f archive] [-G group]\n"              "       pax -r [-0cDdiknOuvYZz] [-E limit] [-f archive] [-G group]\n"
1643              "\t  [-o options] [-p string] [-s replstr] [-T [from_date][,to_date]]\n"              "\t  [-o options] [-p string] [-s replstr] [-T range]\n"
1644              "\t  [-U user] [pattern ...]\n"              "\t  [-U user] [pattern ...]\n"
1645              "       pax -w [-0adHiLOPtuvXz] [-B bytes] [-b blocksize] [-f archive]\n"              "       pax -w [-0adHiLOPtuvXz] [-B bytes] [-b blocksize] [-f archive]\n"
1646              "\t  [-G group] [-M value] [-o options] [-s replstr]\n"              "\t  [-G group] [-M flag] [-o options] [-s replstr]\n"
1647              "\t  [-T [from_date][,to_date][/[c][m]]] [-U user] [-x format] [file ...]\n"              "\t  [-T range] [-U user] [-x format] [file ...]\n"
1648              "       pax -r -w [-0DdHikLlnOPtuvXYZ] [-G group] [-p string] [-s replstr]\n"              "       pax -rw [-0DdHikLlnOPtuvXYZ] [-G group] [-p string] [-s replstr]\n"
1649              "\t  [-T [from_date][,to_date][/[c][m]]] [-U user] [file ...] directory\n",              "\t  [-T range] [-U user] [file ...] directory\n",
1650              stderr);              stderr);
1651          exit(1);          exit(1);
1652  }  }
# Line 1659  void Line 1660  void
1660  tar_usage(void)  tar_usage(void)
1661  {  {
1662          (void)fputs(          (void)fputs(
1663              "usage: tar {crtux}[014578befHhLmOoPpqsvwXZz]\n"              "usage: tar {crtux}[014578befHhLmOoPpqRSsvwXZz]\n"
1664              "\t  [blocking-factor | archive | replstr] [-C directory] [-I file]\n"              "\t  [blocking-factor | archive | replstr] [-C directory] [-I file]\n"
1665              "\t  [file ...]\n"              "\t  [file ...]\n"
1666              "       tar {-crtux} [-014578eHhLmOoPpqvwXZz] [-b blocking-factor] [-M value]\n"              "       tar {-crtux} [-014578eHhLmOoPpqRSvwXZz] [-b blocking-factor] [-M flag]\n"
1667              "\t  [-C directory] [-f archive] [-I file] [-s replstr] [file ...]\n",              "\t  [-C directory] [-f archive] [-I file] [-s replstr] [file ...]\n",
1668              stderr);              stderr);
1669          exit(1);          exit(1);
# Line 1676  tar_usage(void) Line 1677  tar_usage(void)
1677  void  void
1678  cpio_usage(void)  cpio_usage(void)
1679  {  {
1680          (void)fputs("usage: cpio -o [-aABcLvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr);          (void)fputs("usage: cpio -o [-AaBcLvZz] [-C bytes] [-F archive] [-H format]\n", stderr);
1681          (void)fputs("               [-M flag] [-F archive] <name-list [>archive]\n", stderr);          (void)fputs("               [-M flag] [-O archive] <name-list [>archive]\n", stderr);
1682          (void)fputs("       cpio -i [-bBcdfmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr);          (void)fputs("       cpio -i [-6BbcdfmrSstuvZz] [-C bytes] [-E file] [-F archive]\n", stderr);
1683          (void)fputs("               [-I archive] [-F archive] [pattern...] [<archive]\n", stderr);          (void)fputs("               [-H format] [-I archive] [pattern...] [<archive]\n", stderr);
1684          (void)fputs("       cpio -p [-adlLmuvV] destination-directory <name-list\n", stderr);          (void)fputs("       cpio -p [-adLlmuv] destination-directory <name-list\n", stderr);
1685          exit(1);          exit(1);
1686  }  }
1687    

Legend:
Removed from v.3815  
changed lines
  Added in v.3816

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20