New function - same as glibtop_error_r', but doesn't call exit'.

1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* sysdeps/common/error.c (glibtop_warn_r): New function -
	same as `glibtop_error_r', but doesn't call `exit'.
	(glibtop_error_io_r, glibtop_warn_io_r): New functions,
	display `strerror (errno)' together with message.
This commit is contained in:
Martin Baulig
1998-06-14 16:47:09 +00:00
committed by Martin Baulig
parent 8f14d30d11
commit 58707dac42
2 changed files with 51 additions and 0 deletions

View File

@@ -27,8 +27,16 @@
__BEGIN_DECLS
#define glibtop_error(p1, args...) glibtop_error_r(glibtop_global_server , p1 , ## args)
#define glibtop_warn(p1, args...) glibtop_warn_r(glibtop_global_server , p1 , ## args)
#define glibtop_error_io(p1, args...) glibtop_error_io_r(glibtop_global_server , p1 , ## args)
#define glibtop_warn_io(p1, args...) glibtop_warn_io_r(glibtop_global_server , p1 , ## args)
extern void glibtop_error_r __P((glibtop *, char *, ...));
extern void glibtop_warn_r __P((glibtop *, char *, ...));
extern void glibtop_error_io_r __P((glibtop *, char *, ...));
extern void glibtop_warn_io_r __P((glibtop *, char *, ...));
__END_DECLS

View File

@@ -37,3 +37,46 @@ glibtop_error_r (glibtop *server, char *format, ...)
va_end (ap);
exit (1);
}
void
glibtop_error_io_r (glibtop *server, char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "%s: ", server->name);
vfprintf (stderr, format, ap);
fprintf (stderr, ": %s\n", strerror (errno));
va_end (ap);
exit (1);
}
void
glibtop_warn_r (glibtop *server, char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "%s: ", server->name);
vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
va_end (ap);
}
void
glibtop_warn_io_r (glibtop *server, char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "%s: ", server->name);
vfprintf (stderr, format, ap);
fprintf (stderr, ": %s\n", strerror (errno));
va_end (ap);
}