tesseract  5.0.0-alpha-619-ge9db
tessopt.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * File: tessopt.cpp
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 <cstring>
21 #include <cstdio>
22 #include "tessopt.h"
23 
25 char *tessoptarg;
26 
27 /**********************************************************************
28  * tessopt
29  *
30  * parse command line args.
31  **********************************************************************/
32 
33 int tessopt ( //parse args
34 int32_t argc, //arg count
35 char *argv[], //args
36 const char *arglist //string of arg chars
37 ) {
38  const char *arg; //arg char
39 
40  if (tessoptind == 0)
41  tessoptind = 1;
42  if (tessoptind < argc && argv[tessoptind][0] == '-') {
43  arg = strchr (arglist, argv[tessoptind][1]);
44  if (arg == nullptr || *arg == ':')
45  return '?'; //dud option
46  tessoptind++;
47  tessoptarg = argv[tessoptind];
48  if (arg[1] == ':') {
49  if (argv[tessoptind - 1][2] != '\0')
50  //immediately after
51  tessoptarg = argv[tessoptind - 1] + 2;
52  else
53  tessoptind++;
54  }
55  return *arg;
56  }
57  else
58  return EOF;
59 }
tessoptarg
char * tessoptarg
Definition: tessopt.cpp:24
tessopt
int tessopt(int32_t argc, char *argv[], const char *arglist)
Definition: tessopt.cpp:31
tessoptind
int tessoptind
Definition: tessopt.cpp:23
tessopt.h