@var{FILENAME} or @var{DIRNAME} should be an absolute path. The named
file or directory must exist and be readable. Including a directory
includes all files within the directory whose names consist solely of
-alphanumeric characters, dashes, or underscores. Included configuration
-fragments should begin with a section header.
+alphanumeric characters, dashes, or underscores. Included profile files
+are syntactically independent of their parents, so each included file
+must begin with a section header.
The @code{krb5.conf} file may contain any or all of the following
sections:
directory must exist and be readable. Including a directory includes
all files within the directory whose names consist solely of
alphanumeric characters, dashes, or underscores. Included profile
-fragments should begin with a section header.
+files are syntactically independent of their parents, so each included
+file must begin with a section header.
.PP
The following sections are currently used in the
}
-static errcode_t parse_init_state(struct parse_state *state)
-{
- state->state = STATE_INIT_COMMENT;
- state->group_level = 0;
-
- return profile_create_node("(root)", 0, &state->root_section);
-}
-
static errcode_t parse_std_line(char *line, struct parse_state *state)
{
char *cp, ch, *tag, *value;
return 0;
}
-/* Parse lines from filename as if they were part of the profile file. */
+/* Open and parse an included profile file. */
static errcode_t parse_include_file(char *filename, struct parse_state *state)
{
FILE *fp;
errcode_t retval = 0;
+ struct parse_state incstate;
+
+ /* Create a new state so that fragments are syntactically independent,
+ * sharing the root section with the existing state. */
+ incstate.state = STATE_INIT_COMMENT;
+ incstate.group_level = 0;
+ incstate.root_section = state->root_section;
+ incstate.current_section = NULL;
fp = fopen(filename, "r");
if (fp == NULL)
return PROF_FAIL_INCLUDE_FILE;
- retval = parse_file(fp, state);
+ retval = parse_file(fp, &incstate);
fclose(fp);
return retval;
}
}
/*
- * Parse lines from files in dirname as if they were part of the profile file.
- * Only files with names consisting entirely of alphanumeric chracters and
- * underscores are parsed, in order to avoid parsing editor backup files,
- * .rpmsave files, and the like.
+ * Include files within dirname. Only files with names consisting entirely of
+ * alphanumeric chracters, dashes, and underscores are included, in order to
+ * avoid including editor backup files, .rpmsave files, and the like.
*/
static errcode_t parse_include_dir(char *dirname, struct parse_state *state)
{
errcode_t retval;
*root = NULL;
- retval = parse_init_state(&state);
+
+ /* Initialize parsing state with a new root node. */
+ state.state = STATE_INIT_COMMENT;
+ state.group_level = 0;
+ state.current_section = NULL;
+ retval = profile_create_node("(root)", 0, &state.root_section);
if (retval)
return retval;
+
retval = parse_file(f, &state);
if (retval) {
profile_free_node(state.root_section);
puts "OK: test4: include and includedir directives"
}
+proc test5 {} {
+ global wd verbose
+
+ # Test syntactic independence of included profile files.
+ catch [file delete $wd/testinc.ini]
+ set f [open "$wd/testinc.ini" w]
+ puts $f {[sec1]}
+ puts $f "var = {"
+ puts $f "a = 1"
+ puts $f "include testinc2.ini"
+ puts $f "c = 3"
+ puts $f "}"
+ close $f
+ catch [file delete $wd/testinc2.ini]
+ set f [open "$wd/testinc2.ini" w]
+ puts $f {[sec2]}
+ puts $f "b = 2"
+ close $f
+ set p [profile_init_path $wd/testinc.ini]
+ set a [profile_get_values $p {sec1 var a}]
+ set b [profile_get_values $p {sec2 b}]
+ set c [profile_get_values $p {sec1 var c}]
+ if $verbose { puts "Read values [concat $a $b $c] from profile" }
+ if { $a != 1 || $b != 2 || $c != 3 } {
+ puts stderr, "Error: test5: Wrong results from profile"
+ exit 1
+ }
+
+ puts "OK: test5: syntax independence of included files"
+}
+
test1
test2
test3
test4
+test5
exit 0