📄 mail.c
字号:
if (ret = (void *) a) a->flags &= ~AU_DISABLE; break; case DISABLE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); if (ret = (void *) a) a->flags |= AU_DISABLE; break; case UNHIDE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); if (ret = (void *) a) a->flags &= ~AU_HIDE; break; case HIDE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); if (ret = (void *) a) a->flags |= AU_HIDE; break; case SET_EXTERNALAUTHID: if (value) { /* setting external authentication ID */ externalauthid = cpystr ((char *) value); mail_parameters (NIL,UNHIDE_AUTHENTICATOR,"EXTERNAL"); } else { /* clearing external authentication ID */ if (externalauthid) fs_give ((void **) &externalauthid); mail_parameters (NIL,HIDE_AUTHENTICATOR,"EXTERNAL"); } case GET_EXTERNALAUTHID: ret = (void *) externalauthid; break; case SET_GETS: mailgets = (mailgets_t) value; case GET_GETS: ret = (void *) mailgets; break; case SET_READPROGRESS: mailreadprogress = (readprogress_t) value; case GET_READPROGRESS: ret = (void *) mailreadprogress; break; case SET_CACHE: mailcache = (mailcache_t) value; case GET_CACHE: ret = (void *) mailcache; break; case SET_RFC822OUTPUT: mail822out = (rfc822out_t) value; case GET_RFC822OUTPUT: ret = (void *) mail822out; break; case SET_RFC822OUTPUTFULL: mail822outfull = (rfc822outfull_t) value; case GET_RFC822OUTPUTFULL: ret = (void *) mail822outfull; break; case SET_SMTPVERBOSE: mailsmtpverbose = (smtpverbose_t) value; case GET_SMTPVERBOSE: ret = (void *) mailsmtpverbose; break; case SET_MAILPROXYCOPY: mailproxycopy = (mailproxycopy_t) value; case GET_MAILPROXYCOPY: ret = (void *) mailproxycopy; break; case SET_PARSELINE: mailparseline = (parseline_t) value; case GET_PARSELINE: ret = (void *) mailparseline; break; case SET_PARSEPHRASE: mailparsephrase = (parsephrase_t) value; case GET_PARSEPHRASE: ret = (void *) mailparsephrase; break; case SET_NEWSRCQUERY: mailnewsrcquery = (newsrcquery_t) value; case GET_NEWSRCQUERY: ret = (void *) mailnewsrcquery; break; case SET_NEWSRCCANONHOST: mailnewsrccanon = (long) value; case GET_NEWSRCCANONHOST: ret = (void *) mailnewsrccanon; break; case SET_COPYUID: mailcopyuid = (copyuid_t) value; case GET_COPYUID: ret = (void *) mailcopyuid; break; case SET_APPENDUID: mailappenduid = (appenduid_t) value; case GET_APPENDUID: ret = (void *) mailappenduid; break; case SET_FREEENVELOPESPAREP: mailfreeenvelopesparep = (freeenvelopesparep_t) value; case GET_FREEENVELOPESPAREP: ret = (void *) mailfreeenvelopesparep; break; case SET_FREEELTSPAREP: mailfreeeltsparep = (freeeltsparep_t) value; case GET_FREEELTSPAREP: ret = (void *) mailfreeeltsparep; break; case SET_FREESTREAMSPAREP: mailfreestreamsparep = (freestreamsparep_t) value; case GET_FREESTREAMSPAREP: ret = (void *) mailfreestreamsparep; break; case SET_FREEBODYSPAREP: mailfreebodysparep = (freebodysparep_t) value; case GET_FREEBODYSPAREP: ret = (void *) mailfreebodysparep; break; case SET_SSLSTART: mailsslstart = (sslstart_t) value; case GET_SSLSTART: ret = (void *) mailsslstart; break; case SET_SSLCERTIFICATEQUERY: mailsslcertificatequery = (sslcertificatequery_t) value; case GET_SSLCERTIFICATEQUERY: ret = (void *) mailsslcertificatequery; break; case SET_SSLCLIENTCERT: mailsslclientcert = (sslclientcert_t) value; case GET_SSLCLIENTCERT: ret = (void *) mailsslclientcert; break; case SET_SSLCLIENTKEY: mailsslclientkey = (sslclientkey_t) value; case GET_SSLCLIENTKEY: ret = (void *) mailsslclientkey; break; case SET_SSLFAILURE: mailsslfailure = (sslfailure_t) value; case GET_SSLFAILURE: ret = (void *) mailsslfailure; break; case SET_KINIT: mailkinit = (kinit_t) value; case GET_KINIT: ret = (void *) mailkinit; break; case SET_SENDCOMMAND: mailsendcommand = (sendcommand_t) value; case GET_SENDCOMMAND: ret = (void *) mailsendcommand; break; case SET_SERVICENAME: servicename = (char *) value; case GET_SERVICENAME: ret = (void *) servicename; break; case SET_EXPUNGEATPING: expungeatping = (value ? T : NIL); case GET_EXPUNGEATPING: ret = (void *) (expungeatping ? VOIDT : NIL); break; case SET_SORTRESULTS: mailsortresults = (sortresults_t) value; case GET_SORTRESULTS: ret = (void *) mailsortresults; break; case SET_THREADRESULTS: mailthreadresults = (threadresults_t) value; case GET_THREADRESULTS: ret = (void *) mailthreadresults; break; case SET_SSLDRIVER: mailssldriver = (NETDRIVER *) value; case GET_SSLDRIVER: ret = (void *) mailssldriver; break; case SET_TRYSSLFIRST: trysslfirst = (value ? T : NIL); case GET_TRYSSLFIRST: ret = (void *) (trysslfirst ? VOIDT : NIL); break; case SET_NOTIMEZONES: notimezones = (value ? T : NIL); case GET_NOTIMEZONES: ret = (void *) (notimezones ? VOIDT : NIL); break; case SET_TRUSTDNS: trustdns = (value ? T : NIL); case GET_TRUSTDNS: ret = (void *) (trustdns ? VOIDT : NIL); break; case SET_SASLUSESPTRNAME: saslusesptrname = (value ? T : NIL); case GET_SASLUSESPTRNAME: ret = (void *) (saslusesptrname ? VOIDT : NIL); break; case SET_DEBUGSENSITIVE: debugsensitive = (value ? T : NIL); case GET_DEBUGSENSITIVE: ret = (void *) (debugsensitive ? VOIDT : NIL); break; case SET_ACL: mailaclresults = (getacl_t) value; case GET_ACL: ret = (void *) mailaclresults; break; case SET_LISTRIGHTS: maillistrightsresults = (listrights_t) value; case GET_LISTRIGHTS: ret = (void *) maillistrightsresults; break; case SET_MYRIGHTS: mailmyrightsresults = (myrights_t) value; case GET_MYRIGHTS: ret = (void *) mailmyrightsresults; break; case SET_QUOTA: mailquotaresults = (quota_t) value; case GET_QUOTA: ret = (void *) mailquotaresults; break; case SET_QUOTAROOT: mailquotarootresults = (quotaroot_t) value; case GET_QUOTAROOT: ret = (void *) mailquotarootresults; break; case SET_SNARFINTERVAL: mailsnarfinterval = (long) value; case GET_SNARFINTERVAL: ret = (void *) mailsnarfinterval; break; case SET_SNARFPRESERVE: mailsnarfpreserve = (long) value; case GET_SNARFPRESERVE: ret = (void *) mailsnarfpreserve; break; case SET_SNARFMAILBOXNAME: if (stream) { /* have a stream? */ if (stream->snarf.name) fs_give ((void **) &stream->snarf.name); stream->snarf.name = cpystr ((char *) value); } else fatal ("SET_SNARFMAILBOXNAME with no stream"); case GET_SNARFMAILBOXNAME: if (stream) ret = (void *) stream->snarf.name; break; default: if (r = smtp_parameters (function,value)) ret = r; if (r = env_parameters (function,value)) ret = r; if (r = tcp_parameters (function,value)) ret = r; if (stream && stream->dtb) {/* if have stream, do for its driver only */ if (r = (*stream->dtb->parameters) (function,value)) ret = r; } /* else do all drivers */ else for (d = maildrivers; d; d = d->next) if (r = (d->parameters) (function,value)) ret = r; break; } return ret;}/* Mail validate mailbox name * Accepts: MAIL stream * mailbox name * purpose string for error message * Return: driver factory on success, NIL on failure */DRIVER *mail_valid (MAILSTREAM *stream,char *mailbox,char *purpose){ char tmp[MAILTMPLEN]; DRIVER *factory = NIL; /* never allow names with newlines */ if (strpbrk (mailbox,"\015\012")) { if (purpose) { /* if want an error message */ sprintf (tmp,"Can't %s with such a name",purpose); MM_LOG (tmp,ERROR); } return NIL; } /* validate name, find driver factory */ if (strlen (mailbox) < (NETMAXHOST+(NETMAXUSER*2)+NETMAXMBX+NETMAXSRV+50)) for (factory = maildrivers; factory && ((factory->flags & DR_DISABLE) || ((factory->flags & DR_LOCAL) && (*mailbox == '{')) || !(*factory->valid) (mailbox)); factory = factory->next); /* validate factory against non-dummy stream */ if (factory && stream && stream->dtb && (stream->dtb != factory) && strcmp (stream->dtb->name,"dummy")) /* factory invalid; if dummy, use stream */ factory = strcmp (factory->name,"dummy") ? NIL : stream->dtb; if (!factory && purpose) { /* if want an error message */ sprintf (tmp,"Can't %s %.80s: %s",purpose,mailbox,(*mailbox == '{') ? "invalid remote specification" : "no such mailbox"); MM_LOG (tmp,ERROR); } return factory; /* return driver factory */}/* Mail validate network mailbox name * Accepts: mailbox name * mailbox driver to validate against * pointer to where to return host name if non-NIL * pointer to where to return mailbox name if non-NIL * Returns: driver on success, NIL on failure */DRIVER *mail_valid_net (char *name,DRIVER *drv,char *host,char *mailbox){ NETMBX mb; if (!mail_valid_net_parse (name,&mb) || strcmp (mb.service,drv->name)) return NIL; if (host) strcpy (host,mb.host); if (mailbox) strcpy (mailbox,mb.mailbox); return drv;}/* Mail validate network mailbox name * Accepts: mailbox name * NETMBX structure to return values * Returns: T on success, NIL on failure */long mail_valid_net_parse (char *name,NETMBX *mb){ return mail_valid_net_parse_work (name,mb,"imap");}/* Mail validate network mailbox name worker routine * Accepts: mailbox name * NETMBX structure to return values * default service * Returns: T on success, NIL on failure */long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service){ int i,j; char c,*s,*t,*v,tmp[MAILTMPLEN],arg[MAILTMPLEN]; /* initialize structure */ memset (mb,'\0',sizeof (NETMBX)); /* must have host specification */ if (*name++ != '{') return NIL; if (*name == '[') { /* if domain literal, find its ending */ if (!((v = strpbrk (name,"]}")) && (*v++ == ']'))) return NIL; } /* find end of host name */ else if (!(v = strpbrk (name,"/:}"))) return NIL; /* validate length, find mailbox part */ if (!((i = v - name) && (i < NETMAXHOST) && (t = strchr (v,'}')) && ((j = t - v) < MAILTMPLEN) && (strlen (t+1) < (size_t) NETMAXMBX))) return NIL; /* invalid mailbox */ strncpy (mb->host,name,i); /* set host name */ strncpy (mb->orighost,name,i); mb->host[i] = mb->orighost[i] = '\0'; strcpy (mb->mailbox,t+1); /* set mailbox name */ if (t - v) { /* any switches or port specification? */ strncpy (t = tmp,v,j); /* copy it */ tmp[j] = '\0'; /* tie it off */ c = *t++; /* get first delimiter */ do switch (c) { /* act based upon the character */ case ':': /* port specification */ if (mb->port || !(mb->port = strtoul (t,&t,10))) return NIL; c = t ? *t++ : '\0'; /* get delimiter, advance pointer */ break; case '/': /* switch */ /* find delimiter */ if (t = strpbrk (s = t,"/:=")) { c = *t; /* remember delimiter for later */ *t++ = '\0'; /* tie off switch name */ } else c = '\0'; /* no delimiter */ if (c == '=') { /* parse switches which take arguments */ if (*t == '"') { /* quoted string? */ for (v = arg,i = 0,++t; (c = *t++) != '"';) { if (!c) return NIL; /* unterminated string */ /* quote next character */ if (c == '\\') c = *t++; if (!c) return NIL; /* can't quote NUL either */ arg[i++] = c; } c = *t++; /* remember delimiter for later */ arg[i] = '\0'; /* tie off argument */ } else { /* non-quoted argument */ if (t = strpbrk (v = t,"/:")) { c = *t; /* remember delimiter for later */ *t++ = '\0'; /* tie off switch name */ } else c = '\0'; /* no delimiter */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -