Module Name:    src
Committed By:   christos
Date:           Wed Mar  9 15:45:38 UTC 2016

Modified Files:
        src/sys/fs/cd9660: cd9660_util.c

Log Message:
Make it usable from userland.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/fs/cd9660/cd9660_util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/cd9660/cd9660_util.c
diff -u src/sys/fs/cd9660/cd9660_util.c:1.12 src/sys/fs/cd9660/cd9660_util.c:1.13
--- src/sys/fs/cd9660/cd9660_util.c:1.12	Mon Nov 10 13:46:33 2014
+++ src/sys/fs/cd9660/cd9660_util.c	Wed Mar  9 10:45:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_util.c,v 1.12 2014/11/10 18:46:33 maxv Exp $	*/
+/*	$NetBSD: cd9660_util.c,v 1.13 2016/03/09 15:45:37 christos Exp $	*/
 
 /*-
  * Copyright (c) 1994
@@ -37,9 +37,17 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_util.c,v 1.12 2014/11/10 18:46:33 maxv Exp $");
+#ifdef _KERNEL
+__KERNEL_RCSID(0, "$NetBSD: cd9660_util.c,v 1.13 2016/03/09 15:45:37 christos Exp $");
+#else
+/* used by macppc_installboot */
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+#endif
 
 #include <sys/param.h>
+#ifdef _KERNEL
 #include <sys/systm.h>
 #include <sys/namei.h>
 #include <sys/resourcevar.h>
@@ -51,14 +59,24 @@ __KERNEL_RCSID(0, "$NetBSD: cd9660_util.
 #include <sys/mount.h>
 #include <sys/vnode.h>
 #include <sys/dirent.h>
+#else
+#include <assert.h>
+#include <dirent.h>
+#define KASSERT(x)	assert(x)	/* XXX for <fs/unicode.h> */
+#endif
 
 #include <fs/cd9660/iso.h>
+#ifdef _KERNEL
 #include <fs/cd9660/cd9660_extern.h>
+#else
+#include "installboot.h"
+static int isochar(const u_char *, const u_char *, int, uint16_t *);
+#endif
 
 #include <fs/unicode.h>
 
-static u_int16_t wget(const u_char **, size_t *, int);
-static int wput(u_char *, size_t, u_int16_t, int);
+static uint16_t wget(const u_char **, size_t *, int);
+static int wput(u_char *, size_t, uint16_t, int);
 
 int cd9660_utf8_joliet = 1;
 
@@ -68,8 +86,9 @@ int cd9660_utf8_joliet = 1;
  */
 int
 isochar(const u_char *isofn, const u_char *isoend, int joliet_level,
-	u_int16_t *c)
+    uint16_t *c)
 {
+
 	*c = isofn[0];
 	if (joliet_level == 0 || isofn + 1 == isoend) {
 		/* (00) and (01) are one byte in Joliet, too */
@@ -95,12 +114,17 @@ isochar(const u_char *isofn, const u_cha
  */
 int
 isofncmp(const u_char *fn, size_t fnlen, const u_char *isofn, size_t isolen,
-	int joliet_level)
+    int joliet_level)
 {
 	int i, j;
-	u_int16_t fc, ic;
+	uint16_t fc, ic;
 	const u_char *isoend = isofn + isolen;
 
+#ifdef ISOFNCMPDEBUG
+	printf("fn = %s, fnlen = %zu, isofn = %s, isolen = %zu\n",
+	    fn, fnlen, isofn, isolen);
+#endif
+
 	while (fnlen > 0) {
 		fc = wget(&fn, &fnlen, joliet_level);
 
@@ -132,10 +156,10 @@ isofncmp(const u_char *fn, size_t fnlen,
 					if (fc >= 'a' && fc <= 'z')
 						fc -= 'a' - 'A';
 
-					return (int) fc - (int) ic;
+					return (int)fc - (int)ic;
 				}
 			} else
-				return (int) fc - (int) ic;
+				return (int)fc - (int)ic;
 		}
 	}
 	if (isofn != isoend) {
@@ -162,11 +186,11 @@ isofncmp(const u_char *fn, size_t fnlen,
  */
 void
 isofntrans(const u_char *infn, int infnlen, u_char *outfn, u_short *outfnlen,
-	int original, int casetrans, int assoc, int joliet_level)
+    int original, int casetrans, int assoc, int joliet_level)
 {
 	int fnidx = 0;
 	const u_char *infnend = infn + infnlen;
-	u_int16_t c;
+	uint16_t c;
 	int sz;
 
 	if (assoc) {
@@ -199,7 +223,7 @@ isofntrans(const u_char *infn, int infnl
 	*outfnlen = fnidx;
 }
 
-static u_int16_t
+static uint16_t
 wget(const u_char **str, size_t *sz, int joliet_level)
 {
 	if (joliet_level > 0 && cd9660_utf8_joliet) {
@@ -211,7 +235,7 @@ wget(const u_char **str, size_t *sz, int
 		 * this effectively assumes provided file name is using
 		 * ISO-8859-1 subset.
 		 */
-		u_int16_t c = *str[0];
+		uint16_t c = *str[0];
 		(*str)++;
 		(*sz)--;
 
@@ -220,7 +244,7 @@ wget(const u_char **str, size_t *sz, int
 }
 
 static int
-wput(u_char *s, size_t n, u_int16_t c, int joliet_level)
+wput(u_char *s, size_t n, uint16_t c, int joliet_level)
 {
 	if (joliet_level > 0 && cd9660_utf8_joliet) {
 		/* Store Joliet file name encoded into UTF-8 */

Reply via email to