Beispiel #1
0
void free_policy(struct osddb_policy *policy)
{
    int r;
    XDR xdr;
    for ( r = 0 ; r < policy->rules.pol_ruleList_len ; r++ )
	free_regexes(&policy->rules.pol_ruleList_val[r].condition);
    xdrmem_create(&xdr, NULL, 0, XDR_FREE);
    if ( !xdr_osddb_policy(&xdr, policy) )
	ViceLog(0, ("XDR_FREE of policy at 0x%p failed\n", policy));
}
Beispiel #2
0
void
config_load_file(const char *szFilename)
{
	FILE *pStream = fopen(szFilename, "r");
	char szLine[LINE_BUFFER];
	FileEntry *pFileEntry;
	int result;
	regmatch_t rgMatches[2];

	printf("Loading %s\n", szFilename);

	if (!pStream) {
		return;
	}

	compile_regexes(FILE_ENTRIES);

	while (fgets(szLine, LINE_BUFFER, pStream)) {
		pFileEntry = FILE_ENTRIES;
		while (pFileEntry->szParameter) {
			result = regexec(
				pFileEntry->pRegexCompiled, /* preg   */
				szLine,                     /* string */
				2,                          /* nmatch */
				rgMatches,                  /* pmatch */
				0                           /* eflags */
			);

			if (result == 0) {
				/* Insert null at end of match. */
				szLine[rgMatches[1].rm_eo] = '\0';
				pFileEntry->store(szLine + rgMatches[1].rm_so);
			}

			pFileEntry++;
		}
	}

	free_regexes(FILE_ENTRIES);

	fclose(pStream);
}