]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/reveng/getopt.c
1 /*----------------------------------------------------------------------
3 Replacement for Unix "getopt()", for DOS/Windows/etc.
5 getopt.c 1.3 2003/09/17 16:17:59
7 Copyright (C) 1998, 2003 by David A. Hinds -- All Rights Reserved
9 This file is part of ASPEX.
11 ASPEX is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 ASPEX is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with ASPEX; if not, write to the Free Software Foundation,
23 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ----------------------------------------------------------------------*/
32 int optind
= 1, opterr
, optopt
;
34 int getopt(int argc
, char *argv
[], const char *optstring
)
40 if ((optind
>= argc
) || (*argv
[optind
] != '-'))
43 if (argv
[optind
][pos
] == '\0')
47 str
= strchr(optstring
, argv
[optind
][pos
]);
49 optopt
= argv
[optind
][pos
];
51 fprintf(stderr
, "%s: illegal option -- %c\n", argv
[0],
57 if (argv
[optind
][pos
+1] != '\0') {
58 optarg
= &argv
[optind
][pos
+1];
65 fprintf(stderr
, "%s: option requires an argument -- %c\n",
69 optarg
= argv
[optind
];
75 if (argv
[optind
][pos
] == '\0') {