/usr/include/speech_tools/EST_error.h is in libestools-dev 1:2.4~release-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1996,1997 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
/* Date: Thu Aug 14 1997 */
/* -------------------------------------------------------------------- */
/* Fatal error calls. */
/* */
/*************************************************************************/
#ifndef __EST_ERROR_H__
#define __EST_ERROR_H__
/* may get included from C */
#ifdef __cplusplus
#include <cstdarg>
#include <cstdio>
#else
#include <stdarg.h>
#include <stdio.h>
#endif
#include <setjmp.h>
#include "EST_unix.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_ERROR_MESSAGE_LENGTH 1024
typedef void (*EST_error_handler)(const char *format, ...);
extern const char *EST_error_where;
extern char *EST_error_message;
extern EST_error_handler EST_bug_func;
extern EST_error_handler EST_error_func;
extern EST_error_handler EST_sys_error_func;
extern EST_error_handler EST_warning_func;
extern EST_error_handler old_error_function;
extern EST_error_handler old_sys_error_function;
extern FILE *EST_error_stream;
extern FILE *EST_warning_stream;
extern jmp_buf *est_errjmp;
extern long errjmp_ok;
extern void EST_errors_default();
extern void EST_errors_quiet();
void EST_quiet_error_fn(const char *format, ...);
void EST_quiet_sys_error_fn(const char *format, ...);
#define _rxp_S_(X) #X
#define _rxp_s_(X) _rxp_S_(X)
#define EST_bug (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
(*EST_bug_func)
#if defined(EST_DEBUGGING)
#define EST_exit(N) abort()
#define EST_error (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
(*EST_error_func)
#define EST_warning (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
(*EST_warning_func)
#define EST_sys_error (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
(*EST_sys_error_func)
#else
#define EST_exit(N) exit(N)
#define EST_error (EST_error_where = NULL),\
(*EST_error_func)
#define EST_warning (EST_error_where = NULL),\
(*EST_warning_func)
#define EST_sys_error (EST_error_where = NULL),\
(*EST_sys_error_func)
#endif
#define est_error_throw() (est_errjmp ? longjmp(*est_errjmp,1) : (void)EST_exit(-1))
#define est_error() est_error_throw()
#define CATCH_ERRORS_SKEL( INIT,CLEANUP) \
{ \
INIT \
jmp_buf *old_errjmp = est_errjmp; \
int old_errjmp_ok = errjmp_ok; \
errjmp_ok =1; \
est_errjmp = (jmp_buf *)malloc(sizeof(jmp_buf)); \
int jmp_val = setjmp(*est_errjmp); \
if (jmp_val) { free(est_errjmp); est_errjmp = old_errjmp; errjmp_ok = old_errjmp_ok; CLEANUP} \
if (jmp_val)
#define CATCH_ERRORS() \
CATCH_ERRORS_SKEL(\
const int est_err_quiet=0; \
, \
;)
#define CATCH_ERRORS_QUIET() \
CATCH_ERRORS_SKEL(\
const int est_err_quiet=1; \
EST_error_handler old_error_function=EST_error_func; \
EST_error_handler old_sys_error_function=EST_sys_error_func; \
EST_error_func = EST_quiet_error_fn; \
EST_sys_error_func = EST_quiet_sys_error_fn; \
, \
EST_error_func=old_error_function; \
EST_sys_error_func=old_sys_error_function; \
)
#define END_CATCH_ERRORS() \
free(est_errjmp); \
est_errjmp = old_errjmp; \
errjmp_ok = old_errjmp_ok; \
if (est_err_quiet) { \
EST_error_func=old_error_function; \
EST_sys_error_func=old_sys_error_function; \
} \
} while (0)
/** Defines the attitude of a call to possible fatal errors.
* Passing one of these values to a function tells it how much
* care it needs to take to avoid calls to EST_error.
*
* These need snappier names.
* the numbers are their for historical reasons
*/
enum EST_error_behaviour
{
/** Function will not normally return an error unless something
* really bad has gone wrong. For feature lookup, will return
* default value if feature doesn't exist
*/
est_errors_checked = 0,
/** Function will throw errors when feature doesn't exist.
*/
est_errors_allowed = 1,
/** No fatal errors allowed. Function must catch all EST_error calls.
* Will *always* return a default value.
*/
est_errors_never = 2
};
#ifdef __cplusplus
}
#include "EST_String.h"
/* These are used to pass values into error functions inside */
/* templates. For classes we can define a function cast to EST_String, */
/* but we need the basic versions. */
inline const char *error_name(const EST_String val) {return val;}
inline const char *error_name(const void *val) {return EST_String::cat("<<ptr:", EST_String::Number((long)val, 16), ">>");}
inline const char *error_name(const EST_Regex val) {return val.tostring();}
inline const char *error_name(int val) {return EST_String::Number(val);}
inline const char *error_name(long val) {return EST_String::Number(val);}
inline const char *error_name(float val) {return EST_String::Number(val);}
inline const char *error_name(double val) {return EST_String::Number(val);}
inline const char *error_name(char val) {return EST_String::FromChar(val);}
#endif
#endif
|