Debian Codegraph @

src/dvdread/dvd_filesystem.h

raw symbols SCIP
1 /*
2 * This file is part of libdvdread
3 * Copyright (C) 2026 VideoLAN
4 *
5 * This file is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This file is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see
17 * <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef DVDREAD_FILESYSTEM_H_
21 #define DVDREAD_FILESYSTEM_H_
22
23 /* glibc only exposes off64_t under the large file interface */
24 #ifndef _LARGEFILE64_SOURCE
25 #define _LARGEFILE64_SOURCE
26 #endif
27
28 #include <stdint.h>
29 #include <sys/types.h>
30
31 #if defined(_MSC_VER)
32 #include <basetsd.h>
33 #if !defined(ssize_t)
34 typedef SSIZE_T ssize_t;
35 #endif
36 typedef __int64 off64_t;
37 #elif defined(__GLIBC__)
38 /* sys/types.h may have been included before _LARGEFILE64_SOURCE was defined. */
39 typedef __off64_t off64_t;
40 #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
41 /* off_t is already 64 bit here so off64_t is not provided. */
42 typedef off_t off64_t;
43 #endif
44
45 #define DVDREAD_NAME_MAX 255
46 /* directory entry, only d_name is used by the lib */
47 typedef struct
48 {
49 char d_name[DVDREAD_NAME_MAX + 1];
50 } dvd_dirent_t;
51
52 #define DVD_S_IFMT 0170000 /* These bits determine file type. */
53 #define DVD_S_IFCHR 0020000 /* character special */
54 #define DVD_S_IFDIR 0040000 /* directory */
55 #define DVD_S_IFBLK 0060000 /* block special */
56 #define DVD_S_IFREG 0100000 /* regular */
57
58 /* size is fixed width so it does not depend on the caller off_t */
59 typedef struct
60 {
61 uint64_t size;
62 unsigned int st_mode;
63 } dvdstat_t;
64
65 /*
66 * the struct an application fills in to provide its own filesystem
67 *
68 * dir_open and file_open return a handle the application defines, the lib only
69 * hands it back to the matching read, seek and close calls
70 *
71 * stat returns 0 on success or a negative value on error
72 * dir_read returns 0 on success, a positive value at end of directory, a negative value on error
73 * file_read returns the bytes read, 0 at end of file, a negative value on error
74 * file_seek returns the offset from the start of the file or a negative value on error
75 */
76 typedef struct dvd_reader_filesystem_s dvd_reader_filesystem_h;
77 struct dvd_reader_filesystem_s
78 {
79 void *internal;
80 void (*close) (dvd_reader_filesystem_h *fs);
81 int (*stat) (dvd_reader_filesystem_h *fs, const char *path, dvdstat_t *statbuf);
82 void *(*dir_open) (dvd_reader_filesystem_h *fs, const char *dirname);
83 int (*dir_read) (void *dir, dvd_dirent_t *entry);
84 void (*dir_close) (void *dir);
85 void *(*file_open) (dvd_reader_filesystem_h *fs, const char *filename);
86 ssize_t (*file_read) (void *file, char *buf, size_t size);
87 off64_t (*file_seek) (void *file, off64_t offset, int whence);
88 int (*file_close)(void *file);
89 };
90
91 #endif /* DVDREAD_FILESYSTEM_H_ */