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

Diff of /trunk/uar/uar.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by rakinar2, Tue Aug 6 14:24:41 2024 UTC revision 40 by rakinar2, Sat Aug 10 14:44:20 2024 UTC
# Line 2  Line 2 
2  #define UAR_UAR_H  #define UAR_UAR_H
3    
4  #include <stdbool.h>  #include <stdbool.h>
5    #include <stdint.h>
6    #include <sys/stat.h>
7  #include <sys/types.h>  #include <sys/types.h>
8    
9  struct uar_archive;  struct uar_archive;
# Line 10  struct uar_file; Line 12  struct uar_file;
12  enum uar_error  enum uar_error
13  {  {
14      UAR_SUCCESS,      UAR_SUCCESS,
15        UAR_INVALID_ARCHIVE,
16        UAR_UNSUPPORTED_VERSION,
17      UAR_INVALID_MAGIC,      UAR_INVALID_MAGIC,
18      UAR_INVALID_FILE,      UAR_INVALID_FILE,
19      UAR_IO_ERROR,      UAR_IO_ERROR,
# Line 17  enum uar_error Line 21  enum uar_error
21      UAR_INVALID_ARGUMENT,      UAR_INVALID_ARGUMENT,
22      UAR_INVALID_OPERATION,      UAR_INVALID_OPERATION,
23      UAR_INVALID_PATH,      UAR_INVALID_PATH,
24      UAR_SYSTEM_ERROR      UAR_SYSTEM_ERROR,
25        UAR_SYSCALL_ERROR
26  };  };
27    
28  enum uar_file_type  enum uar_file_type
# Line 27  enum uar_file_type Line 32  enum uar_file_type
32      UF_LINK      UF_LINK
33  };  };
34    
35  struct uar_archive *uar_open (const char *filename);  enum uar_error_level
36  bool uar_has_error (const struct uar_archive *restrict uar);  {
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);  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);  const char *uar_strerror (const struct uar_archive *restrict uar);
72  struct uar_archive *uar_create (void);  uint64_t uar_get_file_count (const struct uar_archive *restrict uar);
73  struct uar_file *uar_add_file (struct uar_archive *restrict uar,  
74                                 const char *name, const char *path);  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);  void uar_file_set_mode (struct uar_file *file, mode_t mode);
100  bool uar_write (struct uar_archive *uar, const char *filename);  uint64_t uar_file_get_namelen (const struct uar_file *file);
101  struct uar_file *  time_t uar_file_get_mtime (const struct uar_file *file);
102  uar_add_dir (struct uar_archive *uar, const char *name, const char *path,  uid_t uar_file_get_uid (const struct uar_file *file);
103               bool (*callback) (struct uar_file *file, const char *fullname,  gid_t uar_file_get_gid (const struct uar_file *file);
104                                 const char *fullpath));  const char *uar_get_error_file (const struct uar_archive *uar);
 bool uar_extract (struct uar_archive *uar, const char *cwd,  
                   bool (*callback) (struct uar_file *file));  
 const char *uar_get_file_name (const struct uar_file *file);  
 enum uar_file_type uar_get_entry_type (const struct uar_file *file);  
105    
106  #ifndef NDEBUG  #ifdef UAR_PRINT_VERBOSE_IMPL_INFO
107  void uar_debug_print (const struct uar_archive *uar, bool print_file_contents);  void uar_debug_print (const struct uar_archive *uar, bool print_file_contents);
108  #endif  #endif
109    

Legend:
Removed from v.30  
changed lines
  Added in v.40

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26