]>
Dogcows Code - chaz/tar/blob - src/getoldopt.c
1 /* Replacement for getopt() that can be used by tar.
2 Copyright (C) 1988 Free Software Foundation
4 This file is part of GNU Tar.
6 GNU Tar is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Tar is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Tar; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * Plug-compatible replacement for getopt() for parsing tar-like
22 * arguments. If the first argument begins with "-", it uses getopt;
23 * otherwise, it uses the old rules used by tar, dump, and ps.
25 * Written 25 August 1985 by John Gilmore (ihnp4!hoptoad!gnu)
30 #include "tar.h" /* For msg() declaration if STDC_MSG. */
31 #include <sys/types.h>
35 getoldopt (argc
, argv
, optstring
, long_options
, opt_index
)
39 struct option
*long_options
;
42 extern char *optarg
; /* Points to next arg */
43 extern int optind
; /* Global argv index */
44 static char *key
; /* Points to next keyletter */
45 static char use_getopt
; /* !=0 if argv[1][0] was '-' */
56 if ((*key
== '-') || (*key
== '+'))
63 return getopt_long (argc
, argv
, optstring
,
64 long_options
, opt_index
);
72 place
= index (optstring
, c
);
74 if (place
== NULL
|| c
== ':')
76 msg ("unknown option %c", c
);
85 optarg
= argv
[optind
];
90 msg ("%c argument missing", c
);
This page took 0.038081 seconds and 4 git commands to generate.