void facron_conf_entries_free (FacronConfEntry *entry) { while (entry) { FacronConfEntry *next = entry->next; facron_conf_entry_free (entry); entry = next; } }
FacronConfEntry * facron_parser_parse_entry (FacronParser *parser) { if (!facron_lexer_read_line (parser->lexer)) return NULL; if (facron_lexer_invalid_line (parser->lexer)) goto fail_early; char *path = facron_lexer_read_string (parser->lexer); if (access (path, R_OK)) { fprintf (stderr, "warning: No such file or directory: \"%s\"\n", path); free (path); goto fail_early; } facron_lexer_skip_spaces (parser->lexer); if (facron_lexer_end_of_line (parser->lexer)) { fprintf (stderr, "Error: no Fanotify mask has been specified.\n"); goto fail_early; } FacronConfEntry *entry = facron_conf_entry_new (parser->previous_entry, path); int n = 0; FacronResult result; unsigned long long mask; while (n < 511 && (result = facron_lexer_next_token (parser->lexer, &mask))) /* != S_END */ { switch (result) { case R_ERROR: goto fail; case R_COMMA: entry->mask[n++] |= mask; break; case R_PIPE: entry->mask[n] |= mask; break; default: break; } } entry->mask[n] |= mask; if (n == 0 && !entry->mask[n]) { fprintf (stderr, "Error: no Fanotify mask has been specified.\n"); goto fail; } n = 0; facron_lexer_skip_spaces (parser->lexer); while (!facron_lexer_end_of_line (parser->lexer) && n < 511) { char *tmp = facron_lexer_read_string (parser->lexer); entry->command[n++] = (!strcmp (tmp, "$$")) ? strdup (entry->path): (!strcmp (tmp, "$@")) ? dirname (entry->path): (!strcmp (tmp, "$#")) ? basename (entry->path): NULL; if (entry->command[n-1]) free (tmp); else entry->command[n-1] = tmp; facron_lexer_skip_spaces (parser->lexer); } if (n == 0) { fprintf (stderr, "Error: no command line specified for \"%s\"\n", entry->path); goto fail; } entry->command[n] = NULL; parser->previous_entry = entry; return entry; fail: facron_conf_entry_free (entry, false); fail_early: return facron_parser_parse_entry (parser); }