aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2004-10-17 23:35:16 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2004-10-17 23:35:16 +0000
commit49f89e883cab593c2d513bdcf74ec55b32927808 (patch)
tree989438d33a5e696ccabf502bd855f70fe173ee8d /lib
parent36aeb90e348472432ad0dcbef56a2e4ce78efa5a (diff)
Notes
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 d674a056b6b0c..6ef38f1a2c420 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();
}
}