• Patch: Elm ME+ 2.5 PLalpha51 -> Elm ME+ 2.5 PLalpha52 [3/7] (3/6)

    From Kari Hurtta@21:1/5 to All on Mon Jun 8 19:47:03 2020
    [continued from previous message]

    + int ret = 0;
    +
    + if (len != PROCUUID_LEN) {
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: len %d <> %d\n",
    + len,PROCUUID_LEN));
    +
    + ret = 0;
    + goto fail;
    + }
    +
    + /* 2d6177aa-e245-4100-953c-21379927782a */
    +
    + if ('-' != buffer[8] ||
    + '-' != buffer[13] ||
    + '-' != buffer[18] ||
    + '-' != buffer[23] ||
    + '\n' != buffer[36]) {
    +
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: '-' or newline does not match\n"));
    +
    + ret = 0;
    + goto fail;
    + }
    +
    + for (i = 0; i < 8; i++) {
    + if (-1 == hex(buffer[i])) {
    +
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: not a hex char on #%d\n", + i));
    +
    + ret = 0;
    + goto fail;
    + }
    + }
    + for (i = 9; i < 13; i++) {
    + if (-1 == hex(buffer[i])) {
    +
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: not a hex char on #%d\n", + i));
    +
    + ret = 0;
    + goto fail;
    + }
    + }
    + for (i = 14; i < 18; i++) {
    + if (-1 == hex(buffer[i])) {
    +
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: not a hex char on #%d\n", + i));
    +
    + ret = 0;
    + goto fail;
    + }
    + }
    + for (i = 19; i < 23; i++) {
    + if (-1 == hex(buffer[i])) {
    +
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: not a hex char on #%d\n", + i));
    +
    + ret = 0;
    + goto fail;
    + }
    + }
    + for (i = 24; i < 36; i++) {
    + if (-1 == hex(buffer[i])) {
    +
    + DPRINT(Debug,14,(&Debug, "valid_procuuid: not a hex char on #%d\n", + i));
    +
    + ret = 0;
    + goto fail;
    + }
    + }
    +
    + ret = 1;
    +
    + fail:
    + DPRINT(Debug,14,(&Debug, "valid_procuuid=%d\n",ret));
    +
    + return ret;
    + }
    +
    + static int local_procuuid_supported P_((void));
    + static int local_procuuid_supported()
    + {
    + int ret = 0;
    +
    + if (-1 == procuuid_fd) {
    +
    + if (open_procuuid()) {
    +
    + int len;
    +
    + procuuid_used = buffer_bad;
    + len = read(procuuid_fd,procuuid_buffer,sizeof procuuid_buffer);
    +
    + if (len > 0) {
    + procuuid_len = len;
    +
    + ret = valid_procuuid(procuuid_buffer,len);
    + if (ret)
    + procuuid_used = buffer_initialized;
    +
    + } else if (-1 == len) {
    + int err UNUSED_VAROK = errno;
    +
    + DPRINT(Debug,8,(&Debug,
    + "local_procuuid_supported: read %s (fd=%d): %s (errno=%d)\n",
    + PROCUUID,procuuid_fd,strerror(err),err));
    + }
    + }
    +
    + } else
    + ret = 1;
    +
    + DPRINT(Debug,14,(&Debug, "local_procuuid_supported=%d\n",ret));
    +
    + return ret;
    + }
    +
    + static const char INVALID[] = "(invalid)";
    +
    + static char * generate_localspec P_((int *ok_p));
    + static char * generate_localspec(ok_p)
    + int *ok_p;
    + {
    + char * ret = NULL;
    +
    + if (message_id_localspec >= 0 && message_id_localspec < NUM_msgidlocal)
    + ret = safe_strdup(MSG_ID_localspec[message_id_localspec]);
    + else {
    + ret = safe_strdup(INVALID);
    + if (ok_p)
    + *ok_p = 0;
    + }
    +
    + DPRINT(Debug,14,(&Debug, "generate_localspec="));
    + if (ret) {
    + DPRINT(Debug,14,(&Debug, "%Q",ret));
    + } else {
    + DPRINT(Debug,14,(&Debug, "NULL"));
    + }
    + if (ok_p) {
    + DPRINT(Debug,14,(&Debug, "; *ok_p=%d",*ok_p));
    + }
    + DPRINT(Debug,14,(&Debug, "\n"));
    +
    + return ret;
    + }
    +
    +
    +
    + static char * generate_domspec P_((int *ok_p));
    + static char * generate_domspec(ok_p)
    + int *ok_p;
    + {
    + char * ret = NULL;
    +
    + switch (message_id_domspec) {
    + default:
    + if (message_id_domspec >= 0 && message_id_domspec < NUM_msgiddom)
    + ret = safe_strdup(MSG_ID_domspec[message_id_domspec]);
    + else
    + goto invalid_domspec;
    +
    + break;
    + case msgiddom_whitelisted:
    + case msgiddom_literal:
    + case msgiddom_domain:
    + if (message_id_dinfo[dname_domain]) {
    +
    + if (DOMAIN_INFO_magic != message_id_dinfo[dname_domain]->magic)
    + panic("MAILER PANIC",__FILE__,__LINE__,
    + "generate_domspec",
    + "Bad magic number (domain_info)",0);
    +
    + if (message_id_dinfo[dname_domain]->dompart) {
    + ret = safe_strdup(message_id_dinfo[dname_domain]->dompart);
    + } else
    + goto invalid_domspec;
    +
    + } else {
    + invalid_domspec:
    + ret = safe_strdup(INVALID);
    + if (ok_p)
    + *ok_p = 0;
    + }
    + break;
    + }
    +
    + DPRINT(Debug,14,(&Debug, "generate_domspec="));
    + if (ret) {
    + DPRINT(Debug,14,(&Debug, "%Q",ret));
    + } else {
    + DPRINT(Debug,14,(&Debug, "NULL"));
    + }
    + if (ok_p) {
    + DPRINT(Debug,14,(&Debug, "; *ok_p=%d",*ok_p));
    + }
    + DPRINT(Debug,14,(&Debug, "\n"));
    +
    + return ret;
    + }
    +
    + static unsigned short min_domain_labels = 2;
    + static const unsigned short MAXmin_domain_labels=9;
    +
    + static const char MIN_DOMAIN_LABELS_eq[] = "min-domain-labels=";
    + static const char CHECK_DOMAIN_eq[] = "check-domain=";
    + static const char FALLBACK_DOMAIN_eq[] = "fallback-domain=";
    + static const char DEFAULT_TIMEOUT_eq[] = "default-cache-timeout=";
    +
    + static const char PARAM_SEPARATOR[] = "; ";
    +
    + static char * generate_params P_((int *ok_p));
    + static char * generate_params(ok_p)
    + int *ok_p;
    + {
    + char * ret = NULL;
    +
    + if (fallback_domain) {
    +
    + size_t i;
    +
    + for (i = 0; i < fallback_domain_count; i++) {
    + if (fallback_domain[i]) {
    +
    + if (DOMAIN_INFO_magic != fallback_domain[i]->magic)
    + panic("MAILER PANIC",__FILE__,__LINE__,
    + "add_fallback_domain",
    + "Bad magic number (domain_info)",0);
    +
    + if (fallback_domain[i]->dompart) {
    + const char * dompart = fallback_domain[i]->dompart;
    +
    + if (ret)
    + ret = strmcat(ret,PARAM_SEPARATOR);
    +
    + if (host_name_ok(dompart)) {
    + ret = strmcat(ret,FALLBACK_DOMAIN_eq);
    + ret = strmcat(ret,dompart);
    + } else {
    + char * msg = elm_message(FRM("%s%Q"),
    + FALLBACK_DOMAIN_eq,
    + dompart);
    +
    + if (ret) {
    + ret = strmcat(ret,msg);
    + free(msg);
    + } else {
    + ret = msg;
    + }
    + msg = NULL;
    + }
    + }
    + }
    + }
    + }
    +
    + /* Use empty fallback domain as no fallback domain */
    + if (fallback_initialized && ! fallback_domain_count && !ret &&
    + message_id_localspec > msgidlocal_none) {
    + ret = safe_strdup(FALLBACK_DOMAIN_eq);
    + }
    +
    + if (default_timeout_sec >= 0) {
    + char * msg = elm_message(FRM("%s%ds"),
    + DEFAULT_TIMEOUT_eq,
    + default_timeout_sec);
    +
    +
    +
    + if (ret) {
    + ret = strmcat(ret,PARAM_SEPARATOR);
    + ret = strmcat(ret,msg);
    + free(msg);
    + } else {
    + ret = msg;
    + }
    + msg = NULL;
    + }
    +
    + if (msg_checkdom_mode >= 0 && msg_checkdom_mode < NUM_msg_check_dom_mode) {
    + if (ret)
    + ret = strmcat(ret,PARAM_SEPARATOR);
    +
    + ret = strmcat(ret,CHECK_DOMAIN_eq);
    + ret = strmcat(ret,MSG_CHECKDOM_mode[msg_checkdom_mode]);
    + } else if (msg_checkdom_tag == msg_checkdom_mode && msg_verifydom_tag) { + if (ret)
    + ret = strmcat(ret,PARAM_SEPARATOR);
    +
    + ret = strmcat(ret,CHECK_DOMAIN_eq);
    + ret = strmcat(ret,msg_verifydom_tag);
    + }
    +
    + /* min_domain_labels is unsigned */
    + if ( /* min_domain_labels >= 0 && */
    + min_domain_labels <= MAXmin_domain_labels) {
    + char * msg = elm_message(FRM("%s%u"),
    + MIN_DOMAIN_LABELS_eq,
    + min_domain_labels);
    +
    + if (ret) {
    + ret = strmcat(ret,PARAM_SEPARATOR);
    + ret = strmcat(ret,msg);
    + free(msg);
    + } else {
    + ret = msg;
    + }
    + msg = NULL;
    + }
    +
    +
    + DPRINT(Debug,14,(&Debug, "generate_params="));
    + if (ret) {
    + DPRINT(Debug,14,(&Debug, "%Q",ret));
    + } else {
    + DPRINT(Debug,14,(&Debug, "NULL"));
    + }
    + if (ok_p) {
    + DPRINT(Debug,14,(&Debug, "; *ok_p=%d",*ok_p));
    + }
    + DPRINT(Debug,14,(&Debug, "\n"));
    +
    + return ret;
    + }
    +
    + static int message_id_set;
    +
    + static void configure_message_id P_((void));
    + static void configure_message_id()
    + {
    +
    + message_id_set = 1;
    +
    + DPRINT(Debug,14, (&Debug, "configure_message_id: message_id_localspec=%d",
    + message_id_localspec));
    + switch (message_id_localspec) {
    + case msgidlocal_bad: DPRINT(Debug,14,(&Debug," msgidlocal_bad")); break;
    + case msgidlocal_none: DPRINT(Debug,14,(&Debug," msgidlocal_none")); break;
    + case msgidlocal_md5: DPRINT(Debug,14,(&Debug," msgidlocal_md5")); break;
    + case msgidlocal_devurandom: DPRINT(Debug,14,(&Debug," msgidlocal_devurandom")); break;
    + case msgidlocal_procuuid: DPRINT(Debug,14,(&Debug," msgidlocal_procuuid")); break;
    + case NUM_msgidlocal: DPRINT(Debug,14,(&Debug," NUM_msgidlocal")); break;
    + }
    + DPRINT(Debug,14,(&Debug,", message_id_domspec=%d",
    + message_id_domspec));
    + switch (message_id_domspec) {
    + case msgiddom_whitelisted: DPRINT(Debug,14,(&Debug," msgiddom_whitelisted")); break;
    + case msgiddom_literal: DPRINT(Debug,14,(&Debug," msgiddom_literal")); break;
    + case msgiddom_domain: DPRINT(Debug,14,(&Debug," msgiddom_domain")); break;
    + case msgiddom_bad: DPRINT(Debug,14,(&Debug," msgiddom_bad")); break;
    + case msgiddom_default: DPRINT(Debug,14,(&Debug," msgiddom_default")); break;
    + case msgiddom_hostfullname: DPRINT(Debug,14,(&Debug," msgiddom_hostfullname")); break;
    + case msgiddom_maildomain: DPRINT(Debug,14,(&Debug," msgiddom_maildomain")); break;
    + case NUM_msgiddom: DPRINT(Debug,14,(&Debug," NUM_msgiddom")); break;
    + }
    + DPRINT(Debug,14,(&Debug,"\n"));
    +
    + if (msgidlocal_bad == message_id_localspec) {
    + if (local_md5_supported()) {
    + message_id_localspec = msgidlocal_md5;
    + } else if (local_devurandom_supported()) {
    + message_id_localspec = msgidlocal_devurandom;
    + }
    +
    + if (message_id_localspec >= 0 && message_id_localspec < NUM_msgidlocal) {
    + DPRINT(Debug,14, (&Debug, "configure_message_id: message_id_localspec=%d %s\n",
    + message_id_localspec, MSG_ID_localspec[message_id_localspec]));
    + }
    + }
    +
    + #ifdef FALLBACKMSGIDDOM
    + if (! fallback_initialized && message_id_localspec > msgidlocal_none)
    + add_fallback_domain(FALLBACKMSGIDDOM);
    + #endif
    +
    + }
    +
    + static int parse_fallback_domain P_((const char *value));
    + static int parse_fallback_domain(value)
    + const char *value;
    + {
    + /* Use empty fallback domain as no fallback domain */
    +
    + if (value[0]) {
    + size_t l = strlen(value);
    + /* Result is malloced */
    + char * val = dequote_opt(value,l);
    +
    + if (val[0])
    + add_fallback_domain(val);
    +
    + free(val); val = NULL;
    + }
    +
    + return 1; /* Parsed OK */
    + }
    +
    + static int parse_default_timeout P_((const char *value));
    + static int parse_default_timeout(value)
    + const char *value;
    + {
    + int int_value = 0;
    + int mul = 1;
    + const char * a = value;
    +
    + while (isdigit(*a)) {
    + int v;
    + if (INT_MAX / 10 < int_value) {
    + DPRINT(Debug,8,(&Debug,
    + "parse_default_timeout: overflows: %s\n",
    + value));
    + return 0;
    + }
    +
    + int_value = (int_value*10);
    + v = (*a++ - '0');
    +
    + if (INT_MAX -v < int_value) {
    + DPRINT(Debug,8,(&Debug,
    + "parse_default_timeout: overflows: %s\n",
    + value));
    + return 0;
    + }
    +
    + int_value += v;
    + }
    +
    + if (a == value) {
    + DPRINT(Debug,8,(&Debug,
    + "parse_default_timeout: no digits: %s\n",
    + value));
    + return 0;
    + }
    +
    + if (0 == strcmp(a,"") ||
    + 0 == strcmp(a,"s"))
    + mul = 1;
    + else if (0 == strcmp(a,"m"))
    + mul = 60;
    + else if (0 == strcmp(a,"h"))
    + mul = 3600;
    + else if (0 == strcmp(a,"d"))
    + mul = 86400;
    + else {
    + DPRINT(Debug,8,(&Debug,
    + "parse_default_timeout: bad unit (%s): %s\n",
    + a,value));
    + return 0;
    + }
    +
    + if (INT_MAX / mul < int_value) {
    + DPRINT(Debug,8,(&Debug,
    + "parse_default_timeout overflows: %s\n",
    + value));
    + return 0;
    + }
    +
    + default_timeout_sec = int_value * mul;
    + return 1;
    + }
    +
    + static int parse_min_domain_labels P_((const char *value));
    + static int parse_min_domain_labels(value)
    + const char *value;
    + {
    + /* Returns -1 on error, does not accept negative numbers */
    + int int_value = atonum(value);
    +
    + if (int_value >= 0 && int_value <= MAXmin_domain_labels) {
    + min_domain_labels = int_value;
    +
    + return 1;
    + }
    +
    + return 0;
    + }
    +
    +
    + static int parse_check_domain P_((const char *value, int read_flags));
    + static int parse_check_domain(value,read_flags)
    + const char *value;
    + int read_flags;
    + {
    + if (value[0]) {
    + size_t l = strlen(value);
    + /* Result is malloced */
    + char * val = dequote_opt(value,l);
    + int found = 0;
    +
    + enum msg_check_dom_mode b;
    +
    + for (b = 0; b < NUM_msg_check_dom_mode; b++) {
    + if (0 == strcmp(val,MSG_CHECKDOM_mode[b])) {
    + found = 1;
    + msg_checkdom_mode = b;
    + }
    + }
    +
    + if (!found) {
    + switch (mailerdom_verify_lib_status(val,read_flags)) {
    + case mailerdomlib_bad:
    + found = 0;
    + DPRINT(Debug,14,(&Debug,
    + "parse_check_domain: bad check-domain tag %s\n",val));
    + break;
    + case mailerdomlib_not_loaded:
    + DPRINT(Debug,14,(&Debug,
    + "parse_check_domain: check-domain library %s not loaded\n",val));
    + break;
    + case mailerdomlib_found:
    + DPRINT(Debug,14,(&Debug,
    + "parse_check_domain: check-domain library %s found\n",val));
    + found = 1;
    + msg_checkdom_mode = msg_checkdom_tag;
    + msg_verifydom_tag = strmcpy(msg_verifydom_tag,val);
    + break;
    + case mailerdomlib_delayed:
    + DPRINT(Debug,14,(&Debug,
    + "parse_check_domain: check-domain tag %s not checked\n",val));
    + found = 1;
    + msg_checkdom_mode = msg_checkdom_tag;
    + msg_verifydom_tag = strmcpy(msg_verifydom_tag,val);
    + break;
    + }
    +
    + free(val); val = NULL;
    + if (!found)
    + return 0;
    + }
    + }
    +
    + return 1;
    + }
    +
    +
    +
    +
    + static const char COMMENT_SEP[] = " # ";
    +
    + int message_id_func(value,enter,lineno,filename,read_flags)
    + char **value;
    + int enter;
    + int lineno;
    + const char *filename;
    + int read_flags /* READ_FLAG_IGNORE_MISSING */;
    + {
    + int ok = 1;
    +
    + if (filename || enter || read_flags || *value) {
    + DPRINT(Debug,14, (&Debug, "message_id_func: %s",
    + enter ? "(enter) " : ""));
    + if (filename) {
    + DPRINT(Debug,14, (&Debug, "filename=%Q, lineno=%d",
    + filename,lineno));
    + }
    + if (enter || read_flags) {
    + DPRINT(Debug,14, (&Debug, ", read_flags=%d",
    + read_flags));
    + }
    + if (*value) {
    + DPRINT(Debug,14, (&Debug, ", *value=%Q",
    + *value));
    + }
    + DPRINT(Debug,14, (&Debug, "\n"));
    + }
    +
    + if (enter) {
    +
    + char * temp = safe_strdup(*value);
    + const char * this_value = *value;
    + char * ptr;
    + char * domspec = NULL;
    + char * localspec = temp;
    + char * params = NULL;
    + int reset_saved_on_failure = 0; /* Reset saved_domspec, saved_localspec, saved_params
    + on failure */
    +
    + for (ptr = temp; *ptr; ptr++) {
    +
    + parsenext:
    + switch (*ptr) {
    +
    + case '\0':
    + goto doneparse;
    +
    + case ' ':
    + if (ptr == localspec)
    + localspec = ptr+1;
    + else if (0 == strncmp(ptr,COMMENT_SEP,(sizeof COMMENT_SEP)-1)) {
    + /* Truncate on comment */
    +
    + *ptr ='\0';
    + goto doneparse;
    +
    + } else if (!params) {
    + int len = rfc822_toklen(ptr);
    +
    + if ('\0' == ptr[len] || ';' == ptr[len]) {
    + /* Truncate value */
    +
    + *ptr ='\0';
    + ptr += len;
    + goto parsenext;
    + } else if (0 == strncmp(ptr+len,"# ",2)) {
    + /* Truncate on comment */
    +
    + *ptr ='\0';
    + goto doneparse;
    + }
    +
    + goto failchar;
    +
    + } else if (ptr == params)
    + params = ptr+1;
    +
    + break;
    +
    + case '\t':
    + if (ptr == localspec)
    + localspec = ptr+1;
    + else if (!params) {
    + int len = rfc822_toklen(ptr);
    +
    + if ('\0' == ptr[len] || ';' == ptr[len]) {
    + /* Truncate value */
    +
    + *ptr ='\0';
    + ptr += len;
    + goto parsenext;
    + } else if (0 == strncmp(ptr+len,"# ",2)) {
    + /* Truncate on comment */
    +
    + *ptr ='\0';
    + goto doneparse;
    + } else {
    + unsigned char c = *ptr;
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOptFile,
    + "Bad message-id option %Q character x%02x on line %d on file %s"),
    + this_value,c,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOp,
    + "Bad message-id option %Q character x%02x."),
    + this_value,c);
    + }
    +
    + ok = 0;
    + goto failparse;
    + }
    + } else if (ptr == params+1)
    + params = ptr+1;
    +
    + break;
    +
    + case '@':
    +
    + if (params)
    + break;
    +
    + if (!ptr[1] || domspec)
    + goto failchar;
    +
    + if (ptr == localspec)
    + localspec = NULL;
    +
    + *ptr ='\0';
    + domspec = ptr+1;
    + break;
    + case '[':
    +
    + if ((domspec && ptr == domspec+1) || params) {
    + int len = rfc822_toklen(ptr);
    +
    + if (len < 2 || ']' != ptr[len-1]) {
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadOptFile,
    + "Bad message-id option %Q token \"%c\" on line %d on file %s"),
    + this_value,*ptr,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadOp,
    + "Bad message-id option %Q token \"%c\"."),
    + this_value,*ptr);
    + }
    +
    + ok = 0;
    + goto failparse;
    + }
    +
    +
    + goto skip_on_parms;
    + }
    +
    + goto failchar;
    +
    + case '"':
    + if (params) {
    + int len = rfc822_toklen(ptr);
    +
    + if (len < 2 || '"' != ptr[len-1]) {
    + unsigned char c = *ptr;
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOptFile,
    + "Bad message-id option %Q character x%02x on line %d on file %s"),
    + this_value,c,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOp,
    + "Bad message-id option %Q character x%02x."),
    + this_value,c);
    + }
    +
    + ok = 0;
    + goto failparse;
    + }
    +
    + goto skip_on_parms;
    +
    + }
    +
    + goto failchar;
    +
    + case ';':
    + if (params)
    + break;
    +
    + if (ptr == localspec)
    + localspec = NULL;
    + if (ptr == domspec)
    + domspec = NULL;
    +
    + *ptr ='\0';
    + params = ptr+1;
    + break;
    +
    + case '.':
    + if (domspec && ptr > domspec && '.' != ptr[-1] &&
    + '\0' != ptr[1] && ' ' != ptr[1] && '\t' != ptr[1] &&
    + ';' != ptr[1])
    + break;
    +
    + goto failchar;
    +
    + case '(': {
    + int len = rfc822_toklen(ptr);
    +
    + if (strncpy(ptr,INVALID,len)) {
    +
    + /* Silent failure */
    +
    + ptr += len;
    + goto parsenext;
    + }
    +
    + if (len < 2 || ')' != ptr[len-1]) {
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadOptFile,
    + "Bad message-id option %Q token \"%c\" on line %d on file %s"),
    + this_value,*ptr,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadOp,
    + "Bad message-id option %Q token \"%c\"."),
    + this_value,*ptr);
    + }
    +
    +
    + ok = 0;
    + goto failparse;
    + }
    + }
    + /* FALLTHRU */
    + failchar:
    + case ')':
    + case '=':
    + case ']':
    + case '\\':
    +
    + if (params)
    + goto skip_on_parms;
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadOptFile,
    + "Bad message-id option %Q token \"%c\" on line %d on file %s"),
    + this_value,*ptr,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadOp,
    + "Bad message-id option %Q token \"%c\"."),
    + this_value,*ptr);
    + }
    +
    + ok = 0;
    + goto failparse;
    +
    + skip_on_parms: {
    + int len = rfc822_toklen(ptr);
    +
    + while (len > 0) {
    + if (!isascii(*ptr) || !isprint(*ptr)) {
    + unsigned char c = *ptr;
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOptFile,
    + "Bad message-id option %Q character x%02x on line %d on file %s"),
    + this_value,c,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOp,
    + "Bad message-id option %Q character x%02x."),
    + this_value,c);
    + }
    +
    + ok = 0;
    + goto failparse;
    + }
    +
    + ptr++;
    + len--;
    + }
    +
    + goto parsenext;
    + }
    +
    + default:
    +
    + if (!isascii(*ptr) || !isprint(*ptr)) {
    + unsigned char c = *ptr;
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOptFile,
    + "Bad message-id option %Q character x%02x on line %d on file %s"),
    + this_value,c,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadXOp,
    + "Bad message-id option %Q character x%02x."),
    + this_value,c);
    + }
    +
    + ok = 0;
    + goto failparse;
    +
    + }
    + break;
    +
    + }
    + }
    +
    + doneparse:
    + if (localspec) {
    + if (!localspec[0] || 0 == strcmp(localspec,INVALID))
    + localspec = NULL;
    + else {
    + DPRINT(Debug,15, (&Debug, "message_id_func: localspec=%s\n",localspec));
    + }
    + }
    + if (domspec) {
    + if (!domspec[0] || 0 == strcmp(domspec,INVALID))
    + domspec = NULL;
    + else {
    + DPRINT(Debug,15, (&Debug, "message_id_func: domspec=%s\n",domspec));
    + }
    + }
    + if (params) {
    + if (!params[0])
    + params = NULL;
    + else {
    + DPRINT(Debug,15, (&Debug, "message_id_func: params=%s\n",params));
    + }
    + }
    +
    + if (! localspec && !domspec && ! params && !message_id_set) {
    + DPRINT(Debug,15, (&Debug, "message_id_func: %Q, Null value, configuring\n",
    + this_value));
    + configure_message_id();
    + }
    +
    +
    + if (localspec) {
    + enum msg_id_localspec localspec_val = msgidlocal_bad;
    + enum msg_id_localspec i;
    +
    + int is_valid = 0;
    +
    + for (i = 0; i < NUM_msgidlocal; i++) {
    + if (MSG_ID_localspec[i] &&
    + 0 == strcmp(localspec,MSG_ID_localspec[i])) {
    + localspec_val = i;
    + break;
    + }
    + }
    +
    + switch (localspec_val) {
    + case msgidlocal_bad:
    + case NUM_msgidlocal:
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadLocalOptFile,
    + "Invalid local part keyword %Q on message-id option %Q on line %d on file %s"),
    + localspec,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadLocalOpt, + "Invalid local part keyword %Q on message-id option %Q."),
    + localspec,this_value);
    + }
    + ok = 0;
    + break;
    +
    + case msgidlocal_none:
    + message_id_localspec = localspec_val;
    +
    + if (saved_domspec || saved_params) {
    + DPRINT(Debug,14, (&Debug, "message_id_func: %Q gived. Clearing saved ",
    + localspec));
    +
    + if (saved_domspec) {
    + DPRINT(Debug,14, (&Debug, "domain %Q", saved_domspec));
    + free(saved_domspec);
    + saved_domspec = NULL;
    + }
    +
    + if (saved_params) {
    + DPRINT(Debug,14, (&Debug, "params %Q", saved_params)); + free(saved_params);
    + saved_params = NULL;
    + }
    +
    + DPRINT(Debug,14, (&Debug, "\n"));
    + }
    +
    + break;
    +
    + break;
    + if (0) {
    + case msgidlocal_md5:
    + is_valid = local_md5_supported();
    + } else if (0) {
    + case msgidlocal_devurandom:
    + is_valid = local_devurandom_supported();
    + } else if (0) {
    + case msgidlocal_procuuid:
    + is_valid = local_procuuid_supported();
    + }
    +
    +
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, local %s found as %d%s\n",
    + this_value,localspec,localspec_val,
    + is_valid ? ", supported" : ", fails"));
    +
    + if (is_valid) {
    + message_id_localspec = localspec_val;
    + } else {
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDUnsLocalOptFile,
    + "Unsupported local part keyword %Q on message-id option %Q on line %d on file %s"),
    + localspec,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDUnsLocalOpt,
    + "Unsupported local part keyword %Q on message-id option %Q."),
    + localspec,this_value);
    + }
    +
    + ok = 0;
    + }
    + break;
    + }
    +
    + saved_localspec = strmcpy(saved_localspec,localspec);
    + reset_saved_on_failure = 1;
    + }
    +
    + if (domspec) {
    +
    + if ( msgidlocal_none == message_id_localspec ) {
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDLocalPartNoDomFile,
    + "Local part keyword %Q does not need domain on message-id option %Q line %d on file %s"),
    + localspec,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDLocalPartNoDom,
    + "Local part keyword %Q does not need domain on message-id option %Q."),
    + localspec,this_value);
    + }
    + ok = 0;
    + }
    +
    + if ('[' == domspec[0]) {
    + int len = rfc822_toklen(domspec);
    +
    + if (len < 2 || domspec[len] || domspec[len-1] != ']') {
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, domain %s failed to parse as literal\n",
    + this_value,domspec));
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadLitoptionFile,
    + "Invalid literal %Q on message-id option %Q on line %d on file %s"),
    + domspec,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadLitoption,
    + "Invalid literal %Q on message-id option %Q."),
    + domspec,this_value);
    + }
    +
    + ok = 0;
    + } else {
    +
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, domain %s parsed as literal\n",
    + this_value,domspec));
    +
    + message_id_domspec = msgiddom_literal;
    +
    + set_msgid_dompart(dname_domain,domspec,cds_disabled_ok,NULL);
    + }
    +
    + } else {
    + int len = rfc822_toklen(domspec);
    +
    + if ('.' == domspec[len]) {
    + const char * whitelisted =
    + is_whitelisted_msgid_domain(domspec);
    +
    + /* Is domain name */
    +
    + if (whitelisted) {
    +
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, domain %s whitelisted on %s\n",
    + this_value,whitelisted,domspec));
    +
    + message_id_domspec = msgiddom_whitelisted;
    + set_msgid_dompart(dname_domain,domspec,cds_whitelisted,NULL);
    +
    + } else {
    +
    + const char * reserved_name =
    + is_special_use_domain(domspec);
    +
    + if (reserved_name) {
    +
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, domain %s reserved on %s\n",
    + this_value,reserved_name,domspec));
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDResDomOptFile,
    + "Reserved domain %s on %Q on message-id option %Q on file %s"),
    + reserved_name,domspec,this_value,
    + lineno,filename);
    +
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDResDomOpt,
    + "Reserved domain %s on %Q on message-id option %Q."),
    + reserved_name,domspec,this_value);
    + }
    +
    + message_id_domspec = msgiddom_bad;
    +
    + set_msgid_dompart(dname_domain,NULL,cds_reserved,NULL);
    +
    + ok = 0;
    + } else {
    + message_id_domspec = msgiddom_domain;
    + set_msgid_dompart(dname_domain,domspec,cds_none,NULL);
    + }
    + }
    +
    + } else {
    + enum msg_id_domspec domspec_val = msgiddom_bad;
    + enum msg_id_domspec i;
    +
    + for (i = 0; i < NUM_msgiddom; i++) {
    + if (0 == strcmp(domspec,MSG_ID_domspec[i])) {
    + domspec_val = i;
    + break;
    + }
    + }
    +
    + switch (domspec_val) {
    + case NUM_msgiddom:
    + case msgiddom_whitelisted:
    + case msgiddom_literal:
    + case msgiddom_domain:
    + case msgiddom_bad:
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadDomOptFile,
    + "Invalid domain part keyword %Q on message-id option %Q on line %d on file %s"),
    + domspec,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDBadDomOpt,
    + "Invalid domain part keyword %Q on message-id option %Q."),
    + localspec,this_value);
    + }
    + ok = 0;
    +
    + break;
    +
    + case msgiddom_default:
    + set_msgid_dompart(dname_maildomain,useful_mailname(),cds_none,NULL);
    + /* FALLTHROUG */
    +
    + case msgiddom_hostfullname:
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, domain %s found as %d\n",
    + this_value,domspec,domspec_val));
    +
    + message_id_domspec = domspec_val;
    + set_msgid_dompart(dname_hostfullname,hostfullname,cds_none,NULL);
    + break;
    +
    + case msgiddom_maildomain:
    +
    + DPRINT(Debug,14,
    + (&Debug,
    + "message_id_func: %Q, domain %s found as %d\n",
    + this_value,domspec,domspec_val));
    +
    + message_id_domspec = domspec_val;
    + set_msgid_dompart(dname_maildomain,useful_mailname(),cds_none,NULL);
    + break;
    + }
    + }
    + }
    +
    + saved_domspec = strmcpy(saved_domspec,domspec);
    + reset_saved_on_failure = 1;
    + }
    +
    + if (params) {
    + char * WALK;
    + char * f;
    + int clear_fallback = 1;
    + int default_timout_seen = 0;
    + int check_domain_seen = 0;
    + int min_domain_labels_seen = 0;
    +
    + if ( msgidlocal_none == message_id_localspec ) {
    +
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDLocalPartNoParmFile,
    + "Local part keyword %Q does not need parameters on message-id option %Q line %d on file %s"),
    + localspec,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDLocalPartNoParam,
    + "Local part keyword %Q does not need parameters on message-id option %Q."),
    + localspec,this_value);
    + }
    + ok = 0;
    + }
    +
    + saved_params = strmcpy(saved_params,params);
    + reset_saved_on_failure = 1;
    +
    + for (f = mime_parse_content_opts(params, &WALK); f;
    + f = mime_parse_content_opts(NULL, &WALK)) {
    +
    + char * x = strchr(f,'=');
    +
    + if (x) {
    + size_t len = (x - f) +1;
    +
    + if (0 == strncmp(f,FALLBACK_DOMAIN_eq,len)) {
    + char * a = f+len;
    +
    + if (clear_fallback) {
    + free_fallback_domains();
    + clear_fallback = 0;
    + }
    +
    + if (parse_fallback_domain(a)) {
    + DPRINT(Debug,14,(&Debug,"message_id_func: Parsed %s\n",
    + f));
    + } else {
    + goto bad_param;
    + }
    +
    + } else if (0 == strncmp(f,DEFAULT_TIMEOUT_eq,len)) {
    + char * a = f+len;
    +
    + if (default_timout_seen) {
    + if (filename) {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDDubParamFile,
    + "Duplicate paramater %Q on message-id option %Q on line %d on file %s"),
    + f,this_value,lineno,filename);
    +
    + } else {
    + lib_error(CATGETS(elm_msg_cat, MeSet, MeMsgIDDubParam,
    + "Duplicate paramater %Q on message-id option %Q."),
    + f,this_value);
    + }
    +
    + ok = 0;
    + }
    +
    + if (parse_default_timeout(a)) {
    + DPRINT(Debug,14,(&Debug,"message_id_func: Parsed %s\n",
    + f));
    + default_timout_seen = 1;
    + } else {
    + goto bad_param;
    + }
    +
    + } else if (0 == strncmp(f,CHECK_DOMAIN_eq,len)) {
    + char * a = f+len;
    +

    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)