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
926bc7a9
...
926bc7a99755dc3ed99a39a999caf7016f558de6
authored
2001-06-30 09:22:26 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Honour "metoo" variable. Try to determine user's full email address.
1 parent
20b323c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
1 deletions
mail/alt.c
mail/alt.c
View file @
926bc7a
...
...
@@ -16,8 +16,11 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "mail.h"
#include <pwd.h>
static
list_t
alternate_names
=
NULL
;
static
char
*
my_email
;
static
char
*
my_name
;
/*
* alt[ernates] name...
...
...
@@ -43,8 +46,49 @@ mail_alt (int argc, char **argv)
return
0
;
}
char
*
mail_whoami
()
{
return
my_name
;
}
/* FIXME: this lacks domain name part! */
void
mail_set_my_name
(
char
*
name
)
{
char
hostname
[
256
];
if
(
!
name
)
{
struct
passwd
*
pw
=
getpwuid
(
getuid
());
if
(
!
pw
)
{
util_error
(
"can't determine my username"
);
exit
(
1
);
}
name
=
pw
->
pw_name
;
}
my_name
=
strdup
(
name
);
gethostname
(
hostname
,
sizeof
(
hostname
));
hostname
[
sizeof
(
hostname
)
-
1
]
=
0
;
my_email
=
malloc
(
strlen
(
name
)
+
strlen
(
hostname
)
+
2
);
if
(
!
my_email
)
{
util_error
(
"not enough memory"
);
abort
();
}
sprintf
(
my_email
,
"%s@%s"
,
name
,
hostname
);
}
int
mail_is_
alt
_name
(
char
*
name
)
mail_is_
my
_name
(
char
*
name
)
{
if
(
util_find_env
(
"metoo"
)
->
set
)
return
0
;
if
(
strchr
(
name
,
'@'
)
==
NULL
&&
strcasecmp
(
name
,
my_name
)
==
0
)
return
1
;
if
(
strcasecmp
(
name
,
my_email
)
==
0
)
return
1
;
return
util_slist_lookup
(
alternate_names
,
name
);
}
...
...
Please
register
or
sign in
to post a comment