ReactOS 0.4.15-dev-7958-gcd0bb1a
lfn.c File Reference
#include "vfatlib.h"
#include <debug.h>
Include dependency graph for lfn.c:

Go to the source code of this file.

Classes

struct  LFN_ENT
 

Macros

#define NDEBUG
 
#define LFN_ID_START   0x40
 
#define LFN_ID_SLOTMASK   0x1f
 
#define CHARS_PER_LFN   13
 
#define UNICODE_CONVERTABLE(cl, ch)   (ch == 0 && (cl < 0x80 || cl >= 0xa0))
 
#define UNTIL_0   INT_MAX
 
#define CNV_THIS_PART(lfn)
 
#define CNV_PARTS_SO_FAR()
 
#define BYTES_TO_WCHAR(cl, ch)   ((wchar_t)((unsigned)(cl) + ((unsigned)(ch) << 8)))
 

Functions

static size_t mbslen (wchar_t x)
 
static size_t wctombs (char *dest, wchar_t x)
 
static charcnv_unicode (const unsigned char *uni, int maxlen, int use_q)
 
static void copy_lfn_part (unsigned char *dst, LFN_ENT *lfn)
 
static void clear_lfn_slots (int start, int end)
 
void lfn_fix_checksum (off_t from, off_t to, const char *short_name)
 
void lfn_reset (void)
 
void lfn_add_slot (DIR_ENT *de, off_t dir_offset)
 
charlfn_get (DIR_ENT *de, off_t *lfn_offset)
 
void lfn_check_orphaned (void)
 

Variables

unsigned charlfn_unicode = NULL
 
unsigned char lfn_checksum
 
int lfn_slot = -1
 
off_tlfn_offsets = NULL
 
int lfn_parts = 0
 
static unsigned char fat_uni2esc [64]
 

Macro Definition Documentation

◆ BYTES_TO_WCHAR

#define BYTES_TO_WCHAR (   cl,
  ch 
)    ((wchar_t)((unsigned)(cl) + ((unsigned)(ch) << 8)))

Definition at line 97 of file lfn.c.

◆ CHARS_PER_LFN

#define CHARS_PER_LFN   13

Definition at line 43 of file lfn.c.

◆ CNV_PARTS_SO_FAR

#define CNV_PARTS_SO_FAR ( )
Value:
int lfn_slot
Definition: lfn.c:48
int lfn_parts
Definition: lfn.c:50
#define CHARS_PER_LFN
Definition: lfn.c:43
unsigned char * lfn_unicode
Definition: lfn.c:46
static char * cnv_unicode(const unsigned char *uni, int maxlen, int use_q)
Definition: lfn.c:116

Definition at line 93 of file lfn.c.

◆ CNV_THIS_PART

#define CNV_THIS_PART (   lfn)
Value:
({ \
unsigned char __part_uni[CHARS_PER_LFN*2]; \
copy_lfn_part( __part_uni, lfn ); \
cnv_unicode( __part_uni, CHARS_PER_LFN, 0 ); \
})

Definition at line 76 of file lfn.c.

◆ LFN_ID_SLOTMASK

#define LFN_ID_SLOTMASK   0x1f

Definition at line 41 of file lfn.c.

◆ LFN_ID_START

#define LFN_ID_START   0x40

Definition at line 40 of file lfn.c.

◆ NDEBUG

#define NDEBUG

Definition at line 26 of file lfn.c.

◆ UNICODE_CONVERTABLE

#define UNICODE_CONVERTABLE (   cl,
  ch 
)    (ch == 0 && (cl < 0x80 || cl >= 0xa0))

Definition at line 64 of file lfn.c.

◆ UNTIL_0

#define UNTIL_0   INT_MAX

Definition at line 67 of file lfn.c.

Function Documentation

◆ clear_lfn_slots()

static void clear_lfn_slots ( int  start,
int  end 
)
static

Definition at line 164 of file lfn.c.

