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
Macros | Functions
cutil.cpp File Reference
`#include "cutil.h"`
`#include "tprintf.h"`
`#include "callcpp.h"`
`#include <stdlib.h>`

Go to the source code of this file.

## Macros
#define | RESET_COUNT 2000

## Functions
long | long_rand (long limit)
FILE * | open_file (const char *filename, const char *mode)
bool | exists_file (const char *filename)
| Check whether the file exists.

## Macro Definition Documentation

#define RESET_COUNT 2000

Definition at line 47 of file cutil.cpp.

## Function Documentation

bool exists_file | ( | const char * | filename | ) |

Check whether the file exists.

Definition at line 92 of file cutil.cpp.

{
bool exists = false;
FILE *f = NULL;
if ((f = fopen(filename, "rb")) != NULL) {
fclose(f);
exists = true;
}
return exists;
}

long long_rand | ( | long | limit | ) |

Definition at line 56 of file cutil.cpp.

{
#if RAND_MAX < 0x1000000
static long seed;
long num;
num = (long) rand () << 16;
num |= rand () & 0xffff;
seed ^= num;
long result = num % limit;
while (result < 0) {
result += limit;
}
return result;
#else
return (long)((double)limit * rand()/(RAND_MAX + 1.0));
#endif
}

FILE* open_file | ( | const char * | filename,
|  | const char * | mode
| ) |  |

Definition at line 82 of file cutil.cpp.

{
FILE *thisfile = NULL;
if ((thisfile = fopen (filename, mode)) == NULL) {
tprintf ("Could not open file, %s\n", filename);
exit (1);
}
return (thisfile);
}