summaryrefslogtreecommitdiff
path: root/file/print.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-10-04 21:52:11 +0000
committerjbj <devnull@localhost>2002-10-04 21:52:11 +0000
commit00c78bd40c7328b315b68e777c259983a2ace16d (patch)
tree4d6e69e656ed8f88b958a8a7acc85654fc7f9f52 /file/print.c
parentb8751e90f613909e1da1c7909aa760699203b53a (diff)
downloadlibrpm-tizen-00c78bd40c7328b315b68e777c259983a2ace16d.tar.gz
librpm-tizen-00c78bd40c7328b315b68e777c259983a2ace16d.tar.bz2
librpm-tizen-00c78bd40c7328b315b68e777c259983a2ace16d.zip
Use error(3) if available, diddle up a replacement for those who have not.
Hide stdout in fmagic, drill fmagic through the output routines. CVS patchset: 5752 CVS date: 2002/10/04 21:52:11
Diffstat (limited to 'file/print.c')
-rw-r--r--file/print.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/file/print.c b/file/print.c
index 0b6aafd04..08476a23b 100644
--- a/file/print.c
+++ b/file/print.c
@@ -134,44 +134,52 @@ mdump(struct magic *m)
* ckfprintf - fprintf, but with error checking
*/
void
-ckfputs(const char *str, FILE *fil)
+ckfputs(const char *str, fmagic fm)
{
- if (fputs(str,fil) == EOF)
- error("write failed.\n");
+ FILE *f = (fm->f ? fm->f : stdout);
+ if (fputs(str, f) == EOF)
+ error(EXIT_FAILURE, 0, "ckfputs write failed.\n");
}
/*VARARGS*/
void
-ckfprintf(FILE *f, const char *fmt, ...)
+ckfprintf(fmagic fm, const char *fmt, ...)
{
+ FILE *f = (fm->f ? fm->f : stdout);
+
va_list va;
va_start(va, fmt);
(void) vfprintf(f, fmt, va);
if (ferror(f))
- error("write failed.\n");
+ error(EXIT_FAILURE, 0, "ckfprintf write failed.\n");
va_end(va);
}
+#if !defined(HAVE_ERROR)
/*
* error - print best error message possible and exit
*/
/*VARARGS*/
void
-error(const char *f, ...)
+error(int status, int errnum, const char *fmt, ...)
{
va_list va;
- va_start(va, f);
+ va_start(va, fmt);
/* cuz we use stdout for most, stderr here */
(void) fflush(stdout);
if (progname != NULL)
(void) fprintf(stderr, "%s: ", progname);
- (void) vfprintf(stderr, f, va);
+ (void) vfprintf(stderr, fmt, va);
va_end(va);
- exit(EXIT_FAILURE);
+#if NOTYET
+ if (status)
+#endif
+ exit(status);
}
+#endif
/*VARARGS*/
void