Tesseract
3.02
|
00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: cutil.h 00005 * Description: General utility functions 00006 * Author: Mark Seaman, SW Productivity 00007 * Created: Fri Oct 16 14:37:00 1987 00008 * Modified: Wed Dec 5 15:40:26 1990 (Mark Seaman) marks@hpgrlt 00009 * Language: C 00010 * Package: N/A 00011 * Status: Reusable Software Component 00012 * 00013 * (c) Copyright 1987, Hewlett-Packard Company. 00014 ** Licensed under the Apache License, Version 2.0 (the "License"); 00015 ** you may not use this file except in compliance with the License. 00016 ** You may obtain a copy of the License at 00017 ** http://www.apache.org/licenses/LICENSE-2.0 00018 ** Unless required by applicable law or agreed to in writing, software 00019 ** distributed under the License is distributed on an "AS IS" BASIS, 00020 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 ** See the License for the specific language governing permissions and 00022 ** limitations under the License. 00023 * 00024 ******************************************************************************** 00025 Revision 1.1 2007/02/02 23:39:07 theraysmith 00026 Fixed portability issues 00027 00028 Revision 1.1.1.1 2004/02/20 19:39:06 slumos 00029 Import original HP distribution 00030 00031 */ 00032 00033 #ifndef CUTILH 00034 #define CUTILH 00035 00036 /*---------------------------------------------------------------------- 00037 I n c l u d e s 00038 ----------------------------------------------------------------------*/ 00039 #include <stdio.h> 00040 #include <string.h> 00041 #include <stdlib.h> 00042 00043 #include "host.h" 00044 #include "tprintf.h" 00045 00046 /*---------------------------------------------------------------------- 00047 T y p e s 00048 ----------------------------------------------------------------------*/ 00049 #ifndef TRUE 00050 #define TRUE 1 00051 #endif 00052 00053 #ifndef FALSE 00054 #define FALSE 0 00055 #endif 00056 00057 #define CHARS_PER_LINE 500 00058 00059 #if defined(__STDC__) || defined(__cplusplus) || MAC_OR_DOS 00060 # define _ARGS(s) s 00061 #else 00062 # define _ARGS(s) () 00063 #endif 00064 00065 //typedef int (*int_proc) (void); 00066 typedef void (*void_proc) (...); 00067 typedef void *(*void_star_proc) _ARGS ((...)); 00068 00069 typedef int (*int_void) (void); 00070 typedef void (*void_void) (void); 00071 typedef int (*int_compare) (void *, void *); 00072 typedef void (*void_dest) (void *); 00073 00074 /*---------------------------------------------------------------------- 00075 M a c r o s 00076 ----------------------------------------------------------------------*/ 00077 /********************************************************************** 00078 * new_line 00079 * 00080 * Print a new line character on stdout. 00081 **********************************************************************/ 00082 00083 #define new_line() \ 00084 tprintf("\n") 00085 00086 /********************************************************************** 00087 * print_string 00088 * 00089 * Print a string on stdout. 00090 **********************************************************************/ 00091 00092 #define print_string(str) \ 00093 printf ("%s\n", str) 00094 00095 /********************************************************************** 00096 * strfree 00097 * 00098 * Reserve a spot in memory for the string to be stored. Copy the string 00099 * to it and return the result. 00100 **********************************************************************/ 00101 00102 #define strfree(s) (free_string(s)) 00103 00104 /********************************************************************** 00105 * strsave 00106 * 00107 * Reserve a spot in memory for the string to be stored. Copy the string 00108 * to it and return the result. 00109 **********************************************************************/ 00110 00111 #define strsave(s) \ 00112 ((s) != NULL ? \ 00113 ((char*) strcpy (alloc_string(strlen(s)+1), s)) : \ 00114 (NULL)) 00115 00116 /*---------------------------------------------------------------------- 00117 F u n c t i o n s 00118 ----------------------------------------------------------------------*/ 00119 long long_rand(long limit); 00120 00121 FILE *open_file(const char *filename, const char *mode); 00122 00123 bool exists_file(const char *filename); 00124 00125 /* util.c 00126 long long_rand 00127 _ARGS ((long limit)); 00128 00129 FILE *open_file 00130 _ARGS((char *filename, 00131 char *mode)); 00132 00133 #undef _ARGS 00134 */ 00135 #include "cutil_class.h" 00136 #endif