1 #include <errno.h>
2 #include <stdarg.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <syslog.h>
7
8 #include <portaudio.h>
9
error_syslog(char * format,...)10 void error_syslog(char *format, ...)
11 {
12 char buffer[4096];
13 va_list ap;
14
15 va_start(ap, format);
16 (void) vsnprintf(buffer, 4096, format, ap);
17 va_end(ap);
18
19 /* If you want to write stuff to system log... at your own risk!
20 syslog(LOG_INFO, "%s: %m", buffer);
21 */
22 }
23
error_exit(char * format,...)24 void error_exit(char *format, ...)
25 {
26 int e = errno;
27
28 char buffer[4096];
29 va_list ap;
30
31 va_start(ap, format);
32 (void)vsnprintf(buffer, sizeof buffer, format, ap);
33 va_end(ap);
34
35 fprintf(stderr, "%s\n", buffer);
36 fprintf(stderr, "errno: %d/%s (if applicable)\n", e, strerror(e));
37
38 exit(EXIT_FAILURE);
39 }
40
error_check(PaError err,char * msg)41 void error_check(PaError err, char *msg)
42 {
43 if (err < 0)
44 error_exit("%s (%s)\n", msg, Pa_GetErrorText(err));
45 }
46