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
81dca07b
...
81dca07b3d80f65dbb635a908f51020942265e73
authored
2007-06-24 12:23:57 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Use mu_address_sget functions, where possible.
1 parent
c4226486
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
121 additions
and
209 deletions
examples/addr.c
examples/mta.c
frm/common.c
imap4d/fetch.c
libmu_scm/mu_message.c
mail/alias.c
mail/alt.c
mail/from.c
mail/mail.h
mail/reply.c
mail/send.c
mail/util.c
mailbox/attachment.c
mailbox/mutil.c
mailbox/sendmail.c
mailbox/smtp.c
mh/mh.h
mh/mh_format.c
mh/mh_format.h
mh/mh_init.c
examples/addr.c
View file @
81dca07
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 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
...
...
@@ -32,7 +33,7 @@ parse (const char *str)
size_t
no
=
0
;
size_t
pcount
=
0
;
int
status
;
c
har
buf
[
BUFSIZ
]
;
c
onst
char
*
buf
;
mu_address_t
address
=
NULL
;
mu_set_user_email_domain
(
"localhost"
);
...
...
@@ -59,37 +60,32 @@ parse (const char *str)
if
(
isgroup
)
{
mu_address_
get_personal
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
mu_address_
sget_personal
(
address
,
no
,
&
buf
);
printf
(
"group <%s>
\n
"
,
buf
);
}
else
{
mu_address_
get_email
(
address
,
no
,
buf
,
sizeof
(
buf
),
0
);
mu_address_
sget_email
(
address
,
no
,
&
buf
);
printf
(
"email <%s>
\n
"
,
buf
);
}
mu_address_get_personal
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
&&
!
isgroup
)
if
(
mu_address_sget_personal
(
address
,
no
,
&
buf
)
==
0
&&
buf
&&
!
isgroup
)
printf
(
" personal <%s>
\n
"
,
buf
);
mu_address_get_comments
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
if
(
mu_address_sget_comments
(
address
,
no
,
&
buf
)
==
0
&&
buf
)
printf
(
" comments <%s>
\n
"
,
buf
);
mu_address_get_local_part
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
if
(
mu_address_sget_local_part
(
address
,
no
,
&
buf
)
==
0
&&
buf
)
{
printf
(
" local-part <%s>"
,
buf
);
mu_address_get_domain
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
if
(
mu_address_sget_domain
(
address
,
no
,
&
buf
)
==
0
&&
buf
)
printf
(
" domain <%s>"
,
buf
);
printf
(
"
\n
"
);
}
mu_address_get_route
(
address
,
no
,
buf
,
sizeof
(
buf
),
&
got
);
if
(
got
)
if
(
mu_address_sget_route
(
address
,
no
,
&
buf
)
==
0
&&
buf
)
printf
(
" route <%s>
\n
"
,
buf
);
}
mu_address_destroy
(
&
address
);
...
...
examples/mta.c
View file @
81dca07
/* 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
...
...
@@ -281,10 +281,9 @@ address_email_string (mu_address_t addr)
length
=
0
;
for
(
i
=
1
;
i
<=
count
;
i
++
)
{
char
*
str
;
mu_address_
a
get_email
(
recipients
,
i
,
&
str
);
c
onst
c
har
*
str
;
mu_address_
s
get_email
(
recipients
,
i
,
&
str
);
length
+=
strlen
(
str
)
+
3
;
free
(
str
);
}
value
=
malloc
(
length
+
1
);
...
...
frm/common.c
View file @
81dca07
...
...
@@ -358,7 +358,7 @@ init_output (size_t s)
from `from/from.c' and `mail/util.c'...
*/
static
char
*
rfc2047_decode_wrapper
(
char
*
buf
,
size_t
buflen
)
rfc2047_decode_wrapper
(
c
onst
c
har
*
buf
,
size_t
buflen
)
{
int
rc
;
char
*
tmp
;
...
...
imap4d/fetch.c
View file @
81dca07
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 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
...
...
@@ -1433,8 +1433,6 @@ fetch_header_fields_not (mu_message_t msg, char **arg, unsigned long start,
return
RESP_OK
;
}
/* FIXME: The address is limit by a buffer of 128, no good. We should
allocate the buffer. */
static
int
fetch_send_address
(
const
char
*
addr
)
{
...
...
@@ -1461,39 +1459,33 @@ fetch_send_address (const char *addr)
util_send
(
"("
,
count
);
for
(
i
=
1
;
i
<=
count
;
i
++
)
{
char
buf
[
128
];
const
char
*
str
;
int
is_group
=
0
;
util_send
(
"("
);
*
buf
=
'\0'
;
mu_address_get_personal
(
address
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
util_send_qstring
(
buf
);
mu_address_sget_personal
(
address
,
i
,
&
str
);
util_send_qstring
(
str
);
util_send
(
" "
);
*
buf
=
'\0'
;
mu_address_get_route
(
address
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
util_send_qstring
(
buf
);
mu_address_sget_route
(
address
,
i
,
&
str
);
util_send_qstring
(
str
);
util_send
(
" "
);
*
buf
=
'\0'
;
{
int
is_group
=
0
;
mu_address_is_group
(
address
,
i
,
&
is_group
);
str
=
NULL
;
if
(
is_group
)
mu_address_get_personal
(
address
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
mu_address_sget_personal
(
address
,
i
,
&
str
);
else
mu_address_get_local_part
(
address
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
}
util_send_qstring
(
buf
);
mu_address_sget_local_part
(
address
,
i
,
&
str
);
util_send_qstring
(
str
);
util_send
(
" "
);
*
buf
=
'\0'
;
mu_address_get_domain
(
address
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
util_send_qstring
(
buf
);
mu_address_sget_domain
(
address
,
i
,
&
str
);
util_send_qstring
(
str
);
util_send
(
")"
);
}
...
...
libmu_scm/mu_message.c
View file @
81dca07
...
...
@@ -54,19 +54,20 @@ _get_envelope_sender (mu_envelope_t env)
{
mu_address_t
addr
;
char
buffer
[
128
];
char
*
ptr
;
if
(
mu_envelope_sender
(
env
,
buffer
,
sizeof
(
buffer
),
NULL
)
||
mu_address_create
(
&
addr
,
buffer
))
return
NULL
;
if
(
mu_address_
get_email
(
addr
,
1
,
buffer
,
sizeof
(
buffer
),
NULL
))
if
(
mu_address_
aget_email
(
addr
,
1
,
&
ptr
))
{
mu_address_destroy
(
&
addr
);
return
NULL
;
}
mu_address_destroy
(
&
addr
);
return
strdup
(
buffer
)
;
return
buffer
;
}
static
int
...
...
mail/alias.c
View file @
81dca07
...
...
@@ -110,15 +110,15 @@ alias_destroy (const char *name)
static
void
recursive_alias_expand
(
char
*
name
,
mu_list_t
exlist
,
mu_list_t
origlist
)
recursive_alias_expand
(
c
onst
c
har
*
name
,
mu_list_t
exlist
,
mu_list_t
origlist
)
{
alias_t
al
;
mu_iterator_t
itr
;
if
((
al
=
alias_lookup
(
name
))
==
NULL
)
{
if
(
mu_list_locate
(
exlist
,
name
,
NULL
)
==
MU_ERR_NOENT
)
mu_list_append
(
exlist
,
name
);
if
(
mu_list_locate
(
exlist
,
(
void
*
)
name
,
NULL
)
==
MU_ERR_NOENT
)
mu_list_append
(
exlist
,
(
void
*
)
name
);
return
;
}
...
...
@@ -147,7 +147,7 @@ string_comp (const void *item, const void *value)
}
char
*
alias_expand
(
char
*
name
)
alias_expand
(
c
onst
c
har
*
name
)
{
alias_t
al
;
mu_list_t
list
;
...
...
mail/alt.c
View file @
81dca07
...
...
@@ -77,7 +77,7 @@ mail_set_my_name (char *name)
}
int
mail_is_my_name
(
char
*
name
)
mail_is_my_name
(
c
onst
c
har
*
name
)
{
if
(
strchr
(
name
,
'@'
)
==
NULL
&&
strcasecmp
(
name
,
my_name
)
==
0
)
return
1
;
...
...
mail/from.c
View file @
81dca07
...
...
@@ -44,9 +44,9 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
{
char
name
[
128
];
size_t
len
;
char
*
email
;
c
onst
c
har
*
email
;
if
(
mu_address_
a
get_email
(
address
,
1
,
&
email
)
==
0
)
if
(
mu_address_
s
get_email
(
address
,
1
,
&
email
)
==
0
)
{
if
(
util_getenv
(
NULL
,
"showto"
,
Mail_env_boolean
,
0
)
==
0
&&
mail_is_my_name
(
email
))
...
...
@@ -64,7 +64,6 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
free
(
tmp
);
}
}
free
(
email
);
}
len
=
strlen
(
from
)
+
1
;
...
...
mail/mail.h
View file @
81dca07
...
...
@@ -248,7 +248,7 @@ extern void free_env_headers (compose_env_t *env);
/*extern void print_message (mu_message_t mesg, char *prefix, int all_headers, FILE *file);*/
extern
int
mail_mbox_commit
(
void
);
extern
int
mail_is_my_name
(
char
*
name
);
extern
int
mail_is_my_name
(
c
onst
c
har
*
name
);
extern
void
mail_set_my_name
(
char
*
name
);
extern
char
*
mail_whoami
(
void
);
extern
int
mail_header_is_visible
(
char
*
str
);
...
...
@@ -343,7 +343,7 @@ extern char *util_folder_path (const char *name);
extern
char
*
util_get_sender
(
int
msgno
,
int
strip
);
extern
void
util_slist_print
(
mu_list_t
list
,
int
nl
);
extern
int
util_slist_lookup
(
mu_list_t
list
,
char
*
str
);
extern
int
util_slist_lookup
(
mu_list_t
list
,
c
onst
c
har
*
str
);
extern
void
util_slist_add
(
mu_list_t
*
list
,
char
*
value
);
extern
void
util_slist_remove
(
mu_list_t
*
list
,
char
*
value
);
extern
void
util_slist_destroy
(
mu_list_t
*
list
);
...
...
@@ -381,7 +381,7 @@ extern int ml_reread (const char *prompt, char **text);
extern
char
*
ml_readline
(
char
*
prompt
);
extern
char
*
ml_readline_with_intr
(
char
*
prompt
);
extern
char
*
alias_expand
(
char
*
name
);
extern
char
*
alias_expand
(
c
onst
c
har
*
name
);
extern
void
alias_destroy
(
const
char
*
name
);
typedef
struct
alias_iterator
*
alias_iterator_t
;
...
...
@@ -404,8 +404,8 @@ extern void var_iterate_end (var_iterator_t *itr);
#define COMPOSE_SINGLE_LINE 2
void
compose_init
(
compose_env_t
*
env
);
int
compose_header_set
(
compose_env_t
*
env
,
char
*
name
,
char
*
value
,
int
replace
);
int
compose_header_set
(
compose_env_t
*
env
,
c
onst
c
har
*
name
,
c
onst
c
har
*
value
,
int
replace
);
char
*
compose_header_get
(
compose_env_t
*
env
,
char
*
name
,
char
*
defval
);
void
compose_destroy
(
compose_env_t
*
env
);
...
...
mail/reply.c
View file @
81dca07
...
...
@@ -70,7 +70,6 @@ reply0 (msgset_t *mspec, mu_message_t msg, void *data)
mu_address_t
addr
=
NULL
;
size_t
i
,
count
=
0
;
char
buf
[
512
];
if
(
mu_header_aget_value
(
hdr
,
MU_HEADER_TO
,
&
str
)
==
0
)
{
...
...
@@ -82,11 +81,13 @@ reply0 (msgset_t *mspec, mu_message_t msg, void *data)
/* Make sure we do not include our alternate names */
for
(
i
=
1
;
i
<=
count
;
i
++
)
{
mu_address_get_email
(
addr
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
const
char
*
email
;
if
(
mu_address_sget_email
(
addr
,
i
,
&
email
)
||
email
==
NULL
)
continue
;
if
((
util_getenv
(
NULL
,
"metoo"
,
Mail_env_boolean
,
0
)
==
0
)
||
!
mail_is_my_name
(
buf
))
||
!
mail_is_my_name
(
email
))
compose_header_set
(
&
env
,
MU_HEADER_TO
,
buf
,
email
,
COMPOSE_SINGLE_LINE
);
}
...
...
mail/send.c
View file @
81dca07
...
...
@@ -216,7 +216,8 @@ compose_init (compose_env_t * env)
}
int
compose_header_set
(
compose_env_t
*
env
,
char
*
name
,
char
*
value
,
int
mode
)
compose_header_set
(
compose_env_t
*
env
,
const
char
*
name
,
const
char
*
value
,
int
mode
)
{
int
status
;
char
*
old_value
;
...
...
mail/util.c
View file @
81dca07
...
...
@@ -868,7 +868,7 @@ util_slist_print (mu_list_t list, int nl)
}
int
util_slist_lookup
(
mu_list_t
list
,
char
*
str
)
util_slist_lookup
(
mu_list_t
list
,
c
onst
c
har
*
str
)
{
mu_iterator_t
itr
;
char
*
name
;
...
...
mailbox/attachment.c
View file @
81dca07
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2004, 2005,
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
...
...
@@ -142,8 +143,8 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
static
int
_attachment_setup
(
struct
_msg_info
**
info
,
mu_message_t
msg
,
mu_stream_t
*
stream
,
void
**
data
)
_attachment_setup
(
struct
_msg_info
**
info
,
mu_message_t
msg
,
mu_stream_t
*
stream
,
void
**
data
)
{
int
sfl
,
ret
;
mu_body_t
body
;
...
...
@@ -230,53 +231,8 @@ _header_get_param (char *field_body, const char *param, size_t * len)
return
NULL
;
}
#if 0
int
mu_message_get_attachment_name (mu_message_t msg, char *name, size_t bufsz, size_t *sz)
{
char *pTmp, *fname = NULL;
mu_header_t hdr;
int ret = EINVAL;
size_t size = 0;
if (filename != NULL && (ret = mu_message_get_header (msg, &hdr)) == 0)
{
*filename = NULL;
mu_header_get_value (hdr, "Content-Disposition", NULL, 0, &size);
if (size)
{
if ((pTmp = alloca (size + 1)) == NULL)
ret = ENOMEM;
mu_header_get_value (hdr, "Content-Disposition", pTmp, size + 1, 0);
if (strstr (pTmp, "attachment") != NULL)
fname = _header_get_param (pTmp, "filename", &size);
}
if (fname == NULL)
{
size = 0;
mu_header_get_value (hdr, "Content-Type", NULL, 0, &size);
if (size)
{
if ((pTmp = alloca (size + 1)) == NULL)
ret = ENOMEM;
mu_header_get_value (hdr, "Content-Type", pTmp, size + 1, 0);
fname = _header_get_param (pTmp, "name", &size);
}
}
if (fname)
{
fname[size] = '\0';
if ((*filename = strdup (fname)) == NULL)
ret = ENOMEM;
}
else
ret = MU_ERR_NOENT;
}
return ret;
}
#endif
int
mu_message_aget_attachment_name
(
mu_message_t
msg
,
char
**
name
)
mu_message_aget_attachment_name
(
mu_message_t
msg
,
char
**
name
)
{
size_t
sz
=
0
;
int
ret
=
0
;
...
...
@@ -299,7 +255,8 @@ int mu_message_aget_attachment_name(mu_message_t msg, char** name)
}
int
mu_message_get_attachment_name
(
mu_message_t
msg
,
char
*
buf
,
size_t
bufsz
,
size_t
*
sz
)
mu_message_get_attachment_name
(
mu_message_t
msg
,
char
*
buf
,
size_t
bufsz
,
size_t
*
sz
)
{
int
ret
=
EINVAL
;
mu_header_t
hdr
;
...
...
@@ -360,7 +317,8 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz, size_
}
int
mu_message_save_attachment
(
mu_message_t
msg
,
const
char
*
filename
,
void
**
data
)
mu_message_save_attachment
(
mu_message_t
msg
,
const
char
*
filename
,
void
**
data
)
{
mu_stream_t
istream
;
struct
_msg_info
*
info
=
NULL
;
...
...
mailbox/mutil.c
View file @
81dca07
...
...
@@ -354,7 +354,7 @@ mu_set_user_email (const char *candidate)
mu_address_t
addr
=
NULL
;
size_t
emailno
=
0
;
char
*
email
=
NULL
;
char
*
domain
=
NULL
;
c
onst
c
har
*
domain
=
NULL
;
if
((
err
=
mu_address_create
(
&
addr
,
candidate
))
!=
0
)
return
err
;
...
...
@@ -376,9 +376,8 @@ mu_set_user_email (const char *candidate)
mu_user_email
=
email
;
mu_address_aget_domain
(
addr
,
1
,
&
domain
);
if
((
err
=
mu_address_sget_domain
(
addr
,
1
,
&
domain
))
==
0
)
mu_set_user_email_domain
(
domain
);
free
(
domain
);
cleanup:
mu_address_destroy
(
&
addr
);
...
...
@@ -391,7 +390,7 @@ static char *mu_user_email_domain = 0;
int
mu_set_user_email_domain
(
const
char
*
domain
)
{
char
*
d
=
NULL
;
char
*
d
=
NULL
;
if
(
!
domain
)
return
EINVAL
;
...
...
mailbox/sendmail.c
View file @
81dca07
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 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
...
...
@@ -201,9 +201,9 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
{
int
tunnel
[
2
];
int
argc
=
0
;
char
**
argvec
=
NULL
;
c
onst
c
har
**
argvec
=
NULL
;
size_t
tocount
=
0
;
char
*
emailfrom
=
NULL
;
c
onst
c
har
*
emailfrom
=
NULL
;
/* Count the length of the arg vec: */
...
...
@@ -214,7 +214,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
if
(
from
)
{
if
((
status
=
mu_address_
a
get_email
(
from
,
1
,
&
emailfrom
))
!=
0
)
if
((
status
=
mu_address_
s
get_email
(
from
,
1
,
&
emailfrom
))
!=
0
)
goto
OPEN_STATE_CLEANUP
;
if
(
!
emailfrom
)
...
...
@@ -253,34 +253,18 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
argc
=
0
;
if
((
argvec
[
argc
++
]
=
strdup
(
sendmail
->
path
))
==
0
)
{
status
=
ENOMEM
;
goto
OPEN_STATE_CLEANUP
;
}
argvec
[
argc
++
]
=
sendmail
->
path
;
argvec
[
argc
++
]
=
"-oi"
;
if
((
argvec
[
argc
++
]
=
strdup
(
"-oi"
))
==
0
)
{
status
=
ENOMEM
;
goto
OPEN_STATE_CLEANUP
;
}
if
(
from
)
{
if
((
argvec
[
argc
++
]
=
strdup
(
"-f"
))
==
0
)
{
status
=
ENOMEM
;
goto
OPEN_STATE_CLEANUP
;
}
argvec
[
argc
++
]
=
"-f"
;
argvec
[
argc
++
]
=
emailfrom
;
}
if
(
!
to
||
mailer_property_is_set
(
mailer
,
"READ_RECIPIENTS"
))
{
if
((
argvec
[
argc
++
]
=
strdup
(
"-t"
))
==
0
)
{
status
=
ENOMEM
;
goto
OPEN_STATE_CLEANUP
;
}
argvec
[
argc
++
]
=
"-t"
;
}
else
{
...
...
@@ -291,8 +275,8 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
for
(;
i
<=
count
;
i
++
)
{
c
har
*
email
=
0
;
if
((
status
=
mu_address_
a
get_email
(
to
,
i
,
&
email
))
!=
0
)
c
onst
char
*
email
;
if
((
status
=
mu_address_
s
get_email
(
to
,
i
,
&
email
))
!=
0
)
goto
OPEN_STATE_CLEANUP
;
if
(
!
email
)
{
...
...
@@ -322,7 +306,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
SCLOSE
(
STDERR_FILENO
,
tunnel
);
close
(
tunnel
[
1
]);
dup2
(
tunnel
[
0
],
STDIN_FILENO
);
execv
(
sendmail
->
path
,
argvec
);
execv
(
sendmail
->
path
,
(
char
**
)
argvec
);
exit
(
errno
);
}
else
if
(
sendmail
->
pid
==
-
1
)
...
...
@@ -345,7 +329,6 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
for
(
argc
=
0
;
argvec
&&
argvec
[
argc
];
argc
++
)
{
MAILER_DEBUG1
(
mailer
,
MU_DEBUG_TRACE
,
" %s"
,
argvec
[
argc
]);
free
(
argvec
[
argc
]);
}
MAILER_DEBUG0
(
mailer
,
MU_DEBUG_TRACE
,
"
\n
"
);
free
(
argvec
);
...
...
mailbox/smtp.c
View file @
81dca07
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2006 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
...
...
@@ -95,7 +96,7 @@ struct _smtp
int
extended
;
char
*
mail_from
;
c
onst
c
har
*
mail_from
;
mu_address_t
rcpt_to
;
/* Destroy this if not the same as argto below. */
mu_address_t
rcpt_bcc
;
size_t
rcpt_to_count
;
...
...
@@ -140,10 +141,7 @@ CLEAR_STATE (smtp_t smtp)
smtp
->
extended
=
0
;
if
(
smtp
->
mail_from
)
{
free
(
smtp
->
mail_from
);
smtp
->
mail_from
=
NULL
;
}
if
(
smtp
->
rcpt_to
!=
smtp
->
argto
)
mu_address_destroy
(
&
smtp
->
rcpt_to
);
...
...
@@ -570,7 +568,7 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t argmsg, mu_address_t argfrom
smtp
->
argfrom
=
argfrom
;
smtp
->
argto
=
argto
;
status
=
mu_address_
a
get_email
(
smtp
->
argfrom
,
1
,
&
smtp
->
mail_from
);
status
=
mu_address_
s
get_email
(
smtp
->
argfrom
,
1
,
&
smtp
->
mail_from
);
CHECK_ERROR
(
smtp
,
status
);
status
=
_smtp_set_rcpt
(
smtp
,
smtp
->
argmsg
,
smtp
->
argto
);
...
...
@@ -626,11 +624,11 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t argmsg, mu_address_t argfrom
ENV_RCPT:
{
mu_address_t
addr
=
smtp
->
rcpt_to
;
char
*
to
=
NULL
;
c
onst
c
har
*
to
=
NULL
;
if
(
smtp
->
bccing
)
addr
=
smtp
->
rcpt_bcc
;
status
=
mu_address_
a
get_email
(
addr
,
smtp
->
rcpt_index
,
&
to
);
status
=
mu_address_
s
get_email
(
addr
,
smtp
->
rcpt_index
,
&
to
);
CHECK_ERROR
(
smtp
,
status
);
...
...
@@ -643,8 +641,6 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t argmsg, mu_address_t argfrom
status
=
smtp_writeline
(
smtp
,
"RCPT TO: <%s>
\r\n
"
,
to
);
free
(
to
);
CHECK_ERROR
(
smtp
,
status
);
smtp
->
state
=
SMTP_RCPT_TO
;
...
...
mh/mh.h
View file @
81dca07
...
...
@@ -309,7 +309,7 @@ void mh_expand_aliases (mu_message_t msg, mu_address_t *addr_to,
mu_address_t
*
addr_cc
,
mu_address_t
*
addr_bcc
);
int
mh_is_my_name
(
char
*
name
);
int
mh_is_my_name
(
c
onst
c
har
*
name
);
char
*
mh_my_email
(
void
);
int
mh_iterate
(
mu_mailbox_t
mbox
,
mh_msgset_t
*
msgset
,
...
...
mh/mh_format.c
View file @
81dca07
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
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
...
...
@@ -41,7 +41,7 @@ strobj_free (strobj_t *obj)
}
void
strobj_create
(
strobj_t
*
lvalue
,
char
*
str
)
strobj_create
(
strobj_t
*
lvalue
,
c
onst
c
har
*
str
)
{
if
(
!
str
)
{
...
...
@@ -366,11 +366,10 @@ addr_cmp (void *item, void *data)
mu_address_get_count
(
a
,
&
count
);
for
(
i
=
1
;
rc
==
0
&&
i
<=
count
;
i
++
)
{
char
*
str
;
if
(
mu_address_
a
get_email
(
a
,
i
,
&
str
))
c
onst
c
har
*
str
;
if
(
mu_address_
s
get_email
(
a
,
i
,
&
str
))
continue
;
rc
=
mu_address_contains_email
(
b
,
str
);
free
(
str
);
}
return
rc
;
}
...
...
@@ -1475,8 +1474,7 @@ static void
builtin_addr
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
const
char
*
str
;
int
rc
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
...
...
@@ -1484,8 +1482,8 @@ builtin_addr (struct mh_machine *mach)
if
(
rc
)
return
;
if
(
mu_address_
get_email
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
strobj_create
(
&
mach
->
arg_str
,
buf
);
if
(
mu_address_
sget_email
(
addr
,
1
,
&
str
)
==
0
)
strobj_create
(
&
mach
->
arg_str
,
str
);
mu_address_destroy
(
&
addr
);
}
...
...
@@ -1494,8 +1492,7 @@ static void
builtin_pers
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
const
char
*
str
;
int
rc
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
...
...
@@ -1503,11 +1500,10 @@ builtin_pers (struct mh_machine *mach)
if
(
rc
)
return
;
if
(
mu_address_get_personal
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
&&
n
>
1
)
if
(
mu_address_sget_personal
(
addr
,
1
,
&
str
)
==
0
&&
str
)
{
char
*
p
;
asprintf
(
&
p
,
"
\"
%s
\"
"
,
buf
);
asprintf
(
&
p
,
"
\"
%s
\"
"
,
str
);
strobj_create
(
&
mach
->
arg_str
,
p
);
free
(
p
);
}
...
...
@@ -1520,8 +1516,7 @@ static void
builtin_note
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
const
char
*
str
;
int
rc
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
...
...
@@ -1529,8 +1524,8 @@ builtin_note (struct mh_machine *mach)
if
(
rc
)
return
;
if
(
mu_address_
get_comments
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
strobj_create
(
&
mach
->
arg_str
,
buf
);
if
(
mu_address_
sget_comments
(
addr
,
1
,
&
str
)
==
0
)
strobj_create
(
&
mach
->
arg_str
,
str
);
mu_address_destroy
(
&
addr
);
}
...
...
@@ -1539,8 +1534,7 @@ static void
builtin_mbox
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
char
*
str
;
int
rc
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
...
...
@@ -1548,12 +1542,13 @@ builtin_mbox (struct mh_machine *mach)
if
(
rc
)
return
;
if
(
mu_address_
get_email
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
if
(
mu_address_
aget_email
(
addr
,
1
,
&
str
)
==
0
)
{
char
*
p
=
strchr
(
buf
,
'@'
);
char
*
p
=
strchr
(
str
,
'@'
);
if
(
p
)
*
p
=
0
;
strobj_create
(
&
mach
->
arg_str
,
p
);
free
(
str
);
}
mu_address_destroy
(
&
addr
);
}
...
...
@@ -1563,15 +1558,14 @@ static void
builtin_mymbox
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
const
char
*
str
;
mach
->
arg_num
=
0
;
if
(
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
)))
return
;
if
(
mu_address_
get_email
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
mach
->
arg_num
=
mh_is_my_name
(
buf
);
if
(
mu_address_
sget_email
(
addr
,
1
,
&
str
)
==
0
&&
str
)
mach
->
arg_num
=
mh_is_my_name
(
str
);
mu_address_destroy
(
&
addr
);
}
...
...
@@ -1580,8 +1574,7 @@ static void
builtin_host
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
char
*
str
;
int
rc
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
...
...
@@ -1589,11 +1582,12 @@ builtin_host (struct mh_machine *mach)
if
(
rc
)
return
;
if
(
mu_address_
get_email
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
if
(
mu_address_
aget_email
(
addr
,
1
,
&
str
)
==
0
)
{
char
*
p
=
strchr
(
buf
,
'@'
);
char
*
p
=
strchr
(
str
,
'@'
);
if
(
p
)
strobj_create
(
&
mach
->
arg_str
,
p
+
1
);
free
(
str
);
}
mu_address_destroy
(
&
addr
);
}
...
...
@@ -1603,17 +1597,15 @@ static void
builtin_nohost
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
int
rc
;
const
char
*
str
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
int
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
strobj_free
(
&
mach
->
arg_str
);
if
(
rc
)
return
;
if
(
mu_address_
get_email
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
mach
->
arg_num
=
strchr
(
buf
,
'@'
)
!=
NULL
;
if
(
mu_address_
sget_email
(
addr
,
1
,
&
str
)
==
0
&&
str
)
mach
->
arg_num
=
strchr
(
str
,
'@'
)
!=
NULL
;
else
mach
->
arg_num
=
0
;
mu_address_destroy
(
&
addr
);
...
...
@@ -1625,20 +1617,19 @@ static void
builtin_type
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
int
rc
;
const
char
*
str
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
strobj_free
(
&
mach
->
arg_str
);
if
(
rc
)
return
;
if
(
mu_address_
get_email
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
)
==
0
)
if
(
mu_address_
sget_email
(
addr
,
1
,
&
str
)
==
0
&&
str
)
{
if
(
strchr
(
buf
,
'@'
))
if
(
strchr
(
str
,
'@'
))
mach
->
arg_num
=
1
;
else
if
(
strchr
(
buf
,
'@
'
))
else
if
(
strchr
(
str
,
'!
'
))
mach
->
arg_num
=
-
1
;
else
mach
->
arg_num
=
0
;
/* assume local */
...
...
@@ -1653,16 +1644,13 @@ static void
builtin_path
(
struct
mh_machine
*
mach
)
{
mu_address_t
addr
;
size_t
n
;
char
buf
[
80
];
int
rc
;
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
const
char
*
str
;
int
rc
=
mu_address_create
(
&
addr
,
strobj_ptr
(
&
mach
->
arg_str
));
strobj_free
(
&
mach
->
arg_str
);
if
(
rc
)
return
;
if
(
mu_address_
get_route
(
addr
,
1
,
buf
,
sizeof
buf
,
&
n
))
strobj_create
(
&
mach
->
arg_str
,
buf
);
if
(
mu_address_
sget_route
(
addr
,
1
,
&
str
))
strobj_create
(
&
mach
->
arg_str
,
str
);
mu_address_destroy
(
&
addr
);
}
...
...
@@ -1691,7 +1679,7 @@ builtin_formataddr (struct mh_machine *mach)
size_t
size
;
int
i
;
size_t
num
;
char
*
buf
;
c
onst
c
har
*
buf
;
if
(
strobj_len
(
&
mach
->
reg_str
)
==
0
)
dest
=
NULL
;
...
...
@@ -1707,7 +1695,7 @@ builtin_formataddr (struct mh_machine *mach)
mu_address_get_count
(
addr
,
&
num
);
for
(
i
=
1
;
i
<=
num
;
i
++
)
{
if
(
mu_address_
a
get_email
(
addr
,
i
,
&
buf
)
==
0
)
if
(
mu_address_
s
get_email
(
addr
,
i
,
&
buf
)
==
0
)
{
if
((
rcpt_mask
&
RCPT_ME
)
||
!
mh_is_my_name
(
buf
))
{
...
...
@@ -1721,7 +1709,6 @@ builtin_formataddr (struct mh_machine *mach)
else
mu_address_destroy
(
&
subaddr
);
}
free
(
buf
);
}
}
...
...
mh/mh_format.h
View file @
81dca07
...
...
@@ -57,7 +57,7 @@ struct mh_machine
};
void
strobj_free
(
strobj_t
*
obj
);
void
strobj_create
(
strobj_t
*
lvalue
,
char
*
str
);
void
strobj_create
(
strobj_t
*
lvalue
,
c
onst
c
har
*
str
);
void
strobj_set
(
strobj_t
*
lvalue
,
char
*
str
);
void
strobj_assign
(
strobj_t
*
lvalue
,
strobj_t
*
rvalue
);
void
strobj_copy
(
strobj_t
*
lvalue
,
strobj_t
*
rvalue
);
...
...
mh/mh_init.c
View file @
81dca07
...
...
@@ -160,7 +160,7 @@ emailcmp (char *pattern, char *name)
}
int
mh_is_my_name
(
char
*
name
)
mh_is_my_name
(
c
onst
c
har
*
name
)
{
char
*
pname
,
*
p
;
int
rc
=
0
;
...
...
Please
register
or
sign in
to post a comment