Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1 | #ifndef MTOOLS_VFAT_H |
| 2 | #define MTOOLS_VFAT_H |
| 3 | |
| 4 | /* Copyright 1995 David C. Niemi |
| 5 | * Copyright 1996-1998,2000-2003,2005,2007-2009 Alain Knaff. |
| 6 | * This file is part of mtools. |
| 7 | * |
| 8 | * Mtools is free software: you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation, either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * Mtools is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with Mtools. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #include "msdos.h" |
| 23 | |
| 24 | /* |
| 25 | * VFAT-related common header file |
| 26 | */ |
| 27 | #define VFAT_SUPPORT |
| 28 | |
| 29 | struct unicode_char { |
| 30 | unsigned char lchar; |
| 31 | unsigned char uchar; |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 32 | }; |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 33 | |
| 34 | |
| 35 | /* #define MAX_VFAT_SUBENTRIES 32 */ /* Theoretical max # of VSEs */ |
| 36 | #define MAX_VFAT_SUBENTRIES 20 /* Max useful # of VSEs */ |
| 37 | #define VSE_NAMELEN 13 |
| 38 | |
| 39 | #define VSE1SIZE 5 |
| 40 | #define VSE2SIZE 6 |
| 41 | #define VSE3SIZE 2 |
| 42 | |
| 43 | #include "stream.h" |
| 44 | |
| 45 | struct vfat_subentry { |
| 46 | unsigned char id; /* 0x40 = last; & 0x1f = VSE ID */ |
| 47 | struct unicode_char text1[VSE1SIZE]; |
| 48 | unsigned char attribute; /* 0x0f for VFAT */ |
| 49 | unsigned char hash1; /* Always 0? */ |
| 50 | unsigned char sum; /* Checksum of short name */ |
| 51 | struct unicode_char text2[VSE2SIZE]; |
| 52 | unsigned char sector_l; /* 0 for VFAT */ |
| 53 | unsigned char sector_u; /* 0 for VFAT */ |
| 54 | struct unicode_char text3[VSE3SIZE]; |
| 55 | }; |
| 56 | |
| 57 | /* Enough size for a worst case number of full VSEs plus a null */ |
| 58 | #define VBUFSIZE ((MAX_VFAT_SUBENTRIES*VSE_NAMELEN) + 1) |
| 59 | |
| 60 | /* Max legal length of a VFAT long name */ |
| 61 | #define MAX_VNAMELEN (255) |
| 62 | |
| 63 | #define VSE_PRESENT 0x01 |
| 64 | #define VSE_LAST 0x40 |
| 65 | #define VSE_MASK 0x1f |
| 66 | |
| 67 | struct vfat_state { |
| 68 | wchar_t name[VBUFSIZE]; |
| 69 | int status; /* is now a bit map of 32 bits */ |
| 70 | int subentries; |
| 71 | unsigned char sum; /* no need to remember the sum for each entry, |
| 72 | * it is the same anyways */ |
| 73 | int present; |
| 74 | }; |
| 75 | |
| 76 | |
| 77 | struct scan_state { |
| 78 | int match_free; |
| 79 | int shortmatch; |
| 80 | int longmatch; |
| 81 | unsigned int free_start; |
| 82 | unsigned int free_end; |
| 83 | int slot; |
| 84 | int got_slots; |
| 85 | unsigned int size_needed; |
| 86 | int max_entry; |
| 87 | }; |
| 88 | |
| 89 | #include "mtoolsDirentry.h" |
| 90 | |
| 91 | void clear_vfat(struct vfat_state *); |
| 92 | int unicode_write(wchar_t *, struct unicode_char *, int num, int *end); |
| 93 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 94 | int clear_vses(Stream_t *, int, unsigned int); |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 95 | void autorename_short(struct dos_name_t *, int); |
| 96 | void autorename_long(char *, int); |
| 97 | |
| 98 | #define DO_OPEN 1 /* open all files that are found */ |
| 99 | #define ACCEPT_LABEL 0x08 |
| 100 | #define ACCEPT_DIR 0x10 |
| 101 | #define ACCEPT_PLAIN 0x20 |
| 102 | #define MATCH_ANY 0x40 |
| 103 | #define NO_MSG 0x80 |
| 104 | #define NO_DOTS 0x100 /* accept no dots if matched by wildcard */ |
| 105 | #define DO_OPEN_DIRS 0x400 /* open all directories that are found */ |
| 106 | #define OPEN_PARENT 0x1000 /* in target lookup, open parent |
| 107 | * instead of file itself */ |
| 108 | #define NO_UNIX 0x2000 /* in target lookup, consider all files to reside on |
| 109 | * the DOS fs */ |
| 110 | #endif |