00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "config.h"
00030 #include "system.h"
00031 #include "errors.h"
00032
00033
00034
00035 const char *progname;
00036
00037
00038
00039 int have_error = 0;
00040
00041
00042
00043 void
00044 warning VPARAMS ((const char *format, ...))
00045 {
00046 #ifndef SGI_MONGOOSE
00047 VA_OPEN (ap, format);
00048 VA_FIXEDARG (ap, const char *, format);
00049 #else
00050 va_list ap;
00051
00052 VA_START (ap, format);
00053 #endif
00054
00055 fprintf (stderr, "%s: warning: ", progname);
00056 vfprintf (stderr, format, ap);
00057 #ifndef SGI_MONGOOSE
00058 VA_CLOSE (ap);
00059 #else
00060 va_end (ap);
00061 #endif
00062 fputc('\n', stderr);
00063 }
00064
00065
00066
00067
00068 void
00069 error VPARAMS ((const char *format, ...))
00070 {
00071 #ifndef SGI_MONGOOSE
00072 VA_OPEN (ap, format);
00073 VA_FIXEDARG (ap, const char *, format);
00074 #else
00075 va_list ap;
00076
00077 VA_START (ap, format);
00078 #endif
00079
00080 fprintf (stderr, "%s: ", progname);
00081 vfprintf (stderr, format, ap);
00082 #ifndef SGI_MONGOOSE
00083 VA_CLOSE (ap);
00084 #else
00085 va_end (ap);
00086 #endif
00087 fputc('\n', stderr);
00088
00089 have_error = 1;
00090 }
00091
00092
00093
00094
00095 void
00096 fatal VPARAMS ((const char *format, ...))
00097 {
00098 #ifndef SGI_MONGOOSE
00099 VA_OPEN (ap, format);
00100 VA_FIXEDARG (ap, const char *, format);
00101 #else
00102 va_list ap;
00103
00104 VA_START (ap, format);
00105 #endif
00106
00107 fprintf (stderr, "%s: ", progname);
00108 vfprintf (stderr, format, ap);
00109 #ifndef SGI_MONGOOSE
00110 VA_CLOSE (ap);
00111 #else
00112 va_end (ap);
00113 #endif
00114 fputc('\n', stderr);
00115 exit (FATAL_EXIT_CODE);
00116 }
00117
00118
00119
00120 void
00121 internal_error VPARAMS ((const char *format, ...))
00122 {
00123 #ifndef SGI_MONGOOSE
00124 VA_OPEN (ap, format);
00125 VA_FIXEDARG (ap, const char *, format);
00126 #else
00127 va_list ap;
00128
00129 VA_START (ap, format);
00130 #endif
00131
00132 fprintf (stderr, "%s: Internal error: ", progname);
00133 vfprintf (stderr, format, ap);
00134 #ifndef SGI_MONGOOSE
00135 VA_CLOSE (ap);
00136 #else
00137 va_end (ap);
00138 #endif
00139 fputc ('\n', stderr);
00140 exit (FATAL_EXIT_CODE);
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 const char *
00150 trim_filename (name)
00151 const char *name;
00152 {
00153 static const char this_file[] = __FILE__;
00154 const char *p = name, *q = this_file;
00155
00156
00157 while (*p == *q && *p != 0 && *q != 0)
00158 p++, q++;
00159
00160
00161 while (p > name && p[-1] != DIR_SEPARATOR
00162 #ifdef DIR_SEPARATOR_2
00163 && p[-1] != DIR_SEPARATOR_2
00164 #endif
00165 )
00166 p--;
00167
00168 return p;
00169 }
00170
00171
00172
00173
00174 void
00175 fancy_abort (file, line, func)
00176 const char *file;
00177 int line;
00178 const char *func;
00179 {
00180 internal_error ("abort in %s, at %s:%d", func, file, line);
00181 }