get_default_username and the resulting const propagation

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6327 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-06-15 04:37:36 +00:00
parent e80311c0f6
commit 20a96cbc2e

View File

@@ -96,7 +96,7 @@ usage (int ret)
} }
static int static int
do_connect (char *host, int port, int nodelay) do_connect (const char *host, int port, int nodelay)
{ {
struct hostent *h; struct hostent *h;
struct sockaddr_in addr; struct sockaddr_in addr;
@@ -202,10 +202,10 @@ write_state_destroy (struct write_state *w)
static int static int
doit(int s, doit(int s,
char *host, const char *host,
char *user, const char *user,
char *outfilename, const char *outfilename,
char *header_str, const char *header_str,
int leavep, int leavep,
int verbose, int verbose,
int forkp) int forkp)
@@ -430,11 +430,11 @@ doit(int s,
#ifdef KRB5 #ifdef KRB5
static int static int
do_v5 (char *host, do_v5 (const char *host,
int port, int port,
char *user, const char *user,
char *filename, const char *filename,
char *header_str, const char *header_str,
int leavep, int leavep,
int verbose, int verbose,
int forkp) int forkp)
@@ -484,11 +484,11 @@ do_v5 (char *host,
#ifdef KRB4 #ifdef KRB4
static int static int
do_v4 (char *host, do_v4 (const char *host,
int port, int port,
char *user, const char *user,
char *filename, const char *filename,
char *header_str, const char *header_str,
int leavep, int leavep,
int verbose, int verbose,
int forkp) int forkp)
@@ -507,7 +507,7 @@ do_v4 (char *host,
s, s,
&ticket, &ticket,
"pop", "pop",
host, (char *)host,
krb_realmofhost(host), krb_realmofhost(host),
getpid(), getpid(),
&msg_data, &msg_data,
@@ -529,7 +529,7 @@ do_v4 (char *host,
#ifdef HESIOD_INTERFACES #ifdef HESIOD_INTERFACES
static char * static char *
hesiod_get_pobox (char **user) hesiod_get_pobox (const char **user)
{ {
void *context; void *context;
struct hesiod_postoffice *hpo; struct hesiod_postoffice *hpo;
@@ -560,7 +560,7 @@ hesiod_get_pobox (char **user)
#else /* !HESIOD_INTERFACES */ #else /* !HESIOD_INTERFACES */
static char * static char *
hesiod_get_pobox (char **user) hesiod_get_pobox (const char **user)
{ {
char *ret = NULL; char *ret = NULL;
struct hes_postoffice *hpo; struct hes_postoffice *hpo;
@@ -587,7 +587,7 @@ hesiod_get_pobox (char **user)
#endif /* HESIOD */ #endif /* HESIOD */
static char * static char *
get_pobox (char **user) get_pobox (const char **user)
{ {
char *ret = NULL; char *ret = NULL;
@@ -603,9 +603,10 @@ get_pobox (char **user)
} }
static void static void
parse_pobox (char *a0, char **host, char **user) parse_pobox (char *a0, const char **host, const char **user)
{ {
char *h, *u; const char *h, *u;
char *p;
int po = 0; int po = 0;
if (a0 == NULL) { if (a0 == NULL) {
@@ -628,27 +629,28 @@ parse_pobox (char *a0, char **host, char **user)
a0 += 3; a0 += 3;
po++; po++;
} }
h = strchr(a0, '@'); p = strchr(a0, '@');
if(h) if(p != NULL) {
*h++ = '\0'; *p++ = '\0';
else h = p;
} else {
h = a0; h = a0;
u = strchr(a0, ':'); }
if(u) p = strchr(a0, ':');
*u++ = '\0'; if(p != NULL) {
else *p++ = '\0';
u = p;
} else {
u = a0; u = a0;
}
if(h == u) { if(h == u) {
/* some inconsistent compatibility with various mailers */ /* some inconsistent compatibility with various mailers */
if(po) { if(po) {
h = get_pobox (&u); h = get_pobox (&u);
} else { } else {
struct passwd *pwd = getpwuid(getuid()); u = get_default_username ();
if (pwd == NULL)
errx (1, "Who are you?");
u = strdup(pwd->pw_name);
if (u == NULL) if (u == NULL)
errx (1, "strdup: out of memory"); errx (1, "Who are you?");
} }
} }
*host = h; *host = h;
@@ -661,7 +663,8 @@ main(int argc, char **argv)
int port = 0; int port = 0;
int optind = 0; int optind = 0;
int ret = 1; int ret = 1;
char *host, *user, *filename = NULL, *pobox = NULL; const char *host, *user, *filename = NULL;
char *pobox = NULL;
set_progname (argv[0]); set_progname (argv[0]);