This source file includes following definitions.
- isochar
- isofncmp
- isofntrans
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/namei.h>
44 #include <sys/resourcevar.h>
45 #include <sys/kernel.h>
46 #include <sys/file.h>
47 #include <sys/stat.h>
48 #include <sys/buf.h>
49 #include <sys/proc.h>
50 #include <sys/conf.h>
51 #include <sys/mount.h>
52 #include <sys/vnode.h>
53 #include <sys/malloc.h>
54 #include <sys/dirent.h>
55
56 #include <isofs/cd9660/iso.h>
57 #include <isofs/cd9660/cd9660_extern.h>
58
59
60
61
62
63
64
65 u_char (*cd9660_wchar2char)(u_int32_t wchar) = NULL;
66
67
68
69
70
71
72 int
73 isochar(isofn, isoend, joliet_level, c)
74 const u_char *isofn;
75 const u_char *isoend;
76 int joliet_level;
77 u_char *c;
78 {
79 *c = *isofn++;
80 if (joliet_level == 0 || isofn == isoend)
81
82 return 1;
83
84
85 switch (*c) {
86 default:
87 *c = '?';
88 break;
89 case '\0':
90 *c = *isofn;
91 break;
92 }
93
94
95 if (cd9660_wchar2char != NULL)
96 *c = cd9660_wchar2char((*(isofn - 1) << 8) | *isofn);
97
98 return 2;
99 }
100
101
102
103
104
105
106 int
107 isofncmp(fn, fnlen, isofn, isolen, joliet_level)
108 const u_char *fn, *isofn;
109 int fnlen, isolen, joliet_level;
110 {
111 int i, j;
112 u_char c;
113 const u_char *fnend = fn + fnlen, *isoend = isofn + isolen;
114
115 for (; fn != fnend; fn++) {
116 if (isofn == isoend)
117 return *fn;
118 isofn += isochar(isofn, isoend, joliet_level, &c);
119 if (c == ';') {
120 if (*fn++ != ';')
121 return fn[-1];
122 for (i = 0; fn != fnend; i = i * 10 + *fn++ - '0') {
123 if (*fn < '0' || *fn > '9') {
124 return -1;
125 }
126 }
127 for (j = 0; isofn != isoend; j = j * 10 + c - '0')
128 isofn += isochar(isofn, isoend,
129 joliet_level, &c);
130 return i - j;
131 }
132 if (((u_char) c) != *fn) {
133 if (c >= 'A' && c <= 'Z') {
134 if (c + ('a' - 'A') != *fn) {
135 if (*fn >= 'a' && *fn <= 'z')
136 return *fn - ('a' - 'A') - c;
137 else
138 return *fn - c;
139 }
140 } else
141 return *fn - c;
142 }
143 }
144 if (isofn != isoend) {
145 isofn += isochar(isofn, isoend, joliet_level, &c);
146 switch (c) {
147 default:
148 return -c;
149 case '.':
150 if (isofn != isoend) {
151 isochar(isofn, isoend, joliet_level, &c);
152 if (c == ';')
153 return 0;
154 }
155 return -1;
156 case ';':
157 return 0;
158 }
159 }
160 return 0;
161 }
162
163
164
165
166 void
167 isofntrans(infn, infnlen, outfn, outfnlen, original, assoc, joliet_level)
168 u_char *infn, *outfn;
169 int infnlen;
170 u_short *outfnlen;
171 int original;
172 int assoc;
173 int joliet_level;
174 {
175 int fnidx = 0;
176 u_char c, d = '\0', *infnend = infn + infnlen;
177
178 if (assoc) {
179 *outfn++ = ASSOCCHAR;
180 fnidx++;
181 }
182 for (; infn != infnend; fnidx++) {
183 infn += isochar(infn, infnend, joliet_level, &c);
184
185 if (!original && c == ';') {
186 fnidx -= (d == '.');
187 break;
188 } else
189 *outfn++ = c;
190 d = c;
191 }
192 *outfnlen = fnidx;
193 }