Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
1ccdf8eb
...
1ccdf8eba56f46be5cc8bde04bf9f4c705148a2f
authored
2007-06-26 13:57:04 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Prefer mu_header_sgetwhere possible. Remove obsolete header calls.
1 parent
23e39709
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62 additions
and
163 deletions
examples/mimetest.c
libproto/imap/mbox.c
libproto/mbox/mbox.c
libsieve/actions.c
mail.local/mailquota.c
mail/decode.c
mail/escape.c
mail/mail.h
mail/print.c
mail/retain.c
mail/send.c
mailbox/sendmail.c
examples/mimetest.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2005
, 2007
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -29,8 +29,8 @@
void
message_display_parts
(
mu_message_t
msg
,
int
indent
);
c
har
from
[
256
]
;
c
har
subject
[
256
]
;
c
onst
char
*
from
;
c
onst
char
*
subject
;
int
print_attachments
;
int
indent_level
=
4
;
...
...
@@ -120,9 +120,10 @@ main (int argc, char **argv)
CATCH
(
mu_message_size
(
msg
,
&
msize
));
CATCH
(
mu_message_lines
(
msg
,
&
nlines
));
CATCH
(
mu_message_get_header
(
msg
,
&
hdr
));
mu_header_get_value
(
hdr
,
MU_HEADER_FROM
,
from
,
sizeof
(
from
),
NULL
);
mu_header_get_value
(
hdr
,
MU_HEADER_SUBJECT
,
subject
,
sizeof
(
subject
),
NULL
);
if
(
mu_header_sget_value
(
hdr
,
MU_HEADER_FROM
,
&
from
))
from
=
""
;
if
(
mu_header_sget_value
(
hdr
,
MU_HEADER_SUBJECT
,
&
subject
))
subject
=
""
;
printf
(
"Message: %lu
\n
"
,
(
unsigned
long
)
i
);
printf
(
"From: %s
\n
"
,
from
);
printf
(
"Subject: %s
\n
"
,
subject
);
...
...
@@ -170,8 +171,8 @@ message_display_parts (mu_message_t msg, int indent)
size_t
nparts
,
nsubparts
;
mu_message_t
part
;
mu_header_t
hdr
;
c
har
type
[
256
]
;
c
har
encoding
[
256
]
;
c
onst
char
*
type
;
c
onst
char
*
encoding
;
mu_stream_t
str
;
mu_body_t
body
;
int
offset
,
ismulti
;
...
...
@@ -189,15 +190,22 @@ message_display_parts (mu_message_t msg, int indent)
its own that can have other subparts(recursive). */
for
(
j
=
1
;
j
<=
nparts
;
j
++
)
{
int
status
;
CATCH
(
mu_message_get_part
(
msg
,
j
,
&
part
));
CATCH
(
mu_message_get_header
(
part
,
&
hdr
));
mu_header_get_value
(
hdr
,
MU_HEADER_CONTENT_TYPE
,
type
,
sizeof
(
type
),
NULL
);
status
=
mu_header_sget_value
(
hdr
,
MU_HEADER_CONTENT_TYPE
,
&
type
);
if
(
status
==
MU_ERR_NOENT
)
type
=
""
;
else
if
(
status
!=
0
)
{
type
=
""
;
mu_error
(
"Cannot get header value: %s"
,
mu_strerror
(
status
));
}
printf
(
"%*.*sType of part %d = %s
\n
"
,
indent
,
indent
,
""
,
j
,
type
);
print_message_part_sizes
(
part
,
indent
);
encoding
[
0
]
=
'\0'
;
mu_header_get_value
(
hdr
,
MU_HEADER_CONTENT_TRANSFER_ENCODING
,
encoding
,
sizeof
(
encoding
),
NULL
)
;
if
(
mu_header_sget_value
(
hdr
,
MU_HEADER_CONTENT_TRANSFER_ENCODING
,
&
encoding
))
encoding
=
""
;
ismulti
=
0
;
if
((
type
[
0
]
&&
strncasecmp
(
type
,
"message/rfc822"
,
strlen
(
type
))
==
0
)
...
...
@@ -207,9 +215,10 @@ message_display_parts (mu_message_t msg, int indent)
CATCH
(
mu_message_unencapsulate
(
part
,
&
part
,
NULL
));
CATCH
(
mu_message_get_header
(
part
,
&
hdr
));
mu_header_get_value
(
hdr
,
MU_HEADER_FROM
,
from
,
sizeof
(
from
),
NULL
);
mu_header_get_value
(
hdr
,
MU_HEADER_SUBJECT
,
subject
,
sizeof
(
subject
),
NULL
);
if
(
mu_header_sget_value
(
hdr
,
MU_HEADER_FROM
,
&
from
))
from
=
""
;
if
(
mu_header_sget_value
(
hdr
,
MU_HEADER_SUBJECT
,
&
subject
))
subject
=
""
;
printf
(
"%*.*sEncapsulated message : %s
\t
%s
\n
"
,
indent
,
indent
,
""
,
from
,
subject
);
printf
(
"%*.*sBegin
\n
"
,
indent
,
indent
,
""
);
...
...
libproto/imap/mbox.c
View file @
1ccdf8e
...
...
@@ -100,7 +100,6 @@ static int imap_attr_unset_flags (mu_attribute_t, int);
/* mu_header_t API. */
static
int
imap_header_read
(
mu_header_t
,
char
*
,
size_t
,
mu_off_t
,
size_t
*
);
static
int
imap_header_get_value
(
mu_header_t
,
const
char
*
,
char
*
,
size_t
,
size_t
*
);
/* mu_body_t API. */
static
int
imap_body_read
(
mu_stream_t
,
char
*
,
size_t
,
mu_off_t
,
size_t
*
);
...
...
@@ -545,7 +544,6 @@ imap_get_message0 (msg_imap_t msg_imap, mu_message_t *pmsg)
return
status
;
}
mu_header_set_fill
(
header
,
imap_header_read
,
msg
);
mu_header_set_get_value
(
header
,
imap_header_get_value
,
msg
);
mu_message_set_header
(
msg
,
header
,
msg_imap
);
}
...
...
@@ -1451,7 +1449,6 @@ imap_get_part (mu_message_t msg, size_t partno, mu_message_t *pmsg)
{
mu_header_t
header
;
mu_message_get_header
(
message
,
&
header
);
mu_header_set_get_value
(
header
,
NULL
,
message
);
mu_message_set_stream
(
message
,
NULL
,
msg_imap
->
parts
[
partno
-
1
]);
/* mu_message_set_size (message, NULL, msg_imap->parts[partno - 1]); */
msg_imap
->
parts
[
partno
-
1
]
->
message
=
message
;
...
...
@@ -1721,89 +1718,6 @@ imap_attr_unset_flags (mu_attribute_t attribute, int flag)
/* Header. */
static
int
imap_header_get_value
(
mu_header_t
header
,
const
char
*
field
,
char
*
buffer
,
size_t
buflen
,
size_t
*
plen
)
{
mu_message_t
msg
=
mu_header_get_owner
(
header
);
msg_imap_t
msg_imap
=
mu_message_get_owner
(
msg
);
m_imap_t
m_imap
=
msg_imap
->
m_imap
;
f_imap_t
f_imap
=
m_imap
->
f_imap
;
int
status
;
size_t
len
=
0
;
char
*
value
;
/* Select first. */
status
=
imap_messages_count
(
m_imap
->
mailbox
,
NULL
);
if
(
status
!=
0
)
return
status
;
/* Hack, if buffer == NULL they want to know how big is the field value,
Unfortunately IMAP does not say, so we take a guess hoping that the
value will not be over 1024. */
if
(
buffer
==
NULL
||
buflen
==
0
)
len
=
1024
;
else
len
=
strlen
(
field
)
+
buflen
+
4
;
if
(
f_imap
->
state
==
IMAP_NO_STATE
)
{
/* Select first. */
status
=
imap_messages_count
(
m_imap
->
mailbox
,
NULL
);
if
(
status
!=
0
)
return
status
;
status
=
imap_writeline
(
f_imap
,
"g%s FETCH %s BODY.PEEK[HEADER.FIELDS (%s)]<0.%s>
\r\n
"
,
mu_umaxtostr
(
0
,
f_imap
->
seq
++
),
mu_umaxtostr
(
1
,
msg_imap
->
num
),
field
,
mu_umaxtostr
(
2
,
len
));
CHECK_ERROR
(
f_imap
,
status
);
MAILBOX_DEBUG0
(
m_imap
->
mailbox
,
MU_DEBUG_PROT
,
f_imap
->
buffer
);
f_imap
->
state
=
IMAP_FETCH
;
}
value
=
calloc
(
len
,
sizeof
(
*
value
));
status
=
fetch_operation
(
f_imap
,
msg_imap
,
value
,
len
,
&
len
);
if
(
status
==
0
)
{
char
*
colon
;
/* The field-matching is case-insensitive. In all cases, the
delimiting newline between the header and the body is always
included. Nuke it */
if
(
len
)
value
[
len
-
1
]
=
'\0'
;
/* Move pass the field-name. */
colon
=
strchr
(
value
,
':'
);
if
(
colon
)
{
colon
++
;
if
(
*
colon
==
' '
)
colon
++
;
}
else
colon
=
value
;
while
(
*
colon
&&
colon
[
strlen
(
colon
)
-
1
]
==
'\n'
)
colon
[
strlen
(
colon
)
-
1
]
=
'\0'
;
if
(
buffer
&&
buflen
)
{
strncpy
(
buffer
,
colon
,
buflen
);
buffer
[
buflen
-
1
]
=
'\0'
;
}
len
=
strlen
(
buffer
);
if
(
plen
)
*
plen
=
len
;
if
(
len
==
0
)
status
=
MU_ERR_NOENT
;
}
free
(
value
);
return
status
;
}
static
int
imap_header_read
(
mu_header_t
header
,
char
*
buffer
,
size_t
buflen
,
mu_off_t
offset
,
size_t
*
plen
)
...
...
libproto/mbox/mbox.c
View file @
1ccdf8e
...
...
@@ -63,8 +63,6 @@ static int mbox_readstream (mbox_message_t, char *, size_t,
mu_off_t
,
size_t
*
,
int
,
mu_off_t
,
mu_off_t
);
static
int
mbox_stream_size
(
mu_stream_t
stream
,
mu_off_t
*
psize
);
static
int
mbox_header_size
(
mu_header_t
,
size_t
*
);
static
int
mbox_header_lines
(
mu_header_t
,
size_t
*
);
static
int
mbox_body_size
(
mu_body_t
,
size_t
*
);
static
int
mbox_body_lines
(
mu_body_t
,
size_t
*
);
static
int
mbox_envelope_sender
(
mu_envelope_t
,
char
*
,
size_t
,
size_t
*
);
...
...
@@ -918,30 +916,6 @@ mbox_header_fill (mu_header_t header, char *buffer, size_t len,
}
static
int
mbox_header_size
(
mu_header_t
header
,
size_t
*
psize
)
{
mu_message_t
msg
=
mu_header_get_owner
(
header
);
mbox_message_t
mum
=
mu_message_get_owner
(
msg
);
if
(
mum
==
NULL
)
return
EINVAL
;
if
(
psize
)
*
psize
=
mum
->
body
-
mum
->
header_from_end
;
return
0
;
}
static
int
mbox_header_lines
(
mu_header_t
header
,
size_t
*
plines
)
{
mu_message_t
msg
=
mu_header_get_owner
(
header
);
mbox_message_t
mum
=
mu_message_get_owner
(
msg
);
if
(
mum
==
NULL
)
return
EINVAL
;
if
(
plines
)
*
plines
=
mum
->
header_lines
;
return
0
;
}
static
int
mbox_body_size
(
mu_body_t
body
,
size_t
*
psize
)
{
mu_message_t
msg
=
mu_body_get_owner
(
body
);
...
...
@@ -1120,8 +1094,6 @@ mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
return
status
;
}
mu_header_set_fill
(
header
,
mbox_header_fill
,
msg
);
mu_header_set_size
(
header
,
mbox_header_size
,
msg
);
mu_header_set_lines
(
header
,
mbox_header_lines
,
msg
);
mu_message_set_header
(
msg
,
header
,
mum
);
}
...
...
libsieve/actions.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2006 Free Software Foundation, Inc.
2006
, 2007
Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -146,7 +146,8 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text)
mu_body_t
body
;
mu_header_t
hdr
;
char
datestr
[
80
];
static
char
*
content_header
=
"Content-Type: text/plain;charset="
MU_SIEVE_CHARSET
"
\n
"
static
char
*
content_header
=
"Content-Type: text/plain;charset="
MU_SIEVE_CHARSET
"
\n
"
"Content-Transfer-Encoding: 8bit
\n
"
;
mu_message_create
(
&
newmsg
,
NULL
);
...
...
@@ -160,7 +161,7 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const char *text)
mu_sieve_get_message_sender
(
msg
,
&
sender
);
mu_stream_printf
(
stream
,
&
off
,
"
\n
The original message was received at %s from %s.
\n
"
,
"The original message was received at %s from %s.
\n
"
,
datestr
,
sender
);
free
(
sender
);
mu_stream_printf
(
stream
,
&
off
,
...
...
mail.local/mailquota.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005 Free Software Foundation, Inc.
2005
, 2007
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -155,7 +155,7 @@ sql_retrieve_quota (char *name, mu_off_t *quota)
char
*
query_str
;
int
rc
,
status
;
char
*
tmp
;
mu_off
_t
n
;
size
_t
n
;
query_str
=
mu_sql_expand_query
(
quota_query
,
name
);
if
(
!
query_str
)
...
...
mail/decode.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005 Free Software Foundation, Inc.
2005
, 2007
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -83,19 +83,20 @@ display_headers (FILE *out, mu_message_t mesg, const msgset_t *msgset ARG_UNUSED
{
size_t
num
=
0
;
size_t
i
=
0
;
c
har
buffer
[
512
]
;
c
onst
char
*
sptr
;
mu_message_get_header
(
mesg
,
&
hdr
);
mu_header_get_field_count
(
hdr
,
&
num
);
for
(
i
=
1
;
i
<=
num
;
i
++
)
{
buffer
[
0
]
=
'\0'
;
mu_header_get_field_name
(
hdr
,
i
,
buffer
,
sizeof
(
buffer
),
NULL
)
;
if
(
mail_header_is_visible
(
buffe
r
))
if
(
mu_header_sget_field_name
(
hdr
,
i
,
&
sptr
))
continue
;
if
(
mail_header_is_visible
(
spt
r
))
{
fprintf
(
out
,
"%s: "
,
buffer
);
mu_header_get_field_value
(
hdr
,
i
,
buffer
,
sizeof
(
buffer
),
NULL
);
fprintf
(
out
,
"%s
\n
"
,
buffer
);
fprintf
(
out
,
"%s: "
,
sptr
);
if
(
mu_header_sget_field_value
(
hdr
,
i
,
&
sptr
))
sptr
=
""
;
fprintf
(
out
,
"%s
\n
"
,
sptr
);
}
}
fprintf
(
out
,
"
\n
"
);
...
...
mail/escape.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 2002, 2005, 2006,
2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -456,20 +457,20 @@ quote0 (msgset_t *mspec, mu_message_t mesg, void *data)
if
(
*
(
int
*
)
data
)
{
size_t
i
,
num
=
0
;
c
har
buf
[
512
]
;
c
onst
char
*
sptr
;
mu_message_get_header
(
mesg
,
&
hdr
);
mu_header_get_field_count
(
hdr
,
&
num
);
for
(
i
=
1
;
i
<=
num
;
i
++
)
{
mu_header_
get_field_name
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
if
(
mail_header_is_visible
(
buf
))
mu_header_
sget_field_name
(
hdr
,
i
,
&
sptr
);
if
(
mail_header_is_visible
(
sptr
))
{
char
*
value
;
fprintf
(
ofile
,
"%s%s: "
,
prefix
,
buf
);
if
(
mu_header_aget_value
(
hdr
,
buf
,
&
value
)
==
0
)
fprintf
(
ofile
,
"%s%s: "
,
prefix
,
sptr
);
if
(
mu_header_aget_value
(
hdr
,
sptr
,
&
value
)
==
0
)
{
int
i
;
char
*
p
,
*
s
;
...
...
mail/mail.h
View file @
1ccdf8e
...
...
@@ -251,8 +251,8 @@ extern int mail_mbox_commit (void);
extern
int
mail_is_my_name
(
const
char
*
name
);
extern
void
mail_set_my_name
(
char
*
name
);
extern
char
*
mail_whoami
(
void
);
extern
int
mail_header_is_visible
(
char
*
str
);
extern
int
mail_header_is_unfoldable
(
char
*
str
);
extern
int
mail_header_is_visible
(
c
onst
c
har
*
str
);
extern
int
mail_header_is_unfoldable
(
c
onst
c
har
*
str
);
extern
int
mail_mbox_close
(
void
);
extern
char
*
mail_expand_name
(
const
char
*
name
);
...
...
mail/print.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -61,7 +62,7 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data)
if
(
*
(
int
*
)
data
)
/* print was called with a lowercase 'p' */
{
size_t
i
,
num
=
0
;
c
har
buf
[
512
]
;
c
onst
char
*
sptr
;
char
*
tmp
;
mu_message_get_header
(
mesg
,
&
hdr
);
...
...
@@ -69,12 +70,13 @@ mail_print_msg (msgset_t *mspec, mu_message_t mesg, void *data)
for
(
i
=
1
;
i
<=
num
;
i
++
)
{
mu_header_get_field_name
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
if
(
mail_header_is_visible
(
buf
))
if
(
mu_header_sget_field_name
(
hdr
,
i
,
&
sptr
))
continue
;
if
(
mail_header_is_visible
(
sptr
))
{
fprintf
(
out
,
"%s: "
,
buf
);
fprintf
(
out
,
"%s: "
,
sptr
);
mu_header_aget_field_value
(
hdr
,
i
,
&
tmp
);
if
(
mail_header_is_unfoldable
(
buf
))
if
(
mail_header_is_unfoldable
(
sptr
))
mu_string_unfold
(
tmp
,
NULL
);
util_rfc2047_decode
(
&
tmp
);
fprintf
(
out
,
"%s
\n
"
,
tmp
);
...
...
mail/retain.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 2002, 2004, 2005,
2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -94,13 +95,13 @@ mail_nounfold (int argc, char **argv)
}
int
mail_header_is_unfoldable
(
char
*
str
)
mail_header_is_unfoldable
(
c
onst
c
har
*
str
)
{
return
util_slist_lookup
(
unfolded_headers
,
str
);
}
int
mail_header_is_visible
(
char
*
str
)
mail_header_is_visible
(
c
onst
c
har
*
str
)
{
if
(
retained_headers
)
return
util_slist_lookup
(
retained_headers
,
str
);
...
...
mail/send.c
View file @
1ccdf8e
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2002, 2003, 2004,
2005, 2006 Free Software Foundation, Inc.
2005, 2006
, 2007
Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -366,7 +366,6 @@ mail_send0 (compose_env_t * env, int save_to)
char
*
escape
;
fd
=
mu_tempfile
(
NULL
,
&
filename
);
if
(
fd
==
-
1
)
{
util_error
(
_
(
"Cannot open temporary file"
));
...
...
@@ -527,7 +526,6 @@ mail_send0 (compose_env_t * env, int save_to)
int
rc
;
mu_message_create
(
&
msg
,
NULL
);
mu_message_set_header
(
msg
,
env
->
header
,
NULL
);
/* Fill the body. */
...
...
mailbox/sendmail.c
View file @
1ccdf8e
Please
register
or
sign in
to post a comment