cutil/cutil.h File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "general.h"

Go to the source code of this file.





Define Documentation

#define _ARGS (  )     ()

Definition at line 50 of file cutil.h.

#define CHARS_PER_LINE   500

Maximum characters per line in a file

Definition at line 45 of file cutil.h.

Referenced by add_document_word(), print_choices(), print_seams(), read_list(), read_word_list(), ReadClassFile(), save_summary(), set_float_value(), and set_int_value().

#define FALSE   0

Definition at line 41 of file cutil.h.

#define max ( x,
 )     ((y) < (x) ? (x) : (y))

Maximum of two values.

Definition at line 81 of file cutil.h.

Referenced by AddProtoToProtoPruner(), bounds_of_piece(), IMAGE::convolver(), ELISTIZE(), est_ambigs(), find_trans_point(), fix_rep_char(), full_split_priority(), grade_center_of_blob(), grade_overlap(), grade_split_length(), grade_width_change(), STATS::max_bucket(), STATS::mode(), row_spacing_stats(), and STATS::short_print().

#define min ( x,
 )     ((x) < (y) ? (x) : (y))

Minimum of two values.

Definition at line 73 of file cutil.h.

Referenced by append_next_choice(), append_number_choices(), bounds_of_piece(), ELISTIZE(), est_ambigs(), find_trans_point(), full_split_priority(), grade_center_of_blob(), grade_overlap(), grade_width_change(), init_metrics(), STATS::min_bucket(), permute_compound_words(), permute_subword(), permute_top_choice(), and STATS::short_print().

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

Print a new line character on stdout.

Definition at line 88 of file cutil.h.

Referenced by bin_to_pieces(), print_dawg_node(), print_matrix(), print_state(), PrintProtos(), ReadClassFile(), scale_image(), and word_in_dawg().

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

Print a string on stdout.

Definition at line 94 of file cutil.h.

Referenced by read_squished_dawg().

#define strfree (  )     ((*deallocate) (s))

Free reserved spot in memory for string.

Definition at line 100 of file cutil.h.

Referenced by delete_word(), free_choice(), permute_subword(), permute_top_choice(), recog_word_recursive(), and set_hyphen_word().

#define strsave (  ) 


((s) ?  \
   ((char*) strcpy ((*allocate) (strlen(s)+1), s))  :  \
Reserve a spot in memory for the string.

Copies the string to it and returns the result.

Don't forget to call strfree()

Definition at line 108 of file cutil.h.

Referenced by make_tess_word(), new_choice(), permute_top_choice(), read_list(), set_hyphen_word(), and string_read().

#define TRUE   1

File: cutil.h
General utility functions
Mark Seaman, SW Productivity
Fri Oct 16 14:37:00 1987, Wed Jun 6 16:29:17 1990
 * (c) Copyright 1987, Hewlett-Packard Company.
 ** 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
 ** 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.
  • Revision 2004/02/20 19:39:06 slumos; Import original HP distribution

Definition at line 37 of file cutil.h.

Typedef Documentation

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

Definition at line 56 of file cutil.h.

void program_variables _ARGS

Definition at line 55 of file cutil.h.

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

Definition at line 60 of file cutil.h.

typedef int(*) int_void(void)

Definition at line 58 of file cutil.h.

typedef void(*) void_dest(void *)

Definition at line 61 of file cutil.h.

typedef void(*) void_proc(...)

Definition at line 54 of file cutil.h.

typedef void(*) void_void(void)

Definition at line 59 of file cutil.h.

Function Documentation

long long_rand ( long  limit  ) 

Compute long random number whose value is less than limit.

Do this by calling the standard cheepo random number generator and reseting it pretty often.

Definition at line 44 of file cutil.cpp.

Referenced by new_dawg_node().

00044                            {
00045 #if RAND_MAX < 0x1000000
00046   static long seed;
00048   long num;
00049   num = (long) rand () << 16;
00050   num |= rand () & 0xffff;
00051   seed ^= num;
00052   long result = num % limit;
00053   while (result < 0) {
00054     result += limit;
00055   }
00056   return result;
00057 #else
00058   return (long)((double)limit * rand()/(RAND_MAX + 1.0));
00059 #endif
00060 }

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

Open a file for reading or writing.

If the file name parameter is NULL use stdin (or stdout) for the file. If the file can not be opened then call the error routine.

Definition at line 70 of file cutil.cpp.

References NULL.

Referenced by add_document_word(), edit_with_ocr(), read_list(), read_squished_dawg(), read_word_list(), ReadClassFile(), save_summary(), and start_recording().

00070                                                         {
00071   FILE *thisfile = NULL;
00072   if ((thisfile = fopen (filename, mode)) == NULL) {
00073     printf ("Could not open file, %s\n", filename);
00074     exit (1);
00075   }
00076   return (thisfile);
00077 }

Variable Documentation

char_proc allocate

Definition at line 36 of file cutil.cpp.

void_proc deallocate

Definition at line 35 of file cutil.cpp.

Generated on Wed Feb 28 19:49:21 2007 for Tesseract by  doxygen 1.5.1