1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either package_version 2
9 of the License, or (at your option) any later package_version.
11 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 Dr. David Kirkby, e-mail drkirkby at gmail.com
27 * Here's something you've all been waiting for: the AT&T public domain
28 * source for getopt(3). It is the code which was given out at the 1985
29 * UNIFORUM conference in Dallas. I obtained it by electronic mail
30 * directly from AT&T. The people there assure me that it is indeed
31 * in the public domain.
33 * There is no manual page. That is because the one they gave out at
34 * UNIFORUM was slightly different from the current System V Release 2
35 * manual page. The difference apparently involved a note about the
36 * famous rules 5 and 6, recommending using white space between an option
37 * and its first argument, and not grouping options that have arguments.
38 * Getopt itself is currently lenient about both of these things White
39 * space is allowed, but not mandatory, and the last option in a group can
40 * have an argument. That particular package_version of the man page evidently
41 * has no official existence, and my source at AT&T did not send a copy.
42 * The current SVR2 man page reflects the actual behavor of this getopt.
43 * However, I am not about to post a copy of anything licensed by AT&T.
48 #include "definitions.h"
70 void ERR(const char *s, char c, char **argv)
77 /* (void) write(2, argv[0], (unsigned)strlen(argv[0]));
78 (void) write(2, s, (unsigned)strlen(s));
79 (void) write(2, errbuf, 2); */
80 (void) fwrite(argv[0], (unsigned)strlen(argv[0]),1,stderr);
81 (void) fwrite(s, (unsigned)strlen(s),1,stderr);
82 (void) fwrite(errbuf, 2, 1,stderr);
86 char *index2(const char *str, char c)
89 ret=strchr((char *) str,c);
94 int get_options(int argc, char **argv, const char *opts)
106 if(my_optind >= argc ||
107 argv[my_optind][0] != '-' || argv[my_optind][1] == '\0')
109 else if(strcmp(argv[my_optind], "--") == 0) {
114 my_optopt = c = argv[my_optind][sp];
115 if(c == ':' || (cp=index2((char *) opts, c)) == NULL) {
116 ERR(": illegal option -- ", c,argv);
117 if(argv[my_optind][++sp] == '\0') {
124 if(argv[my_optind][sp+1] != '\0')
125 my_optarg = &argv[my_optind++][sp+1];
126 else if(++my_optind >= argc) {
127 ERR(": option requires an argument -- ", c,argv);
131 my_optarg = argv[my_optind++];
134 if(argv[my_optind][++sp] == '\0') {