📄 pref-loadsave.c
字号:
printf ("replyaddr: %s\n",replyaddr); printf ("organization: %s\n",organization); printf ("signature: %s\n",signature); printf ("attachdir: %s\n",attachdir); printf ("msgCount: %s\n",msgCount); printf ("type: %s\n",thetype); printf ("******************************\n");#endif /* I don't think the exta junk is needed anymore!!! */ if (curpop->extra) { length=strlen(name)+strlen(phost)+strlen(puser)+strlen(ppasswd)+ strlen(pport)+strlen(shost)+strlen(suser)+strlen(sport)+ strlen(flags)+strlen(timeout)+strlen(folder)+strlen(real_name)+ strlen(emailaddr)+strlen(replyaddr)+strlen(organization)+ strlen(signature)+strlen(attachdir)+strlen(eport)+strlen(enc_type)+ strlen(compress_type)+strlen(auth_type)+strlen(msgCount)+25; ret=(char *)calloc(length, sizeof(char)); snprintf (ret, length, "\"%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03\"", name,phost,puser,ppasswd,pport,shost,suser,sport,flags,timeout, folder,real_name,emailaddr,replyaddr,organization,signature, attachdir,msgCount,eport,enc_type,compress_type,auth_type); } else { /* dont try to understand, just accept */ length=strlen(name)+strlen(phost)+strlen(puser)+strlen(ppasswd)+ strlen(pport)+strlen(shost)+strlen(suser)+strlen(sport)+ strlen(flags)+strlen(timeout)+strlen(folder)+strlen(real_name)+ strlen(emailaddr)+strlen(replyaddr)+strlen(organization)+ strlen(signature)+strlen(attachdir)+strlen(msgCount)+strlen(thetype)+22 ; ret=(char *)calloc(length, sizeof(char)); snprintf (ret, length, "\"%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03%s\03\"", name,phost,puser,ppasswd,pport,shost,suser,sport,flags,timeout, folder,real_name,emailaddr,replyaddr,organization,signature,attachdir,msgCount,thetype); } free (name); free (phost); free (puser); free (ppasswd); free (pport); free (shost); free (suser); free (sport); free (flags); free (folder); free (real_name); free (emailaddr); free (replyaddr); free (organization); free (signature); free (timeout); free (attachdir); free( msgCount ) ; free (thetype); if (eport) free (eport); if (enc_type) free (enc_type); if (compress_type) free (compress_type); if (auth_type) free (auth_type); return ret;}int save_preferences () { PopAccount *poplist=first_popaccount (); Llist *mimetypelist=mime_type_first (); MimeType *mtype; // FilterRule *rseek; GList *seek; int fd, len; char buffer[256]; char *dir=(char *)calloc(1024, sizeof(char)); char *file1=(char *)calloc(1024, sizeof(char)); char *file2=(char *)calloc(1024, sizeof(char)); char *tmpstr1; char *tmpstr2; snprintf (dir, 1024, "$(HOME)/.tradeclient"); env_srch_rep(dir); mkdir(dir, S_IREAD | S_IWRITE | S_IEXEC); free (dir); snprintf (file1,1024, "$(HOME)/.tradeclient/.tradeclientrc~"); snprintf (file2,1024, "$(HOME)/.tradeclient/.tradeclientrc"); env_srch_rep(file1); env_srch_rep(file2); fd=open (file1, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); tmpstr1=(char *)calloc(1024, sizeof(char)); /* Might need this one day for backward compatibility */ snprintf (tmpstr1, 1024, "# Generated by TradeClient %s, DO NOT EDIT.\n", VERSION ); write (fd, tmpstr1, strlen (tmpstr1)); free (tmpstr1); popaccounts_dump_em_all ("Top of save preferences"); while (poplist) { tmpstr1=popaccounts_to_string (poplist); tmpstr2=(char *)calloc(strlen(tmpstr1)+13, sizeof(char)); snprintf (tmpstr2, strlen(tmpstr1)+13,"popaccount=%s\n",tmpstr1); write (fd, tmpstr2, strlen(tmpstr2)); free (tmpstr1); free (tmpstr2); poplist=(PopAccount *)poplist->next; } popaccounts_dump_em_all ("Bottom of save preferences"); write (fd, "\n", 1); for (seek=filter_first ();seek;seek=seek->next) { write (fd, "filter=\"", 8); tmpstr1=filter_to_char (seek->data); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); write (fd, "\"\n", 2); } write (fd, "\n", 1); while (mimetypelist) { mtype=((MimeType *)mimetypelist->data); write (fd, "mime_type=\"", 11); if (mtype->type) write (fd, mtype->type, strlen(mtype->type)); write (fd, "; ", 2); if (mtype->handle) write (fd, mtype->handle, strlen(mtype->handle)); write (fd, "; ", 2); if (mtype->ext) write (fd, mtype->ext, strlen(mtype->ext)); write (fd, ";\"\n", 3); mimetypelist=mimetypelist->next; } write (fd, "\n", 1); if (tm_globs->default_account) { len=strlen(tm_globs->default_account)+30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"default_account=\"%s\"\n",tm_globs->default_account); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } if (tm_globs->real_name) { len=strlen(tm_globs->real_name)+30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_real_name=\"%s\"\n",tm_globs->real_name); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } if (tm_globs->email) { len=strlen(tm_globs->email)+30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_email=\"%s\"\n",tm_globs->email); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } if (tm_globs->replyto) { len=strlen(tm_globs->replyto)+30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_replyto=\"%s\"\n",tm_globs->replyto); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } if (tm_globs->organization) { len=strlen(tm_globs->organization)+30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_organization=\"%s\"\n",tm_globs->organization); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } if (tm_globs->signature) { len=strlen(tm_globs->signature)+30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_signature=\"%s\"\n",tm_globs->signature); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } len=30; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_flags=%d\n",(int)tm_globs->flags); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); len=40; tmpstr1=(char *)calloc(len, sizeof(char)); snprintf (tmpstr1, len,"global_wasted_space=%d\n",(int)tm_globs->wasted); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); if (tm_globs->printer) { len=strlen(tm_globs -> printer) ; if( len ) { len += 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)) ; snprintf (tmpstr1, len, "printer=\"%s\"\n", tm_globs -> printer ) ; write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } }#ifdef WANTLDAP if( tm_globs -> ldap_host ) { len=strlen(tm_globs -> ldap_host) ; if( len ) { len += 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)) ; snprintf (tmpstr1, len, "ldap_host=\"%s\"\n", tm_globs -> ldap_host ) ; write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } } if( tm_globs -> ldap_username ) { len=strlen(tm_globs -> ldap_username) ; if( len ) { len += 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)) ; snprintf (tmpstr1, len, "ldap_username=\"%s\"\n", tm_globs -> ldap_username ) ; write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } } if( tm_globs -> ldap_password ) { len=strlen(tm_globs->ldap_password) ; if( len ) { len += 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)); tmpstr2 = strdup( tm_globs -> ldap_password ) ; password_hide( tmpstr2 ) ; snprintf (tmpstr1, len, "ldap_password=\"%s\"\n", tmpstr2 ) ; write (fd, tmpstr1, strlen(tmpstr1)); free( tmpstr1 ) ; free( tmpstr2 ) ; } } /* We'll allow the port to ALWAYS be written out. No problem. */ if( tm_globs -> ldap_port ) { len=4 + 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)); snprintf (tmpstr1, len, "ldap_port=\"%d\"\n", tm_globs -> ldap_port ) ; write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); }#ifdef WANTSSL if( tm_globs -> ldap_ssl ) { len=4 + 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)); snprintf (tmpstr1, len, "ldap_ssl=\"%d\"\n", tm_globs -> ldap_ssl ) ; write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); }#endif if( tm_globs -> ldap_base ) { len=strlen(tm_globs->ldap_base) ; if( len ) { len += 4096 ; tmpstr1=(char *)malloc(len*sizeof(char)); snprintf (tmpstr1, len, "ldap_base=\"%s\"\n", tm_globs -> ldap_base ) ; write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); } }#endif snprintf(buffer, sizeof(buffer), "1 %d %d %d %d %d %d %d %d %d %d", tm_globs->wsize.main_window.x, tm_globs->wsize.main_window.y, tm_globs->wsize.new_message_window.x, tm_globs->wsize.new_message_window.y, tm_globs->wsize.message_window.x, tm_globs->wsize.message_window.y, tm_globs->wsize.calendar_window.x, tm_globs->wsize.calendar_window.y, tm_globs->wsize.msearch_window.x, tm_globs->wsize.msearch_window.y); len=strlen(buffer); len += 4096; tmpstr1=(char *)malloc(len*sizeof(char)); snprintf (tmpstr1, len, "wsize=\"%s\"\n", buffer); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); snprintf(buffer, sizeof(buffer), "1 %d %d %d %d", tm_globs->ppos.mnw_hp1, tm_globs->ppos.mnw_vp1, tm_globs->ppos.mnw_vp2, tm_globs->ppos.msgw_vp1); len=strlen(buffer); len += 4096; tmpstr1=(char *)malloc(len*sizeof(char)); snprintf (tmpstr1, len, "ppos=\"%s\"\n", buffer); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); snprintf(buffer, sizeof(buffer), "1 %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", tm_globs->cpos.mw_fl[0], tm_globs->cpos.mw_fl[1], tm_globs->cpos.mw_fl[2], tm_globs->cpos.mw_msg[0], tm_globs->cpos.mw_msg[1], tm_globs->cpos.mw_msg[2], tm_globs->cpos.mw_msg[3], tm_globs->cpos.mw_msg[4], tm_globs->cpos.mw_msg[5], tm_globs->cpos.mw_mime[0], tm_globs->cpos.mw_mime[1], tm_globs->cpos.mw_mime[2], tm_globs->cpos.msgw[0], tm_globs->cpos.msgw[1], tm_globs->cpos.msgw[2], tm_globs->cpos.nmsgw[0], tm_globs->cpos.nmsgw[1], tm_globs->cpos.nmsgw[2], tm_globs->cpos.ab[0], tm_globs->cpos.ab[1], tm_globs->cpos.msw[0], tm_globs->cpos.msw[1], tm_globs->cpos.msw[2], tm_globs->cpos.msw[3], tm_globs->cpos.msw[4], tm_globs->cpos.msw[5]); len=strlen(buffer); len += 4096; tmpstr1=(char *)malloc(len*sizeof(char)); snprintf (tmpstr1, len, "cpos=\"%s\"\n", buffer); write (fd, tmpstr1, strlen(tmpstr1)); free (tmpstr1); close (fd); unlink (file2); rename (file1,file2); free (file1); free (file2); return 0;}intsave_hashkey( const unsigned char *hash ) { int fd ; int ret ; char tmp[4096] ; char hashString[13] ; unsigned char rawHash[6] ; /* Make our resource directory if needed */ snprintf( tmp, 4095, "$(HOME)/.tradeclient" ) ; env_srch_rep( tmp ) ; mkdir( tmp, S_IREAD | S_IWRITE | S_IEXEC ) ; strncat( tmp, ".tradehashkey", 4095 ) ; fd = open( tmp, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR ) ; snprintf( tmp, 4095, "# Generated by TradeClient %s, DO NOT EDIT.\n" \ "# Editing this file will invalidate all account passwords.\n\n", VERSION ) ; ret = write( fd, tmp, strlen(tmp) ) ; /* If we don't have a hash, create one first! */ if( hash == (unsigned char *)NULL ) { hashTime( rawHash ) ; hashTimeString( hashString, rawHash ) ; printf( "Creating new cipher key. Deleting or changing this key will invalidate\n" "all account passwords. Don't do it!\n" ) ; } else { hashTimeString( hashString, hash ) ; } ret = write( fd, hashString, strlen(hashString) ) ; close( fd ) ; return ret ;}void delete_message (GtkWidget *widget, gpointer data) { destroy_message (tm_globs->msg_selected);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -