#include #include "hostlist.h" #include "gzip.h" #include "params.h" // inplace tolower() and add to pool static bool addpool(strpool **hostlist, char **s, const char *end) { char *p; // advance until eol lowering all chars for (p = *s; pstr)) return false; } return true; } bool NonEmptyHostlist(strpool **hostlist) { // add impossible hostname if the list is empty return *hostlist ? true : StrPoolAddStrLen(hostlist, "@&()", 4); } bool SearchHostList(strpool *hostlist, const char *host) { if (hostlist) { const char *p = host; bool bInHostList; while (p) { bInHostList = StrPoolCheckStr(hostlist, p); if (params.debug) printf("Hostlist check for %s : %s\n", p, bInHostList ? "positive" : "negative"); if (bInHostList) return true; p = strchr(p, '.'); if (p) p++; } } return false; } // return : true = apply fooling, false = do not apply bool HostlistCheck(strpool *hostlist, strpool *hostlist_exclude, const char *host, bool *excluded) { if (excluded) *excluded = false; if (hostlist_exclude) { if (params.debug) printf("Checking exclude hostlist\n"); if (SearchHostList(hostlist_exclude, host)) { if (excluded) *excluded = true; return false; } } if (hostlist) { if (params.debug) printf("Checking include hostlist\n"); return SearchHostList(hostlist, host); } return true; }