72c21b5dbc06878edac7084e8340f8b860203e81
[wimlib] / include / wimlib / apply.h
1 #ifndef _WIMLIB_APPLY_H
2 #define _WIMLIB_APPLY_H
3
4 #include "wimlib/list.h"
5 #include "wimlib/types.h"
6 #include "wimlib.h"
7
8 /* These can be treated as counts (for required_features) or booleans (for
9  * supported_features).  */
10 struct wim_features {
11         unsigned long archive_files;
12         unsigned long hidden_files;
13         unsigned long system_files;
14         unsigned long compressed_files;
15         unsigned long encrypted_files;
16         unsigned long encrypted_directories;
17         unsigned long not_context_indexed_files;
18         unsigned long sparse_files;
19         unsigned long named_data_streams;
20         unsigned long hard_links;
21         unsigned long reparse_points;
22         unsigned long symlink_reparse_points;
23         unsigned long other_reparse_points;
24         unsigned long security_descriptors;
25         unsigned long short_names;
26         unsigned long unix_data;
27         unsigned long timestamps;
28         unsigned long case_sensitive_filenames;
29 };
30
31 struct wim_lookup_table_entry;
32 struct read_stream_list_callbacks;
33
34 struct apply_ctx {
35         /* The WIMStruct from which files are being extracted from the currently
36          * selected image.  */
37         WIMStruct *wim;
38
39         /* The target of the extraction, usually the path to a directory.  */
40         const tchar *target;
41
42         /* Length of @target in tchars.  */
43         size_t target_nchars;
44
45         /* Extraction flags (WIMLIB_EXTRACT_FLAG_*)  */
46         int extract_flags;
47
48         /* User-provided progress function, or NULL if not specified.  */
49         wimlib_progress_func_t progress_func;
50
51         /* Progress data buffer, with progress.extract initialized.  */
52         union wimlib_progress_info progress;
53
54         /* Features required to extract the files (with counts)  */
55         struct wim_features required_features;
56
57         /* Features supported by the extraction mode (with booleans)  */
58         struct wim_features supported_features;
59
60         /* The members below should not be used outside of extract.c  */
61         u64 next_progress;
62         unsigned long invalid_sequence;
63         unsigned long num_streams_remaining;
64         struct list_head stream_list;
65         const struct read_stream_list_callbacks *saved_cbs;
66         struct wim_lookup_table_entry *cur_stream;
67 };
68
69 /* Returns any of the aliases of an inode that are being extracted.  */
70 #define inode_first_extraction_dentry(inode)            \
71         list_first_entry(&(inode)->i_extraction_aliases,        \
72                          struct wim_dentry, d_extraction_alias_node)
73
74 extern int
75 extract_stream_list(struct apply_ctx *ctx,
76                     const struct read_stream_list_callbacks *cbs);
77
78 struct apply_operations {
79         const char *name;
80         int (*get_supported_features)(const tchar *target,
81                                       struct wim_features *supported_features);
82
83         int (*extract)(struct list_head *dentry_list, struct apply_ctx *ctx);
84
85         size_t context_size;
86         bool single_tree_only;
87 };
88
89 #ifdef __WIN32__
90   extern const struct apply_operations win32_apply_ops;
91 #else
92   extern const struct apply_operations unix_apply_ops;
93 #endif
94
95 #ifdef WITH_NTFS_3G
96   extern const struct apply_operations ntfs_3g_apply_ops;
97 #endif
98
99 #endif /* _WIMLIB_APPLY_H */