static void test_prepend_scalar_idempotent(void **state) { Rlist *list = NULL; IdempPrependRScalar(&list, "stuff", CF_SCALAR); IdempPrependRScalar(&list, "stuff", CF_SCALAR); assert_string_equal(list->item, "stuff"); assert_int_equal(RlistLen(list), 1); DeleteRlist(list); }
static void InitIgnoreInterfaces() { FILE *fin; char filename[CF_BUFSIZE],regex[CF_MAXVARSIZE]; snprintf(filename, sizeof(filename), "%s%cinputs%c%s", CFWORKDIR, FILE_SEPARATOR, FILE_SEPARATOR, CF_IGNORE_INTERFACES); if ((fin = fopen(filename,"r")) == NULL) { CfOut(cf_verbose, "", " -> No interface exception file %s",filename); return; } while (!feof(fin)) { regex[0] = '\0'; fscanf(fin,"%s",regex); if (*regex != '\0') { IdempPrependRScalar(&IGNORE_INTERFACES,regex,CF_SCALAR); } } fclose(fin); }
static void AddOccurrence(Occurrence **list, char *reference, Rlist *represents, enum representations rtype, char *context) { Occurrence *op = NULL; Rlist *rp; if ((op = OccurrenceExists(*list, reference, rtype, context)) == NULL) { op = xcalloc(1, sizeof(Occurrence)); op->occurrence_context = xstrdup(ToLowerStr(context)); op->locator = xstrdup(reference); op->rep_type = rtype; op->next = *list; *list = op; CF_OCCUR++; CfOut(cf_verbose, "", " -> Noted occurrence for %s::%s", context, reference); } /* Occurrence now exists, so add new subtype promises */ if (represents == NULL) { CfOut(cf_error, "", " !! Topic occurrence \"%s\" claims to represent no aspect of its topic, discarding...", reference); return; } for (rp = represents; rp != NULL; rp = rp->next) { IdempPrependRScalar(&(op->represents), rp->item, rp->type); } }