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

📄 pref-loadsave.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 3 页
字号:
/* TradeClient <http://tradeclient.sourceforge.net> * $Id: pref-loadsave.c,v 1.28 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 "pref-loadsave.h"#include "hashtime.h"// MEMWATCH#ifdef MEMWATCH#include "memwatch.h"#endif// DMALLOC#ifdef DMALLOC#include "dmalloc.h"#endif#ifdef write#undef write#endifchar sep='\03';#define EOW	'\04'void make_default_prefrances () {	char *home;	char *tmp;	char *sep=(char *)calloc(2, sizeof(char));	char *tmps;	unsigned long tmpflags;	int fd;	sep[0]=EOW;	home=(char *)calloc(1024, sizeof(char));	snprintf (home, 1024, "$(HOME)");	env_srch_rep(home);	tmp=(char *)calloc(1024, sizeof(char));	snprintf (tmp, 1024, "%s/.tradeclient", home);	mkdir (tmp, S_IREAD | S_IWRITE | S_IEXEC);	snprintf (tmp, 1024, "%s/.tradeclient/Addressbooks", home);	mkdir (tmp, S_IREAD | S_IWRITE | S_IEXEC);	snprintf (tmp, 1024, "%s/.tradeclient/Inbox", home);	if (access (tmp, R_OK)) {		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		close (fd);		snprintf (tmp, 1024, "%s/.tradeclient/.Inbox.smi", home);		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		write (fd, sep, 1);		tmpflags=CAN_STORE_NEW_MAIL|CAN_HAVE_SUBFOLDERS;		tmps=disassemble_long (tmpflags);		write (fd, tmps, 4);		free (tmps);		close (fd);	}	snprintf (tmp, 1024, "%s/.tradeclient/Outbox", home);	if (access (tmp, R_OK)) {		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		close (fd);		snprintf (tmp, 1024, "%s/.tradeclient/.Outbox.smi", home);		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		write (fd, sep, 1);		tmpflags=CAN_HAVE_SUBFOLDERS;		tmps=disassemble_long (tmpflags);		write (fd, tmps, 4);		free (tmps);		close (fd);	}	snprintf (tmp, 1024, "%s/.tradeclient/Sent-Items", home);	if (access (tmp, R_OK)) {		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		close (fd);		snprintf (tmp, 1024, "%s/.tradeclient/.Sent-Items.smi", home);		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		write (fd, sep, 1);		tmpflags=CAN_HAVE_SUBFOLDERS;		tmps=disassemble_long (tmpflags);		write (fd, tmps, 4);		free (tmps);		close (fd);	}	snprintf (tmp, 1024, "%s/.tradeclient/Trash", home);	if (access (tmp, R_OK)) {		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		close (fd);		snprintf (tmp, 1024, "%s/.tradeclient/.Trash.smi", home);		fd=open (tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);		write (fd, sep, 1);		tmpflags=CAN_HAVE_SUBFOLDERS;		tmps=disassemble_long (tmpflags);		write (fd, tmps, 4);		free (tmps);		close (fd);	}	free (tmp);	free (home);	free (sep);}void password_hide (char *pw) {	int i=0, lenght=0;#if DEBUG > 6	char *bits;#endif	if (pw!=NULL) {		lenght=strlen(pw);#if DEBUG > 6		printf ("before hide pw=%s\n", pw);#endif		for (i=0; i<lenght; i++) {#if DEBUG > 6			bits=bits8(pw[i]);			printf ("%d: %s:%d\t<<\t", i, bits, (unsigned int)pw[i]);			free (bits);#endif			if (pw[i]!='\0') {				pw[i]=(char)((pw[i])<<1);			}#if DEBUG > 6			bits=bits8(pw[i]);			printf ("%s:%d\n", bits, (unsigned int)pw[i]);			free (bits);#endif		}#if DEBUG > 6		printf ("after hide pw=%s\n", pw);#endif	}}void password_unhide (char *pw) {	int i=0, lenght=0;#if DEBUG > 6	char *bits;#endif	if (pw!=NULL) {		lenght=strlen(pw);#if DEBUG > 6		printf ("before unhide pw=%s\n", pw);#endif		for (i=0; i<lenght; i++) {#if DEBUG > 6			bits=bits8(pw[i]);			printf ("%d: %s:%d\t>>\t", i, bits, (unsigned int)pw[i]);			free (bits);#endif			if (pw[i]!='\0') {				pw[i]=(char)((pw[i])>>1)&0x7f;			}#if DEBUG > 6			bits=bits8(pw[i]);			printf ("%s:%d\n", bits, (unsigned int)pw[i]);			free (bits);#endif		}#if DEBUG > 6		printf ("after unhide pw=%s\n", pw);#endif	}}void add_popaccount_char (char *text) {	char *name=NULL;	char *phost=NULL;	char *puser=NULL;	char *ppasswd=NULL;	int pport=-1;	char *shost=NULL;	char *suser=NULL;	int sport=-1;	unsigned long flags=0;	int timeout=60;	char *folder=NULL;	char *real_name=NULL;	char *emailaddr=NULL;	char *replyaddr=NULL;	char *organization=NULL;	char *signature=NULL;	char *attachdir;	char *tmps=NULL, *tmpsi=NULL;	int popid;	int lastMsgCount ;	int thetype;	PopAccount *account;	#if DEBUG > 4	printf ("Adding an account from global prefs file\n");#endif	name=cut_string(text, sep, 1, 1);	tmps=cut_string(text, sep, 2, 1);	phost=cut_string(tmps, sep, 1, 1);	if (tmps) free (tmps);		tmps=cut_string(text, sep, 2, 2);	puser=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 3);	ppasswd=cut_string(tmps, sep, 1, 1);	password_unhide(ppasswd);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 4);	tmpsi=cut_string (tmps, sep, 1, 1);	if (tmpsi!=NULL) {		pport=atoi(tmpsi);	}	else {		pport=110;	}	if (tmps) free(tmps);	if (tmpsi) free(tmpsi);	tmps=cut_string(text, sep, 2, 5);	shost=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 6);	suser=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 7);	tmpsi=cut_string (tmps, sep, 1, 1);	if (tmpsi!=NULL) {		sport=atoi(tmpsi);	} else {		sport=25;	}	if (tmpsi) free (tmpsi);	if (tmps) free(tmps);		tmps=cut_string(text, sep, 2, 8);	tmpsi=cut_string (tmps, sep, 1, 1);	if (tmps!=NULL) {		flags=atol(tmpsi);	} else {		flags=0;	}	if (tmpsi) free (tmpsi);	if (tmps) free (tmps);	tmps=cut_string(text, sep, 2, 9);	tmpsi=cut_string (tmps, sep, 1, 1);	if (*tmps!='\0') {		timeout=atoi(tmpsi);	} else {		timeout=-1;	}	if (tmpsi) free (tmpsi);	if (tmps) free (tmps);	tmps=cut_string(text, sep, 2, 10);	folder=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 11);	real_name=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 12);	emailaddr=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 13);	replyaddr=cut_string(tmps, sep, 1, 1);	if (tmps) free(tmps);	tmps=cut_string(text, sep, 2, 14);	organization=cut_string(tmps, sep, 1, 1);	if (tmps) free (tmps);	tmps=cut_string(text, sep, 2, 15);	signature=cut_string(tmps, sep, 1, 1);	if (tmps) free (tmps);	tmps=cut_string( text, sep, 2, 16 ) ;	attachdir=cut_string(tmps, sep, 1, 1);	if( tmps ) free( tmps ) ;	tmps=cut_string(text, sep, 2, 17);	tmpsi=cut_string (tmps, sep, 1, 1);	if (tmpsi!=NULL) {	  lastMsgCount = atoi( tmpsi ) ;	} else {	  lastMsgCount = 0 ;	}	if (tmpsi) free (tmpsi);	if (tmps) free(tmps);		tmps=cut_string (text, sep, 2, 18);	tmpsi=cut_string (tmps, sep, 1, 1);	if (tmpsi != NULL) {		thetype = atoi (tmpsi);	} else {		thetype = POP3;	}	if (tmpsi) free (tmpsi);	if (tmps) free(tmps);	if (name[0]=='\0') {		free (name);		name=NULL;	}	if (phost[0]=='\0') {		free (phost);		phost=NULL;	}	if (puser[0]=='\0') {		free (puser);		puser=NULL;	}	if (ppasswd[0]=='\0') {		free (ppasswd);		ppasswd=NULL;	}	if (shost[0]=='\0') {		free (shost);		shost=NULL;	}	if (suser[0]=='\0') {		free (suser);		suser=NULL;	}	if (folder[0]=='\0') {		free (folder);		folder=NULL;	}	if (real_name[0]=='\0') {		free (real_name);		real_name=NULL;	}	if (emailaddr[0]=='\0') {		free (emailaddr);		emailaddr=NULL;	}	if (replyaddr[0]=='\0') {		free (replyaddr);		replyaddr=NULL;	}	if (organization[0]=='\0') {		free (organization);		organization=NULL;	}	if (signature[0]=='\0') {		free (signature);		signature=NULL;	}		if (attachdir[0]=='\0') {		free (attachdir);		attachdir=NULL;	}	popid=new_popaccount (name, phost, puser, ppasswd, pport, shost, suser,	                      sport, flags, timeout, folder, real_name, emailaddr,	                      replyaddr, organization, signature, attachdir, lastMsgCount, NULL);

⌨️ 快捷键说明

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