1 /* -*-C-*- 2 ******************************************************************************** 3 * 4 * File: cutil.h 5 * Description: General utility functions 6 * Author: Mark Seaman, SW Productivity 7 * Created: Fri Oct 16 14:37:00 1987 8 * Modified: Wed Dec 5 15:40:26 1990 (Mark Seaman) marks@hpgrlt 9 * Language: C 10 * Package: N/A 11 * Status: Reusable Software Component 12 * 13 * (c) Copyright 1987, Hewlett-Packard Company. 14 ** Licensed under the Apache License, Version 2.0 (the "License"); 15 ** you may not use this file except in compliance with the License. 16 ** You may obtain a copy of the License at 17 ** http://www.apache.org/licenses/LICENSE-2.0 18 ** Unless required by applicable law or agreed to in writing, software 19 ** distributed under the License is distributed on an "AS IS" BASIS, 20 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 ** See the License for the specific language governing permissions and 22 ** limitations under the License. 23 * 24 ******************************************************************************** 25 Revision 1.1 2007/02/02 23:39:07 theraysmith 26 Fixed portability issues 27 28 Revision 1.1.1.1 2004/02/20 19:39:06 slumos 29 Import original HP distribution 30 31 */ 32 33 #ifndef CUTILH 34 #define CUTILH 35 36 /*---------------------------------------------------------------------- 37 I n c l u d e s 38 ----------------------------------------------------------------------*/ 39 #include <stdio.h> 40 #include <string.h> 41 #include <stdlib.h> 42 43 #include "general.h" 44 #include "tprintf.h" 45 46 /*---------------------------------------------------------------------- 47 T y p e s 48 ----------------------------------------------------------------------*/ 49 #ifndef TRUE 50 #define TRUE 1 51 #endif 52 53 #ifndef FALSE 54 #define FALSE 0 55 #endif 56 57 #define CHARS_PER_LINE 500 58 59 #if defined(__STDC__) || defined(__cplusplus) || MAC_OR_DOS 60 # define _ARGS(s) s 61 #else 62 # define _ARGS(s) () 63 #endif 64 65 //typedef int (*int_proc) (void); 66 typedef void (*void_proc) (...); 67 typedef void *(*void_star_proc) _ARGS ((...)); 68 69 typedef int (*int_void) (void); 70 typedef void (*void_void) (void); 71 typedef int (*int_compare) (void *, void *); 72 typedef void (*void_dest) (void *); 73 74 /*---------------------------------------------------------------------- 75 M a c r o s 76 ----------------------------------------------------------------------*/ 77 /********************************************************************** 78 * new_line 79 * 80 * Print a new line character on stdout. 81 **********************************************************************/ 82 83 #define new_line() \ 84 tprintf("\n") 85 86 /********************************************************************** 87 * print_string 88 * 89 * Print a string on stdout. 90 **********************************************************************/ 91 92 #define print_string(str) \ 93 printf ("%s\n", str) 94 95 /********************************************************************** 96 * strfree 97 * 98 * Reserve a spot in memory for the string to be stored. Copy the string 99 * to it and return the result. 100 **********************************************************************/ 101 102 #define strfree(s) (free_string(s)) 103 104 /********************************************************************** 105 * strsave 106 * 107 * Reserve a spot in memory for the string to be stored. Copy the string 108 * to it and return the result. 109 **********************************************************************/ 110 111 #define strsave(s) \ 112 ((s) != NULL ? \ 113 ((char*) strcpy (alloc_string(strlen(s)+1), s)) : \ 114 (NULL)) 115 116 /*---------------------------------------------------------------------- 117 F u n c t i o n s 118 ----------------------------------------------------------------------*/ 119 long long_rand(long limit); 120 121 FILE *open_file(const char *filename, const char *mode); 122 123 /* util.c 124 long long_rand 125 _ARGS ((long limit)); 126 127 FILE *open_file 128 _ARGS((char *filename, 129 char *mode)); 130 131 #undef _ARGS 132 */ 133 #include "cutil_class.h" 134 #endif 135