#include "cutil.h"
#include "callcpp.h"
#include <stdlib.h>
Go to the source code of this file.
#define RESET_COUNT 2000 |
* (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.
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 }
void_proc deallocate = (void_proc) c_free_string |