Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tessopt.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 * File: getopt.c
3 * Description: Re-implementation of the unix code.
4 * Author: Ray Smith
5 * Created: Tue Nov 28 05:52:50 MST 1995
6 *
7 * (C) Copyright 1995, Hewlett-Packard Co.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 *
18 **********************************************************************/
19
20 #include "mfcpch.h" //precompiled headers
21 #include <string.h>
22 #include <stdio.h>
23 #include "tessopt.h"
24 #include "notdll.h" //must be last include
25
26 int tessoptind;
27 char *tessoptarg;
28
29 /**********************************************************************
30 * tessopt
31 *
32 * parse command line args.
33 **********************************************************************/
34
35 int tessopt ( //parse args
36 inT32 argc, //arg count
37 char *argv[], //args
38 const char *arglist //string of arg chars
39 ) {
40 const char *arg; //arg char
41
42 if (tessoptind == 0)
43 tessoptind = 1;
44 if (tessoptind < argc && argv[tessoptind][0] == '-') {
45 arg = strchr (arglist, argv[tessoptind][1]);
46 if (arg == NULL || *arg == ':')
47 return '?'; //dud option
48 tessoptind++;
49 tessoptarg = argv[tessoptind];
50 if (arg[1] == ':') {
51 if (argv[tessoptind - 1][2] != '\0')
52 //immediately after
53 tessoptarg = argv[tessoptind - 1] + 2;
54 else
55 tessoptind++;
56 }
57 return *arg;
58 }
59 else
60 return EOF;
61 }