static void newmsg_header(const char *label, const char *field, const char *val) { // by lfan printf("<TR><TD CLASS=\"new-message-header\" ALIGN=RIGHT WIDTH=60>" //"<FONT CLASS=\"new-message-header-%s\">%s</FONT></TD>" "%s</TD>" "<TD WIDTH=6> </TD>", //field, label); label); //printf("<TD><INPUT NAME=%s SIZE=50 MAXLENGTH=512 VALUE=\"", printf("<TD><INPUT CLASS=\"myinput\" NAME=%s SIZE=50 MAXLENGTH=512 VALUE=\"", field); if (val) { char *s; s=rfc2047_decode_simple(val); if (!s) enomem(); output_attrencoded(s); free(s); } printf("\"></TD></TR>\n"); }
static char *get_suitable_filename(struct rfc2045 *r, const char *pfix, int ignore_filename) { const char *disposition_s; const char *disposition_name_s; const char *disposition_filename_s; char *filename_buf; const char *content_name_s; char *p, *q; char *dyn_disp_name=0; rfc2045_dispositioninfo(r, &disposition_s, &disposition_name_s, &disposition_filename_s); content_name_s=rfc2045_contentname(r); if (!disposition_filename_s || !*disposition_filename_s) disposition_filename_s=disposition_name_s; if (!disposition_filename_s || !*disposition_filename_s) disposition_filename_s=content_name_s; filename_buf=rfc2047_decode_simple(disposition_filename_s); if (!filename_buf) { perror("rfc2047_decode_simple"); exit(1); } if (strlen(filename_buf) > 32) { p=filename_buf; q=filename_buf + strlen(filename_buf)-32; while ( (*p++ = *q++) != 0) ; } disposition_filename_s=filename_buf; if (ignore_filename) { char numbuf[NUMBUFSIZE]; static size_t counter=0; const char *p=str_size_t(++counter, numbuf); dyn_disp_name=malloc(strlen(disposition_filename_s) + strlen(p)+2); if (!dyn_disp_name) { perror("malloc"); exit(1); } disposition_filename_s=strcat(strcat(strcpy( dyn_disp_name, p), "-"), disposition_filename_s); } else if (!disposition_filename_s || !*disposition_filename_s) { dyn_disp_name=tempname("."); disposition_filename_s=dyn_disp_name+2; /* Skip over ./ */ } p=malloc((pfix ? strlen(pfix):0)+strlen(disposition_filename_s)+1); if (!p) { perror("malloc"); exit(1); } *p=0; if (pfix) strcpy(p, pfix); q=p+strlen(p); for (strcpy(q, disposition_filename_s); *q; q++) if (!isalnum(*q) && *q != '.' && *q != '-') *q='_'; if (dyn_disp_name) free(dyn_disp_name); if (!pfix) { const char *content_type_s; const char *content_transfer_encoding_s; const char *charset_s; int c; static char filenamebuf[256]; char *t; FILE *tty; if ((tty=fopen("/dev/tty", "r+")) == 0) { perror("/dev/tty"); exit(1); } rfc2045_mimeinfo(r, &content_type_s, &content_transfer_encoding_s, &charset_s); fprintf (tty, "Extract %s? ", content_type_s); fflush(tty); c=getc(tty); if (c != '\n' && c != EOF) { int cc; while ((cc=getc(tty)) != '\n' && cc != EOF) ; } if (c != 'y' && c != 'Y') { free(p); fclose(tty); free(filename_buf); return (0); } fprintf (tty, "Filename [%s]: ", p); fgets(filenamebuf, sizeof(filenamebuf)-1, tty); fclose(tty); t=strchr(filenamebuf, '\n'); if (t) *t=0; else { fprintf(stderr, "Filename too long.\n"); exit(1); } if (filenamebuf[0]) { free(p); p=strdup(filenamebuf); if (!p) { perror("malloc"); exit(1); } } } free(filename_buf); return (p); }
static void do_print_info(struct rfc2045 *s) { const char *content_type, *transfer_encoding, *charset; off_t start, end, body; const char *disposition; const char *disposition_name; const char *disposition_filename; const char *content_name; off_t nlines, nbodylines; const char *p; rfc2045_mimeinfo(s, &content_type, &transfer_encoding, &charset); rfc2045_mimepos(s, &start, &end, &body, &nlines, &nbodylines); rfc2045_dispositioninfo(s, &disposition, &disposition_name, &disposition_filename); content_name=rfc2045_contentname(s); printf("content-type: %s\n", content_type); if (content_name) { char *s=rfc2047_decode_simple(content_name); if (!s) { perror("rfc2047_decode_simple"); exit(1); } printf("content-name: %s\n", s); free(s); } printf("content-transfer-encoding: %s\n", transfer_encoding); printf("charset: %s\n", charset); if (disposition && *disposition) printf("content-disposition: %s\n", disposition); if (disposition_name && *disposition_name) { char *s=rfc2047_decode_simple(disposition_name); if (!s) { perror("rfc2047_decode_simple"); exit(1); } printf("content-disposition-name: %s\n", s); free(s); } if (disposition_filename && *disposition_filename) { char *s=rfc2047_decode_simple(disposition_filename); if (!s) { perror("rfc2047_decode_simple"); exit(1); } printf("content-disposition-filename: %s\n", s); free(s); } if (*(p=rfc2045_content_id(s))) printf("content-id: <%s>\n", p); if (*(p=rfc2045_content_description(s))) { char *s=rfc2047_decode_simple(p); if (!s) { perror("rfc2047_decode_simple"); exit(1); } printf("content-description: %s\n", s); free(s); } if (*(p=rfc2045_content_language(s))) printf("content-language: %s\n", p); if (*(p=rfc2045_content_md5(s))) printf("content-md5: %s\n", p); printf("starting-pos: %lu\n", (unsigned long)start); printf("starting-pos-body: %lu\n", (unsigned long)body); printf("ending-pos: %lu\n", (unsigned long)end); printf("line-count: %lu\n", (unsigned long)nlines); printf("body-line-count: %lu\n", (unsigned long)nbodylines); }