]>
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. */
33 getoldopt(argc
, argv
, optstring
, long_options
, opt_index
)
37 struct option
*long_options
;
40 extern char *optarg
; /* Points to next arg */
41 extern int optind
; /* Global argv index */
42 static char *key
; /* Points to next keyletter */
43 static char use_getopt
; /* !=0 if argv[1][0] was '-' */
50 if (key
== NULL
) { /* First time */
51 if (argc
< 2) return EOF
;
53 if ((*key
== '-') || (*key
== '+'))
60 return getopt_long(argc
, argv
, optstring
,
61 long_options
, opt_index
);
68 place
= index(optstring
, c
);
70 if (place
== NULL
|| c
== ':') {
71 msg("unknown option %c", c
);
78 optarg
= argv
[optind
];
81 msg("%c argument missing", c
);
This page took 0.038006 seconds and 5 git commands to generate.