tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
scanutils.h
1 // Copyright 2006 Google Inc.
2 // All Rights Reserved.
3 // Author: renn
4 //
5 // Contains file io functions (mainly for file parsing), that might not be
6 // available, on embedded devices, or that have an incomplete implementation
7 // there.
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 
19 #ifndef TESSERACT_CCUTIL_SCANUTILS_H_
20 #define TESSERACT_CCUTIL_SCANUTILS_H_
21 
22 #include <cstdint>
23 #include <cstddef>
24 #include <cstdio>
25 #include <sys/stat.h>
26 
37 int tfscanf(FILE* stream, const char *format, ...);
38 
39 #ifdef EMBEDDED
40 
41 // Attempts to parse the given file stream s as an integer of the base
42 // 'base'. Returns the first successfully parsed integer as a uintmax_t, or
43 // 0, if none was found.
44 uintmax_t streamtoumax(FILE* s, int base);
45 
46 // Parse a file stream according to the given format. See the fscanf manpage
47 // for more information, as this function attempts to mimic its behavior.
48 // Note that scientific floating-point notation is not supported.
49 int fscanf(FILE* stream, const char *format, ...);
50 
51 // Parse a file stream according to the given format. See the fscanf manpage
52 // for more information, as this function attempts to mimic its behavior.
53 // Note that scientific floating-point notation is not supported.
54 int vfscanf(FILE* stream, const char *format, va_list ap);
55 
56 // Create a file at the specified path. See the creat manpage for more
57 // information, as this function attempts to mimic its behavior.
58 int creat(const char *pathname, mode_t mode);
59 
60 // Convert the specified C-String to a float. Returns the first parsed float,
61 // or 0.0 if no floating point value could be found. Note that scientific
62 // floating-point notation is not supported.
63 double strtofloat(const char* s);
64 
65 #endif // EMBEDDED
66 
67 #endif // TESSERACT_CCUTIL_SCANUTILS_H_