#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "general.h"
Go to the source code of this file.
#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 max | ( | x, | |||
y | ) | ((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, | |||
y | ) | ((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 | ( | s | ) | ((*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 | ) |
Value:
Reserve a spot in memory for the string.Copies the string to it and returns the result.
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 |
* (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 ** http://www.apache.org/licenses/LICENSE-2.0 ** 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.
typedef int(*) int_compare(void *, void *) |
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; 00047 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 }