예제 #1
0
파일: conf.c 프로젝트: andreiw/polaris
/* print the config file */
static void
conf_print(FILE *stream)
{
	struct confinfo *cp;

	for (cp = Confinfo; cp; cp = cp->cf_next) {
		if (cp->cf_flags & CONFF_DELETED)
			continue;
		if (cp->cf_entry) {
			char **p;

			opts_printword(cp->cf_entry, stream);
			if (cp->cf_opts) {
				/* existence of opts overrides args */
				opts_print(cp->cf_opts, stream, "fhnrvVw");
			} else if (cp->cf_args) {
				for (p = cp->cf_args; *p; p++) {
					(void) fprintf(stream, " ");
					opts_printword(*p, stream);
				}
			}
		}
		if (cp->cf_com) {
			if (cp->cf_entry)
				(void) fprintf(stream, " ");
			(void) fprintf(stream, "#%s", cp->cf_com);
		}
		(void) fprintf(stream, "\n");
	}
}
예제 #2
0
/* print the config file */
static void
conf_print(FILE *cstream, FILE *tstream)
{
	struct confinfo *cp;
	char *exclude_opts = "PFfhnrvVw";
	const char *timestamp;

	if (tstream == NULL) {
		exclude_opts++;		/* -P option goes to config file */
	} else {
		(void) fprintf(tstream, gettext(
		    "# This file holds internal data for logadm(1M).\n"
		    "# Do not edit.\n"));
	}
	for (cp = Confinfo; cp; cp = cp->cf_next) {
		if (cp->cf_flags & CONFF_DELETED)
			continue;
		if (cp->cf_entry) {
			opts_printword(cp->cf_entry, cstream);
			if (cp->cf_opts)
				opts_print(cp->cf_opts, cstream, exclude_opts);
			/* output timestamps to tstream */
			if (tstream != NULL && (timestamp =
			    opts_optarg(cp->cf_opts, "P")) != NULL) {
				opts_printword(cp->cf_entry, tstream);
				(void) fprintf(tstream, " -P ");
				opts_printword(timestamp, tstream);
				(void) fprintf(tstream, "\n");
			}
		}
		if (cp->cf_com) {
			if (cp->cf_entry)
				(void) fprintf(cstream, " ");
			(void) fprintf(cstream, "#%s", cp->cf_com);
		}
		(void) fprintf(cstream, "\n");
	}
}