diff options
author | dcs <dcs@FreeBSD.org> | 1999-04-18 10:58:03 +0000 |
---|---|---|
committer | dcs <dcs@FreeBSD.org> | 1999-04-18 10:58:03 +0000 |
commit | 1ff58a39ac4af3d04225faf560ca091084c36a15 (patch) | |
tree | cab4e4ad15edd5adf5a3c91c2ec05b9ed8c7be23 /sys/isofs/cd9660/cd9660_util.c | |
parent | 9af4b2b5eaaa8eb06f4d72ff0f9e55ab9ef42eb9 (diff) | |
download | FreeBSD-src-1ff58a39ac4af3d04225faf560ca091084c36a15.zip FreeBSD-src-1ff58a39ac4af3d04225faf560ca091084c36a15.tar.gz |
Add support for Joliet extensions to the iso9660 fs. The related PR
cannot yet be closed, though.
I hope I got all credits right, and that the multiple submitted by lines
do not break anyone's scripts...
PR: kern/5038, kern/5567
Submitted by: Keith Jang <keith@email.gcn.net.tw>
Submitted by: Joachim Kuebart <joki@kuebart.stuttgart.netsurf.de>
Submitted by: Byung Yang <byung@wam.umd.edu>
Submitted by: Motomichi Matsuzaki <mzaki@e-mail.ne.jp>
Diffstat (limited to 'sys/isofs/cd9660/cd9660_util.c')
-rw-r--r-- | sys/isofs/cd9660/cd9660_util.c | 98 |
1 files changed, 66 insertions, 32 deletions
diff --git a/sys/isofs/cd9660/cd9660_util.c b/sys/isofs/cd9660/cd9660_util.c index 090f10d..69ae333 100644 --- a/sys/isofs/cd9660/cd9660_util.c +++ b/sys/isofs/cd9660/cd9660_util.c @@ -5,7 +5,8 @@ * This code is derived from software contributed to Berkeley * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension * Support code is derived from software contributed to Berkeley - * by Atsushi Murai (amurai@spec.co.jp). + * by Atsushi Murai (amurai@spec.co.jp). Joliet support was added by + * Joachim Kuebart (joki@kuebart.stuttgart.netsurf.de). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,7 +37,7 @@ * SUCH DAMAGE. * * @(#)cd9660_util.c 8.3 (Berkeley) 12/5/94 - * $Id: cd9660_util.c,v 1.9 1997/02/22 09:38:50 peter Exp $ + * $Id: cd9660_util.c,v 1.10 1997/04/10 14:35:11 bde Exp $ */ #include <sys/param.h> @@ -46,37 +47,65 @@ #include <isofs/cd9660/iso.h> /* + * Get one character out of an iso filename + * Obey joliet_level + * Return number of bytes consumed + */ +int +isochar(isofn, isoend, joliet_level, c) + u_char *isofn; + u_char *isoend; + int joliet_level; + u_char *c; +{ + *c = *isofn++; + if (joliet_level == 0 || isofn == isoend) + /* (00) and (01) are one byte in Joliet, too */ + return 1; + + /* No Unicode support yet :-( */ + switch (*c) { + default: + *c = '?'; + break; + case '\0': + *c = *isofn; + break; + } + return 2; +} + +/* * translate and compare a filename + * returns (fn - isofn) * Note: Version number plus ';' may be omitted. */ int -isofncmp(fn, fnlen, isofn, isolen) +isofncmp(fn, fnlen, isofn, isolen, joliet_level) u_char *fn; int fnlen; u_char *isofn; int isolen; + int joliet_level; { int i, j; - unsigned char c; + u_char c, *fnend = fn + fnlen, *isoend = isofn + isolen; - while (--fnlen >= 0) { - if (--isolen < 0) + for (; fn != fnend; fn++) { + if (isofn == isoend) return *fn; - if ((c = *isofn++) == ';') { - switch (*fn++) { - default: - return *--fn; - case 0: - return 0; - case ';': - break; - } - for (i = 0; --fnlen >= 0; i = i * 10 + *fn++ - '0') { + isofn += isochar(isofn, isoend, joliet_level, &c); + if (c == ';') { + if (*fn++ != ';') + return fn[-1]; + for (i = 0; fn != fnend; i = i * 10 + *fn++ - '0') { if (*fn < '0' || *fn > '9') { return -1; } } - for (j = 0; --isolen >= 0; j = j * 10 + *isofn++ - '0'); + for (j = 0; isofn != isoend; j = j * 10 + c - '0') + isofn += isochar(isofn, isoend, + joliet_level, &c); return i - j; } if (c != *fn) { @@ -90,15 +119,19 @@ isofncmp(fn, fnlen, isofn, isolen) } else return *fn - c; } - fn++; } - if (isolen > 0) { - switch (*isofn) { + if (isofn != isoend) { + isofn += isochar(isofn, isoend, joliet_level, &c); + switch (c) { default: - return -1; + return -c; case '.': - if (isofn[1] != ';') - return -1; + if (isofn != isoend) { + isochar(isofn, isoend, joliet_level, &c); + if (c == ';') + return 0; + } + return -1; case ';': return 0; } @@ -107,35 +140,36 @@ isofncmp(fn, fnlen, isofn, isolen) } /* - * translate a filename + * translate a filename of length > 0 */ void -isofntrans(infn, infnlen, outfn, outfnlen, original, assoc) +isofntrans(infn, infnlen, outfn, outfnlen, original, assoc, joliet_level) u_char *infn; int infnlen; u_char *outfn; u_short *outfnlen; int original; int assoc; + int joliet_level; { int fnidx = 0; + u_char c, d = '\0', *infnend = infn + infnlen; if (assoc) { *outfn++ = ASSOCCHAR; fnidx++; - infnlen++; } - for (; fnidx < infnlen; fnidx++) { - char c = *infn++; + for (; infn != infnend; fnidx++) { + infn += isochar(infn, infnend, joliet_level, &c); if (!original && c >= 'A' && c <= 'Z') *outfn++ = c + ('a' - 'A'); - else if (!original && c == '.' && *infn == ';') - break; - else if (!original && c == ';') + else if (!original && c == ';') { + fnidx -= (d == '.'); break; - else + } else *outfn++ = c; + d = c; } *outfnlen = fnidx; } |