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

📄 pref-loadsave.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 3 页
字号:
	account=seek_popaccount (popid);	account->type=thetype;	tm_globs->num_accounts++;	if (name!=NULL) free (name);	if (phost!=NULL) free (phost);	if (puser!=NULL) free (puser);	if (ppasswd!=NULL) free (ppasswd);	if (shost!=NULL) free (shost);	if (suser!=NULL) free (suser);	if (folder!=NULL) free (folder);	if (real_name!=NULL) free (real_name);	if (emailaddr!=NULL) free (emailaddr);	if (replyaddr!=NULL) free (replyaddr);	if (organization!=NULL) free (organization);	if (signature!=NULL) free (signature);	if (attachdir!=NULL) free (attachdir);}void set_global_real_name (char *var) {	tm_globs->real_name=var;}void set_global_email (char *var) {	tm_globs->email=var;}void set_global_replyto (char *var) {	tm_globs->replyto=var;}void set_global_organization (char *var) {	tm_globs->organization=var;}void set_global_signature (char *var) {	tm_globs->signature=var;}void set_default_account (char *var) {	tm_globs->default_account=var;}voidset_printer (char *var){	tm_globs->printer = var;	return;}#ifdef WANTLDAPvoidset_ldap_host( char *var ) {  tm_globs -> ldap_host = var ;  return ;}voidset_ldap_port( char *var ) {  tm_globs -> ldap_port = atoi(var) ;  if( tm_globs -> ldap_port == 0 ) tm_globs -> ldap_port = 389 ;  return ;}voidset_ldap_username( char *var ) {  tm_globs -> ldap_username = var ;  return ;}/* * This one is used when we read from a file.  It fully * expects that the password is encrypted. */voidset_ldap_password( char *var ) {  if( var ) {    password_unhide( var ) ;    tm_globs -> ldap_password = var ;  }  return ;}/* * This is the plain text function that is used when the * password is update from a dialog box. */voidset_ldap_ppassword( char *var ) {  if( var ) {    tm_globs -> ldap_password = var ;  }  return ;}voidset_ldap_base( char *var ) {  tm_globs -> ldap_base = var ;  return ;}#endifvoid set_wasted_space (int *value) {	int val = *value;	tm_globs->wasted = val;	return;}void add_mime_type_char (char *text) {	char *type, *handle, *ext;	char *tmps;	int i, j, len;	if (text) {		type=cut_string (text, ';', 1, 1);		if (type) {			len=strlen (type);			for (i=0; i<len; i++) {				if (type[i]==' ') {					for (j=0; j<len-i; j++) {						type[i+j]=type[i+j+1];					}					i--;				}			}		}		tmps=cut_string (text, ';', 2, 1);		handle=cut_string (tmps, ';', 1, 1);		if (handle) {			len=strlen (handle);			if (handle[0]==' ') {				for (i=0; i<len; i++) {					handle[i]=handle[i+1];				}			}		}		if (tmps) free (tmps); tmps=NULL;		tmps=cut_string (text, ';', 2, 2);		ext=cut_string (tmps, ';', 1, 1);		if (ext) {			len=strlen (ext);			for (i=0; i<len; i++) {				if (ext[i]==' ') {					for (j=0; j<len-i; j++) {						ext[i+j]=ext[i+j+1];					}					i--;				}			}		}		if (tmps) free (tmps); tmps=NULL;		mime_type_add (type, handle, ext);		if (type) free (type);		if (handle) free (handle);		if (ext) free (ext);	}}int load_preferences (void) {	int i ;	char *rcfile=(char *)calloc(1024, sizeof(char));#ifdef WANTLDAP#ifdef WANTSSL	int kwn=21;#else	int kwn=20;#endif#else	int kwn=15;#endif	PopAccount *fseek;	keyword *kwlist[kwn];	memmove (rcfile, "$(HOME)/.tradeclient/.tradeclientrc", strlen("$(HOME)/.tradeclient/.tradeclientrc"));	kwlist[0]=set_option( (const struct keyword) {"popaccount", "char*", NULL, (void *)add_popaccount_char} );	kwlist[1]=set_option( (const struct keyword) {"mime_type", "char*", NULL, (void *)add_mime_type_char} );	kwlist[2]=set_option( (const struct keyword) {"default_account", "char*", NULL, (void *)set_default_account} );	kwlist[3]=set_option( (const struct keyword) {"global_real_name", "char*", NULL, (void *)set_global_real_name} );	kwlist[4]=set_option( (const struct keyword) {"global_email", "char*", NULL, (void *)set_global_email} );	kwlist[5]=set_option( (const struct keyword) {"global_replyto", "char*", NULL, (void *)set_global_replyto} );	kwlist[6]=set_option( (const struct keyword) {"global_organization", "char*", NULL, (void *)set_global_organization} );	kwlist[7]=set_option( (const struct keyword) {"global_signature", "char*", NULL, (void *)set_global_signature} );	kwlist[8]=set_option( (const struct keyword) {"global_flags", "int", &tm_globs->flags, NULL} );	kwlist[9]=set_option( (const struct keyword) {"global_wasted_space", "int", NULL, (void *)set_wasted_space} );	kwlist[10]=set_option( (const struct keyword) {"filter", "char*", NULL, (void *)filter_add_rule} );	kwlist[11]=set_option( (const struct keyword) {"wsize", "char*", NULL, (void *)window_sizes_set} );	kwlist[12]=set_option( (const struct keyword) {"ppos", "char*", NULL, (void *)paned_pos_set} );	kwlist[13]=set_option( (const struct keyword) {"cpos", "char*", NULL, (void *)clist_pos_set} );	kwlist[14]=set_option( (const struct keyword) {"printer", "char*", NULL, (void *)set_printer} );#ifdef WANTLDAP	kwlist[15]=set_option( (const struct keyword) {"ldap_host", "char*", NULL, (void *)set_ldap_host} );	kwlist[16]=set_option( (const struct keyword) {"ldap_username", "char*", NULL, (void *)set_ldap_username} );	kwlist[17]=set_option( (const struct keyword) {"ldap_password", "char*", NULL, (void *)set_ldap_password} );	kwlist[18]=set_option( (const struct keyword) {"ldap_port", "int", &tm_globs -> ldap_port} ) ;	kwlist[19]=set_option( (const struct keyword) {"ldap_base", "char*", NULL, (void *)set_ldap_base} );#ifdef WANTSSL	kwlist[20]=set_option( (const struct keyword) {"ldap_ssl", "int", &tm_globs -> ldap_ssl} ) ;#endif#endif	env_srch_rep (rcfile);	if (parse(rcfile, kwlist, kwn)==FALSE) {		preferences_rehash_interface ();		free (rcfile);		/* Free the memory that just got consumed */		for( i = 0 ; i < kwn ; i++ ) free (kwlist[i]);		return -1;	}	window_sizes_rehash();	paned_pos_rehash();	clist_pos_rehash();	preferences_rehash_interface ();	fseek=first_popaccount ();	/* Free the memory that just got consumed */	for( i = 0 ; i < kwn ; i++ ) free (kwlist[i]);	free (rcfile);	return 0;}char *popaccounts_to_string (PopAccount *curpop) {	int length;	char *ret;	char *name=NULL;	char *phost=NULL;	char *puser=NULL;	char *ppasswd=NULL;	char *pport=NULL;	char *shost=NULL;	char *suser=NULL;	char *sport=NULL;	char *flags=NULL;	char *timeout=NULL;	char *folder=NULL;	char *real_name=NULL;	char *emailaddr=NULL;	char *replyaddr=NULL;	char *organization=NULL;	char *signature=NULL;	char *attachdir=NULL;	char *eport=NULL;	char *enc_type=NULL;	char *compress_type=NULL;	char *auth_type=NULL;	char *msgCount = NULL ;	char *thetype=NULL;	if (curpop->name!=NULL) {		name=strdup(curpop->name);	} else {		name=(char *)calloc(2, sizeof(char));	}	if (curpop->phost!=NULL) {		phost=strdup(curpop->phost);	} else {		phost=(char *)calloc(2, sizeof(char));	}	if (curpop->puser!=NULL) {		puser=strdup(curpop->puser);	} else {		puser=(char *)calloc(2, sizeof(char));	}	if (((curpop->flags&REMBER_PASSWORD_ALWAYS)==REMBER_PASSWORD_ALWAYS)&&	    (curpop->ppasswd!=NULL)) {		ppasswd=strdup(curpop->ppasswd);		password_hide(ppasswd);	} else {		ppasswd=(char *)calloc(2, sizeof(char));	}	if (curpop->pport>0) {		pport=(char *)calloc(6, sizeof(char));		snprintf (pport, 6, "%d", curpop->pport);	} else {		pport=(char *)calloc(4, sizeof(char));		pport[0]='1';		pport[1]='1';		pport[2]='0';	}	if (curpop->shost!=NULL) {		shost=strdup(curpop->shost);	} else {		shost=(char *)calloc(2, sizeof(char));	}	if (curpop->suser!=NULL) {		suser=strdup(curpop->suser);	} else {		suser=(char *)calloc(2, sizeof(char));	}	if (curpop->sport>0) {		sport=(char *)calloc(6, sizeof(char));		snprintf (sport, 6, "%d", curpop->sport);	} else {		sport=(char *)calloc(3, sizeof(char));		sport[0]='2';		sport[1]='5';	}	if (curpop->flags>0) {		flags=(char *)calloc(6, sizeof(char));		snprintf (flags, 6, "%d", (int)curpop->flags);	} else {		flags=(char *)calloc(2, sizeof(char));		*flags='0';	}	if (curpop->timeout>=0) {		timeout=(char *)calloc(6, sizeof(char));		snprintf (timeout, 6, "%d", curpop->timeout);	} else {		timeout=(char *)calloc(3, sizeof(char));		timeout[0]='6';		timeout[1]='0';	}	if (curpop->folder!=NULL) {		folder=strdup(curpop->folder);	} else {		folder=(char *)calloc(2, sizeof(char));	}	if (curpop->real_name!=NULL) {		real_name=strdup(curpop->real_name);	} else {		real_name=(char *)calloc(2, sizeof(char));	}	if (curpop->emailaddr!=NULL) {		emailaddr=strdup(curpop->emailaddr);	} else {		emailaddr=(char *)calloc(2, sizeof(char));	}	if (curpop->replyaddr!=NULL) {		replyaddr=strdup(curpop->replyaddr);	} else {		replyaddr=(char *)calloc(2, sizeof(char));	}	if (curpop->organization!=NULL) {		organization=strdup(curpop->organization);	} else {		organization=(char *)calloc(2, sizeof(char));	}	if (curpop->signature!=NULL) {		signature=strdup(curpop->signature);	} else {		signature=(char *)calloc(2, sizeof(char));	}	if (curpop->attachdir!=NULL) {		attachdir=strdup(curpop->attachdir);	} else {		attachdir=(char *)calloc(2, sizeof(char));	}	/* Save the message counter!!! Very important for non-delete mode accounts! */	msgCount = (char *)malloc( 8*sizeof(char) ) ;	snprintf( msgCount, 8, "%07d", curpop -> popcmsg ) ;        thetype=(char *)calloc(5, sizeof(char));        snprintf (thetype, 5, "%03d", curpop->type);#if DEBUG > 6	printf ("** popaccounts_to_string () **\n");	printf ("name: %s\n",name);	printf ("phost: %s\n",phost);	printf ("puser: %s\n",puser);	printf ("ppasswd: NOT VISABLE");	printf ("pport: %s\n",pport);	printf ("shost: %s\n",shost);	printf ("suser: %s\n",suser);	printf ("sport: %s\n",sport);	printf ("flags: %s\n",flags);	printf ("folder: %s\n",folder);	printf ("real_name: %s\n",real_name);	printf ("emailaddr: %s\n",emailaddr);

⌨️ 快捷键说明

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