00001
00021 #ifndef CUTILH
00022 #define CUTILH
00023
00024
00025
00026
00027 #include <stdio.h>
00028 #include <string.h>
00029 #include <stdlib.h>
00030
00031 #include "general.h"
00032
00033
00034
00035
00036 #ifndef TRUE
00037 #define TRUE 1
00038 #endif
00039
00040 #ifndef FALSE
00041 #define FALSE 0
00042 #endif
00043
00045 #define CHARS_PER_LINE 500
00046
00047 #if defined(__STDC__) || defined(__cplusplus) || MAC_OR_DOS
00048 # define _ARGS(s) s
00049 #else
00050 # define _ARGS(s) ()
00051 #endif
00052
00053
00054 typedef void (*void_proc) (...);
00055 typedef char *(*char_proc) _ARGS ((...));
00056 typedef void *(*void_star_proc) _ARGS ((...));
00057
00058 typedef int (*int_void) (void);
00059 typedef void (*void_void) (void);
00060 typedef int (*int_compare) (void *, void *);
00061 typedef void (*void_dest) (void *);
00062
00063 extern void_proc deallocate;
00064 extern char_proc allocate;
00065
00066
00067
00068
00072 #ifndef min
00073 #define min(x,y) \
00074 ((x) < (y) ? (x) : (y))
00075 #endif
00076
00080 #ifndef max
00081 #define max(x,y) \
00082 ((y) < (x) ? (x) : (y))
00083 #endif
00084
00088 #define new_line() \
00089 printf ("\n")
00090
00094 #define print_string(str) \
00095 printf ("%s\n", str)
00096
00100 #define strfree(s) ((*deallocate) (s))
00101
00108 #define strsave(s) \
00109 ((s) ? \
00110 ((char*) strcpy ((*allocate) (strlen(s)+1), s)) : \
00111 (NULL))
00112
00113
00114
00115
00116 long long_rand(long limit);
00117
00118 FILE *open_file(const char *filename, const char *mode);
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 #endif