1 /** 2 * @file util.h 3 * 4 * <JA> 5 * @brief ���ѥ桼�ƥ���ƥ��ؿ����˴ؤ������ 6 * 7 * ���Υե�����ˤϡ��ƥ������ɤ߹��ߤ䰵�̥ե������� 8 * �������դ����Х��ȥ����������ѤΥ�å��������ϴؿ��ʤɤ� 9 * ���ѤΥ桼�ƥ���ƥ��ؿ��˴ؤ���������ޤޤ�Ƥ��ޤ��� 10 * 11 * </JA> 12 * <EN> 13 * @brief Definitions for common utility functions 14 * 15 * This file contains definitions for common utility functions: 16 * text reading and parsing, compressed file input, memory allocation, 17 * byte order changing, common printf function (j_printf etc.) and so on. 18 * 19 * </EN> 20 * 21 * @author Akinobu LEE 22 * @date Sat Feb 12 12:30:40 2005 23 * 24 * $Revision: 1.6 $ 25 * 26 */ 27 /* 28 * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University 29 * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology 30 * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology 31 * All rights reserved 32 */ 33 34 #ifndef __SENT_UTIL_H__ 35 #define __SENT_UTIL_H__ 36 37 /* 38 * 39 */ 40 /** 41 * @brief Memory block size in bytes for mybmalloc() 42 * 43 * mybmalloc() allocate memory per big block to reduce memory 44 * management overhead. This value sets the block size to be allocated. 45 * Smaller value may leads to finer granularity, but overhead may increase. 46 * Larger value may result in reduction of overhead, but too much memory 47 * can be allocated for a small memory requirement. 48 * 49 */ 50 #define MYBMALLOC_BLOCK_SIZE 10000 51 52 /// Information of allocated memory block for mybmalloc() 53 typedef struct _bmalloc_base { 54 void *base; ///< Pointer to the actually allocated memory block 55 char *now; ///< Start Pointer of Currently assigned area 56 char *end; ///< End Pointer of Currently assigned area 57 struct _bmalloc_base *next; ///< Link to next data, NULL if no more 58 } BMALLOC_BASE; 59 60 /* readfile.c */ 61 char *getl(char *, int, FILE *); 62 char *getl_fp(char *, int, FILE *); 63 char *get_line_from_stdin(char *buf, int buflen, char *prompt); 64 65 /* gzfile.c */ 66 FILE *fopen_readfile(char *); 67 int fclose_readfile(FILE *); 68 FILE *fopen_writefile(char *); 69 int fclose_writefile(FILE *); 70 size_t myfread(void *ptr, size_t size, size_t n, FILE *fp); 71 size_t myfwrite(void *ptr, size_t size, size_t n, FILE *fp); 72 int myfgetc(FILE *fp); 73 int myfeof(FILE *fp); 74 int myfrewind(FILE *fp); 75 76 /* mybmalloc.c */ 77 void *mybmalloc2(unsigned int size, BMALLOC_BASE **list); 78 char *mybstrdup2(char *, BMALLOC_BASE **list); 79 void mybfree2(BMALLOC_BASE **list); 80 81 /* mymalloc.c */ 82 void *mymalloc(size_t size); 83 void *mymalloc_big(size_t elsize, size_t nelem); 84 void *myrealloc(void *, size_t); 85 void *mycalloc(size_t, size_t); 86 87 /* endian.c */ 88 void swap_sample_bytes(SP16 *buf, int len); 89 void swap_bytes(char *buf, size_t unitbyte, size_t unitnum); 90 91 /* j_printf.c */ 92 void jlog_set_output(FILE *fp); 93 FILE *jlog_get_fp(); 94 void jlog(char *format, ...); 95 int jlog_flush(); 96 97 /* mystrtok.c */ 98 char *mystrtok_quotation(char *str, char *delim, int left_paren, int right_paren, int mode); /* mode:0=normal, 1=just move to next token */ 99 char *mystrtok_quote(char *str, char *delim); 100 char *mystrtok(char *str, char *delim); 101 char *mystrtok_movetonext(char *str, char *delim); 102 103 /* confout.c */ 104 void confout(FILE *strm); 105 void confout_version(FILE *strm); 106 void confout_audio(FILE *strm); 107 void confout_lm(FILE *strm); 108 void confout_am(FILE *strm); 109 void confout_lib(FILE *strm); 110 void confout_process(FILE *strm); 111 112 /* qsort.c */ 113 void qsort_reentrant(void *base, int count, int size, int (*compare)(const void *, const void *, void *), void *pointer); 114 115 116 #endif /* __SENT_UTIL_H__ */ 117