]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - VtoyTool/BabyISO/biso.h
added Spanish (Latinoamérica) translation (#1865)
[Ventoy.git] / VtoyTool / BabyISO / biso.h
1 /******************************************************************************
2 * biso.h
3 *
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef __BISO_H__
22 #define __BISO_H__
23
24 #include "stdio.h"
25 #include "stdlib.h"
26 #include "string.h"
27 #include "time.h"
28
29 extern int g_biso_debug;
30 void BISO_SetDebug(int debug);
31
32 #define BISO_DIAG(fmt, ...) if(g_biso_debug) printf(fmt, ##__VA_ARGS__)
33 #define BISO_DUMP printf
34
35 #ifndef STATIC
36 #define STATIC static
37 #endif
38
39 #ifndef CONST
40 #define CONST const
41 #endif
42
43 #ifndef INLINE
44 #define INLINE inline
45 #endif
46
47 #ifndef VOID
48 #define VOID void
49 #endif
50
51 #ifndef PVOID
52 typedef VOID * PVOID;
53 #endif
54
55 #ifndef CHAR
56 #define CHAR char
57 #endif
58
59 #ifndef UCHAR
60 #define UCHAR unsigned char
61 #endif
62
63 #ifndef SHORT
64 #define SHORT short
65 #endif
66
67 #ifndef USHORT
68 #define USHORT unsigned short
69 #endif
70
71 #ifndef LONG
72 #define LONG long
73 #endif
74
75 #ifndef ULONG
76 #define ULONG unsigned long
77 #endif
78
79 #ifndef ULONGLONG
80 #define ULONGLONG unsigned long long
81 #endif
82
83
84 #ifndef INT
85 #define INT int
86 #endif
87
88 #ifndef UINT
89 #define UINT unsigned int
90 #endif
91
92 #ifndef INT16
93 #define INT16 short
94 #endif
95
96 #ifndef UINT16
97 #define UINT16 unsigned short
98 #endif
99
100 #ifndef INT32
101 #define INT32 int
102 #endif
103
104 #ifndef UINT32
105 #define UINT32 unsigned int
106 #endif
107
108 #ifndef BOOL_T
109 typedef USHORT BOOL_T;
110 #define BOOL_TRUE ((BOOL_T)1)
111 #define BOOL_FALSE ((BOOL_T)0)
112 #endif
113
114 typedef long long INT64;
115 typedef unsigned long long UINT64;
116
117 #define BISO_PATH_STRCMP strcmp
118
119 #ifndef NULL
120 #define NULL (void *)0
121 #endif
122
123 #ifndef IN
124 #define IN
125 #endif
126
127 #ifndef OUT
128 #define OUT
129 #endif
130
131 #ifndef INOUT
132 #define INOUT
133 #endif
134
135 #define BISO_TRUE 1
136 #define BISO_FALSE 0
137
138 typedef VOID BISO_READ_S;
139 typedef VOID BISO_WRITE_S;
140 typedef CONST VOID * BISO_HANDLE;
141
142 /* error code */
143 #define BISO_SUCCESS 0
144 #define BISO_ERR_BASE 0x1000
145 #define BISO_ERR_FAILED (BISO_ERR_BASE + 1)
146 #define BISO_ERR_NULL_PTR (BISO_ERR_BASE + 2)
147 #define BISO_ERR_ALLOC_MEM (BISO_ERR_BASE + 3)
148 #define BISO_ERR_OPEN_FILE (BISO_ERR_BASE + 4)
149 #define BISO_ERR_READ_FILE (BISO_ERR_BASE + 5)
150 #define BISO_ERR_WRITE_FILE (BISO_ERR_BASE + 6)
151 #define BISO_ERR_INVALID_ISO9660 (BISO_ERR_BASE + 7)
152 #define BISO_ERR_UNSUPPORTED_BLKSIZE (BISO_ERR_BASE + 8)
153 #define BISO_ERR_INVALID_PARAM (BISO_ERR_BASE + 9)
154 #define BISO_ERR_NOT_FOUND (BISO_ERR_BASE + 10)
155 #define BISO_ERR_NOT_RECORD (BISO_ERR_BASE + 11)
156 #define BISO_ERR_HANDLE_UNINITIALIZED (BISO_ERR_BASE + 12)
157 #define BISO_ERR_INVALID_RRIP_SP (BISO_ERR_BASE + 13)
158 #define BISO_ERR_ABORT (BISO_ERR_BASE + 14)
159
160 typedef struct tagBISO_VOLUME_SUMMARY
161 {
162 CHAR szVolumeId[33];
163 CHAR szSystemId[33];
164 CHAR szPublisherId[129];
165 CHAR szPreparerId[129];
166 CHAR szApplicationId[129];
167 CHAR szCopyrightFileId[38];
168 CHAR szAbstractFileId[38];
169
170 UINT uiRockRidgeVer;
171 UINT uiJolietLevel;
172
173 UINT uiTotDirNum;
174 UINT uiTotFileNum;
175 UINT uiTotLinkNum;
176 }BISO_VOLUME_SUMMARY_S;
177
178 #define BISO_TREE_FLAG_CUR 1
179 #define BISO_TREE_FLAG_DFS 2
180 #define BISO_TREE_FLAG_BFS 3
181
182 /* time */
183 typedef struct tagBISO_DATE
184 {
185 USHORT usYear;
186 UCHAR ucMonth;
187 UCHAR ucDay;
188 UCHAR ucHour;
189 UCHAR ucMin;
190 UCHAR ucSecond;
191 USHORT usMillSec;
192 CHAR cZone;
193 }BISO_DATE_S;
194
195 typedef enum tagBISO_DATE_TYPE
196 {
197 BISO_DATE_TYPE_CREATE = 0,
198 BISO_DATE_TYPE_MODIFY,
199 BISO_DATE_TYPE_EXPIRATION,
200 BISO_DATE_TYPE_EFFECTIVE,
201 BISO_DATE_TYPE_BUTT
202 }BISO_DATE_TYPE_E;
203
204 /* dir stat */
205 typedef struct tagBISO_DIR_STAT
206 {
207 UINT uiCurDirNum;
208 UINT uiCurFileNum;
209 UINT uiCurLinkNum;
210 UINT uiCurUsedSec;
211 UINT64 ui64CurSpace;
212 UINT uiTotDirNum;
213 UINT uiTotFileNum;
214 UINT uiTotLinkNum;
215 UINT64 ui64TotSpace;
216 UINT uiTotUsedSec;
217 }BISO_DIR_STAT_S;
218
219 #define BISO_NODE_REGFILE 1
220 #define BISO_NODE_SYMLINK 2
221 #define BISO_NODE_DIRECTORY 4
222
223 /* file tree */
224 typedef struct tagBISO_FILE_NODE
225 {
226 /*
227 * ucFlag
228 * BISO_NODE_REGFILE
229 * BISO_NODE_SYMLINK
230 * BISO_NODE_DIRECTORY
231 */
232 UCHAR ucFlag;
233 CHAR szName[256];
234 CHAR szLinkTgt[256];
235 UINT64 ui64FileSize;
236 UINT64 ui64Seek;
237 UINT64 ui64DirRecOffet;
238 BISO_HANDLE hParent;
239 BISO_HANDLE hCurrent;
240 }BISO_FILE_NODE_S;
241
242 typedef struct tagBISO_SVD_FILE_NODE
243 {
244 UINT64 ui64FileSize;
245 UINT64 ui64Seek;
246 UINT64 ui64DirRecOffet;
247 }BISO_SVD_FILE_NODE_S;
248
249 /* timestamp type */
250 #define BISO_EXTRACT_TIME_FOLLOW 1
251 #define BISO_EXTRACT_TIME_SPECIFY 2
252
253 typedef struct tagBISO_EXTRACT_CTRL
254 {
255 UCHAR ucATimeFlag;
256 UCHAR ucMTimeFlag;
257 BISO_DATE_S stATime;
258 BISO_DATE_S stMTime;
259 }BISO_EXTRACT_CTRL_S;
260
261 #define BISO_EXTRACT_MSG_MAKE_DIR 1
262 #define BISO_EXTRACT_MSG_CREATE_FILE 2
263 #define BISO_EXTRACT_MSG_SYMLINK 3
264
265 typedef struct tagBISO_EXTRACT_NOTIFY
266 {
267 UINT uiMsg;
268 ULONG ulResult;
269 CONST CHAR *pcFileName;
270 }BISO_EXTRACT_NOTIFY_S;
271
272 typedef ULONG (* BISO_EXTRACE_CB_PF)(IN CONST BISO_EXTRACT_NOTIFY_S *pstNotify);
273
274 CONST CHAR * BISO_GetErrMsg(IN ULONG ulErrCode);
275
276 VOID BISO_GetNow(OUT BISO_DATE_S *pstTM);
277
278 VOID BISO_TimeConv(IN ULONG ulTime, OUT BISO_DATE_S *pstTM);
279
280 BISO_READ_S * BISO_AllocReadHandle(VOID);
281
282 VOID BISO_FreeReadHandle(INOUT BISO_READ_S *pstRead);
283
284 BOOL_T BISO_IsISOFile(IN CONST CHAR *pcFileName);
285
286 BOOL_T BISO_IsUDFFile(IN CONST CHAR *pcFileName);
287
288 ULONG BISO_OpenImage(IN CONST CHAR *pcFileName, OUT BISO_READ_S *pstRead);
289 ULONG BISO_OpenImageWithSVD(IN CONST CHAR *pcFileName, OUT BISO_READ_S *pstRead);
290 BOOL_T BISO_HasSVD(IN CONST BISO_READ_S *pstRead);
291
292 ULONG BISO_GetVolumeSummary
293 (
294 IN CONST BISO_READ_S *pstRead,
295 OUT BISO_VOLUME_SUMMARY_S *pstSummary
296 );
297
298 ULONG BISO_GetDate
299 (
300 IN CONST BISO_READ_S *pstRead,
301 IN BISO_DATE_TYPE_E enType,
302 OUT BISO_DATE_S *pstDate
303 );
304
305 UINT BISO_GetRockRidgeVer(IN CONST BISO_READ_S *pstRead);
306
307 UINT BISO_GetJolietLevel(IN CONST BISO_READ_S *pstRead);
308
309 BISO_HANDLE BISO_GetRoot(IN CONST BISO_READ_S *pstRead);
310
311 ULONG BISO_GetFileNodeByHdl
312 (
313 IN BISO_HANDLE hFileHdl,
314 OUT BISO_FILE_NODE_S *pstFileNode
315 );
316
317 ULONG BISO_GetFileNodeByName
318 (
319 IN CONST BISO_READ_S *pstRead,
320 IN CONST CHAR *pcFullPath,
321 IN UCHAR ucFollowLink,
322 OUT BISO_FILE_NODE_S *pstFileNode
323 );
324
325 ULONG BISO_GetFileNodeByExtent
326 (
327 IN CONST BISO_READ_S *pstRead,
328 IN UINT uiExtent,
329 OUT BISO_FILE_NODE_S *pstFileNode
330 );
331
332 ULONG BISO_GetSVDFileNodeByExtent
333 (
334 IN CONST BISO_READ_S *pstRead,
335 IN UINT uiExtent,
336 OUT BISO_SVD_FILE_NODE_S *pstFileNode
337 );
338
339 ULONG BISO_GetFileTree
340 (
341 IN BISO_HANDLE hTopDir,
342 IN UINT uiFlag,
343 OUT BISO_HANDLE *phFileTree,
344 OUT UINT *puiNodeNum
345 );
346
347 ULONG BISO_GetDirStat
348 (
349 IN BISO_HANDLE hTopDir,
350 OUT BISO_DIR_STAT_S *pstDirStat
351 );
352
353 ULONG BISO_ExtractFile
354 (
355 IN CONST BISO_READ_S *pstRead,
356 IN CONST BISO_HANDLE hTopDir,
357 IN CONST CHAR *pcDstPath,
358 IN CONST BISO_EXTRACT_CTRL_S *pstCtrl,
359 IN BISO_EXTRACE_CB_PF pfCallBack
360 );
361
362 VOID BISO_Fill733(IN UINT uiData, OUT VOID *pBuf);
363 UINT BISO_Get733(IN CONST VOID *pBuf);
364 UINT BISO_GetFileOccupySize(IN UINT uiRawSize);
365 UINT BISO_GetBootEntryNum(IN CONST BISO_READ_S *pstRead);
366
367 VOID BISO_DumpVD(IN CONST BISO_READ_S *pstRead);
368
369 VOID BISO_DumpPathTable(IN CONST BISO_READ_S *pstRead);
370
371 VOID BISO_DumpFileTree(IN CONST BISO_READ_S *pstRead);
372
373 typedef struct tagBISO_FILE
374 {
375 UINT64 CurPos;
376 UINT64 FileSize;
377 }BISO_FILE_S;
378
379 UINT64 BISO_PLAT_GetFileSize(IN CONST CHAR *pcFileName);
380
381 VOID BISO_PLAT_UTime
382 (
383 IN CONST CHAR *pcFileName,
384 IN CONST BISO_DATE_S *pstAccessTime,
385 IN CONST BISO_DATE_S *pstModifyTime
386 );
387
388 BOOL_T BISO_PLAT_IsPathExist(IN CONST CHAR *pcPath);
389
390 BOOL_T BISO_PLAT_IsFileExist(IN CONST CHAR *pcFilePath);
391
392 ULONG BISO_PLAT_MkDir(IN CONST CHAR *pcFullPath);
393
394 BISO_FILE_S * BISO_PLAT_OpenExistFile(IN CONST CHAR *pcFileName);
395 BISO_FILE_S * BISO_PLAT_CreateNewFile(IN CONST CHAR *pcFileName);
396
397 VOID BISO_PLAT_CloseFile(IN BISO_FILE_S *pstFile);
398
399 INT64 BISO_PLAT_SeekFile(BISO_FILE_S *pstFile, INT64 i64Offset, INT iFromWhere);
400
401 UINT64 BISO_PLAT_ReadFile
402 (
403 IN BISO_FILE_S *pstFile,
404 IN UINT uiBlkSize,
405 IN UINT uiBlkNum,
406 OUT VOID *pBuf
407 );
408
409 UINT64 BISO_PLAT_WriteFile
410 (
411 IN BISO_FILE_S *pstFile,
412 IN UINT uiBlkSize,
413 IN UINT uiBlkNum,
414 IN VOID *pBuf
415 );
416
417 CHAR * BISO_PLAT_GetCurDir(VOID);
418 UINT64 BISO_UTIL_WholeFile2Buf(IN CONST CHAR *szFileName, OUT UCHAR *pucBuf);
419
420 #endif /* __BISO_H__ */
421