aboutsummaryrefslogtreecommitdiffstats
path: root/libsemanage/src/parse_utils.h
diff options
context:
space:
mode:
authorJoshua Brindle <method@manicmethod.com>2008-08-19 15:30:36 -0400
committerJoshua Brindle <method@manicmethod.com>2008-08-19 15:30:36 -0400
commit13cd4c8960688af11ad23b4c946149015c80d549 (patch)
tree61e928c962bcf6981ef4dc02dfb0b46d1c16b818 /libsemanage/src/parse_utils.h
downloadandroid_external_selinux-13cd4c8960688af11ad23b4c946149015c80d549.tar.gz
android_external_selinux-13cd4c8960688af11ad23b4c946149015c80d549.tar.bz2
android_external_selinux-13cd4c8960688af11ad23b4c946149015c80d549.zip
initial import from svn trunk revision 2950
Diffstat (limited to 'libsemanage/src/parse_utils.h')
-rw-r--r--libsemanage/src/parse_utils.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/libsemanage/src/parse_utils.h b/libsemanage/src/parse_utils.h
new file mode 100644
index 00000000..0f334860
--- /dev/null
+++ b/libsemanage/src/parse_utils.h
@@ -0,0 +1,82 @@
+/* Copyright (C) 2005 Red Hat, Inc. */
+
+#ifndef _SEMANAGE_PARSE_UTILS_INTERNAL_H_
+#define _SEMANAGE_PARSE_UTILS_INTERNAL_H_
+
+#include <stdio.h>
+#include <semanage/handle.h>
+
+typedef struct parse_info {
+ unsigned int lineno; /* Current line number */
+ char *orig_line; /* Original copy of the line being parsed */
+ char *working_copy; /* Working copy of the line being parsed */
+ char *ptr; /* Current parsing location */
+
+ const char *filename; /* Input stream file name */
+ FILE *file_stream; /* Input stream handle */
+
+ void *parse_arg; /* Caller supplied argument */
+} parse_info_t;
+
+/* Initialize structure */
+extern int parse_init(semanage_handle_t * handle,
+ const char *filename,
+ void *parse_arg, parse_info_t ** info);
+
+/* Release structure */
+extern void parse_release(parse_info_t * info);
+
+/* Open file */
+extern int parse_open(semanage_handle_t * handle, parse_info_t * info);
+
+/* Close file */
+extern void parse_close(parse_info_t * info);
+
+/* Release resources for current line */
+extern void parse_dispose_line(parse_info_t * info);
+
+/* Skip all whitespace and comments */
+extern int parse_skip_space(semanage_handle_t * handle, parse_info_t * info);
+
+/* Throw an error if we're at the EOF */
+extern int parse_assert_noeof(semanage_handle_t * handle, parse_info_t * info);
+
+/* Throw an error if no whitespace follows,
+ * otherwise eat the whitespace */
+extern int parse_assert_space(semanage_handle_t * handle, parse_info_t * info);
+
+/* Throw an error if the specified character
+ * does not follow, otherwise eat that character */
+extern int parse_assert_ch(semanage_handle_t * handle,
+ parse_info_t * info, const char ch);
+
+/* Throw an error if the specified string
+ * does not follow is not found, otherwise
+ * eat the string */
+extern int parse_assert_str(semanage_handle_t * handle,
+ parse_info_t * info, const char *assert_str);
+
+/* Eat the optional character, if found,
+ * or return STATUS_NODATA */
+extern int parse_optional_ch(parse_info_t * info, const char ch);
+
+/* Eat the optional string, if found,
+ * or return STATUS_NODATA */
+extern int parse_optional_str(parse_info_t * info, const char *str);
+
+/* Extract the next integer, and move
+ * the read pointer past it. Stop if
+ * the optional character delim is encountered,
+ * or if whitespace/eof is encountered */
+int parse_fetch_int(semanage_handle_t * hgandle,
+ parse_info_t * info, int *num, char delim);
+
+/* Extract the next string (delimited by
+ * whitespace), and move the read pointer past it.
+ * Stop of the optional character delim is encountered,
+ * or if whitespace/eof is encountered. Fail if the
+ * string is of length 0. */
+extern int parse_fetch_string(semanage_handle_t * handle,
+ parse_info_t * info, char **str_ptr, char delim);
+
+#endif