2
* function: Miscellaneous functions for aacDECdrop
4
* This program is distributed under the GNU General Public License, version 2.
5
* A copy of this license is included with this source.
7
* Copyright (C) 2002 John Edwards
16
static char *_filename;
17
void (*error_handler)(const char *fmt, ...) = error_dialog;
20
* Set the current input file name.
23
void set_filename(char *filename)
29
* Display an error dialog, possibly adding system error information.
32
void error_dialog(const char *fmt, ...)
38
/* A really rough sanity check to protect against blatant buffer overrun */
39
if (strlen(fmt) > 750)
41
sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
45
if (_filename != NULL && strlen(_filename) < 255)
47
sprintf(msgbuf, "%s: ", _filename);
48
bufp += strlen(msgbuf);
53
vsprintf(bufp, fmt, ap);
59
bufp = msgbuf + strlen(msgbuf);
60
sprintf(bufp, " error is %s (%d)", strerror(errno), errno);
65
MessageBox(NULL, msgbuf, "Error", 0);
68
void log_error(const char *fmt, ...)
75
/* A really rough sanity check to protect against blatant buffer overrun */
76
if (strlen(fmt) > 750)
78
sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
82
if (_filename != NULL && strlen(_filename) < 255)
84
sprintf(msgbuf, "%s : ", _filename);
85
bufp += strlen(msgbuf);
90
vsprintf(bufp, fmt, ap);
96
bufp = msgbuf + strlen(msgbuf);
97
sprintf(bufp, " error is: %s (%d)", strerror(errno), errno);
104
if ((fp = fopen("oggdrop.log", "a")) == (FILE *)NULL)
107
fprintf(fp, "%s\n", msgbuf);
114
void set_use_dialogs(int use_dialogs)
117
error_handler = error_dialog;
119
error_handler = log_error;
123
/******************************** end of misc.c ********************************/
2
* function: Miscellaneous functions for aacDECdrop
4
* This program is distributed under the GNU General Public License, version 2.
5
* A copy of this license is included with this source.
7
* Copyright (C) 2002 John Edwards
16
static char *_filename;
17
void (*error_handler)(const char *fmt, ...) = error_dialog;
20
* Set the current input file name.
23
void set_filename(char *filename)
29
* Display an error dialog, possibly adding system error information.
32
void error_dialog(const char *fmt, ...)
38
/* A really rough sanity check to protect against blatant buffer overrun */
39
if (strlen(fmt) > 750)
41
sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
45
if (_filename != NULL && strlen(_filename) < 255)
47
sprintf(msgbuf, "%s: ", _filename);
48
bufp += strlen(msgbuf);
53
vsprintf(bufp, fmt, ap);
59
bufp = msgbuf + strlen(msgbuf);
60
sprintf(bufp, " error is %s (%d)", strerror(errno), errno);
65
MessageBox(NULL, msgbuf, "Error", 0);
68
void log_error(const char *fmt, ...)
75
/* A really rough sanity check to protect against blatant buffer overrun */
76
if (strlen(fmt) > 750)
78
sprintf(msgbuf, "%s %s", "<buffer overflow> ", fmt);
82
if (_filename != NULL && strlen(_filename) < 255)
84
sprintf(msgbuf, "%s : ", _filename);
85
bufp += strlen(msgbuf);
90
vsprintf(bufp, fmt, ap);
96
bufp = msgbuf + strlen(msgbuf);
97
sprintf(bufp, " error is: %s (%d)", strerror(errno), errno);
104
if ((fp = fopen("oggdrop.log", "a")) == (FILE *)NULL)
107
fprintf(fp, "%s\n", msgbuf);
114
void set_use_dialogs(int use_dialogs)
117
error_handler = error_dialog;
119
error_handler = log_error;
123
/******************************** end of misc.c ********************************/