/[osn-commons]/trunk/uar/uar.h
ViewVC logotype

Contents of /trunk/uar/uar.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (show annotations)
Sat Aug 10 14:44:20 2024 UTC (7 months, 2 weeks ago) by rakinar2
File MIME type: text/x-c
File size: 3865 byte(s)
feat(uar): finalize extraction/creation/listing of archives
1 #ifndef UAR_UAR_H
2 #define UAR_UAR_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <sys/stat.h>
7 #include <sys/types.h>
8
9 struct uar_archive;
10 struct uar_file;
11
12 enum uar_error
13 {
14 UAR_SUCCESS,
15 UAR_INVALID_ARCHIVE,
16 UAR_UNSUPPORTED_VERSION,
17 UAR_INVALID_MAGIC,
18 UAR_INVALID_FILE,
19 UAR_IO_ERROR,
20 UAR_OUT_OF_MEMORY,
21 UAR_INVALID_ARGUMENT,
22 UAR_INVALID_OPERATION,
23 UAR_INVALID_PATH,
24 UAR_SYSTEM_ERROR,
25 UAR_SYSCALL_ERROR
26 };
27
28 enum uar_file_type
29 {
30 UF_FILE,
31 UF_DIR,
32 UF_LINK
33 };
34
35 enum uar_error_level
36 {
37 UAR_ELEVEL_NONE,
38 UAR_ELEVEL_ERROR,
39 UAR_ELEVEL_WARNING,
40 };
41
42 typedef bool (*uar_callback_t) (struct uar_archive *uar, struct uar_file *file,
43 const char *uar_name, const char *fs_name);
44
45 typedef bool (*uar_create_callback_t) (
46 struct uar_archive *uar, struct uar_file *file, const char *uar_name,
47 const char *fs_name, enum uar_error_level level, const char *message);
48
49 typedef bool (*uar_extract_callback_t) (
50 struct uar_archive *uar, struct uar_file *file, const char *uar_name,
51 const char *fs_name, enum uar_error_level level, const char *message);
52
53 void uar_set_create_callback (struct uar_archive *uar,
54 uar_create_callback_t callback);
55 void uar_set_extract_callback (struct uar_archive *uar,
56 uar_extract_callback_t callback);
57 bool uar_stream_extract (struct uar_archive *uar, const char *dest);
58
59 struct uar_archive *uar_create (void);
60 struct uar_archive *uar_stream_open (const char *filename);
61 struct uar_archive *uar_stream_create (void);
62 void uar_close (struct uar_archive *uar);
63
64 struct uar_file *uar_stream_add_file (struct uar_archive *uar,
65 const char *uar_filename,
66 const char *fs_filename,
67 struct stat *stinfo);
68 bool uar_stream_write (struct uar_archive *uar, const char *filename);
69
70 bool uar_has_error (const struct uar_archive *restrict uar);
71 const char *uar_strerror (const struct uar_archive *restrict uar);
72 uint64_t uar_get_file_count (const struct uar_archive *restrict uar);
73
74 bool uar_stream_iterate (struct uar_archive *uar,
75 bool (*callback) (struct uar_file *file, void *data),
76 void *data);
77
78 struct uar_file *uar_file_create (const char *name, uint64_t namelen,
79 uint64_t size, uint32_t offset);
80
81 bool uar_add_file_entry (struct uar_archive *restrict uar,
82 struct uar_file *file);
83
84 void uar_file_destroy (struct uar_file *file);
85
86 struct uar_file *uar_stream_add_entry (struct uar_archive *uar,
87 const char *uar_name,
88 const char *fs_name,
89 struct stat *stinfo);
90 struct uar_file *uar_stream_add_dir (struct uar_archive *uar,
91 const char *uar_dirname,
92 const char *fs_dirname,
93 struct stat *stinfo);
94
95 const char *uar_file_get_name (const struct uar_file *file);
96 enum uar_file_type uar_file_get_type (const struct uar_file *file);
97 uint64_t uar_file_get_size (const struct uar_file *file);
98 mode_t uar_file_get_mode (const struct uar_file *file);
99 void uar_file_set_mode (struct uar_file *file, mode_t mode);
100 uint64_t uar_file_get_namelen (const struct uar_file *file);
101 time_t uar_file_get_mtime (const struct uar_file *file);
102 uid_t uar_file_get_uid (const struct uar_file *file);
103 gid_t uar_file_get_gid (const struct uar_file *file);
104 const char *uar_get_error_file (const struct uar_archive *uar);
105
106 #ifdef UAR_PRINT_VERBOSE_IMPL_INFO
107 void uar_debug_print (const struct uar_archive *uar, bool print_file_contents);
108 #endif
109
110 #endif /* UAR_UAR_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26