home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / include / util / macros.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-22  |  6.0 KB  |  147 lines

  1. /**********************************************************************/
  2. /*                                                                    */
  3. /*             FILENAME:  macros.h                                    */
  4. /*             BY:  Jonathan G. Fiscus                                */
  5. /*                  NATIONAL INSTITUTE OF STANDARDS AND TECHNOLOGY    */
  6. /*                  SPEECH RECOGNITION GROUP                          */
  7. /*                                                                    */
  8. /*           DESC:  This file contains general macros used            */
  9. /*                  throughout the scoring package                    */
  10. /*                                                                    */
  11. /**********************************************************************/
  12. #define strip_newline(_str) \
  13.       { register int _pos; \
  14.         if (_str[_pos=(strlen(_str)-1)] == '\n') \
  15.            _str[_pos] = (char)0; \
  16.       } \
  17.  
  18. #define skip_white_space(_ptr) \
  19.     while ((*_ptr == ' ') || (*_ptr == '\t')) \
  20.         _ptr++; \
  21.  
  22. #define char2char(_ptr,_from,_to) \
  23.     { char *_tp; _tp = _ptr; \
  24.       while (*_tp != '\0') {\
  25.          if (*_tp == _from) \
  26.             *_tp = _to; \
  27.          _tp++; \
  28.       } \
  29.     }
  30.  
  31. /***************************************************************/
  32. /*  move the pointer to the end of the word                    */
  33. /***************************************************************/
  34. #define find_end_of_word(_ptr) \
  35.     while ((*_ptr != ' ') && (*_ptr != '\t') && (*_ptr != (char)0) && \
  36.            (*_ptr != '\n')) \
  37.         _ptr++; 
  38.  
  39. #define pct(num,dem)    (((dem)==0) ? 0 : (double)(num)/(double)(dem) * 100.0)
  40. #define ROUND(_x) ((int) ((_x) + 0.5))
  41. #define INT(_x) ((int) floor((double) (_x)))
  42. #define TRUNC(_x) (floor((double) (_x)))
  43. #define MOD(_x,_y) ((int) ((_x) - TRUNC((double)(_x)/(double)(_y))*(_y)))
  44. #define DIV(_x,_y) ((int) (_x)/(_y))
  45.  
  46. #ifndef MAX
  47. #define MAX(_a,_b) (((_a) > (_b)) ? (_a) : (_b))
  48. #endif
  49.  
  50. #include <util/min.h>
  51.  
  52. #define swap_short(_x) \
  53. {short *_p=(short *)&_x,_t; _t=*(_p+1); *(_p+1)=*(_p); *(_p)=_t;}
  54. #define swap_bytes(_x) \
  55. {char *_p=(char *)&_x,_t; _t=*(_p+1); *(_p+1)=*(_p); *(_p)=_t;}
  56.  
  57.  
  58. #define move_to_null(to) \
  59.     while (*to != NULL_CHAR) \
  60.         to++; 
  61.  
  62. #define form_feed()    printf(" ");
  63.  
  64. /* cause a core dump in a nice manner                          */
  65. #define die() {fflush(stderr); fflush(stdout); abort(); }
  66.  
  67. /***************************************************************/
  68. /*  make a usable filename from a directory and a filename     */
  69. /***************************************************************/
  70. #define mk_fname(str,dir,name)    sprintf(str,"%s/%s",dir,name);
  71.  
  72. #ifndef M_LOG10E
  73. #define    M_LOG10E    0.43429448190325182765
  74. #endif
  75.  
  76. /***************************************************************/
  77. /*    misc external function definitions                       */
  78. /***************************************************************/
  79. #if defined(__STDC__) || defined(__GNUC__) || defined(sgi)
  80. #define PROTO(ARGS)    ARGS
  81. #else
  82. #define PROTO(ARGS)    ()
  83. #endif
  84.  
  85. /* pad.c */    void init_pad_util PROTO((int pr_width)) ;
  86. /* pad.c */    int pad_pr_width PROTO((void)) ;
  87. /* pad.c */    void set_pad PROTO((char *pad, char *str)) ;
  88. /* pad.c */    void set_pad_n PROTO((char *pad, int n)) ;
  89. /* pad.c */    void set_pad_cent_n PROTO((char *pad, int len)) ;
  90. /* pad.c */    char *center PROTO((char *str, int len)) ;
  91.  
  92. /* string.c */ void search_for_char PROTO((char **ptr, char chr)) ;
  93. /* string.c */ void search_back_for_char PROTO((char *beg_ptr, char **ptr, char chr)) ;
  94. /* string.c */ void strcpy_to_char PROTO((char *to, char *from, char chr)) ;
  95. /* string.c */ void strcpy_to_before_char PROTO((char *to, char *from, char chr)) ;
  96. /* string.c */ void strncpy_to_before_char PROTO((char *to, char *from, char chr, int len)) ;
  97. /* string.c */ void strcpy_lc PROTO((char *to, char *from)) ;
  98. /* string.c */ void strncpy_pad PROTO((char *to, char *from, int len, char chr)) ;
  99. /* string.c */ char *str2up PROTO((char *str)) ;
  100. /* string.c */ char *str2low PROTO((char *str)) ;
  101. /* string.c */ int is_number PROTO((char *str)) ;
  102. /* string.c */ int is_integer PROTO((char *str)) ;
  103. /* string.c */ int strcmp_nhu PROTO((char *s, char *t)) ;
  104.  
  105. /* sfgets.c */   char *safe_fgets PROTO((char *arr, int len, FILE *fp)) ;
  106.  
  107. /* comments.c */ int is_comment PROTO((char *str)) ;
  108. /* comments.c */ int is_comment_info PROTO((char *str)) ;
  109.  
  110. /* word.c */     int wrdlen PROTO((char *ptr)) ;
  111. /* word.c */     void wrdcpy PROTO((char *to, char *from)) ;
  112. /* word.c */     void find_next_word PROTO((char **ptr)) ;
  113.  
  114. /* itoa.c */     void nist_itoa PROTO((int val, char *buff, int max_len));
  115.  
  116. /* str_srch.c */ int strings_search PROTO((char **list, int count, char *goal)) ;
  117.  
  118. /* ds.c       */ void direct_search PROTO((int *IN_psi, int IN_K, double *IN_DELTA, double IN_rho, double *IN_delta, double (*IN_S) (int *), int full_search));
  119. #ifdef __STDC__
  120. /* rsprintf.c */ char *rsprintf PROTO((char *format , ...));
  121. #else
  122. /* rsprintf.c */ char *rsprintf PROTO((va_alist));
  123. #endif
  124.  
  125. /* dir.c */  int dir_exists PROTO((char *dir)) ;
  126. /* dir.c */  int file_readable PROTO((char *fname)) ;
  127. /* dir.c */  int file_size PROTO((char *fname));
  128.  
  129. /* string.c */  int is_empty PROTO((char *str)) ;
  130. /* string.c */  void search_for_char PROTO((char **ptr, char chr)) ;
  131. /* string.c */  void search_back_for_char PROTO((char *beg_ptr, char **ptr, char chr)) ;
  132. /* string.c */  void strcpy_to_char PROTO((char *to, char *from, char chr)) ;
  133. /* string.c */  void strcpy_to_before_char PROTO((char *to, char *from, char chr)) ;
  134. /* string.c */  void strncpy_to_before_char PROTO((char *to, char *from, char chr, int len)) ;
  135. /* string.c */  void strcpy_lc PROTO((char *to, char *from)) ;
  136. /* string.c */  void strncpy_pad PROTO((char *to, char *from, int len, char chr)) ;
  137. /* string.c */  char *str2up PROTO((char *str)) ;
  138. /* string.c */  char *str2low PROTO((char *str)) ;
  139. /* string.c */  int is_number PROTO((char *str)) ;
  140. /* string.c */  int is_integer PROTO((char *str)) ;
  141. /* string.c */  char *strstr1_i PROTO((char *ps1, char *ps2)) ;
  142. /* string.c */  char *strstr1 PROTO((char *ps1, char *ps2)) ;
  143. /* t_or_f.c */  char *t_or_f PROTO((int val));
  144.  
  145.  
  146.  
  147.