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 | Typedefs | Functions
cutil.h File Reference
`#include <stdio.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include "host.h"`
`#include "tprintf.h"`
`#include "cutil_class.h"`

Go to the source code of this file.

## Macros
#define | TRUE 1
#define | FALSE 0
#define | CHARS_PER_LINE 500
#define | _ARGS(s) ()
#define | new_line() tprintf("\n")
#define | print_string(str) printf ("%s\n", str)
#define | strfree(s) (free_string(s))
#define | strsave(s)

## Typedefs
typedef void(* | void_proc )(...)
typedef void *void_star_proc | _ARGS ((...))
typedef int(* | int_void )(void)
typedef void(* | void_void )(void)
typedef int(* | int_compare )(void *, void *)
typedef void(* | void_dest )(void *)

## 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 _ARGS | ( |  | s | ) | ()

Definition at line 62 of file cutil.h.

#define CHARS_PER_LINE 500

Definition at line 57 of file cutil.h.

#define FALSE 0

Definition at line 54 of file cutil.h.

#define new_line | ( |  | ) | tprintf("\n")

Definition at line 83 of file cutil.h.

#define print_string | ( |  | str | ) | printf ("%s\n", str)

Definition at line 92 of file cutil.h.

#define strfree | ( |  | s | ) | (free_string(s))

Definition at line 102 of file cutil.h.

#define strsave | ( |  | s | ) |

Value:
((s) != NULL ? \
((char*) strcpy (alloc_string(strlen(s)+1), s)) : \
(NULL))

Definition at line 111 of file cutil.h.

#define TRUE 1

Definition at line 50 of file cutil.h.

## Typedef Documentation

typedef void* void_star_proc _ARGS((...))

Definition at line 67 of file cutil.h.

typedef int(* int_compare)(void *, void *)

Definition at line 71 of file cutil.h.

typedef int(* int_void)(void)

Definition at line 69 of file cutil.h.

typedef void(* void_dest)(void *)

Definition at line 72 of file cutil.h.

typedef void(* void_proc)(...)

Definition at line 66 of file cutil.h.

typedef void(* void_void)(void)

Definition at line 70 of file cutil.h.

## 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);
}