diff options
-rw-r--r-- | sys/fs/udf/osta.c | 45 | ||||
-rw-r--r-- | sys/fs/udf/osta.h | 1 |
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); |