Deleted Added
full compact
options.c (90110) options.c (90113)
1/*
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 26 unchanged lines hidden (view full) ---

35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
41#endif
42static const char rcsid[] =
1/*
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 26 unchanged lines hidden (view full) ---

35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
41#endif
42static const char rcsid[] =
43 "$FreeBSD: head/bin/pax/options.c 90110 2002-02-02 06:48:10Z imp $";
43 "$FreeBSD: head/bin/pax/options.c 90113 2002-02-02 07:07:59Z imp $";
44#endif /* not lint */
45
46#include <sys/types.h>
47#include <sys/stat.h>
48#include <sys/mtio.h>
49#include <stdio.h>
50#include <string.h>
51#include <errno.h>

--- 15 unchanged lines hidden (view full) ---

67static OPLIST *ophead = NULL; /* head for format specific options -x */
68static OPLIST *optail = NULL; /* option tail */
69
70static int no_op(void);
71static void printflg(unsigned int);
72static int c_frmt(const void *, const void *);
73static off_t str_offt(char *);
74static char *getline(FILE *fp);
44#endif /* not lint */
45
46#include <sys/types.h>
47#include <sys/stat.h>
48#include <sys/mtio.h>
49#include <stdio.h>
50#include <string.h>
51#include <errno.h>

--- 15 unchanged lines hidden (view full) ---

67static OPLIST *ophead = NULL; /* head for format specific options -x */
68static OPLIST *optail = NULL; /* option tail */
69
70static int no_op(void);
71static void printflg(unsigned int);
72static int c_frmt(const void *, const void *);
73static off_t str_offt(char *);
74static char *getline(FILE *fp);
75static void pax_options(register int, register char **);
75static void pax_options(int, char **);
76static void pax_usage(void);
76static void pax_usage(void);
77static void tar_options(register int, register char **);
77static void tar_options(int, char **);
78static void tar_usage(void);
78static void tar_usage(void);
79static void cpio_options(register int, register char **);
79static void cpio_options(int, char **);
80static void cpio_usage(void);
81
82/* errors from getline */
83#define GETLINE_FILE_CORRUPT 1
84#define GETLINE_OUT_OF_MEM 2
85static int getline_error;
86
87

--- 57 unchanged lines hidden (view full) ---

145
146/*
147 * options()
148 * figure out if we are pax, tar or cpio. Call the appropriate options
149 * parser
150 */
151
152void
80static void cpio_usage(void);
81
82/* errors from getline */
83#define GETLINE_FILE_CORRUPT 1
84#define GETLINE_OUT_OF_MEM 2
85static int getline_error;
86
87

--- 57 unchanged lines hidden (view full) ---

