tesseract  4.00.00dev
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)
 

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. More...
 

Macro Definition Documentation

◆ _ARGS

#define _ARGS (   s)    ()

Definition at line 62 of file cutil.h.

◆ CHARS_PER_LINE

#define CHARS_PER_LINE   500

Definition at line 57 of file cutil.h.

◆ FALSE

#define FALSE   0

Definition at line 54 of file cutil.h.

◆ new_line

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

Definition at line 83 of file cutil.h.

◆ print_string

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

Definition at line 92 of file cutil.h.

◆ TRUE

#define TRUE   1

Definition at line 50 of file cutil.h.

Typedef Documentation

◆ _ARGS

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

Definition at line 67 of file cutil.h.

◆ int_compare

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

Definition at line 71 of file cutil.h.

◆ int_void

typedef int(* int_void) (void)

Definition at line 69 of file cutil.h.

◆ void_dest

typedef void(* void_dest) (void *)

Definition at line 72 of file cutil.h.

◆ void_proc

typedef void(* void_proc) (...)

Definition at line 66 of file cutil.h.

◆ void_void

typedef void(* void_void) (void)

Definition at line 70 of file cutil.h.

Function Documentation

◆ exists_file()

bool exists_file ( const char *  filename)

Check whether the file exists.

Definition at line 92 of file cutil.cpp.

92  {
93  bool exists = false;
94  FILE *f = NULL;
95  if ((f = fopen(filename, "rb")) != NULL) {
96  fclose(f);
97  exists = true;
98  }
99  return exists;
100 }
const char * filename
Definition: ioapi.h:38

◆ long_rand()

long long_rand ( long  limit)

Definition at line 56 of file cutil.cpp.

56  {
57 #if RAND_MAX < 0x1000000
58  static long seed;
59 
60  long num;
61  num = (long) rand () << 16;
62  num |= rand () & 0xffff;
63  seed ^= num;
64  long result = num % limit;
65  while (result < 0) {
66  result += limit;
67  }
68  return result;
69 #else
70  return (long)((double)limit * rand()/(RAND_MAX + 1.0));
71 #endif
72 }
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque

◆ open_file()

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

Definition at line 82 of file cutil.cpp.

82  {
83  FILE *thisfile = NULL;
84  if ((thisfile = fopen (filename, mode)) == NULL) {
85  tprintf ("Could not open file, %s\n", filename);
86  exit (1);
87  }
88  return (thisfile);
89 }
#define tprintf(...)
Definition: tprintf.h:31
const char int mode
Definition: ioapi.h:38
const char * filename
Definition: ioapi.h:38