165{
166 int i;
168
169 /* New dir entry is zeroed except first byte, which is set to 0xe5.
170 * This is to avoid that some FAT-reading OSes (not Linux! ;) stop reading
171 * a directory at the first zero entry...
172 */
173 memset(&empty, 0, sizeof(empty));
174 empty.id = DELETED_FLAG;
175
176 for (i = start; i <= end; ++i) {
177 fs_write(lfn_offsets[i], sizeof(LFN_ENT), &empty);
178 }
179}
static const WCHAR empty[]
Definition: main.c:47
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
off_t * lfn_offsets
Definition: lfn.c:49
#define DELETED_FLAG
Definition: msdos_fs.h:43
void fs_write(off_t pos, int size, void *data)
Definition: io.c:344
#define memset(x, y, z)
Definition: compat.h:39
Definition: lfn.c:29

Referenced by lfn_add_slot(), lfn_check_orphaned(), and lfn_get().

◆ cnv_unicode()

static char * cnv_unicode ( const unsigned char uni,
int  maxlen,
int  use_q 
)
static

Definition at line 116 of file lfn.c.

117{
118 const unsigned char *up;
119 unsigned char *out, *cp;
120 int len, val;
121 size_t x;
122
123 for (len = 0, up = uni; (up - uni) / 2 < maxlen && (up[0] || up[1]);
124 up += 2) {
125 if ((x = mbslen(BYTES_TO_WCHAR(up[0], up[1]))) != (size_t) - 1)
126 len += x;
127 else if (UNICODE_CONVERTABLE(up[0], up[1]))
128 ++len;
129 else
130 len += 4;
131 }
132 cp = out = use_q ? qalloc(&mem_queue, len + 1) : alloc(len + 1);
133
134 for (up = uni; (up - uni) / 2 < maxlen && (up[0] || up[1]); up += 2) {
135 if ((x =
136 wctombs((char *)cp, BYTES_TO_WCHAR(up[0], up[1]))) != (size_t) - 1)
137 cp += x;
138 else if (UNICODE_CONVERTABLE(up[0], up[1]))
139 *cp++ = up[0];
140 else {
141 /* here the same escape notation is used as in the Linux kernel */
142 *cp++ = ':';
143 val = (up[1] << 8) + up[0];
144 cp[2] = fat_uni2esc[val & 0x3f];
145 val >>= 6;
146 cp[1] = fat_uni2esc[val & 0x3f];
147 val >>= 6;
148 cp[0] = fat_uni2esc[val & 0x3f];
149 cp += 3;
150 }
151 }
152 *cp = 0;
153
154 return (char *)out;
155}
__kernel_size_t size_t
Definition: linux.h:237
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
#define up(mutex)
Definition: glue.h:30
#define UNICODE_CONVERTABLE(cl, ch)
Definition: lfn.c:64
static unsigned char fat_uni2esc[64]
Definition: lfn.c:52
static size_t wctombs(char *dest, wchar_t x)
Definition: lfn.c:104
static size_t mbslen(wchar_t x)
Definition: lfn.c:98
#define BYTES_TO_WCHAR(cl, ch)
Definition: lfn.c:97
POINT cp
Definition: magnifier.c:59
static FILE * out
Definition: regtests2xml.c:44
#define mem_queue
Definition: rosglue.h:44
#define alloc
Definition: rosglue.h:13
void * qalloc(void **root, int size)
Definition: common.c:139

Referenced by lfn_get().

◆ copy_lfn_part()

static void copy_lfn_part ( unsigned char dst,
LFN_ENT lfn 
)
static

Definition at line 157 of file lfn.c.

158{
159 memcpy(dst, lfn->name0_4, 10);
160 memcpy(dst + 10, lfn->name5_10, 12);
161 memcpy(dst + 22, lfn->name11_12, 4);
162}
GLenum GLenum dst
Definition: glext.h:6340
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
uint8_t name5_10[12]
Definition: lfn.c:35
uint8_t name11_12[4]
Definition: lfn.c:37
uint8_t name0_4[10]
Definition: lfn.c:31

Referenced by lfn_add_slot().

◆ lfn_add_slot()

void lfn_add_slot ( DIR_ENT *  de,
off_t  dir_offset 
)

Definition at line 206 of file lfn.c.