145
146/*
147 * options()
148 * figure out if we are pax, tar or cpio. Call the appropriate options
149 * parser
150 */
151
152void
153options(register int argc, register char **argv)
153options(int argc, char **argv)
154{
155
156 /*
157 * Are we acting like pax, tar or cpio (based on argv[0])
158 */
159 if ((argv0 = strrchr(argv[0], '/')) != NULL)
160 argv0++;
161 else

--- 12 unchanged lines hidden (view full) ---

174
175/*
176 * pax_options()
177 * look at the user specified flags. set globals as required and check if
178 * the user specified a legal set of flags. If not, complain and exit
179 */
180
181static void
154{
155
156 /*
157 * Are we acting like pax, tar or cpio (based on argv[0])
158 */
159 if ((argv0 = strrchr(argv[0], '/')) != NULL)
160 argv0++;
161 else

--- 12 unchanged lines hidden (view full) ---

174
175/*
176 * pax_options()
177 * look at the user specified flags. set globals as required and check if
178 * the user specified a legal set of flags. If not, complain and exit
179 */
180
181static void
182pax_options(register int argc, register char **argv)
182pax_options(int argc, char **argv)
183{
183{
184 register int c;
185 register int i;
184 int c;
185 int i;
186 unsigned int flg = 0;
187 unsigned int bflg = 0;
186 unsigned int flg = 0;
187 unsigned int bflg = 0;
188 register char *pt;
188 char *pt;
189 FSUB tmp;
190
191 /*
192 * process option flags
193 */
194 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ"))
195 != -1) {
196 switch (c) {

--- 375 unchanged lines hidden (view full) ---

572
573/*
574 * tar_options()
575 * look at the user specified flags. set globals as required and check if
576 * the user specified a legal set of flags. If not, complain and exit
577 */
578
579static void
189 FSUB tmp;
190
191 /*
192 * process option flags
193 */
194 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ"))
195 != -1) {
196 switch (c) {

--- 375 unchanged lines hidden (view full) ---

572
573/*
574 * tar_options()
575 * look at the user specified flags. set globals as required and check if
576 * the user specified a legal set of flags. If not, complain and exit
577 */
578
579static void
580tar_options(register int argc, register char **argv)
580tar_options(int argc, char **argv)
581{
581{
582 register int c;
582 int c;
583 int fstdin = 0;
584 int Oflag = 0;
585 int nincfiles = 0;
586 int incfiles_max = 0;
587 struct incfile {
588 char *file;
589 char *dir;
590 };

--- 378 unchanged lines hidden (view full) ---

969 }
970}
971
972int
973mkpath(path)
974 char *path;
975{
976 struct stat sb;
583 int fstdin = 0;
584 int Oflag = 0;
585 int nincfiles = 0;
586 int incfiles_max = 0;
587 struct incfile {
588 char *file;
589 char *dir;
590 };

--- 378 unchanged lines hidden (view full) ---

969 }
970}
971
972int
973mkpath(path)
974 char *path;
975{
976 struct stat sb;
977 register char *slash;
977 char *slash;
978 int done = 0;
979
980 slash = path;
981
982 while (!done) {
983 slash += strspn(slash, "/");
984 slash += strcspn(slash, "/");
985

--- 18 unchanged lines hidden (view full) ---

1004}
1005/*
1006 * cpio_options()
1007 * look at the user specified flags. set globals as required and check if
1008 * the user specified a legal set of flags. If not, complain and exit
1009 */
1010
1011static void
978 int done = 0;
979
980 slash = path;
981
982 while (!done) {
983 slash += strspn(slash, "/");
984 slash += strcspn(slash, "/");
985

--- 18 unchanged lines hidden (view full) ---

1004}
1005/*
1006 * cpio_options()
1007 * look at the user specified flags. set globals as required and check if
1008 * the user specified a legal set of flags. If not, complain and exit
1009 */
1010
1011static void
1012cpio_options(register int argc, register char **argv)
1012cpio_options(int argc, char **argv)
1013{
1013{
1014 register int c, i;
1014 int c, i;
1015 char *str;
1016 FSUB tmp;
1017 FILE *fp;
1018
1019 kflag = 1;
1020 pids = 1;
1021 pmode = 1;
1022 pmtime = 0;

--- 294 unchanged lines hidden (view full) ---

1317 * bad_opt()
1318 * generic routine used to complain about a format specific options
1319 * when the format does not support options.
1320 */
1321
1322int
1323bad_opt(void)
1324{
1015 char *str;
1016 FSUB tmp;
1017 FILE *fp;
1018
1019 kflag = 1;
1020 pids = 1;
1021 pmode = 1;
1022 pmtime = 0;

--- 294 unchanged lines hidden (view full) ---

1317 * bad_opt()
1318 * generic routine used to complain about a format specific options
1319 * when the format does not support options.
1320 */
1321
1322int
1323bad_opt(void)
1324{
1325 register OPLIST *opt;
1325 OPLIST *opt;
1326
1327 if (ophead == NULL)
1328 return(0);
1329 /*
1330 * print all we were given
1331 */
1332 paxwarn(1,"These format options are not supported");
1333 while ((opt = opt_next()) != NULL)

--- 7 unchanged lines hidden (view full) ---

1341 * breaks the value supplied to -o into a option name and value. options
1342 * are given to -o in the form -o name-value,name=value
1343 * multiple -o may be specified.
1344 * Return:
1345 * 0 if format in name=value format, -1 if -o is passed junk
1346 */
1347
1348int
1326
1327 if (ophead == NULL)
1328 return(0);
1329 /*
1330 * print all we were given
1331 */
1332 paxwarn(1,"These format options are not supported");
1333 while ((opt = opt_next()) != NULL)

--- 7 unchanged lines hidden (view full) ---

1341 * breaks the value supplied to -o into a option name and value. options
1342 * are given to -o in the form -o name-value,name=value
1343 * multiple -o may be specified.
1344 * Return:
1345 * 0 if format in name=value format, -1 if -o is passed junk
1346 */
1347
1348int
1349opt_add(register char *str)
1349opt_add(char *str)
1350{
1350{
1351 register OPLIST *opt;
1352 register char *frpt;
1353 register char *pt;
1354 register char *endpt;
1351 OPLIST *opt;
1352 char *frpt;
1353 char *pt;
1354 char *endpt;
1355
1356 if ((str == NULL) || (*str == '\0')) {
1357 paxwarn(0, "Invalid option name");
1358 return(-1);
1359 }
1360 if ((str = strdup(str)) == NULL) {
1361 paxwarn(0, "Unable to allocate space for option list");
1362 return(-1);

--- 216 unchanged lines hidden ---
1355
1356 if ((str == NULL) || (*str == '\0')) {
1357 paxwarn(0, "Invalid option name");
1358 return(-1);
1359 }
1360 if ((str = strdup(str)) == NULL) {
1361 paxwarn(0, "Unable to allocate space for option list");
1362 return(-1);

--- 216 unchanged lines hidden ---