Edinburgh Speech Tools  2.1-release
EST_error.c
Go to the documentation of this file.
1  /************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1996,1997 */
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  /* */
34  /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
35  /* Date: Thu Aug 14 1997 */
36  /* -------------------------------------------------------------------- */
37  /* Fatal error calls. */
38  /* */
39  /*************************************************************************/
40 
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <errno.h>
44 #include <string.h>
45 #include "EST_error.h"
46 
47 const char * EST_error_where=NULL;
48 static char EST_error_message_buf[MAX_ERROR_MESSAGE_LENGTH];
49 char *EST_error_message = EST_error_message_buf;
50 
51 void EST_default_bug_fn(const char *format, ...)
52 {
53  va_list ap;
54  char *p=EST_error_message;
55 
57  EST_error_stream = stderr;
58 
59  fprintf(EST_error_stream, "-=-=-=-=-=- EST Bug! -=-=-=-=-=-\n");
60  if (EST_error_where)
61  fprintf(EST_error_stream," %s\n", EST_error_where);
62 
63  va_start(ap, format);
64  vsprintf(p, format, ap);
65  va_end(ap);
66  fprintf(EST_error_stream, "%s\n", p);
67 
68  fprintf(EST_error_stream, "Please report this in as much detail as possible\n to festival@cstr.ed.ac.uk\n");
69  putc('\n', EST_error_stream);
70  fprintf(EST_error_stream, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
72 }
73 
74 void EST_default_error_fn(const char *format, ...)
75 {
76  va_list ap;
77  char *p=EST_error_message;
78 
80  EST_error_stream = stderr;
81 
82  fprintf(EST_error_stream, "-=-=-=-=-=- EST Error -=-=-=-=-=-\n");
83  if (EST_error_where)
84  fprintf(EST_error_stream," %s\n", EST_error_where);
85 
86  va_start(ap, format);
87  vsprintf(p, format, ap);
88  va_end(ap);
89  fprintf(EST_error_stream, "%s\n", p);
90 
91  fprintf(EST_error_stream, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
93 }
94 
95 void EST_quiet_error_fn(const char *format, ...)
96 {
97  va_list ap;
98  char *p=EST_error_message;
99 
100  va_start(ap, format);
101  vsprintf(p, format, ap);
102  va_end(ap);
103 
104  est_error_throw();
105 }
106 
107 void EST_default_warning_fn(const char *format, ...)
108 {
109  va_list ap;
110  char *p=EST_error_message;
111 
113  EST_warning_stream = stderr;
114 
115  fprintf(EST_warning_stream, "-=-=-=-=-=- EST Warning -=-=-=-=-=-\n");
116  if (EST_error_where)
117  fprintf(EST_warning_stream," %s\n", EST_error_where);
118 
119  va_start(ap, format);
120  vsprintf(p, format, ap);
121  va_end(ap);
122  fprintf(EST_warning_stream, "%s\n", p);
123 
124  fprintf(EST_warning_stream, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
125 }
126 
127 void EST_quiet_warning_fn(const char *format, ...)
128 {
129  va_list ap;
130  char *p=EST_error_message;
131 
132  va_start(ap, format);
133  vsprintf(p, format, ap);
134  va_end(ap);
135 }
136 
137 void EST_default_sys_error_fn(const char *format, ...)
138 {
139  va_list ap;
140  char *p=EST_error_message;
141  const char *msg = strerror(errno);
142 
143  if (EST_error_stream==NULL)
144  EST_error_stream = stderr;
145 
146  fprintf(EST_error_stream, "-=-=-=-=-=- EST IO Error -=-=-=-=-\n");
147  if (EST_error_where)
148  fprintf(EST_error_stream," %s\n", EST_error_where);
149 
150  va_start(ap, format);
151  vsprintf(p, format, ap);
152  va_end(ap);
153  fprintf(EST_error_stream, "%s - %s\n", p, msg);
154 
155  fprintf(EST_error_stream, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
156  est_error_throw();
157 }
158 
159 void EST_quiet_sys_error_fn(const char *format, ...)
160 {
161  va_list ap;
162  char *p=EST_error_message;
163  const char *msg = strerror(errno);
164 
165  va_start(ap, format);
166  vsprintf(p, format, ap);
167  va_end(ap);
168 
169  while (*p)
170  ++p;
171  strcat(p, " - ");
172  p+=3;
173  strcat(p, msg);
174 
175  est_error_throw();
176 }
177 
179 {
183 }
184 
186 {
190 }
191 
196 
199 
202 
203 jmp_buf *est_errjmp = 0;
204 long errjmp_ok=0;
205 
206 
207 
208 
209 
void(* EST_error_handler)(const char *format,...)
Definition: EST_error.h:63
FILE * EST_error_stream
Definition: EST_error.c:200
#define MAX_ERROR_MESSAGE_LENGTH
Definition: EST_error.h:61
void EST_default_warning_fn(const char *format,...)
Definition: EST_error.c:107
EST_error_handler old_error_function
Definition: EST_error.c:197
void EST_default_sys_error_fn(const char *format,...)
Definition: EST_error.c:137
void EST_quiet_error_fn(const char *format,...)
Definition: EST_error.c:95
EST_error_handler EST_error_func
Definition: EST_error.c:193
const char * EST_error_where
Definition: EST_error.c:47
EST_error_handler EST_bug_func
Definition: EST_error.c:192
void EST_quiet_warning_fn(const char *format,...)
Definition: EST_error.c:127
EST_error_handler EST_sys_error_func
Definition: EST_error.c:194
jmp_buf * est_errjmp
Definition: EST_error.c:203
void EST_quiet_sys_error_fn(const char *format,...)
Definition: EST_error.c:159
#define est_error_throw()
Definition: EST_error.h:112
FILE * EST_warning_stream
Definition: EST_error.c:201
void EST_default_bug_fn(const char *format,...)
Definition: EST_error.c:51
EST_error_handler old_sys_error_function
Definition: EST_error.c:198
char * EST_error_message
Definition: EST_error.c:49
NULL
Definition: EST_WFST.cc:55
void EST_default_error_fn(const char *format,...)
Definition: EST_error.c:74
long errjmp_ok
Definition: EST_error.c:204
void EST_errors_quiet()
Definition: EST_error.c:185
void EST_errors_default()
Definition: EST_error.c:178
EST_error_handler EST_warning_func
Definition: EST_error.c:195