Remove quotes in do_load_text_file()
[wimlib] / include / wimlib / textfile.h
1 #ifndef _WIMLIB_TEXTFILE_H_
2 #define _WIMLIB_TEXTFILE_H_
3
4 #include <wimlib/types.h>
5
6 struct string_set {
7         tchar **strings;
8         size_t num_strings;
9         size_t num_alloc_strings;
10 };
11
12 #define STRING_SET_INITIALIZER \
13         { .strings = NULL, .num_strings = 0, .num_alloc_strings = 0, }
14
15 #define STRING_SET(_strings) \
16         struct string_set _strings = STRING_SET_INITIALIZER
17
18 typedef int (*line_mangle_t)(tchar *line, const tchar *filename,
19                              unsigned long line_no);
20
21 struct text_file_section {
22         const tchar *name;
23         struct string_set *strings;
24 };
25
26 #define LOAD_TEXT_FILE_REMOVE_QUOTES 0x00000001
27
28 extern int
29 do_load_text_file(const tchar *path, tchar *buf, size_t buflen, tchar **buf_ret,
30                   const struct text_file_section *pos_sections,
31                   int num_pos_sections, int flags,
32                   line_mangle_t mangle_line);
33
34 static inline int
35 load_text_file(const tchar *path, tchar **buf_ret,
36                const struct text_file_section *pos_sections,
37                int num_pos_sections, line_mangle_t mangle_line)
38 {
39         return do_load_text_file(path, NULL, 0, buf_ret,
40                                  pos_sections, num_pos_sections,
41                                  LOAD_TEXT_FILE_REMOVE_QUOTES, mangle_line);
42 }
43
44 static inline int
45 load_text_buffer(tchar *buf, size_t buflen,
46                  const struct text_file_section *pos_sections,
47                  int num_pos_sections, line_mangle_t mangle_line)
48 {
49         return do_load_text_file(NULL, buf, buflen, &buf,
50                                  pos_sections, num_pos_sections,
51                                  LOAD_TEXT_FILE_REMOVE_QUOTES, mangle_line);
52 }
53
54 #endif /* _WIMLIB_TEXTFILE_H_ */