if (file_info->filename) {
// Check white/black lists.
- if (state->parsed->whitelist_contains) {
- for (SDArchiverLLNode *node =
- state->parsed->whitelist_contains->head->next;
- node != state->parsed->whitelist_contains->tail;
- node = node->next) {
- if (node->data) {
- if (!simple_archiver_helper_string_contains(file_info->filename,
- node->data)) {
- // Skipping since filename does not contain whitelist text.
- return 0;
- }
- }
- }
- }
- if (state->parsed->whitelist_begins) {
- for (SDArchiverLLNode *node = state->parsed->whitelist_begins->head->next;
- node != state->parsed->whitelist_begins->tail;
- node = node->next) {
- if (node->data) {
- if (!simple_archiver_helper_string_starts(file_info->filename,
- node->data)) {
- // Skipping since filename does not start with whitelist text.
- return 0;
- }
- }
- }
- }
- if (state->parsed->whitelist_ends) {
- for (SDArchiverLLNode *node = state->parsed->whitelist_ends->head->next;
- node != state->parsed->whitelist_ends->tail;
- node = node->next) {
- if (node->data) {
- if (!simple_archiver_helper_string_ends(file_info->filename,
- node->data)) {
- // Skipping since filename does not end with whitelist text.
- return 0;
- }
- }
- }
- }
-
- if (state->parsed->blacklist_contains) {
- for (SDArchiverLLNode *node =
- state->parsed->blacklist_contains->head->next;
- node != state->parsed->blacklist_contains->tail;
- node = node->next) {
- if (node->data) {
- if (simple_archiver_helper_string_contains(file_info->filename,
- node->data)) {
- // Skipping since filename contains blacklist text.
- return 0;
- }
- }
- }
- }
- if (state->parsed->blacklist_begins) {
- for (SDArchiverLLNode *node = state->parsed->blacklist_begins->head->next;
- node != state->parsed->blacklist_begins->tail;
- node = node->next) {
- if (node->data) {
- if (simple_archiver_helper_string_starts(file_info->filename,
- node->data)) {
- // Skipping since filename starts with blacklist text.
- return 0;
- }
- }
- }
- }
- if (state->parsed->blacklist_ends) {
- for (SDArchiverLLNode *node = state->parsed->blacklist_ends->head->next;
- node != state->parsed->blacklist_ends->tail;
- node = node->next) {
- if (node->data) {
- if (simple_archiver_helper_string_ends(file_info->filename,
- node->data)) {
- // Skipping since filename ends with blacklist text.
- return 0;
- }
- }
- }
+ if (!simple_archiver_helper_string_allowed_lists(
+ file_info->filename,
+ state->parsed->whitelist_contains,
+ state->parsed->whitelist_begins,
+ state->parsed->whitelist_ends,
+ state->parsed->blacklist_contains,
+ state->parsed->blacklist_begins,
+ state->parsed->blacklist_ends)) {
+ return 0;
}
if (file_info->link_dest) {
return 0;
}
+
+uint_fast8_t simple_archiver_helper_string_allowed_lists(
+ const char *cstring,
+ const SDArchiverLinkedList *w_contains,
+ const SDArchiverLinkedList *w_begins,
+ const SDArchiverLinkedList *w_ends,
+ const SDArchiverLinkedList *b_contains,
+ const SDArchiverLinkedList *b_begins,
+ const SDArchiverLinkedList *b_ends) {
+ if (w_contains) {
+ for (const SDArchiverLLNode *node = w_contains->head->next;
+ node != w_contains->tail;
+ node = node->next) {
+ if (node->data) {
+ if (!simple_archiver_helper_string_contains(cstring, node->data)) {
+ return 0;
+ }
+ }
+ }
+ }
+ if (w_begins) {
+ for (const SDArchiverLLNode *node = w_begins->head->next;
+ node != w_begins->tail;
+ node = node->next) {
+ if (node->data) {
+ if (!simple_archiver_helper_string_starts(cstring, node->data)) {
+ return 0;
+ }
+ }
+ }
+ }
+ if (w_ends) {
+ for (const SDArchiverLLNode *node = w_ends->head->next;
+ node != w_ends->tail;
+ node = node->next) {
+ if (node->data) {
+ if (!simple_archiver_helper_string_ends(cstring, node->data)) {
+ return 0;
+ }
+ }
+ }
+ }
+
+ if (b_contains) {
+ for (const SDArchiverLLNode *node = b_contains->head->next;
+ node != b_contains->tail;
+ node = node->next) {
+ if (node->data) {
+ if (simple_archiver_helper_string_contains(cstring, node->data)) {
+ return 0;
+ }
+ }
+ }
+ }
+ if (b_begins) {
+ for (const SDArchiverLLNode *node = b_begins->head->next;
+ node != b_begins->tail;
+ node = node->next) {
+ if (node->data) {
+ if (simple_archiver_helper_string_starts(cstring, node->data)) {
+ return 0;
+ }
+ }
+ }
+ }
+ if (b_ends) {
+ for (const SDArchiverLLNode *node = b_ends->head->next;
+ node != b_ends->tail;
+ node = node->next) {
+ if (node->data) {
+ if (simple_archiver_helper_string_ends(cstring, node->data)) {
+ return 0;
+ }
+ }
+ }
+ }
+
+ return 1;
+}
uint_fast8_t simple_archiver_helper_string_ends(const char *cstring,
const char *ends);
+// Returns non-zero if "cstring" is allowed by lists.
+uint_fast8_t simple_archiver_helper_string_allowed_lists(
+ const char *cstring,
+ const SDArchiverLinkedList *w_contains,
+ const SDArchiverLinkedList *w_begins,
+ const SDArchiverLinkedList *w_ends,
+ const SDArchiverLinkedList *b_contains,
+ const SDArchiverLinkedList *b_begins,
+ const SDArchiverLinkedList *b_ends);
+
#endif