⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message-fun.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 2 页
字号:
/* TradeClient <http://tradeclient.sourceforge.net> * $Id: message-fun.c,v 1.27 2001/03/21 00:45:22 ttabner Exp $ * * Copyright (C) 1999-2000 Bynari Inc. * Copyright (C) 2001 Project TradeClient * * LGPL * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library * General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include "puma.h"/*   A whole bunch of subrutines for processing rfc822 messages, some need   cleaning up.*/char *getnline (CNSS *ss) {	char *ret;	int i=0;	while (i<ss->len) {		if (ss->str[i+ss->pos]=='\n') {			ret=(char *)calloc(i+2, sizeof(char));			memmove (ret, ss->str+ss->pos, i);			ss->pos+=i+1;			return ret;		}		i++;	}	return NULL;}char *getnl_rfc822 (CNSS *ss) {	char *ret;	int i=0;	while ((i+ss->pos)<ss->len) {		if ((ss->str[i+ss->pos]=='\n')&&(isspace(ss->str[i+ss->pos+1])==0)) {			ret=(char *)calloc(i+2, sizeof(char));			memmove (ret, ss->str+ss->pos, i+1);			ss->pos+=i+1;			return ret;		}		i++;	}	return NULL;}void putnline (CNSS *ss, char *string) {	int i=strlen (string);	if (i+ss->pos<ss->len) {		memmove (ss->str+ss->pos, string, i);		ss->pos+=i;	} else {		i=(ss->pos+i)+ss->len;		if (i>0) {			memmove (ss->str+ss->pos, string, i);			ss->pos+=i;		}	}}void destroy_hinfo (Header_Info *hinfo) {  if (hinfo) {    if (hinfo->from) free (hinfo->from);    if (hinfo->to) free (hinfo->to);    if (hinfo->cc) free (hinfo->cc);    if (hinfo->subject) free (hinfo->subject);    if (hinfo->date) free (hinfo->date);    if (hinfo->content_type) free (hinfo->content_type);    if (hinfo->content_t_e) free (hinfo->content_t_e);    if (hinfo->content_d) free (hinfo->content_d);    if (hinfo->disposition_notify) free (hinfo->disposition_notify);    if (hinfo->uidl) free (hinfo->uidl);    if (hinfo->mid) free (hinfo->mid);    if (hinfo->priority) free (hinfo->priority);    if (hinfo->replyto) free (hinfo->replyto);    if (hinfo->sensitivity) free (hinfo->sensitivity);    if (hinfo->replyby) free (hinfo->replyby);    if (hinfo->expiry) free (hinfo->expiry);    if (hinfo->keywords) free (hinfo->keywords);    free (hinfo);    hinfo = NULL ;  }  return ;}char *header_displayable (char *head) {	int len=0;	CNSS *ss=(CNSS *)calloc(1, sizeof(CNSS));	char *ret=(char *)calloc (strlen (head)+2, sizeof(char));	char *tmps;	ss->str=head;	ss->len=strlen (head);	ss->pos=0;	if ((tm_globs->flags&SHOW_ALL_HEADER)==SHOW_ALL_HEADER) {		free (ss);		free (ret);		return strdup(head);	}	if ((tm_globs->flags&SHOW_SOME_HEADER)==SHOW_SOME_HEADER) {		while ((tmps=getnl_rfc822(ss))!=NULL) {			if (strncasecmp(tmps, "from: ", 6)==0) {				memmove (ret+len, tmps, strlen (tmps));				len+=strlen (tmps);			}			if (strncasecmp(tmps, "to: ", 4)==0) {				memmove (ret+len, tmps, strlen (tmps));				len+=strlen (tmps);			}			if (strncasecmp(tmps, "cc: ", 4)==0) {				memmove (ret+len, tmps, strlen (tmps));				len+=strlen (tmps);			}			if (strncasecmp(tmps, "subject: ", 9)==0) {				memmove (ret+len, tmps, strlen (tmps));				len+=strlen (tmps);			}			if (strncasecmp(tmps, "date: ", 6)==0) {				memmove (ret+len, tmps, strlen (tmps));				len+=strlen (tmps);			}			if (tmps) { free (tmps); tmps=NULL; }		}		memmove (ret+len, "\n", 1);		len++;	} else {		free (ss);		free (ret);		return (char *)calloc(2, sizeof(char));	}	free (ss);	return ret;}Header_Info *parse_header (char *head) {	Header_Info *headinf=(Header_Info *)calloc(1, sizeof(Header_Info));	CNSS *ss=(CNSS *)calloc(1, sizeof(CNSS));	char *tmps;	char *rm;	char *tmpp;	int i;	ss->str=head;	ss->len=strlen(head);	ss->pos=0;#ifdef DMALLOC	dmalloc_verify( 0 ) ;#endif	while ((tmps=getnl_rfc822(ss))!=NULL) {		if (strncasecmp(tmps, "from: ", 6)==0) {			rm = rm_crlf(tmps);			headinf->from=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "to: ", 4)==0) {			rm = rm_crlf(tmps);			headinf->to=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "cc: ", 4)==0) {			rm = rm_crlf(tmps);			headinf->cc=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "bcc: ", 4)==0) {			rm = rm_crlf(tmps);			headinf->bcc=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "subject: ", 9)==0) {			rm = rm_crlf(tmps);			headinf->subject=cut_string (rm, ' ', 2, 1);			free (rm);			for(i=0;i<strlen(headinf->subject);i++)				if(!isprint(*(headinf->subject+i)))					*(headinf->subject+i)='\0';							}		if (strncasecmp(tmps, "date: ", 6)==0) {			rm = rm_crlf(tmps);			headinf->date=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "content-type: ", 14)==0) {			rm = rm_crlf(tmps);			headinf->content_type=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "content-transfer-encoding: ", 27)==0) {			rm = rm_crlf(tmps);			headinf->content_t_e=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "content-disposition: ", 21)==0) {			rm = rm_crlf(tmps);			headinf->content_d=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "disposition-notification-to: ", 29)==0) {			rm = rm_crlf(tmps);			headinf->disposition_notify=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "x-uidl: ", 8)==0) {			rm = rm_crlf(tmps);			headinf->uidl=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (strncasecmp(tmps, "keywords:", 9)==0) {			rm = rm_crlf(tmps);			headinf->keywords=cut_string (rm, ' ', 2, 1);			free (rm);		}                if (strncasecmp(tmps, "reply-to:", 9)==0) {                        rm = rm_crlf(tmps);                        headinf->replyto=cut_string (rm, ' ', 2, 1);                        free (rm);                }                if (strncasecmp(tmps, "sensitivity:", 12)==0) {                        rm = rm_crlf(tmps);                        headinf->sensitivity=cut_string (rm, ' ', 2, 1);                        free (rm);                }                if (strncasecmp(tmps, "reply-by:", 9)==0) {                        rm = rm_crlf(tmps);                        headinf->replyby=cut_string (rm, ' ', 2, 1);                        free (rm);                }                if (strncasecmp(tmps, "expiry-date:", 12)==0) {                        rm = rm_crlf(tmps);                        headinf->expiry=cut_string (rm, ' ', 2, 1);                        free (rm);                }                if (strncasecmp(tmps, "x-priority: ", 12)==0) {			rm = rm_crlf(tmps);			tmpp=cut_string (rm, ' ', 2, 1);			free (rm);			switch (*(tmpp+0)) {				case '1':					headinf->priority=strdup("1");					break;				case '2':					headinf->priority=strdup("2");					break;				case '3':					headinf->priority=strdup("3");					break;				case '4':					headinf->priority=strdup("4");					break;				case '5':					headinf->priority=strdup("5");					break;				default:					headinf->priority=strdup("3");			}			if (tmpp) { free (tmpp); tmpp=NULL; }                }		if (strncasecmp(tmps, "message-id: ", 12)==0) {			rm = rm_crlf(tmps);			headinf->mid=cut_string (rm, ' ', 2, 1);			free (rm);		}		if (tmps) { free (tmps); tmps=NULL; }	}	if (headinf->priority==NULL) headinf->priority=strdup("3");	if (headinf->content_type==NULL || headinf->content_type[0]=='\0') {		headinf->content_type=strdup ("text/plain");	}	free (ss);#ifdef DMALLOC	dmalloc_verify( 0 ) ;#endif	return headinf;}char *message_get_reply_quoted (Message *msg) {	int headinfo ;	char *newMsg ;	int newMsgLen ;	Attachment *att ;	Header_Info *info ;	char *email, *first, *last ;	char *body, *body_processed, *body_ret ;	const char qvar[] = "\n\nOn %s, %s wrote:\n%s" ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -