Edinburgh Speech Tools 2.4-release
EST_cutils.h
1/*************************************************************************/
2/* */
3/* Centre for Speech Technology Research */
4/* University of Edinburgh, UK */
5/* Copyright (c) 1994,1995,1996 */
6/* All Rights Reserved. */
7/* */
8/* Permission is hereby granted, free of charge, to use and distribute */
9/* this software and its documentation without restriction, including */
10/* without limitation the rights to use, copy, modify, merge, publish, */
11/* distribute, sublicense, and/or sell copies of this work, and to */
12/* permit persons to whom this work is furnished to do so, subject to */
13/* the following conditions: */
14/* 1. The code must retain the above copyright notice, this list of */
15/* conditions and the following disclaimer. */
16/* 2. Any modifications must be clearly marked as such. */
17/* 3. Original authors' names are not deleted. */
18/* 4. The authors' names are not used to endorse or promote products */
19/* derived from this software without specific prior written */
20/* permission. */
21/* */
22/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30/* THIS SOFTWARE. */
31/* */
32/*************************************************************************/
33/* Author : Paul Taylor and Alan W Black */
34/* Date : July 1996 */
35/*-----------------------------------------------------------------------*/
36/* Various C utility functions */
37/* */
38/*=======================================================================*/
39#ifndef __EST_CUTILS_H__
40#define __EST_CUTILS_H__
41
42#include "EST_common.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48extern const char * const est_tools_version;
49extern const char * const est_name;
50extern const char * const est_libdir;
51extern const char * const est_datadir;
52extern const char * const est_ostype;
53
54#include "EST_walloc.h"
55#include "EST_system.h"
56
57#ifndef streq
58#define streq(X,Y) (strcmp(X,Y)==0)
59#endif
60
61char *cmake_tmp_filename();
62
63/* NOTE perqs (from Three Rivers) have the third byte order, are not */
64/* supported, if you find a working one let me know and I'll add */
65/* support -- awb (hoping no one responds :-) */
66enum EST_bo_t {bo_big, bo_little, bo_perq};
67
68extern int est_endian_loc;
69/* Sun, HP, SGI Mips, M68000 */
70#define EST_BIG_ENDIAN (((char *)&est_endian_loc)[0] == 0)
71/* Intel, Alpha, DEC Mips, Vax */
72#define EST_LITTLE_ENDIAN (((char *)&est_endian_loc)[0] != 0)
73#define EST_NATIVE_BO (EST_BIG_ENDIAN ? bo_big : bo_little)
74#define EST_SWAPPED_BO (EST_BIG_ENDIAN ? bo_little : bo_big)
75
76#define SWAPINT(x) ((((unsigned)x) & 0xff) << 24 | \
77 (((unsigned)x) & 0xff00) << 8 | \
78 (((unsigned)x) & 0xff0000) >> 8 | \
79 (((unsigned)x) & 0xff000000) >> 24)
80#define SWAPSHORT(x) ((((unsigned)x) & 0xff) << 8 | \
81 (((unsigned)x) & 0xff00) >> 8)
82void swapdouble(double *d);
83void swapfloat(float *f);
84
85void swap_bytes_ushort(unsigned short *data, int length);
86void swap_bytes_short(short *data, int length);
87void swap_bytes_uint(unsigned int *data, int length);
88void swap_bytes_int(int *data, int length);
89void swap_bytes_float(float *data, int length);
90void swap_bytes_double(double *data, int length);
91
92enum EST_bo_t str_to_bo(const char *boname);
93const char *bo_to_str(enum EST_bo_t bo);
94
95/* return the greater of the two values */
96#define Gof(a, b) (((a) > (b)) ? (a) : (b))
97/* return the lesser of the two values */
98#define Lof(a, b) (((a) < (b)) ? (a) : (b))
99
100
101#ifdef __cplusplus
102}
103#endif
104
105
106#endif /*__EST_CUTILS_H__ */