summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-10-17 23:35:16 +0000
committerkientzle <kientzle@FreeBSD.org>2004-10-17 23:35:16 +0000
commit229af4a1167ba36c23c8ef805ed97f960187d459 (patch)
tree989438d33a5e696ccabf502bd855f70fe173ee8d /lib
parentb36ed839e4822fe325b30fcd7a9ec42feaec5c68 (diff)
downloadFreeBSD-src-229af4a1167ba36c23c8ef805ed97f960187d459.zip
FreeBSD-src-229af4a1167ba36c23c8ef805ed97f960187d459.tar.gz
Don't rely on stdio here.
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_check_magic.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/libarchive/archive_check_magic.c b/lib/libarchive/archive_check_magic.c
index d674a05..6ef38f1 100644
--- a/lib/libarchive/archive_check_magic.c
+++ b/lib/libarchive/archive_check_magic.c
@@ -36,6 +36,12 @@ __FBSDID("$FreeBSD$");
#include "archive_private.h"
static void
+errmsg(const char *m)
+{
+ write(2, m, strlen(m));
+}
+
+static void
diediedie(void)
{
*(char *)0 = 1; /* Deliberately segfault and force a coredump. */
@@ -58,15 +64,16 @@ state_name(unsigned s)
static void
-write_all_states(FILE *f, int states)
+write_all_states(int states)
{
unsigned lowbit;
/* A trick for computing the lowest set bit. */
while ((lowbit = states & (-states)) != 0) {
states &= ~lowbit; /* Clear the low bit. */
- fprintf(f, "%s%s", state_name(lowbit),
- (states != 0) ? "/" : "");
+ errmsg(state_name(lowbit));
+ if (states != 0)
+ errmsg("/");
}
}
@@ -81,8 +88,9 @@ __archive_check_magic(struct archive *a, unsigned magic, unsigned state,
const char *function)
{
if (a->magic != magic) {
- fprintf(stderr, "INTERNAL ERROR: Function %s invoked"
- " with invalid struct archive structure.\n", function);
+ errmsg("INTERNAL ERROR: Function ");
+ errmsg(function);
+ errmsg(" invoked with invalid struct archive structure.\n");
diediedie();
}
@@ -90,12 +98,13 @@ __archive_check_magic(struct archive *a, unsigned magic, unsigned state,
return;
if ((a->state & state) == 0) {
- fprintf(stderr, "INTERNAL ERROR: Function '%s' invoked"
- " with archive structure in state '", function);
- write_all_states(stderr, a->state);
- fprintf(stderr,"', should be in state '");
- write_all_states(stderr, state);
- fprintf(stderr, "'\n");
+ errmsg("INTERNAL ERROR: Function '");
+ errmsg(function);
+ errmsg("' invoked with archive structure in state '");
+ write_all_states(a->state);
+ errmsg("', should be in state '");
+ write_all_states(state);
+ errmsg("'\n");
diediedie();
}
}
OpenPOWER on IntegriCloud