void module_cons(mowgli_eventloop_t *eventloop, mowgli_config_file_entry_t *entry) { mowgli_config_file_entry_t *ce; memset(th_list, 0, sizeof(th_list)); MOWGLI_ITER_FOREACH(ce, entry) { if (!strcasecmp(ce->varname, "range")) parse_threshold(ce->vardata, ce->entries); } HOOK_REGISTER(HOOK_CHECK_THRES, hook_check_thres); }
int main(int argc, char **argv) { int removewide; char *line, *input_ptr; size_t line_len, rest_len; --argc; ++argv; if (argc == 0) usage(); if (strcmp(*argv, "-w") == 0 || strcmp(*argv, "+w") == 0) { if (**argv == '-') opt_minus_w = 1; else opt_plus_w = 1; --argc; ++argv; } if (argc != 1 || (opt_plus_w && opt_minus_w)) usage(); if (parse_threshold(*argv)) { fprintf(stderr, "Illegal threshold %s\n", *argv); usage(); } if (opt_minus_w) removewide = 1; else if (opt_plus_w) removewide = 0; else removewide = (threshold <= 0x3200); line_len = 1024; if ((line = malloc(line_len)) == NULL) { fprintf(stderr, "malloc failed"); exit(EXIT_FAILURE); } for (;;) { if (fgets(line, line_len, stdin) == NULL) break; while (strlen(line) == line_len - 1 && !feof(stdin)) { if (line_len > SSIZE_MAX) { fprintf(stderr, "input line too large"); exit(EXIT_FAILURE); } line = realloc(line, line_len * 2); if (line == NULL) { fprintf(stderr, "realloc failed"); exit(EXIT_FAILURE); } input_ptr = line + line_len - 1; rest_len = line_len + 1; line_len *= 2; if (fgets(input_ptr, rest_len, stdin) == NULL) { /* Should not happen, but handle as EOF */ break; } } process_line(line); } return EXIT_SUCCESS; }