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

📄 main.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 2 页
字号:
/* TradeClient <http://tradeclient.sourceforge.net> * $Id: main.c,v 1.47 2001/03/20 22:19:33 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"#include "ipc.h"#ifdef WANTLDAP#include "tcldap.h"#endifTradeClientGlobs *tm_globs=NULL;Folders *folders=NULL;time_t works_before () {	struct tm time;	time.tm_sec=0;	time.tm_min=0;	time.tm_hour=0;	time.tm_mday=0;	time.tm_mon=2;	time.tm_year=100;	time.tm_wday=0;	time.tm_yday=0;	time.tm_isdst=-1;	return mktime (&time);}char *stringdup (char *str) {	char *ret=NULL;	unsigned long len=0;	if (str) {		len=strlen(str);		ret=(char *)calloc(len+1, sizeof(char));		memmove (ret, str, len);	}	return ret;}char *unique_name (unsigned int seed, int length) {	char *ret=(char *)calloc(length+2, sizeof(char));	int i=0;	if (!length) {		free (ret);		return NULL;	}	srandom (seed);	for (i=0; i<length; i++) {		ret[i]=gethex ((int)(random()%16));	}	return ret;}char *bits32 (unsigned long x) {	char *ret=(char *)calloc (40, sizeof(char));	ret[0 ]=((x&0x80000000)>>31) == 1 ? '1' : '0';	ret[1 ]=((x&0x40000000)>>30) == 1 ? '1' : '0';	ret[2 ]=((x&0x20000000)>>28) == 1 ? '1' : '0';	ret[3 ]=((x&0x10000000)>>28) == 1 ? '1' : '0';	ret[4 ]=((x&0x08000000)>>27) == 1 ? '1' : '0';	ret[5 ]=((x&0x04000000)>>26) == 1 ? '1' : '0';	ret[6 ]=((x&0x02000000)>>25) == 1 ? '1' : '0';	ret[7 ]=((x&0x01000000)>>24) == 1 ? '1' : '0';	ret[8 ]=((x&0x00800000)>>23) == 1 ? '1' : '0';	ret[9 ]=((x&0x00400000)>>22) == 1 ? '1' : '0';	ret[10]=((x&0x00200000)>>21) == 1 ? '1' : '0';	ret[11]=((x&0x00100000)>>20) == 1 ? '1' : '0';	ret[12]=((x&0x00080000)>>19) == 1 ? '1' : '0';	ret[13]=((x&0x00040000)>>18) == 1 ? '1' : '0';	ret[14]=((x&0x00020000)>>17) == 1 ? '1' : '0';	ret[15]=((x&0x00010000)>>16) == 1 ? '1' : '0';	ret[16]=((x&0x00008000)>>15) == 1 ? '1' : '0';	ret[17]=((x&0x00004000)>>14) == 1 ? '1' : '0';	ret[18]=((x&0x00002000)>>13) == 1 ? '1' : '0';	ret[19]=((x&0x00001000)>>12) == 1 ? '1' : '0';	ret[20]=((x&0x00000800)>>11) == 1 ? '1' : '0';	ret[21]=((x&0x00000400)>>10) == 1 ? '1' : '0';	ret[22]=((x&0x00000200)>>9 ) == 1 ? '1' : '0';	ret[23]=((x&0x00000100)>>8 ) == 1 ? '1' : '0';	ret[24]=((x&0x00000080)>>7 ) == 1 ? '1' : '0';	ret[25]=((x&0x00000040)>>6 ) == 1 ? '1' : '0';	ret[26]=((x&0x00000020)>>5 ) == 1 ? '1' : '0';	ret[27]=((x&0x00000010)>>4 ) == 1 ? '1' : '0';	ret[28]=((x&0x00000008)>>3 ) == 1 ? '1' : '0';	ret[29]=((x&0x00000004)>>2 ) == 1 ? '1' : '0';	ret[30]=((x&0x00000002)>>1 ) == 1 ? '1' : '0';	ret[31]=((x&0x00000001)    ) == 1 ? '1' : '0';	return ret;}char *bits8 (int x) {	char *ret=(char *)calloc (20, sizeof(char));	ret[0 ]=((x&0x80)>>7) == 1 ? '1' : '0';	ret[1 ]=((x&0x40)>>6) == 1 ? '1' : '0';	ret[2 ]=((x&0x20)>>5) == 1 ? '1' : '0';	ret[3 ]=((x&0x10)>>4) == 1 ? '1' : '0';	ret[4 ]=((x&0x08)>>3) == 1 ? '1' : '0';	ret[5 ]=((x&0x04)>>2) == 1 ? '1' : '0';	ret[6 ]=((x&0x02)>>1) == 1 ? '1' : '0';	ret[7 ]=((x&0x01)   ) == 1 ? '1' : '0';	return ret;}int count_delimiters (char *stream, char delim) {	char *tmps=stream;	int num=0;	if (tmps) {		while ( (tmps=strchr (tmps, (int)delim))!=NULL ) {			tmps++;			num++;		}	}	return num;}char *remove_charecter (char *stream, char delim) {	int num;	char *ret=NULL;	int rpos=0, spos=0, len=0;	if (stream) {		num=count_delimiters (stream, delim);		len=strlen (stream);		ret=(char *)calloc (len-num+2, sizeof(char));		if (num>0) {			for (spos=0;spos<len;spos++) {				if (stream[spos]!=delim) {					ret[rpos]=stream[spos];					rpos++;				}				}		} else {			ret=strdup (stream);		}	}	return ret;}char *rm_cr (char *string) {	char *ret=NULL, *tmps=NULL;	unsigned long length=0, i=0;	if (string) {		if (string[0]=='\0') {			ret=(char *)calloc (2, sizeof(char));			return ret;		}		length=strlen (string);		ret=(char *)calloc (length+2, sizeof(char));		tmps=ret;		for (i=0;i<length;i++) {			if (string[i]!='\r') {				*ret=string[i];				ret++;			}		}	}	ret=tmps;	return ret;}/* Modified to removed any leading spaces too */char *rm_crlf (char *string) {	char *ret=NULL, *tmps=NULL; 	unsigned long length=0, i=0;	if (string) {		if (string[0]=='\0') {			ret=(char *)calloc (2, sizeof(char));			return ret;		}		length = strlen( string ) ;		ret=(char *)calloc(length+2, sizeof(char));		tmps=ret;		for (i=0; i<length; i++) {			if ((string[i]!='\r')&&(string[i]!='\n')) {				*ret=string[i];				ret++;			}		}	}	ret=tmps;	return ret;}char *add_cr (char *string) {	char *ret=NULL; char *tmps1=NULL; char *tmps2=NULL;	unsigned long length=0, i=0;	if (string) {		if (string[0]=='\0') {			ret=(char *)calloc (2, sizeof(char));			return ret;		}		length=strlen (string);		ret=(char *)calloc (length*2, sizeof(char));		tmps1=ret;		for (i=0; i<length; i++) {			if (i>0) {				if ((string[i]=='\n') && (string[i-1]!='\r')) {					*ret='\r';					ret++;				}			} else {				if (string[i]=='\n') {					*ret='\r';					ret++;				}			}			*ret=string[i];			ret++;		}		tmps2=strdup (tmps1);		free (tmps1);	}	ret=tmps2;	return ret;}char *insert_reply_indicator (char *body) {	int len=strlen (body), i;	char *tmpret=(char *)calloc( len*2 + 2, sizeof(char)), *ret;	char *tmpretb=tmpret;	*tmpret='>';	tmpret++;	for (i=0; i<len; i++) {		*tmpret=body[i];		if (*tmpret=='\n') {			tmpret++;			*tmpret='>';		}		tmpret++;	}	ret=(char *)calloc (strlen(tmpretb)+2, sizeof(char));	memmove (ret, tmpretb, strlen(tmpretb));	free (tmpretb);	return ret;}intstrip_lead_spaces( char *string ){  int i ;  int length ;  /* This clips any leading spaces */  length = strlen( string ) ;  i = 0 ;  while( (i < length) && string[i] == ' ' ) i++ ;  if( i ) {    memcpy( string, &string[i], length - i ) ;    string[length-i] = 0x00 ;  }  return i ;}char *cut_string(char *string, char delimiter, int side, int occurrence) {	char *ret;	char *errret;	int length ;	int charpos=0, i=0, j=0;	if (!string) {			errret=(char *)calloc (2, sizeof(char));			return errret;	}	length = strlen( string ) ;	for (j=0; j<occurrence; j++) {		while (((unsigned)i<length) && (string[i]!=delimiter)) {			i++;		}		i++;		if ((unsigned)i>=length+1) {			errret=(char *)calloc (2, sizeof(char));			return errret;		}	}	i--;	charpos=i;	if (side<=1) {		ret=(char *)calloc(i+2, sizeof(char));		for (i=0; i<charpos; i++) {			ret[i]=string[i];		}	} else {		ret=(char *)calloc((length-i)+2, sizeof(char));		for (i=charpos+1; (unsigned)i<=length; i++) {			ret[i-charpos-1]=string[i];		}	}	return ret;}//static char valids[]={ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]-_,.{}+=@#$%^&*()" };char *validate_file_string (char *data) {//	int count, vpos, cpos;	int spos, len=strlen (data);//	char *returnable=(char *)calloc (1, len);	for (spos=0;spos<len;spos++) {//		for (vpos=0;vpos<strlen (valids)	}	return NULL;}void puma_error ( char *fmt, ...) {/*	GtkWidget *window;	va_list ap;	char outstr[1024];	va_start (ap, fmt);	vsnprintf (outstr, 1024, fmt, ap);	va_end (ap);	window=create_ewmd_dialog (ERROR_DIALOG, "Fatal Error Occured", outstr);	gtk_widget_show (window);*/}void puma_warning (int level, char *fmt, ...) {#ifdef DEBUG	if ((level==0) || (level<=DEBUG)) {#else	if (level==0) {#endif		va_list ap;		va_start (ap, fmt);		insert_warning (fmt, ap);	}}void puma_message (int level, char *fmt, ...) {#ifdef DEBUG	if ((level==0) || (level<=DEBUG)) {#else	if (level==0) {#endif		va_list ap;		va_start (ap, fmt);		insert_message (fmt, ap);	}}void puma_debug (int level, char *fmt, ...) {#ifdef DEBUG	if ((level==0) || (level<=DEBUG)) {#else	if (level==0) {#endif		va_list ap;		va_start (ap, fmt);		insert_debug (fmt, ap);	}}void startup (int argc, char **argv) {	GtkWidget *clist;	int i;	gtk_init (&argc, &argv);/*	add_pixmap_directory ("./pics");	add_pixmap_directory ("/usr/local/share/puma/pics"); */	tm_globs=(TradeClientGlobs *)calloc (1, sizeof(TradeClientGlobs));	for (i=0;i<20;i++) tm_globs->new_messages[i]=NULL;	tm_globs->status=create_status_window ();	tm_globs->main_window=create_main_window ();		tm_globs->acct_selected=-1;	tm_globs->num_accounts=0;	tm_globs->newserver_type=NULL;	tm_globs->visable=NULL;	tm_globs->message_popup=NULL;	tm_globs->folder_popup=create_folder_popup ();	tm_globs->create_folder=create_create_folder ();	tm_globs->msg_row=-1;	clist=lookup_widget (tm_globs->main_window, "message_clist");	tm_globs->read_odd=gtk_style_copy (clist->style);	tm_globs->read_even=gtk_style_copy (clist->style);	tm_globs->unread_odd=gtk_style_copy (clist->style);

⌨️ 快捷键说明

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