/usr/include/tesseract/nwmain.h is in libtesseract-dev 3.02.01-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | /**********************************************************************
* File: nwmain.h
* Description: Tool to declare main, making windows invisible.
* Author: Ray Smith
* Created: Fri Sep 07 13:27:50 MDT 1995
*
* (C) Copyright 1995, Hewlett-Packard Co.
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*
**********************************************************************/
#ifndef RUNMAIN_H
#define RUNMAIN_H
#include "host.h"
#include "params.h"
#include "notdll.h" //must be last include
#define DECLARE_MAIN(ARGC,ARGV)\
STRING_VAR(init_config_file,"config","Config file to read on startup");\
REALLY_DECLARE_MAIN(ARGC,ARGV)
#define DECLARE_MAIN_CONFIG(ARGC,ARGV,NAME)\
STRING_VAR(init_config_file,NAME,"Config file to read on startup");\
REALLY_DECLARE_MAIN(ARGC,ARGV)
#ifndef __UNIX__
#define REALLY_DECLARE_MAIN(ARGC,ARGV)\
\
/**********************************************************************\
* parse_args\
*\
* Turn a list of args into a new list of args with each separate\
* whitespace spaced string being an arg.\
**********************************************************************/\
\
inT32 parse_args( /*refine arg list*/\
inT32 argc, /*no of input args*/\
char *argv[], /*input args*/\
char *arglist[] /*output args*/\
)\
{\
inT32 argcount; /*converted argc*/\
char *testchar; /*char in option string*/\
inT32 arg; /*current argument*/\
\
argcount=0; /*no of options*/\
for (arg=0;arg<argc;arg++)\
{\
testchar=argv[arg]; /*start of arg*/\
do\
{\
while (*testchar\
&& (*testchar==' ' || *testchar=='"' || *testchar=='\n' || *testchar=='\t'))\
testchar++; /*skip white space*/\
if (*testchar)\
{\
arglist[argcount++]=testchar; /*new arg*/\
do\
{\
for (testchar++;*testchar\
&& *testchar!=' ' && *testchar!='"' && *testchar!='\n' && *testchar!='\t';\
testchar++); /*skip to white space*/\
}\
while (*testchar=='"' && testchar[1]!=' ' && testchar[1]!='\0' && testchar[1]!='\n' && testchar[1]!='\t');\
if (*testchar)\
*testchar++='\0'; /*turn to separate args*/\
}\
}\
while (*testchar);\
}\
return argcount; /*new number of args*/\
}\
\
inT32 global_exit_code;\
inT32 real_main(inT32,const char**);\
\
inT32 run_main( /*the main thread*/\
CWinApp* theapp /*arguments*/\
)\
{\
char **argv;\
char *argsin[2];\
inT32 argc;\
inT32 exit_code;\
\
argsin[0]=strdup(theapp->m_pszExeName);\
argsin[1]=strdup(theapp->m_lpCmdLine);\
/*allocate memory for the args. There can never be more than half*/\
/*the total number of characters in the arguments.*/\
argv=(char**)malloc(((strlen(argsin[0])+strlen(argsin[1]))/2+1)*sizeof(char*));\
\
/*now construct argv as it should be for C.*/\
argc=parse_args(2,argsin,argv);\
\
/*call main(argc,argv) here*/\
exit_code=real_main(argc,(const char **)argv);\
\
\
/*now get rid of the main app window*/\
if (theapp!=NULL && theapp->m_pMainWnd!=NULL)\
PostMessage(theapp->m_pMainWnd->m_hWnd,WM_QUIT,0,0);\
free(argsin[0]);\
free(argsin[1]);\
free(argv);\
global_exit_code=exit_code;\
return exit_code;\
}\
\
inT32 real_main(inT32 ARGC,const char* ARGV[])\
#else
#define REALLY_DECLARE_MAIN(ARGC,ARGV)\
\
/**********************************************************************\
* parse_args\
*\
* Turn a list of args into a new list of args with each separate\
* whitespace spaced string being an arg.\
**********************************************************************/\
\
inT32 parse_args( /*refine arg list*/\
inT32 argc, /*no of input args*/\
char *argv[], /*input args*/\
char *arglist[] /*output args*/\
)\
{\
inT32 argcount; /*converted argc*/\
char *testchar; /*char in option string*/\
inT32 arg; /*current argument*/\
\
argcount=0; /*no of options*/\
for (arg=0;arg<argc;arg++)\
{\
testchar=argv[arg]; /*start of arg*/\
do\
{\
while (*testchar\
&& (*testchar==' ' || *testchar=='"' || *testchar=='\n' || *testchar=='\t'))\
testchar++; /*skip white space*/\
if (*testchar)\
{\
arglist[argcount++]=testchar; /*new arg*/\
do\
{\
for (testchar++;*testchar\
&& *testchar!=' ' && *testchar!='"' && *testchar!='\n' && *testchar!='\t';\
testchar++); /*skip to white space*/\
}\
while (*testchar=='"' && testchar[1]!=' ' && testchar[1]!='\0' && testchar[1]!='\n' && testchar[1]!='\t');\
if (*testchar)\
*testchar++='\0'; /*turn to separate args*/\
}\
}\
while (*testchar);\
}\
return argcount; /*new number of args*/\
}\
\
inT32 main(inT32 ARGC,const char* ARGV[])\
#endif
#else
#error "NOT allowed to include nwmain.h or runmain.h twice!!"
#endif
|