FreeBSD/contrib/openbsm/bin/auditfilterd/auditfilterd_conf.c
/*
 * Read a configuration file, and populate 'list' with the configuration
 * lines.  Does not attempt to instantiate the configuration, just read it
 * into a useful set of data structures.
 */
Read a configuration file, and populate 'list' with the configuration
lines.  Does not attempt to instantiate the configuration, just read it
into a useful set of data structures.
Read a configuration file and populate ' list ' with the configuration lines . Does not attempt to instantiate the configuration just read it into a useful set of data structures .
static int
auditfilterd_conf_read(const char *filename, FILE *fp,
    struct auditfilter_module_list *list)
{
	int error, linenumber, syntaxerror;
	struct auditfilter_module *am;
	char buffer[LINE_MAX];
	syntaxerror = 0;
	linenumber = 0;
	while (!feof(fp) && !ferror(fp)) {
		if (fgets(buffer, LINE_MAX, fp) == NULL)
			break;
		linenumber++;
		if (buffer[0] == '#' || strlen(buffer) < 1)
			continue;
		buffer[strlen(buffer)-1] = '\0';
		am = auditfilter_module_parse(filename, linenumber, buffer);
		if (am == NULL) {
			syntaxerror = 1;
			break;
		}
		TAILQ_INSERT_HEAD(list, am, am_list);
	}
	if (ferror(fp)) {
		error = errno;
		auditfilter_module_list_free(list);
		errno = error;
		return (-1);
	}
	if (syntaxerror) {
		auditfilter_module_list_free(list);
		errno = EINVAL;
		return (-1);
	}
	return (0);
}
static int auditfilterd_conf_read ( const char * filename , FILE * fp , struct auditfilter_module_list * list ) { int error , linenumber , syntaxerror ; struct auditfilter_module * am ; char buffer [ LINE_MAX ] ; syntaxerror = 0 ; linenumber = 0 ; while ( ! feof ( fp ) && ! ferror ( fp ) ) { if ( fgets ( buffer , LINE_MAX , fp ) == NULL ) break ; linenumber ++ ; if ( buffer [ 0 ] == ' ' || strlen ( buffer ) < 1 ) continue ; buffer [ strlen ( buffer ) - 1 ] = ' \0 ' ; am = auditfilter_module_parse ( filename , linenumber , buffer ) ; if ( am == NULL ) { syntaxerror = 1 ; break ; } TAILQ_INSERT_HEAD ( list , am , am_list ) ; } if ( ferror ( fp ) ) { error = errno ; auditfilter_module_list_free ( list ) ; errno = error ; return ( -1 ) ; } if ( syntaxerror ) { auditfilter_module_list_free ( list ) ; errno = EINVAL ; return ( -1 ) ; } return ( 0 ) ; }
Read a configuration file, and populate 'list' with the configuration
 lines.
Read a configuration file and populate ' list ' with the configuration lines .
/*
	 * File I/O error.
	 */ /*
	 * Syntax error.
	 */