summaryrefslogtreecommitdiffstats
path: root/sys/fs/udf
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2003-11-05 06:55:23 +0000
committerscottl <scottl@FreeBSD.org>2003-11-05 06:55:23 +0000
commitc7d964d2cef031c840960d17686a8247a9528514 (patch)
tree2e7be0a33ddd8a09177e3c3fd0d202284d62aaaf /sys/fs/udf
parent6e846fedd8852d787b0b5bf5669ca8a101a32e5e (diff)
downloadFreeBSD-src-c7d964d2cef031c840960d17686a8247a9528514.zip
FreeBSD-src-c7d964d2cef031c840960d17686a8247a9528514.tar.gz
Add udf_UncompressUnicodeByte() for processing cs0 strings in a way that the
iconv mehtods can handle Submitted by: imura@ryu16.org
Diffstat (limited to 'sys/fs/udf')
-rw-r--r--sys/fs/udf/osta.c45
-rw-r--r--sys/fs/udf/osta.h1
2 files changed, 46 insertions, 0 deletions
diff --git a/sys/fs/udf/osta.c b/sys/fs/udf/osta.c
index a816b88..c85c4f9 100644
--- a/sys/fs/udf/osta.c
+++ b/sys/fs/udf/osta.c
@@ -73,6 +73,51 @@ udf_UncompressUnicode(
return(returnValue);
}
+/*
+ * Almost same as udf_UncompressUnicode(). The difference is that
+ * it keeps byte order of unicode string.
+ */
+int
+udf_UncompressUnicodeByte(
+ int numberOfBytes, /* (Input) number of bytes read from media. */
+ byte *UDFCompressed, /* (Input) bytes read from media. */
+ byte *unicode) /* (Output) uncompressed unicode characters. */
+{
+ unsigned int compID;
+ int returnValue, unicodeIndex, byteIndex;
+
+ /* Use UDFCompressed to store current byte being read. */
+ compID = UDFCompressed[0];
+
+ /* First check for valid compID. */
+ if (compID != 8 && compID != 16) {
+ returnValue = -1;
+ } else {
+ unicodeIndex = 0;
+ byteIndex = 1;
+
+ /* Loop through all the bytes. */
+ while (byteIndex < numberOfBytes) {
+ if (compID == 16) {
+ /* Move the first byte to the high bits of the
+ * unicode char.
+ */
+ unicode[unicodeIndex++] =
+ UDFCompressed[byteIndex++];
+ } else {
+ unicode[unicodeIndex++] = 0;
+ }
+ if (byteIndex < numberOfBytes) {
+ /*Then the next byte to the low bits. */
+ unicode[unicodeIndex++] =
+ UDFCompressed[byteIndex++];
+ }
+ }
+ returnValue = unicodeIndex;
+ }
+ return(returnValue);
+}
+
/***********************************************************************
* DESCRIPTION:
* Takes a string of unicode wide characters and returns an OSTA CS0
diff --git a/sys/fs/udf/osta.h b/sys/fs/udf/osta.h
index 5c26b6b..a5e3b86 100644
--- a/sys/fs/udf/osta.h
+++ b/sys/fs/udf/osta.h
@@ -21,6 +21,7 @@ typedef unsigned short unicode_t;
typedef unsigned char byte;
int udf_UncompressUnicode(int, byte *, unicode_t *);
+int udf_UncompressUnicodeByte(int, byte *, byte *);
int udf_CompressUnicode(int, int, unicode_t *, byte *);
unsigned short udf_cksum(unsigned char *, int);
unsigned short udf_unicode_cksum(unsigned short *, int);
OpenPOWER on IntegriCloud