Lines Matching refs:ct

124 static void prefer_parts(CT ct);
201 CT ct; in parse_mime() local
251 if (!(ct = get_content (fp, file, 1))) { in parse_mime()
259 ct->c_unlink = 1; /* temp file to remove */ in parse_mime()
261 ct->c_fp = NULL; in parse_mime()
263 if (ct->c_end == 0L) { in parse_mime()
265 ct->c_end = ftell (fp); in parse_mime()
268 if (ct->c_ctinitfnx && (*ct->c_ctinitfnx) (ct) == NOTOK) { in parse_mime()
270 free_content (ct); in parse_mime()
275 return ct; in parse_mime()
296 CT ct; in get_content() local
301 NEW0(ct); in get_content()
302 ct->c_fp = in; in get_content()
303 ct->c_file = add (file, NULL); in get_content()
304 ct->c_begin = ftell (ct->c_fp) + 1; in get_content()
330 add_header (ct, np, vp); in get_content()
333 ct->c_begin = ftell (in) + 1; in get_content()
355 ct->c_begin = ftell(in) - bufsz; in get_content()
357 ct->c_begin = ftell (in) - (bufsz - 1); in get_content()
362 ct->c_begin = ftell (in); in get_content()
385 hp = ct->c_first_hf; /* start at first header field */ in get_content()
410 get_comment (ct->c_file, VRSN_FIELD, &cp, NULL) == NOTOK) in get_content()
421 ct->c_file, VRSN_FIELD, cp); in get_content()
423 if (!ct->c_vrsn) { in get_content()
424 ct->c_vrsn = vrsn; in get_content()
428 ct->c_file, VRSN_FIELD); in get_content()
435 CI ci = &ct->c_ctinfo; in get_content()
438 if (ct->c_ctline) { in get_content()
440 ct->c_file, TYPE_FIELD); in get_content()
445 if (get_ctinfo (hp->value, ct, 0) == NOTOK) in get_content()
457 ct->c_type = s2i->si_val; in get_content()
458 ct->c_ctinitfnx = s2i->si_init; in get_content()
469 if (ct->c_celine) { in get_content()
471 ct->c_file, ENCODING_FIELD); in get_content()
476 ct->c_celine = cp = add (hp->value, NULL); in get_content()
495 ct->c_encoding = s2i->si_val; in get_content()
498 if (s2i->si_init && (*s2i->si_init) (ct) == NOTOK) in get_content()
508 if (ct->c_digested) { in get_content()
510 ct->c_file, MD5_FIELD); in get_content()
528 get_comment (ct->c_file, MD5_FIELD, &cp, NULL) == NOTOK) { in get_content()
537 readDigest (ct, cp); in get_content()
539 ct->c_digested++; in get_content()
543 ct->c_id = add (hp->value, ct->c_id); in get_content()
547 ct->c_descr = add (hp->value, ct->c_descr); in get_content()
551 if (get_dispo(hp->value, ct, 0) == NOTOK) in get_content()
564 if (!ct->c_ctline) { in get_content()
570 if (get_ctinfo ("message/rfc822", ct, 0) == NOTOK) in get_content()
572 ct->c_type = CT_MESSAGE; in get_content()
573 ct->c_ctinitfnx = InitMessage; in get_content()
578 if (get_ctinfo ("text/plain", ct, 0) == NOTOK) in get_content()
580 ct->c_type = CT_TEXT; in get_content()
581 ct->c_ctinitfnx = InitText; in get_content()
586 if (!ct->c_celine) { in get_content()
587 ct->c_encoding = CE_7BIT; in get_content()
588 Init7Bit (ct); in get_content()
591 return ct; in get_content()
594 free_content (ct); in get_content()
604 add_header (CT ct, char *name, char *value) in add_header() argument
617 if (ct->c_first_hf == NULL) { in add_header()
618 ct->c_first_hf = hp; /* this is the first */ in add_header()
619 ct->c_last_hf = hp; in add_header()
621 ct->c_last_hf->next = hp; /* add it to the end */ in add_header()
622 ct->c_last_hf = hp; in add_header()
634 get_ctinfo (char *cp, CT ct, int magic) in get_ctinfo() argument
641 ci = &ct->c_ctinfo; in get_ctinfo()
644 cp = ct->c_ctline = add (cp, NULL); in get_ctinfo()
662 if (*cp == '(' && get_comment (ct->c_file, TYPE_FIELD, &cp, in get_ctinfo()
676 TYPE_FIELD, ct->c_file); in get_ctinfo()
684 if (*cp == '(' && get_comment (ct->c_file, TYPE_FIELD, &cp, in get_ctinfo()
698 if (*cp == '(' && get_comment (ct->c_file, TYPE_FIELD, &cp, in get_ctinfo()
712 TYPE_FIELD, ct->c_file, ci->ci_type); in get_ctinfo()
721 if (*cp == '(' && get_comment (ct->c_file, TYPE_FIELD, &cp, in get_ctinfo()
725 if ((status = parse_header_attrs (ct->c_file, TYPE_FIELD, &cp, in get_ctinfo()
735 mh_xfree(ct->c_id); in get_ctinfo()
736 ct->c_id = NULL; in get_ctinfo()
737 if (!(dp = strchr(ct->c_id = ++cp, '>'))) { in get_ctinfo()
738 inform("invalid ID in message %s", ct->c_file); in get_ctinfo()
743 if (*ct->c_id) in get_ctinfo()
744 ct->c_id = concat ("<", ct->c_id, ">\n", NULL); in get_ctinfo()
746 ct->c_id = NULL; in get_ctinfo()
758 ct->c_descr = ++cp; in get_ctinfo()
763 inform("invalid description in message %s", ct->c_file); in get_ctinfo()
764 ct->c_descr = NULL; in get_ctinfo()
770 if (*ct->c_descr) in get_ctinfo()
771 ct->c_descr = concat (ct->c_descr, "\n", NULL); in get_ctinfo()
773 ct->c_descr = NULL; in get_ctinfo()
790 inform("invalid disposition in message %s", ct->c_file); in get_ctinfo()
791 ct->c_dispo = NULL; in get_ctinfo()
798 if (get_dispo(cp, ct, 1) != OK) in get_ctinfo()
831 ct->c_reqencoding = CE_UNKNOWN; in get_ctinfo()
835 ct->c_reqencoding = kv->kv_value; in get_ctinfo()
840 if (ct->c_reqencoding == CE_UNKNOWN) { in get_ctinfo()
860 if (ct->c_dispo_type && in get_ctinfo()
861 !get_param(ct->c_dispo_first, "filename", '_', 1)) { in get_ctinfo()
862 add_param(&ct->c_dispo_first, &ct->c_dispo_last, "filename", in get_ctinfo()
868 ct->c_file, TYPE_FIELD, strlen(invo_name) + 2, "", cp); in get_ctinfo()
880 get_dispo (char *cp, CT ct, int buildflag) in get_dispo() argument
911 if (*cp == '(' && get_comment (ct->c_file, DISPO_FIELD, &cp, NULL) == in get_dispo()
921 ct->c_dispo_type = mh_xstrdup(cp); /* store disposition type */ in get_dispo()
925 if (*cp == '(' && get_comment (ct->c_file, DISPO_FIELD, &cp, NULL) == NOTOK) in get_dispo()
928 if ((status = parse_header_attrs (ct->c_file, DISPO_FIELD, &cp, in get_dispo()
929 &ct->c_dispo_first, &ct->c_dispo_last, in get_dispo()
937 ct->c_file, DISPO_FIELD, strlen(invo_name) + 2, "", cp); in get_dispo()
943 ct->c_dispo = dispoheader; in get_dispo()
1018 InitGeneric (CT ct) in InitGeneric() argument
1020 NMH_UNUSED (ct); in InitGeneric()
1031 InitText (CT ct) in InitText() argument
1038 CI ci = &ct->c_ctinfo; in InitText()
1045 ct->c_subtype = ct_str_subtype (CT_TEXT, ci->ci_subtype); in InitText()
1049 ct->c_ctparams = (void *) t; in InitText()
1074 ct->c_termproc = mh_xstrdup(cp); in InitText()
1086 InitMultiPart (CT ct) in InitMultiPart() argument
1098 CI ci = &ct->c_ctinfo; in InitMultiPart()
1106 if (! skip_mp_cte_check && ct->c_encoding != CE_7BIT && in InitMultiPart()
1107 ct->c_encoding != CE_8BIT && ct->c_encoding != CE_BINARY) { in InitMultiPart()
1110 char *cte = mh_xstrdup(ct->c_celine ? ct->c_celine : "(null)"); in InitMultiPart()
1121 ci->ci_type, ci->ci_subtype, ct->c_file, bp); in InitMultiPart()
1128 ct->c_subtype = ct_str_subtype (CT_MULTIPART, ci->ci_subtype); in InitMultiPart()
1145 ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD); in InitMultiPart()
1151 ct->c_ctparams = (void *) m; in InitMultiPart()
1158 ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD); in InitMultiPart()
1172 if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) { in InitMultiPart()
1173 advise (ct->c_file, "unable to open for reading"); in InitMultiPart()
1177 fseek (fp = ct->c_fp, pos = ct->c_begin, SEEK_SET); in InitMultiPart()
1178 last = ct->c_end; in InitMultiPart()
1198 if (!(p = get_content (fp, ct->c_file, in InitMultiPart()
1199 ct->c_subtype == MULTI_DIGEST ? -1 : 0))) { in InitMultiPart()
1201 ct->c_fp = NULL; in InitMultiPart()
1227 inform("bogus multipart content in message %s", ct->c_file); in InitMultiPart()
1233 p->c_end = ct->c_end; in InitMultiPart()
1247 if (ct->c_subtype == MULTI_ALTERNATE) { in InitMultiPart()
1248 reverse_parts (ct); in InitMultiPart()
1249 prefer_parts (ct); in InitMultiPart()
1261 if (ct->c_partno) { in InitMultiPart()
1262 snprintf (partnam, sizeof(partnam), "%s.", ct->c_partno); in InitMultiPart()
1278 fclose (ct->c_fp); in InitMultiPart()
1279 ct->c_fp = NULL; in InitMultiPart()
1285 get_leftover_mp_content (ct, 1); in InitMultiPart()
1286 get_leftover_mp_content (ct, 0); in InitMultiPart()
1289 fclose (ct->c_fp); in InitMultiPart()
1290 ct->c_fp = NULL; in InitMultiPart()
1306 reverse_parts (CT ct) in reverse_parts() argument
1308 struct multipart *m = (struct multipart *) ct->c_ctparams; in reverse_parts()
1322 move_preferred_part (CT ct, char *type, char *subtype) in move_preferred_part() argument
1324 struct multipart *m = (struct multipart *) ct->c_ctparams; in move_preferred_part()
1369 prefer_parts(CT ct) in prefer_parts() argument
1373 move_preferred_part(ct, preferred_types[i], preferred_subtypes[i]); in prefer_parts()
1383 reverse_alternative_parts (CT ct) { in reverse_alternative_parts() argument
1384 if (ct->c_type == CT_MULTIPART) { in reverse_alternative_parts()
1385 struct multipart *m = (struct multipart *) ct->c_ctparams; in reverse_alternative_parts()
1388 if (ct->c_subtype == MULTI_ALTERNATE) { in reverse_alternative_parts()
1389 reverse_parts (ct); in reverse_alternative_parts()
1405 InitMessage (CT ct) in InitMessage() argument
1407 CI ci = &ct->c_ctinfo; in InitMessage()
1409 if ((ct->c_encoding != CE_7BIT) && (ct->c_encoding != CE_8BIT)) { in InitMessage()
1412 ct->c_file); in InitMessage()
1421 ct->c_subtype = ct_str_subtype (CT_MESSAGE, ci->ci_subtype); in InitMessage()
1423 switch (ct->c_subtype) { in InitMessage()
1433 ct->c_ctparams = (void *) p; in InitMessage()
1447 ct->c_file, TYPE_FIELD); in InitMessage()
1464 ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD); in InitMessage()
1478 ct->c_ctparams = (void *) e; in InitMessage()
1480 if (!ct->c_fp in InitMessage()
1481 && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) { in InitMessage()
1482 advise (ct->c_file, "unable to open for reading"); in InitMessage()
1486 fseek (fp = ct->c_fp, ct->c_begin, SEEK_SET); in InitMessage()
1488 if (!(p = get_content (fp, ct->c_file, 0))) { in InitMessage()
1489 ct->c_fp = NULL; in InitMessage()
1493 e->eb_parent = ct; in InitMessage()
1497 if ((exresult = params_external (ct, 0)) != NOTOK in InitMessage()
1502 if ((size = ct->c_end - p->c_begin) <= 0) { in InitMessage()
1504 content_error (NULL, ct, in InitMessage()
1529 fclose (ct->c_fp); in InitMessage()
1530 ct->c_fp = NULL; in InitMessage()
1546 e->eb_partno = ct->c_partno; in InitMessage()
1563 params_external (CT ct, int composing) in params_external() argument
1566 struct exbody *e = (struct exbody *) ct->c_ctparams; in params_external()
1567 CI ci = &ct->c_ctinfo; in params_external()
1569 ct->c_ceopenfnx = NULL; in params_external()
1650 ci->ci_type, ci->ci_subtype, ct->c_file, TYPE_FIELD); in params_external()
1663 InitApplication (CT ct) in InitApplication() argument
1665 CI ci = &ct->c_ctinfo; in InitApplication()
1668 ct->c_subtype = ct_str_subtype (CT_APPLICATION, ci->ci_subtype); in InitApplication()
1679 init_encoding (CT ct, OpenCEFunc openfnx) in init_encoding() argument
1681 ct->c_ceopenfnx = openfnx; in init_encoding()
1682 ct->c_ceclosefnx = close_encoding; in init_encoding()
1683 ct->c_cesizefnx = size_encoding; in init_encoding()
1690 close_encoding (CT ct) in close_encoding() argument
1692 CE ce = &ct->c_cefile; in close_encoding()
1702 size_encoding (CT ct) in size_encoding() argument
1707 CE ce = &ct->c_cefile; in size_encoding()
1719 if (ct->c_encoding == CE_EXTERNAL) in size_encoding()
1720 return (ct->c_end - ct->c_begin); in size_encoding()
1723 if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK) in size_encoding()
1724 return (ct->c_end - ct->c_begin); in size_encoding()
1731 (*ct->c_ceclosefnx) (ct); in size_encoding()
1741 InitBase64 (CT ct) in InitBase64() argument
1743 return init_encoding (ct, openBase64); in InitBase64()
1748 openBase64 (CT ct, char **file) in openBase64() argument
1755 CE ce = &ct->c_cefile; in openBase64()
1767 content_error (ce->ce_file, ct, "unable to fopen for reading"); in openBase64()
1781 ci = &ct->c_ctinfo; in openBase64()
1802 content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); in openBase64()
1806 if ((len = ct->c_end - ct->c_begin) < 0) in openBase64()
1811 if (! ct->c_fp) { in openBase64()
1812 if ((ct->c_fp = fopen (ct->c_file, "r")) == NULL) { in openBase64()
1813 content_error (ct->c_file, ct, "unable to open for reading"); in openBase64()
1819 lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET); in openBase64()
1824 content_error (ct->c_file, ct, "error reading from"); in openBase64()
1828 content_error (NULL, ct, "premature eof"); in openBase64()
1842 if (decodeBase64 (buffer, &decoded, &decoded_len, ct->c_type == CT_TEXT, in openBase64()
1843 ct->c_digested ? digest : NULL) == OK) { in openBase64()
1851 content_error (ce->ce_file, ct, "error writing to"); in openBase64()
1855 if (ct->c_digested) { in openBase64()
1856 if (memcmp(digest, ct->c_digest, in openBase64()
1858 content_error (NULL, ct, in openBase64()
1870 fseek (ct->c_fp, 0L, SEEK_SET); in openBase64()
1873 content_error (ce->ce_file, ct, "error writing to"); in openBase64()
1882 fclose (ct->c_fp); in openBase64()
1883 ct->c_fp = NULL; in openBase64()
1890 fclose (ct->c_fp); in openBase64()
1891 ct->c_fp = NULL; in openBase64()
1893 free_encoding (ct, 0); in openBase64()
1924 InitQuoted (CT ct) in InitQuoted() argument
1926 return init_encoding (ct, openQuoted); in InitQuoted()
1931 openQuoted (CT ct, char **file) in openQuoted() argument
1939 CE ce = &ct->c_cefile; in openQuoted()
1951 content_error (ce->ce_file, ct, "unable to fopen for reading"); in openQuoted()
1965 ci = &ct->c_ctinfo; in openQuoted()
1986 content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); in openQuoted()
1990 if ((len = ct->c_end - ct->c_begin) < 0) in openQuoted()
1993 if (! ct->c_fp) { in openQuoted()
1994 if ((ct->c_fp = fopen (ct->c_file, "r")) == NULL) { in openQuoted()
1995 content_error (ct->c_file, ct, "unable to open for reading"); in openQuoted()
2001 if ((digested = ct->c_digested)) in openQuoted()
2009 fseek (ct->c_fp, ct->c_begin, SEEK_SET); in openQuoted()
2011 if ((gotlen = getline(&bufp, &buflen, ct->c_fp)) == -1) { in openQuoted()
2012 content_error (NULL, ct, "premature eof"); in openQuoted()
2042 content_error (ce->ce_file, ct, "error writing to"); in openQuoted()
2086 content_error (ce->ce_file, ct, "error writing to"); in openQuoted()
2092 content_error (NULL, ct, in openQuoted()
2097 fseek (ct->c_fp, 0L, SEEK_SET); in openQuoted()
2100 content_error (ce->ce_file, ct, "error writing to"); in openQuoted()
2108 if (memcmp((char *) digest, (char *) ct->c_digest, in openQuoted()
2110 content_error (NULL, ct, in openQuoted()
2122 fclose (ct->c_fp); in openQuoted()
2123 ct->c_fp = NULL; in openQuoted()
2129 free_encoding (ct, 0); in openQuoted()
2131 fclose (ct->c_fp); in openQuoted()
2132 ct->c_fp = NULL; in openQuoted()
2144 Init7Bit (CT ct) in Init7Bit() argument
2146 if (init_encoding (ct, open7Bit) == NOTOK) in Init7Bit()
2149 ct->c_cesizefnx = NULL; /* no need to decode for real size */ in Init7Bit()
2155 open7Bit (CT ct, char **file) in open7Bit() argument
2162 CE ce = &ct->c_cefile; in open7Bit()
2171 content_error (ce->ce_file, ct, "unable to fopen for reading"); in open7Bit()
2185 ci = &ct->c_ctinfo; in open7Bit()
2206 content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); in open7Bit()
2210 if (ct->c_type == CT_MULTIPART) { in open7Bit()
2211 CI ci = &ct->c_ctinfo; in open7Bit()
2238 if (ct->c_id) in open7Bit()
2239 fprintf (ce->ce_fp, "%s:%s", ID_FIELD, ct->c_id); in open7Bit()
2240 if (ct->c_descr) in open7Bit()
2241 fprintf (ce->ce_fp, "%s:%s", DESCR_FIELD, ct->c_descr); in open7Bit()
2242 if (ct->c_dispo) in open7Bit()
2243 fprintf (ce->ce_fp, "%s:%s", DISPO_FIELD, ct->c_dispo); in open7Bit()
2247 if ((len = ct->c_end - ct->c_begin) < 0) in open7Bit()
2250 if (! ct->c_fp) { in open7Bit()
2251 if ((ct->c_fp = fopen (ct->c_file, "r")) == NULL) { in open7Bit()
2252 content_error (ct->c_file, ct, "unable to open for reading"); in open7Bit()
2258 lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET); in open7Bit()
2262 content_error (ct->c_file, ct, "error reading from"); in open7Bit()
2266 content_error (NULL, ct, "premature eof"); in open7Bit()
2278 content_error (ce->ce_file, ct, "error writing to"); in open7Bit()
2283 fseek (ct->c_fp, 0L, SEEK_SET); in open7Bit()
2286 content_error (ce->ce_file, ct, "error writing to"); in open7Bit()
2295 fclose (ct->c_fp); in open7Bit()
2296 ct->c_fp = NULL; in open7Bit()
2301 free_encoding (ct, 0); in open7Bit()
2303 fclose (ct->c_fp); in open7Bit()
2304 ct->c_fp = NULL; in open7Bit()
2315 openExternal (CT ct, CT cb, CE ce, char **file, int *fd) in openExternal() argument
2326 content_error (ce->ce_file, ct, "unable to fopen for reading"); in openExternal()
2332 if (find_cache (ct, rcachesw, (int *) 0, cb->c_id, in openExternal()
2356 InitFile (CT ct) in InitFile() argument
2358 return init_encoding (ct, openFile); in InitFile()
2363 openFile (CT ct, char **file) in openFile() argument
2367 struct exbody *e = ct->c_ctexbody; in openFile()
2368 CE ce = &ct->c_cefile; in openFile()
2382 content_error (NULL, ct, "missing name parameter"); in openFile()
2390 content_error (ce->ce_file, ct, "unable to fopen for reading"); in openFile()
2439 InitFTP (CT ct) in InitFTP() argument
2441 return init_encoding (ct, openFTP); in InitFTP()
2446 openFTP (CT ct, char **file) in openFTP() argument
2453 CE ce = &ct->c_cefile; in openFTP()
2457 e = ct->c_ctexbody; in openFTP()
2477 content_error (NULL, ct, "missing %s parameter", in openFTP()
2558 content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); in openFTP()
2652 InitMail (CT ct) in InitMail() argument
2654 return init_encoding (ct, openMail); in InitMail()
2659 openMail (CT ct, char **file) in openMail() argument
2664 struct exbody *e = ct->c_ctexbody; in openMail()
2665 CE ce = &ct->c_cefile; in openMail()
2679 content_error (NULL, ct, "missing server parameter"); in openMail()
2751 content_error (ce->ce_file, ct, "unable to fopen for reading/writing"); in openMail()
2757 mh_xfree(ct->c_showproc); in openMail()
2758 ct->c_showproc = mh_xstrdup("true"); in openMail()
2771 InitURL (CT ct) in InitURL() argument
2773 return init_encoding (ct, openURL); in InitURL()
2778 openURL (CT ct, char **file) in openURL() argument
2780 struct exbody *e = ct->c_ctexbody; in openURL()
2781 CE ce = &ct->c_cefile; in openURL()
2792 content_error(NULL, ct, "No entry for nmh-access-url in profile"); in openURL()
2808 content_error(NULL, ct, "missing url parameter"); in openURL()
2838 content_error(ce->ce_file, ct, "unable to fopen for read/writing"); in openURL()
2908 readDigest (CT ct, char *cp) in readDigest() argument
2914 const size_t maxlen = sizeof ct->c_digest; in readDigest()
2917 memcpy (ct->c_digest, digest, maxlen); in readDigest()
2924 fprintf (stderr, "%02x", ct->c_digest[i] & 0xff); in readDigest()
2947 get_leftover_mp_content (CT ct, int before /* or after */) in get_leftover_mp_content() argument
2949 struct multipart *m = (struct multipart *) ct->c_ctparams; in get_leftover_mp_content()
2966 fseeko (ct->c_fp, ct->c_begin, SEEK_SET); in get_leftover_mp_content()
2967 max = m->mp_parts->mp_part->c_begin - ct->c_begin; in get_leftover_mp_content()
2982 fseeko (ct->c_fp, last_subpart->mp_part->c_end, SEEK_SET); in get_leftover_mp_content()
2983 max = ct->c_end - last_subpart->mp_part->c_end; in get_leftover_mp_content()
2988 while ((gotlen = getline(&bufp, &buflen, ct->c_fp)) != -1) { in get_leftover_mp_content()
3029 if ((before || ! feof (ct->c_fp)) && in get_leftover_mp_content()
3656 content_charset (CT ct) { in content_charset() argument
3659 ret_charset = get_param(ct->c_ctinfo.ci_first_pm, "charset", '?', 0); in content_charset()