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

Contents of /trunk/uar/uar.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations)
Thu Aug 8 19:13:26 2024 UTC (7 months, 3 weeks ago) by rakinar2
File MIME type: text/x-c
File size: 4109 byte(s)
feat(uar): better content listing; including owner and group info
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 void uar_set_create_callback (struct uar_archive *uar,
50 uar_create_callback_t callback);
51
52 struct uar_archive *uar_create (void);
53 struct uar_archive *uar_open (const char *filename);
54 struct uar_archive *uar_stream_open (const char *filename);
55 struct uar_archive *uar_stream_create (void);
56 void uar_close (struct uar_archive *uar);
57
58 struct uar_file *uar_stream_add_file (struct uar_archive *uar,
59 const char *uar_filename,
60 const char *fs_filename,
61 struct stat *stinfo);
62 bool uar_stream_write (struct uar_archive *uar, const char *filename);
63
64 bool uar_has_error (const struct uar_archive *restrict uar);
65 const char *uar_strerror (const struct uar_archive *restrict uar);
66 uint64_t uar_get_file_count (const struct uar_archive *restrict uar);
67
68 struct uar_file *uar_add_file (struct uar_archive *restrict uar,
69 const char *name, const char *path,
70 struct stat *stinfo);
71 struct uar_file *
72 uar_add_dir (struct uar_archive *uar, const char *name, const char *path,
73 bool (*callback) (struct uar_file *file, const char *fullname,
74 const char *fullpath));
75 bool uar_extract (struct uar_archive *uar, const char *cwd,
76 bool (*callback) (struct uar_file *file));
77 bool uar_write (struct uar_archive *uar, const char *filename);
78 bool uar_iterate (struct uar_archive *uar,
79 bool (*callback) (struct uar_file *file, void *data),
80 void *data);
81
82 struct uar_file *uar_file_create (const char *name, uint64_t namelen,
83 uint64_t size, uint32_t offset);
84
85 bool uar_add_file_entry (struct uar_archive *restrict uar,
86 struct uar_file *file);
87
88 void uar_file_destroy (struct uar_file *file);
89
90 struct uar_file *uar_stream_add_entry (struct uar_archive *uar,
91 const char *uar_name,
92 const char *fs_name,
93 struct stat *stinfo);
94 struct uar_file *uar_stream_add_dir (struct uar_archive *uar,
95 const char *uar_dirname,
96 const char *fs_dirname,
97 struct stat *stinfo);
98
99 const char *uar_file_get_name (const struct uar_file *file);
100 enum uar_file_type uar_file_get_type (const struct uar_file *file);
101 uint64_t uar_file_get_size (const struct uar_file *file);
102 mode_t uar_file_get_mode (const struct uar_file *file);
103 void uar_file_set_mode (struct uar_file *file, mode_t mode);
104 uint64_t uar_file_get_namelen (const struct uar_file *file);
105 time_t uar_file_get_mtime (const struct uar_file *file);
106 uid_t uar_file_get_uid (const struct uar_file *file);
107 gid_t uar_file_get_gid (const struct uar_file *file);
108 const char *uar_get_error_file (const struct uar_archive *uar);
109
110 #ifdef UAR_PRINT_VERBOSE_IMPL_INFO
111 void uar_debug_print (const struct uar_archive *uar, bool print_file_contents);
112 #endif
113
114 #endif /* UAR_UAR_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26