summaryrefslogtreecommitdiff
path: root/cpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpio.c')
-rw-r--r--cpio.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/cpio.c b/cpio.c
new file mode 100644
index 0000000..5d5d20b
--- /dev/null
+++ b/cpio.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004 Michael Schroeder (mls@suse.de)
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cpio.h"
+
+/****************************************************************
+ *
+ * cpio archive
+ *
+ */
+
+unsigned int cpion(char *s)
+{
+ int i;
+ unsigned int r = 0;
+ for (i = 0; i < 8; i++, s++)
+ if (*s >= '0' && *s <= '9')
+ r = (r << 4) | (*s - '0');
+ else if (*s >= 'a' && *s <= 'f')
+ r = (r << 4) | (*s - ('a' - 10));
+ else if (*s >= 'A' && *s <= 'F')
+ r = (r << 4) | (*s - ('a' - 10));
+ else
+ {
+ fprintf(stderr, "bad cpio archive\n");
+ exit(1);
+ }
+ return r;
+}
+