123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #include <stdio.h>
- #include <stdarg.h>
- #include <stdlib.h>
- #include <string.h>
- #include <error.h>
- libc_hidden_proto(putc)
- libc_hidden_proto(fflush)
- libc_hidden_proto(fputc)
- libc_hidden_proto(__fputc_unlocked)
- unsigned int error_message_count = 0;
- int error_one_per_line;
- void (*error_print_progname) (void) = NULL;
- extern __typeof(error) __error attribute_hidden;
- void __error (int status, int errnum, const char *message, ...)
- {
- va_list args;
- fflush (stdout);
- if (error_print_progname)
- (*error_print_progname) ();
- else
- fprintf (stderr, "%s: ", __uclibc_progname);
- va_start (args, message);
- vfprintf (stderr, message, args);
- va_end (args);
- ++error_message_count;
- if (errnum) {
- fprintf (stderr, ": %s", strerror (errnum));
- }
- putc ('\n', stderr);
- if (status)
- exit (status);
- }
- weak_alias(__error,error)
- extern __typeof(error_at_line) __error_at_line attribute_hidden;
- void __error_at_line (int status, int errnum, const char *file_name,
- unsigned int line_number, const char *message, ...)
- {
- va_list args;
- if (error_one_per_line) {
- static const char *old_file_name;
- static unsigned int old_line_number;
- if (old_line_number == line_number &&
- (file_name == old_file_name || !strcmp (old_file_name, file_name)))
-
- return;
- old_file_name = file_name;
- old_line_number = line_number;
- }
- fflush (stdout);
- if (error_print_progname)
- (*error_print_progname) ();
- else
- fprintf (stderr, "%s:", __uclibc_progname);
- if (file_name != NULL)
- fprintf (stderr, "%s:%d: ", file_name, line_number);
- va_start (args, message);
- vfprintf (stderr, message, args);
- va_end (args);
- ++error_message_count;
- if (errnum) {
- fprintf (stderr, ": %s", strerror (errnum));
- }
- putc ('\n', stderr);
- if (status)
- exit (status);
- }
- weak_alias(__error_at_line,error_at_line)
|