+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#include <lib-lib/macros.h>
+#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/file.h>
+#include <lib-lib/ascii.h>
+
+#include <lib-mime/mime.h>
+
static int address_header_decode (char **str);
static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout,
char *date);
static int address_header_decode (char **str);
static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout,
char *date);
-mutt_copy_hdr (FILE * in, FILE * out, long off_start, long off_end, int flags,
- const char *prefix)
-{
+mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
+ int flags, const char *prefix) {
- if (ftell (in) != off_start)
- fseek (in, off_start, 0);
+ if (ftello (in) != off_start)
+ fseeko (in, off_start, 0);
- debug_print (1, ("WEED is %s\n", (flags & CH_WEED) ? "Set" : "Not"));
-
- headers = mem_calloc (hdr_count, sizeof (char *));
+ headers = p_new(char *, hdr_count);
- mem_realloc (&headers[x], str_len (headers[x]) +
- str_len (this_one) + sizeof (char));
- strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
- mem_free (&this_one);
+ p_realloc(&headers[x], m_strlen(headers[x]) + m_strlen(this_one) + 1);
+ strcat(headers[x], this_one); /* __STRCAT_CHECKED__ */
+ p_delete(&this_one);
/* Find x -- the array entry where this header is to be saved */
if (flags & CH_REORDER) {
for (t = HeaderOrderList, x = 0; (t); t = t->next, x++) {
/* Find x -- the array entry where this header is to be saved */
if (flags & CH_REORDER) {
for (t = HeaderOrderList, x = 0; (t); t = t->next, x++) {
- if (!ascii_strncasecmp (buf, t->data, str_len (t->data))) {
- debug_print (2, ("Reorder: %s matches %s\n", t->data, buf));
+ if (!ascii_strncasecmp (buf, t->data, m_strlen(t->data))) {
/* we do want to see all lines if this header doesn't feature
* abbreviations (curline is 0), $max_display_recips is 0 and
* while the number hasn't reached $max_display_recips yet */
else if (curline == 0 || MaxDispRecips == 0 || ++curline <= MaxDispRecips) {
/* we do want to see all lines if this header doesn't feature
* abbreviations (curline is 0), $max_display_recips is 0 and
* while the number hasn't reached $max_display_recips yet */
else if (curline == 0 || MaxDispRecips == 0 || ++curline <= MaxDispRecips) {
strcat (this_one, buf); /* __STRCAT_CHECKED__ */
/* only for the first line which doesn't exeeds
* $max_display_recips: abbreviate it */
} else if (curline == MaxDispRecips+1) {
strcat (this_one, buf); /* __STRCAT_CHECKED__ */
/* only for the first line which doesn't exeeds
* $max_display_recips: abbreviate it */
} else if (curline == MaxDispRecips+1) {
fputs ("Content-Transfer-Encoding: 8bit\n", out);
fputs ("Content-Type: text/plain; charset=", out);
mutt_canonical_charset (chsbuf, sizeof (chsbuf),
Charset ? Charset : "us-ascii");
fputs ("Content-Transfer-Encoding: 8bit\n", out);
fputs ("Content-Type: text/plain; charset=", out);
mutt_canonical_charset (chsbuf, sizeof (chsbuf),
Charset ? Charset : "us-ascii");
- rfc822_cat (buffer, sizeof (buffer), chsbuf, MimeSpecials);
+ rfc822_strcpy(buffer, sizeof(buffer), chsbuf, MimeSpecials);
/* Mutt stores references in reverse order, thus we create
* a reordered refs list that we can put in the headers */
for (; listp; listp = listp->next, refs = t) {
/* Mutt stores references in reverse order, thus we create
* a reordered refs list that we can put in the headers */
for (; listp; listp = listp->next, refs = t) {
/* clearing refs from memory */
for (t = refs; refs; refs = t->next, t = refs)
/* clearing refs from memory */
for (t = refs; refs; refs = t->next, t = refs)
if (h->lines != 0 || h->content->length == 0)
fprintf (out, "Lines: %d\n", h->lines);
}
if (h->lines != 0 || h->content->length == 0)
fprintf (out, "Lines: %d\n", h->lines);
}
-static int count_delete_lines (FILE * fp, BODY * b, long *length,
+static int count_delete_lines (FILE * fp, BODY * b, off_t *length,
else
_mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context,
hdr, 0);
else
_mutt_make_string (prefix, sizeof (prefix), NONULL (Prefix), Context,
hdr, 0);
- count_delete_lines (fpin, body, &new_length, str_len (date));
+ count_delete_lines (fpin, body, &new_length, m_strlen(date));
/* Copy the headers */
if (mutt_copy_header (fpin, hdr, fpout,
chflags | CH_NOLEN | CH_NONEWLINE, NULL))
return -1;
/* Copy the headers */
if (mutt_copy_header (fpin, hdr, fpout,
chflags | CH_NOLEN | CH_NONEWLINE, NULL))
return -1;
if (new_lines <= 0)
new_lines = 0;
else
fprintf (fpout, "Lines: %d\n\n", new_lines);
if (ferror (fpout) || feof (fpout))
return -1;
if (new_lines <= 0)
new_lines = 0;
else
fprintf (fpout, "Lines: %d\n\n", new_lines);
if (ferror (fpout) || feof (fpout))
return -1;
if (copy_delete_attach (body, fpin, fpout, date))
return -1;
if (copy_delete_attach (body, fpin, fpout, date))
return -1;
hdr->content->type == TYPEMULTIPART) {
if (crypt_pgp_decrypt_mime (fpin, &fp, hdr->content, &cur))
return (-1);
hdr->content->type == TYPEMULTIPART) {
if (crypt_pgp_decrypt_mime (fpin, &fp, hdr->content, &cur))
return (-1);
&& hdr->content->type == TYPEAPPLICATION) {
if (crypt_smime_decrypt_mime (fpin, &fp, hdr->content, &cur))
return (-1);
&& hdr->content->type == TYPEAPPLICATION) {
if (crypt_smime_decrypt_mime (fpin, &fp, hdr->content, &cur))
return (-1);
_mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags,
chflags)) == 0 && (ferror (fpout)
|| feof (fpout))) {
_mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags,
chflags)) == 0 && (ferror (fpout)
|| feof (fpout))) {
-_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src,
+_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src __attribute__ ((unused)),
HEADER * hdr, BODY * body, int flags, int chflags) {
char buf[STRING];
MESSAGE *msg;
int r;
HEADER * hdr, BODY * body, int flags, int chflags) {
char buf[STRING];
MESSAGE *msg;
int r;
if (fgets (buf, sizeof (buf), fpin) == NULL)
return (-1);
if ((msg = mx_open_new_message (dest, hdr, is_from (buf, NULL, 0, NULL) ? 0 : M_ADD_FROM)) == NULL)
if (fgets (buf, sizeof (buf), fpin) == NULL)
return (-1);
if ((msg = mx_open_new_message (dest, hdr, is_from (buf, NULL, 0, NULL) ? 0 : M_ADD_FROM)) == NULL)
for (part = b->parts; part; part = part->next) {
if (part->deleted || part->parts) {
/* Copy till start of this part */
for (part = b->parts; part; part = part->next) {
if (part->deleted || part->parts) {
/* Copy till start of this part */
"\n", date + 5, part->length);
if (ferror (fpout))
return -1;
/* Copy the original mime headers */
"\n", date + 5, part->length);
if (ferror (fpout))
return -1;
/* Copy the original mime headers */
}
else {
if (copy_delete_attach (part, fpin, fpout, date))
}
else {
if (copy_delete_attach (part, fpin, fpout, date))
int l, linelen, buflen, count;
int l, linelen, buflen, count;
a->next = NULL;
*buf = *cbuf = *c2buf = '\0';
rfc822_write_address (buf, sizeof (buf), a, 0);
a->next = tmp;
a->next = NULL;
*buf = *cbuf = *c2buf = '\0';
rfc822_write_address (buf, sizeof (buf), a, 0);
a->next = tmp;
if (count && linelen + l > 74) {
strcpy (cbuf, "\n\t"); /* __STRCPY_CHECKED__ */
linelen = l + 8;
if (count && linelen + l > 74) {
strcpy (cbuf, "\n\t"); /* __STRCPY_CHECKED__ */
linelen = l + 8;
strcat (*h, cbuf); /* __STRCAT_CHECKED__ */
strcat (*h, buf); /* __STRCAT_CHECKED__ */
strcat (*h, c2buf); /* __STRCAT_CHECKED__ */
strcat (*h, cbuf); /* __STRCAT_CHECKED__ */
strcat (*h, buf); /* __STRCAT_CHECKED__ */
strcat (*h, c2buf); /* __STRCAT_CHECKED__ */
- *h = mem_calloc (1, l + 2);
-
- strfcpy (*h, s, l + 1);
+ *h = p_dupstr(s, l + 1);