📄 compos~1.cpp
字号:
if(*printed) printf(", "); else *printed=-1; } if(addr[x].name != NULL) { if( strchr(addr[x].name,',') != NULL ) printf(""%s"",addr[x].name); else printf("%s",addr[x].name); if( (((addr[x].status)&0x01)==0) && (addr[x].email != NULL) ) printf(" <%s>",addr[x].email); } else { if(addr[x].email != NULL) printf("%s",addr[x].email); } } } return(0);}///////////////////////////////////////////////////////////////////int subject_line_value(mail_header* mail_h){ if(mail_h == NULL) return(0); if(mail_h->subject == NULL) return(0); if(mail_action != reply_message && mail_action != reply_all_message && mail_action != forward_message ) return(0); printf(" VALUE=\""); if(mail_action == reply_message || mail_action == reply_all_message) { if( strncasecmp(mail_h->subject,"Re:",sizeof("Re:")-1) != 0) printf("Re: "); } else if(mail_action == forward_message) { if( strncasecmp(mail_h->subject,"Fw:",sizeof("Fw:")-1) != 0) printf("Fw: "); } printf("%s\"",mail_h->subject); return(0);}///////////////////////////////////////////////////////////////////status_type body_value(mail_header* mail_h, FILE* user_mail_file){ struct tm* time_data=NULL; char time_string[50]; int x=0; int printed=0; status_type status=st_done; if(mail_h == NULL) return(st_done); if(mail_action != reply_message && mail_action != reply_all_message && mail_action != forward_message) return(st_done); for(x=0;x<50;x++) time_string[x]='\0'; if(mail_h->from != NULL) mail_h->from[0].status=0; if(mail_h->to != NULL) for(x=0; mail_h->to[x].name || mail_h->to[x].email; x++) mail_h->to[x].status=0; if(mail_h->cc != NULL) for(x=0; mail_h->cc[x].name || mail_h->cc[x].email; x++) mail_h->cc[x].status=0; printf("\n\n\n" "----- Original Message -----\n"); if(mail_h->date_received != 0) { time_data=localtime(&(mail_h->date_received)); strftime(time_string,50,"%a %B %d, %Y %I:%M %p",time_data); printf("Date: %s\n",time_string); } if(mail_h->from != NULL) { printf("From: "); disp_addr(mail_h->from,&printed); printf("\n"); } printed=0; if(mail_h->to != NULL) { printf("To: "); disp_addr(mail_h->to,&printed); printf("\n"); } printed=0; if(mail_h->cc != NULL) { printf("cc: "); disp_addr(mail_h->cc,&printed); printf("\n"); } if(mail_h->subject != NULL) printf("Subject: %s\n",mail_h->subject); printf("\n"); status=refw_body_send(user_mail_file,mail_h); return(status);}///////////////////////////////////////////////////////////////////status_type refw_body_send(FILE* user_mail_file, mail_header* mail_h){ mail_header* next_head_multi=NULL; mail_header* next_head_alt=NULL; status_type status=st_pending; if(user_mail_file == NULL || mail_h == NULL) return(st_error); if(mail_h->cont_type == ct_text_plain || mail_h->cont_type == ct_none) { send_body(user_mail_file, NULL, mail_h->cont_type_enc); return(st_done); } else if(mail_h->cont_type == ct_multipart_alternative) { status=find_next_border(user_mail_file,mail_h->cont_boundary); if(status == st_error || status == st_done) return(status); next_head_alt=fill_mail_h_struct(user_mail_file,0); if(next_head_alt == NULL) return(st_error); if(next_head_alt->cont_type == ct_text_plain) { send_body(user_mail_file, mail_h->cont_boundary, next_head_alt->cont_type_enc); free_mail_headers(next_head_alt); return(st_done); } else { free_mail_headers(next_head_alt); return(st_pending); } } else if(mail_h->cont_type == ct_multipart_mixed) { status=find_next_border(user_mail_file,mail_h->cont_boundary); if(status == st_error || status == st_done) return(status); next_head_multi=fill_mail_h_struct(user_mail_file,0); if(next_head_multi == NULL) return(st_error); if(next_head_multi->cont_type == ct_text_plain || next_head_multi->cont_type == ct_none) { status=send_body(user_mail_file, mail_h->cont_boundary, next_head_multi->cont_type_enc); free_mail_headers(next_head_multi); return(status); } else if(next_head_multi->cont_type == ct_multipart_alternative) { status=find_next_border(user_mail_file, next_head_multi->cont_boundary); if(status == st_error || status == st_done) { free_mail_headers(next_head_multi); if(status != st_error) status=find_next_border(user_mail_file,mail_h->cont_boundary); return(status); } next_head_alt=fill_mail_h_struct(user_mail_file,0); if(next_head_alt == NULL) { free_mail_headers(next_head_multi); return(st_error); } if(next_head_alt->cont_type == ct_text_plain || next_head_alt->cont_type == ct_none) { status=send_body(user_mail_file, next_head_multi->cont_boundary, next_head_alt->cont_type_enc); status=find_next_border(user_mail_file,mail_h->cont_boundary); free_mail_headers(next_head_alt); free_mail_headers(next_head_multi); return(status); } else { free_mail_headers(next_head_multi); free_mail_headers(next_head_alt); return(st_pending); } } else { free_mail_headers(next_head_multi); return(st_pending); } } else { return(st_pending); } return(st_error);}///////////////////////////////////////////////////////////////////status_type send_body(FILE* user_mail_file, char* boundary, content_type_encoding encoding){ char* file_buff=NULL; size_t file_buff_size=0; ssize_t b_read=0; status_type status=st_pending; do { b_read=getline(&file_buff,&file_buff_size,user_mail_file); if(b_read <= 0 || file_buff == NULL) { if(file_buff != NULL) free(file_buff); status=st_error; } else if(status == st_nl) status=is_boundary(file_buff,boundary); if(status == st_pending) { if(encoding == cte_quoted_printable) fix_quoted_to_text(file_buff); text_to_html(file_buff); if(*file_buff == '\n') status=st_nl; } } while(status == st_pending || status == st_nl); if(file_buff != NULL) free(file_buff); return(status);}///////////////////////////////////////////////////////////////////// This will compare the reply_to emails to address book. If found// in address book, will remove from real and set address book// to display name only// // Addr status & 0x00 == display full// status & 0x01 == hide email if name != NULL// status & 0x02 == dont display anythingint find_email_in_book(addr_t* real, addr_t* book, addr_t* skip, addr_t* from){ int x=0; int y=0; if(real != NULL) for(x=0; real[x].name || real[x].email; x++) real[x].status=0x00; if(book != NULL) for(y=0; book[y].name || book[y].email; y++) book[y].status=0x03; if(real != NULL && book != NULL) { for(x=0; real[x].name || real[x].email; x++) { for(y=0; book[y].name || book[y].email; y++) { if(real[x].email != NULL && book[y].email != NULL) if(strcasecmp(real[x].email,book[y].email) == 0) { real[x].status=0x02; book[y].status=0x01; } } } } if(skip != NULL && skip->email != NULL) { if(real != NULL) { for(x=0; real[x].name || real[x].email; x++) if(real[x].email != NULL) if(strcasecmp(real[x].email,skip->email) == 0) real[x].status=0x02; } if(book != NULL) { for(y=0; book[y].name || book[y].email; y++) if(book[y].email != NULL) if(strcasecmp(book[y].email,skip->email) == 0) book[y].status=0x02; } } if(from != NULL && from[0].email != NULL ) { if(real != NULL) { for(x=0; real[x].name || real[x].email; x++) if(real[x].email != NULL) if(strcasecmp(real[x].email,from[0].email) == 0) real[x].status=0x02; } if(book != NULL) { for(y=0; book[y].name || book[y].email; y++) if(book[x].email != NULL) if(strcasecmp(book[y].email,from[0].email) == 0) { from[0].status=0x02; book[y].status=0x01; } } } return(0);}///////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -