2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 #include <toollib/error.h>
12 Error (const char * fmt
, ...)
16 fprintf (stderr
, "Error: ");
17 vfprintf (stderr
, fmt
, args
);
18 fprintf (stderr
, "\n");
23 Warn (const char * fmt
, ...)
27 fprintf (stderr
, "Warning: ");
28 vfprintf (stderr
, fmt
, args
);
29 fprintf (stderr
, "\n");
34 StdError (const char * fmt
, ...)
38 fprintf (stderr
, "Error: ");
39 vfprintf (stderr
, fmt
, args
);
40 fprintf (stderr
, ": %s\n", strerror (errno
));
45 StdWarn (const char * fmt
, ...)
49 fprintf (stderr
, "Warning: ");
50 vfprintf (stderr
, fmt
, args
);
51 fprintf (stderr
, ": %s\n", strerror (errno
));
55 static int ErrorSP
= 0;
56 static char * ErrorStack
[32];
59 PushMsg (const char * pre
, const char * fmt
, va_list args
, const char * post
)
65 len
= strlen (buffer
);
66 strcpy (buffer
+len
, ": ");
69 rest
= sizeof (buffer
) - len
;
72 len
= vsnprintf (buffer
+len
, rest
, fmt
, args
);
74 len
= vsprintf (buffer
+len
, fmt
, args
);
85 strcat (buffer
, ": ");
91 strcpy (buffer
+ sizeof(buffer
) - rest
, post
);
95 strncpy (buffer
+ sizeof(buffer
) - rest
, post
, rest
-1);
96 buffer
[sizeof (buffer
) - 1] = 0;
100 ErrorStack
[ErrorSP
++] = xstrdup (buffer
);
104 PrintErrorStack (void)
107 fprintf (stderr
, "%s\n", ErrorStack
[ErrorSP
]);
113 ClearErrorStack (void)
119 PushError (const char * fmt
, ...)
122 VA_START (args
, fmt
);
123 PushMsg ("Error", fmt
, args
, NULL
);
128 PushWarn (const char * fmt
, ...)
131 VA_START (args
, fmt
);
132 PushMsg ("Warning", fmt
, args
, NULL
);
137 PushStdError (const char * fmt
, ...)
140 VA_START (args
, fmt
);
141 PushMsg ("Error", fmt
, args
, strerror (errno
));
146 PushStdWarn (const char * fmt
, ...)
149 VA_START (args
, fmt
);
150 PushMsg ("Warning", fmt
, args
, strerror (errno
));