#include "varable.h"
#include "notdll.h"
Go to the source code of this file.
void main_setup | ( | const char * | argv0, | |
const char * | basename, | |||
int | argc, | |||
const char *const * | argv | |||
) |
Main for mithras demo program.
Read the arguments and set up globals.
Definition at line 59 of file mainblk.cpp.
References _XSTR, ABORT, CANTOPENFILE, datadir, DBG, ERRCODE::error(), getpath(), imagebasename, NO_PATH, NULL, print_variables(), read_variables_file(), STRING::string(), TESSDATA_PREFIX, and VARDIR.
Referenced by init_tesseract().
00064 { 00065 INT32 arg; /*argument */ 00066 INT32 offset; //for flag 00067 FILE *fp; /*variables file */ 00068 char flag[2]; //+/- 00069 STRING varfile; /*name of file */ 00070 00071 imagebasename = basename; /*name of image */ 00072 if (getpath (argv0, datadir) < 0) 00073 #ifdef __UNIX__ 00074 CANTOPENFILE.error ("main", ABORT, "%s to get path", argv[0]); 00075 #else 00076 NO_PATH.error ("main", DBG, NULL); 00077 #endif 00078 00079 for (arg = 0; arg < argc; arg++) { 00080 if (argv[arg][0] == '+' || argv[arg][0] == '-') { 00081 offset = 1; 00082 flag[0] = argv[arg][0]; 00083 } 00084 else { 00085 offset = 0; 00086 } 00087 flag[offset] = '\0'; 00088 varfile = flag; 00089 /*attempt open */ 00090 fp = fopen (argv[arg] + offset, "r"); 00091 if (fp != NULL) { 00092 fclose(fp); /*was only to test */ 00093 } 00094 else { 00095 varfile += datadir; 00096 varfile += m_data_sub_dir; /*data directory */ 00097 varfile += VARDIR; /*variables dir */ 00098 } 00099 /*actual name */ 00100 varfile += argv[arg] + offset; 00101 read_variables_file (varfile.string ()); 00102 } 00103 00104 if (m_print_variables) 00105 print_variables(stdout); /*print them all */ 00106 00107 /* 00108 Allows the required data files to be at a fixed location 00109 not relative to the directory where the binary was executed 00110 From a patch posted on the tesseract-ocr forums on sf.net 00111 00112 Run configure with --with-prefix /usr/local/tesseract-1.03/ 00113 Or uncomment and modify the following #define */ 00114 00115 // #define TESSDATA_PREFIX /usr/local/tesseract-1.03f3/ 00116 00117 #ifdef TESSDATA_PREFIX 00118 # define _STR(a) #a 00119 # define _XSTR(a) _STR(a) 00120 datadir = _XSTR(TESSDATA_PREFIX); 00121 # undef _XSTR 00122 # undef _STR 00123 #endif 00124 00125 datadir += m_data_sub_dir; /*data directory */ 00126 00127 #ifdef __UNIX__ 00128 if (memgrab_size > 0) { 00129 void *membuf; //test virtual mem 00130 //test memory 00131 membuf = malloc (memgrab_size); 00132 if (membuf == NULL) { 00133 raise(SIGTTOU); //hangup for jobber 00134 sleep (10); 00135 } 00136 else 00137 free(membuf); 00138 } 00139 #endif 00140 }
* (C) Copyright 1991, Hewlett-Packard Ltd. ** 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.
Definition at line 81 of file tessedit2.cpp.
DLLSYM STRING imagebasename |
Definition at line 82 of file tessedit2.cpp.