207{
208 LFN_ENT *lfn = (LFN_ENT *) de;
209 int slot = lfn->id & LFN_ID_SLOTMASK;
210 unsigned offset;
211
212 if (lfn_slot == 0)
214
215 if (de->attr != VFAT_LN_ATTR)
216 die("lfn_add_slot called with non-LFN directory entry");
217
218 if (lfn->id & LFN_ID_START && slot != 0) {
219 if (lfn_slot != -1) {
220 int can_clear = 0;
221 /* There is already a LFN "in progess", so it is an error that a
222 * new start entry is here. */
223 /* Causes: 1) if slot# == expected: start bit set mysteriously, 2)
224 * old LFN overwritten by new one */
225 /* Fixes: 1) delete previous LFN 2) if slot# == expected and
226 * checksum ok: clear start bit */
227 /* XXX: Should delay that until next LFN known (then can better
228 * display the name) */
229 printf("A new long file name starts within an old one.\n");
230 if (slot == lfn_slot && lfn->alias_checksum == lfn_checksum) {
231 char *part1 = CNV_THIS_PART(lfn);
232 char *part2 = CNV_PARTS_SO_FAR();
233 printf(" It could be that the LFN start bit is wrong here\n"
234 " if \"%s\" seems to match \"%s\".\n", part1, part2);
235 free(part1);
236 free(part2);
237 can_clear = 1;
238 }
239 if (interactive) {
240 printf("1: Delete previous LFN\n2: Leave it as it is.\n");
241 if (can_clear)
242 printf("3: Clear start bit and concatenate LFNs\n");
243 } else
244 printf(" Not auto-correcting this.\n");
245 if (interactive) {
246 switch (get_key(can_clear ? "123" : "12", "?")) {
247 case '1':
249 lfn_reset();
250 break;
251 case '2':
252 break;
253 case '3':
254 lfn->id &= ~LFN_ID_START;
255 fs_write(dir_offset + offsetof(LFN_ENT, id),
256 sizeof(lfn->id), &lfn->id);
257 break;
258 }
259 }
260 }
261 lfn_slot = slot;
264 lfn_offsets = alloc(lfn_slot * sizeof(off_t));
265 lfn_parts = 0;
266 } else if (lfn_slot == -1 && slot != 0) {
267 /* No LFN in progress, but slot found; start bit missing */
268 /* Causes: 1) start bit got lost, 2) Previous slot with start bit got
269 * lost */
270 /* Fixes: 1) delete LFN, 2) set start bit */
271 char *part = CNV_THIS_PART(lfn);
272 printf("Long filename fragment \"%s\" found outside a LFN "
273 "sequence.\n (Maybe the start bit is missing on the "
274 "last fragment)\n", part);
275 free(part);
276 if (interactive) {
277 printf("1: Delete fragment\n2: Leave it as it is.\n"
278 "3: Set start bit\n");
279 } else
280 printf(" Not auto-correcting this.\n");
281 switch (interactive ? get_key("123", "?") : '2') {
282 case '1':
283 if (!lfn_offsets)
284 lfn_offsets = alloc(sizeof(off_t));
285 lfn_offsets[0] = dir_offset;
286 clear_lfn_slots(0, 0);
287 lfn_reset();
288 return;
289 case '2':
290 lfn_reset();
291 return;
292 case '3':
293 lfn->id |= LFN_ID_START;
294 fs_write(dir_offset + offsetof(LFN_ENT, id),
295 sizeof(lfn->id), &lfn->id);
296 lfn_slot = slot;
299 lfn_offsets = alloc(lfn_slot * sizeof(off_t));
300 lfn_parts = 0;
301 break;
302 }
303 } else if (slot != lfn_slot) {
304 /* wrong sequence number */
305 /* Causes: 1) seq-no destroyed */
306 /* Fixes: 1) delete LFN, 2) fix number (maybe only if following parts
307 * are ok?, maybe only if checksum is ok?) (Attention: space
308 * for name was allocated before!) */
309 int can_fix = 0;
310 printf("Unexpected long filename sequence number "
311 "(%d vs. expected %d).\n", slot, lfn_slot);
312 if (lfn->alias_checksum == lfn_checksum && lfn_slot > 0) {
313 char *part1 = CNV_THIS_PART(lfn);
314 char *part2 = CNV_PARTS_SO_FAR();
315 printf(" It could be that just the number is wrong\n"
316 " if \"%s\" seems to match \"%s\".\n", part1, part2);
317 free(part1);
318 free(part2);
319 can_fix = 1;
320 }
321 if (interactive) {
322 printf
323 ("1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n");
324 if (can_fix)
325 printf("3: Correct sequence number\n");
326 } else
327 printf(" Not auto-correcting this.\n");
328 switch (interactive ? get_key(can_fix ? "123" : "12", "?") : '2') {
329 case '1':
330 if (!lfn_offsets) {
331 lfn_offsets = alloc(sizeof(off_t));
332 lfn_parts = 0;
333 }
334 lfn_offsets[lfn_parts++] = dir_offset;
336 lfn_reset();
337 return;
338 case '2':
339 lfn_reset();
340 return;
341 case '3':
342 lfn->id = (lfn->id & ~LFN_ID_SLOTMASK) | lfn_slot;
343 fs_write(dir_offset + offsetof(LFN_ENT, id),
344 sizeof(lfn->id), &lfn->id);
345 break;
346 }
347 }
348
349 if (lfn->alias_checksum != lfn_checksum) {
350 /* checksum mismatch */
351 /* Causes: 1) checksum field here destroyed */
352 /* Fixes: 1) delete LFN, 2) fix checksum */
353 printf("Checksum in long filename part wrong "
354 "(%02x vs. expected %02x).\n",
356 if (interactive) {
357 printf("1: Delete LFN\n2: Leave it as it is.\n"
358 "3: Correct checksum\n");
359 } else
360 printf(" Not auto-correcting this.\n");
361 if (interactive) {
362 switch (get_key("123", "?")) {
363 case '1':
364 lfn_offsets[lfn_parts++] = dir_offset;
366 lfn_reset();
367 return;
368 case '2':
369 break;
370 case '3':
372 fs_write(dir_offset + offsetof(LFN_ENT, alias_checksum),
373 sizeof(lfn->alias_checksum), &lfn->alias_checksum);
374 break;
375 }
376 }
377 }
378
379 if (lfn_slot != -1) {
380 lfn_slot--;
383 if (lfn->id & LFN_ID_START)
384 lfn_unicode[offset + 26] = lfn_unicode[offset + 27] = 0;
385 lfn_offsets[lfn_parts++] = dir_offset;
386 }
387
388 if (lfn->reserved != 0) {
389 printf("Reserved field in VFAT long filename slot is not 0 "
390 "(but 0x%02x).\n", lfn->reserved);
391 if (interactive)
392 printf("1: Fix.\n2: Leave it.\n");
393 else
394 printf("Auto-setting to 0.\n");
395 if (!interactive || get_key("12", "?") == '1') {
396 lfn->reserved = 0;
397 fs_write(dir_offset + offsetof(LFN_ENT, reserved),
398 sizeof(lfn->reserved), &lfn->reserved);
399 }
400 }
401 if (lfn->start != htole16(0)) {
402 printf("Start cluster field in VFAT long filename slot is not 0 "
403 "(but 0x%04x).\n", lfn->start);
404 if (interactive)
405 printf("1: Fix.\n2: Leave it.\n");
406 else
407 printf("Auto-setting to 0.\n");
408 if (!interactive || get_key("12", "?") == '1') {
409 lfn->start = htole16(0);
410 fs_write(dir_offset + offsetof(LFN_ENT, start),
411 sizeof(lfn->start), &lfn->start);
412 }
413 }
414}
#define free
Definition: debug_ros.c:5
r reserved
Definition: btrfs.c:3006
__kernel_off_t off_t
Definition: linux.h:201
#define printf
Definition: freeldr.h:97
#define VFAT_LN_ATTR
Definition: fsck.fat.h:78
GLintptr offset
Definition: glext.h:5920
#define CNV_PARTS_SO_FAR()
Definition: lfn.c:93
#define CNV_THIS_PART(lfn)
Definition: lfn.c:76
#define LFN_ID_SLOTMASK
Definition: lfn.c:41
unsigned char lfn_checksum
Definition: lfn.c:47
static void clear_lfn_slots(int start, int end)
Definition: lfn.c:164
void lfn_check_orphaned(void)
Definition: lfn.c:517
static void copy_lfn_part(unsigned char *dst, LFN_ENT *lfn)
Definition: lfn.c:157
void lfn_reset(void)
Definition: lfn.c:193
#define LFN_ID_START
Definition: lfn.c:40
#define die(str)
Definition: mkdosfs.c:347
#define interactive
Definition: rosglue.h:34
#define offsetof(TYPE, MEMBER)
char get_key(const char *valid, const char *prompt)
Definition: common.c:184
#define htole16(x)
Definition: storage32.h:546
uint8_t id
Definition: lfn.c:30
uint8_t reserved
Definition: lfn.c:33
uint16_t start
Definition: lfn.c:36
uint8_t alias_checksum
Definition: lfn.c:34
Definition: vfat.h:185
struct _slot slot
Definition: vfat.h:196

Referenced by add_file().

◆ lfn_check_orphaned()

void lfn_check_orphaned ( void  )

Definition at line 517 of file lfn.c.

518{
519 char *long_name;
520
521 if (lfn_slot == -1)
522 return;
523
525 printf("Orphaned long file name part \"%s\"\n", long_name);
527 if (interactive)
528 printf("1: Delete.\n2: Leave it.\n");
529#ifdef __REACTOS__
530 else if (rw)
531#else
532 else
533#endif
534 printf(" Auto-deleting.\n");
535#ifdef __REACTOS__
536 if ((!interactive && rw) || (interactive && get_key("12", "?") == '1')) {
537#else
538 if (!interactive || get_key("12", "?") == '1') {
539#endif
541 }
542 lfn_reset();
543}
const WCHAR * long_name
Definition: reg.c:30
#define rw
Definition: rosglue.h:38

Referenced by add_file(), lfn_add_slot(), scan_dir(), and scan_root().

◆ lfn_fix_checksum()

void lfn_fix_checksum ( off_t  from,
off_t  to,
const char short_name 
)

Definition at line 181 of file lfn.c.

182{
183 int i;
184 uint8_t sum;
185 for (sum = 0, i = 0; i < 11; i++)
186 sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + short_name[i];
187
188 for (; from < to; from += sizeof(LFN_ENT)) {
189 fs_write(from + offsetof(LFN_ENT, alias_checksum), sizeof(sum), &sum);
190 }
191}
const WCHAR * short_name
Definition: reg.c:29
BYTE uint8_t
Definition: msvideo1.c:66
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
CardRegion * from
Definition: spigame.cpp:19

Referenced by auto_rename(), and rename_file().

◆ lfn_get()

char * lfn_get ( DIR_ENT *  de,
off_t lfn_offset 
)

Definition at line 418 of file lfn.c.

419{
420 char *lfn;
421 uint8_t sum;
422 int i;
423
424 *lfn_offset = 0;
425 if (de->attr == VFAT_LN_ATTR)
426 die("lfn_get called with LFN directory entry");
427
428#if 0
429 if (de->lcase)
430 printf("lcase=%02x\n", de->lcase);
431#endif
432
433 if (lfn_slot == -1)
434 /* no long name for this file */
435 return NULL;
436
437 if (lfn_slot != 0) {
438 /* The long name isn't finished yet. */
439 /* Causes: 1) LFN slot overwritten by non-VFAT aware tool */
440 /* Fixes: 1) delete LFN 2) move overwriting entry to somewhere else
441 * and let user enter missing part of LFN (hard to do :-()
442 * 3) renumber entries and truncate name */
443 char *long_name = CNV_PARTS_SO_FAR();
444 char *short_name = file_name(de->name);
445 printf("Unfinished long file name \"%s\".\n"
446 " (Start may have been overwritten by %s)\n",
449 if (interactive) {
450 printf("1: Delete LFN\n2: Leave it as it is.\n"
451 "3: Fix numbering (truncates long name and attaches "
452 "it to short name %s)\n", short_name);
453 } else
454 printf(" Not auto-correcting this.\n");
455 switch (interactive ? get_key("123", "?") : '2') {
456 case '1':
458 lfn_reset();
459 return NULL;
460 case '2':
461 lfn_reset();
462 return NULL;
463 case '3':
464 for (i = 0; i < lfn_parts; ++i) {
465 uint8_t id = (lfn_parts - i) | (i == 0 ? LFN_ID_START : 0);
467 sizeof(id), &id);
468 }
471 break;
472 }
473 }
474
475 for (sum = 0, i = 0; i < MSDOS_NAME; i++)
476 sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + de->name[i];
477 if (sum != lfn_checksum) {
478 /* checksum doesn't match, long name doesn't apply to this alias */
479 /* Causes: 1) alias renamed */
480 /* Fixes: 1) Fix checksum in LFN entries */
481 char *long_name = CNV_PARTS_SO_FAR();
482 char *short_name = file_name(de->name);
483 printf("Wrong checksum for long file name \"%s\".\n"
484 " (Short name %s may have changed without updating the long name)\n",
487 if (interactive) {
488 printf("1: Delete LFN\n2: Leave it as it is.\n"
489 "3: Fix checksum (attaches to short name %s)\n", short_name);
490 } else
491 printf(" Not auto-correcting this.\n");
492 if (interactive) {
493 switch (get_key("123", "?")) {
494 case '1':
496 lfn_reset();
497 return NULL;
498 case '2':
499 lfn_reset();
500 return NULL;
501 case '3':
502 for (i = 0; i < lfn_parts; ++i) {
503 fs_write(lfn_offsets[i] + offsetof(LFN_ENT, alias_checksum),
504 sizeof(sum), &sum);
505 }
506 break;
507 }
508 }
509 }
510
511 *lfn_offset = lfn_offsets[0];
513 lfn_reset();
514 return (lfn);
515}
#define NULL
Definition: types.h:112
#define UNTIL_0
Definition: lfn.c:67
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static LPCWSTR file_name
Definition: protocol.c:147
#define MSDOS_NAME
Definition: msdos_fs.h:46

Referenced by add_file().

◆ lfn_reset()

void lfn_reset ( void  )

Definition at line 193 of file lfn.c.

194{
195 if (lfn_unicode)
198 if (lfn_offsets)
201 lfn_slot = -1;
202}

Referenced by lfn_add_slot(), lfn_check_orphaned(), lfn_get(), and new_dir().

◆ mbslen()

static size_t mbslen ( wchar_t  x)
static

Definition at line 98 of file lfn.c.

99{
100 wchar_t wstr[] = { x, 0 };
101 return wcstombs(NULL, wstr, 0);
102}
size_t __cdecl wcstombs(_Out_writes_opt_z_(_MaxCount) char *_Dest, _In_z_ const wchar_t *_Source, _In_ size_t _MaxCount)

Referenced by cnv_unicode().

◆ wctombs()

static size_t wctombs ( char dest,
wchar_t  x 
)
static

Definition at line 104 of file lfn.c.

105{
106 wchar_t wstr[] = { x, 0 };
107 size_t size = wcstombs(NULL, wstr, 0);
108 if (size != (size_t) - 1)
109 size = wcstombs(dest, wstr, size + 1);
110 return size;
111}
GLsizeiptr size
Definition: glext.h:5919
static char * dest
Definition: rtl.c:135

Referenced by cnv_unicode().

Variable Documentation

◆ fat_uni2esc

unsigned char fat_uni2esc[64]
static
Initial value:
= {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '+', '-'
}

Definition at line 52 of file lfn.c.

Referenced by cnv_unicode().

◆ lfn_checksum

unsigned char lfn_checksum

Definition at line 47 of file lfn.c.

Referenced by lfn_add_slot(), and lfn_get().

◆ lfn_offsets

off_t* lfn_offsets = NULL

Definition at line 49 of file lfn.c.

Referenced by clear_lfn_slots(), lfn_add_slot(), lfn_get(), and lfn_reset().

◆ lfn_parts

int lfn_parts = 0

Definition at line 50 of file lfn.c.

Referenced by lfn_add_slot(), lfn_check_orphaned(), and lfn_get().

◆ lfn_slot

int lfn_slot = -1

Definition at line 48 of file lfn.c.

Referenced by lfn_add_slot(), lfn_check_orphaned(), lfn_get(), and lfn_reset().

◆ lfn_unicode

unsigned char* lfn_unicode = NULL

Definition at line 46 of file lfn.c.

Referenced by lfn_add_slot(), lfn_get(), and lfn_reset().