void exit_free(void) { passwd_free(); debug(9, "passwd_free()"); hosts_free(); debug(9, "hosts_free()"); uplinks_free(); debug(9, "uplinks_free()"); areasbbs_free(); debug(9, "areasbbs_free()"); config_free(); debug(9, "config_free()"); #ifdef FTN_ACL acl_ftn_free(); debug(9, "acl_ftn_free()"); #endif /* FTN_ACL */ charset_free(); debug(9, "charset_free()"); }
static int squatter_build_query(search_builder_t *bx, const char *query) { tok_t tok = TOK_INITIALIZER(query, NULL, 0); char *p; char *q; int r = 0; int part; charset_t utf8 = charset_lookupname("utf-8"); while ((p = tok_next(&tok))) { if (!strncasecmp(p, "__begin:", 8)) { q = p + 8; if (!strcasecmp(q, "and")) bx->begin_boolean(bx, SEARCH_OP_AND); else if (!strcasecmp(q, "or")) bx->begin_boolean(bx, SEARCH_OP_OR); else if (!strcasecmp(q, "not")) bx->begin_boolean(bx, SEARCH_OP_NOT); else goto error; continue; } if (!strncasecmp(p, "__end:", 6)) { q = p + 6; if (!strcasecmp(q, "and")) bx->end_boolean(bx, SEARCH_OP_AND); else if (!strcasecmp(q, "or")) bx->end_boolean(bx, SEARCH_OP_OR); else if (!strcasecmp(q, "not")) bx->end_boolean(bx, SEARCH_OP_NOT); else goto error; continue; } /* everything else is a ->match() of some kind */ q = strchr(p, ':'); if (q) q++; if (!q) { part = SEARCH_PART_ANY; q = p; } else if (!strncasecmp(p, "to:", 3)) part = SEARCH_PART_TO; else if (!strncasecmp(p, "from:", 5)) part = SEARCH_PART_FROM; else if (!strncasecmp(p, "cc:", 3)) part = SEARCH_PART_CC; else if (!strncasecmp(p, "bcc:", 4)) part = SEARCH_PART_BCC; else if (!strncasecmp(p, "subject:", 8)) part = SEARCH_PART_SUBJECT; else if (!strncasecmp(p, "listid:", 7)) part = SEARCH_PART_LISTID; else if (!strncasecmp(p, "contenttype:", 12)) part = SEARCH_PART_TYPE; else if (!strncasecmp(p, "header:", 7)) part = SEARCH_PART_HEADERS; else if (!strncasecmp(p, "body:", 5)) part = SEARCH_PART_BODY; else goto error; q = charset_convert(q, utf8, charset_flags); bx->match(bx, part, q); free(q); } r = 0; out: charset_free(&utf8); tok_fini(&tok); return r; error: syslog(LOG_ERR, "bad query expression at \"%s\"", p); r = IMAP_PROTOCOL_ERROR; goto out; }