00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _GENERAL_H_
00019 #define _GENERAL_H_
00020
00021 #include <stdio.h>
00022 #include <sys/types.h>
00023 #include <math.h>
00024 #include <string.h>
00025
00026 #define CMU_SLM_VERSION "CMU SLM Toolkit, Version for internal CMU use"
00027
00033 typedef int int32;
00034 typedef short int16;
00035
00037 FILE *rr_fopen(char *filename, char *mode);
00038
00040 void *rr_fseek(FILE *fp, int offset, int mode, char *description);
00041
00043 void *rr_fread();
00044
00046 void *rr_fwrite();
00047
00049 char *rr_malloc(size_t n_bytes);
00050
00052 char *rr_calloc(size_t nelem, size_t elsize);
00053
00055 int rr_filesize(int fd);
00056
00058 int rr_feof(FILE *fp);
00059
00061 char *salloc(char *str);
00062
00064 int rr_fexists(char *path);
00065 FILE *rr_iopen(char *path);
00066 void *rr_iclose(FILE *fp);
00067 FILE *rr_oopen(char *path);
00068 void *rr_oclose(FILE *fp);
00069 void parse_line(char *line, int mwords, int canonize,
00070 char **pword_begin, char **pword_end, int *p_nwords, int *p_overflow);
00071 int quit(int rc, char *msg, ...);
00072
00073 typedef char Boolean;
00074 typedef unsigned short wordid_t;
00075 typedef int cluster_t;
00076
00077 #ifndef MIN
00078 #define MIN(X,Y) ( ((X)<(Y)) ? (X) : (Y))
00079 #endif
00080 #ifndef MAX
00081 #define MAX(X,Y) ( ((X)>(Y)) ? (X) : (Y))
00082 #endif
00083
00084 #define LOG_BASE 9.9995e-5
00085 #define MIN_LOG -690810000
00086 #define LOG(x) ((x == 0.0) ? MIN_LOG : ((x > 1.0) ? \
00087 (int) ((log (x) / LOG_BASE) + 0.5) :\
00088 (int) ((log (x) / LOG_BASE) - 0.5)))
00089 #define EXP(x) (exp ((double) (x) * LOG_BASE))
00090
00091 #ifdef __alpha
00092 #define SLM_SWAP_BYTES 1
00093 #endif
00094
00095
00096
00097 #define quit0(rc,msg) {fprintf(stderr,msg); exit(rc);}
00098 #define quit1(rc,msg,i1) {fprintf(stderr,msg,i1); exit(rc);}
00099 #define quit2(rc,msg,i1,i2) {fprintf(stderr,msg,i1,i2); exit(rc);}
00100 #define quit3(rc,msg,i1,i2,i3) {fprintf(stderr,msg,i1,i2,i3); exit(rc);}
00101 #define quit4(rc,msg,i1,i2,i3,i4) {fprintf(stderr,msg,i1,i2,i3,i4); exit(rc);}
00102
00103 #define MAX_WORDS_PER_DOC 65534
00104
00105 #endif