00001 00028 #include "cutil.h" 00029 #include "callcpp.h" 00030 00031 #include <stdlib.h> 00032 00033 #define RESET_COUNT 2000 00034 00035 void_proc deallocate = (void_proc) c_free_string; 00036 char_proc allocate = (char_proc) c_alloc_string; 00037 00044 long long_rand(long limit) { 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 } 00061 00062 00070 FILE *open_file(const char *filename, const char *mode) { 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 }