Lines Matching +full:char +full:- +full:regex
15 #include "../src/regex.h"
17 static const char *policy_file;
20 static int validate_context(char **ctxp) in validate_context()
22 char *ctx = *ctxp; in validate_context()
25 ctx_err = -1; in validate_context()
32 static int process_file(struct selabel_handle *rec, const char *filename) in process_file()
36 char *line_buf = NULL; in process_file()
39 const char *prefix = NULL; in process_file()
45 return -1; in process_file()
53 /* With -p option need to check and fail if ctx err as in process_file()
58 rc = -1; in process_file()
71 * u32 - magic number
72 * u32 - version
73 * u32 - length of pcre version EXCLUDING nul
74 * char - pcre version string EXCLUDING nul
75 * u32 - number of stems
77 * u32 - length of stem EXCLUDING nul
78 * char - stem char array INCLUDING nul
79 * u32 - number of regexs
81 * u32 - length of upcoming context INCLUDING nul
82 * char - char array of the raw context
83 * u32 - length of the upcoming regex_str
84 * char - char array of the original regex string including the stem.
85 * u32 - mode bits for >= SELINUX_COMPILED_FCONTEXT_MODE
87 * s32 - stemid associated with the regex
88 * u32 - spec has meta characters
89 * u32 - The specs prefix_len if >= SELINUX_COMPILED_FCONTEXT_PREFIX_LEN
90 * u32 - data length of the pcre regex
91 * char - a buffer holding the raw pcre regex info
92 * u32 - data length of the pcre regex study daya
93 * char - a buffer holding the raw pcre regex study data
98 struct spec *specs = data->spec_arr; in write_binary_file()
105 const char *reg_version; in write_binary_file()
106 const char *reg_arch; in write_binary_file()
125 /* write version of the regex back-end */ in write_binary_file()
133 len = fwrite(reg_version, sizeof(char), section_len, bin_file); in write_binary_file()
137 /* write regex arch string */ in write_binary_file()
145 len = fwrite(reg_arch, sizeof(char), section_len, bin_file); in write_binary_file()
150 section_len = data->num_stems; in write_binary_file()
156 char *stem = data->stem_arr[i].buf; in write_binary_file()
157 uint32_t stem_len = data->stem_arr[i].len; in write_binary_file()
166 len = fwrite(stem, sizeof(char), stem_len, bin_file); in write_binary_file()
172 section_len = data->nspec; in write_binary_file()
178 char *context = specs[i].lr.ctx_raw; in write_binary_file()
179 char *regex_str = specs[i].regex_str; in write_binary_file()
183 struct regex_data *re = specs[i].regex; in write_binary_file()
193 len = fwrite(context, sizeof(char), to_write, bin_file); in write_binary_file()
197 /* length of the original regex string (including nul) */ in write_binary_file()
203 /* original regex string */ in write_binary_file()
204 len = fwrite(regex_str, sizeof(char), to_write, bin_file); in write_binary_file()
214 /* stem for this regex (could be -1) */ in write_binary_file()
231 /* Write regex related data */ in write_binary_file()
242 rc = -1; in write_binary_file()
248 struct spec *specs = data->spec_arr; in free_specs()
249 unsigned int num_entries = data->nspec; in free_specs()
257 regex_data_free(specs[i].regex); in free_specs()
261 num_entries = data->num_stems; in free_specs()
263 free(data->stem_arr[i].buf); in free_specs()
264 free(data->stem_arr); in free_specs()
269 static __attribute__ ((__noreturn__)) void usage(const char *progname) in usage()
272 "usage: %s [-o out_file] [-p policy_file] fc_file\n" in usage()
274 "-o Optional file name of the PCRE formatted binary\n\t" in usage()
277 "-p Optional binary policy file that will be used to\n\t" in usage()
279 "-r Omit precompiled regular expressions from the output.\n\t" in usage()
285 "-i Print regular expression info end exit. That is, back\n\t" in usage()
288 " <pointer width>-<size type width>-<endianness>, e.g.,\n\t" in usage()
289 " \"8-8-el\" for x86_64.\n\t" in usage()
295 int main(int argc, char *argv[]) in main()
297 const char *path = NULL; in main()
298 const char *out_file = NULL; in main()
300 char stack_path[PATH_MAX + 1]; in main()
301 char *tmp = NULL; in main()
366 rec->backend = SELABEL_CTX_FILE; in main()
372 * validation - unless the -p option is used in which case if an in main()
374 rec->validating = 1; in main()
387 rec->data = data; in main()
443 fprintf(stderr, "%s: rename %s -> %s failed: %s\n", argv[0], tmp, stack_path, strerror(errno)); in main()
461 rc = -1; in main()