2 * Epson Inkjet Printer Driver (ESC/P-R) for Linux
3 * Copyright (C) 2002-2005 AVASYS CORPORATION.
4 * Copyright (C) Seiko Epson Corporation 2002-2012.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA.
35 static char err_pname[256] = "";
36 static FILE *debug_f = NULL;
38 /* static functions */
39 static void err_doit (enum msgtype, int, const char *, va_list);
41 void debug_msg(const char *fmt, ...){
46 debug_f = fopen(DEBUG_PATH, "wb");
50 fchmod (fileno (debug_f), 0777);
54 vfprintf (debug_f, fmt, ap);
62 err_init (const char *name)
64 if (name && strlen (name) < 256)
65 strcpy (err_pname, name);
70 err_msg (enum msgtype type, const char *fmt, ...)
75 err_doit (type, 0, fmt, ap);
82 err_fatal (const char *fmt, ...)
87 err_doit (MSGTYPE_ERROR, 0, fmt, ap);
94 err_system (const char *fmt,...)
101 err_doit (MSGTYPE_ERROR, e, fmt, ap);
108 err_doit (enum msgtype type, int e, const char *fmt, va_list ap)
110 if (err_pname[0] != '\0')
111 fprintf (stderr, "%s : ", err_pname);
113 if (type == MSGTYPE_ERROR)
114 fprintf (stderr, "**** ERROR **** : ");
115 else if (type == MSGTYPE_WARNING)
116 fprintf (stderr, "**** WARNING **** : ");
117 else if (type == MSGTYPE_INFO)
118 fprintf (stderr, "**** INFO **** : ");
120 vfprintf (stderr, fmt, ap);
123 fprintf (stderr, " : %s", strerror (e));
125 fprintf (stderr, "\n");