#include <locale.h>
#endif
+#ifndef HAVE_DECL_GETENV
extern char *getenv(const char *); /* needed on sysV68 R3V7.1. */
+#endif
void envquery(int argc, char **argv)
/* set up basic stuff from the environment (including the rc file name) */
user = xstrdup(pwp->pw_name);
}
+ endpwent();
+
/* compute user's home directory */
home = getenv("HOME_ETC");
if (!home && !(home = getenv("HOME")))
- home = pwp->pw_dir;
+ home = xstrdup(pwp->pw_dir);
/* compute fetchmail's home directory */
if (!(fmhome = getenv("FETCHMAILHOME")))
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags=AI_CANONNAME;
+ hints.ai_flags = AI_CANONNAME;
e = fm_getaddrinfo(tmpbuf, NULL, &hints, &res);
if (e) {
}
}
- result = xstrdup(res->ai_canonname);
+ result = xstrdup(res->ai_canonname ? res->ai_canonname : tmpbuf);
fm_freeaddrinfo(res);
}
else
needed = strlen(buf) * 5 + 1; /* worst case: HEX, plus NUL byte */
- if (needed > vbufs) {
+ if (!vbuf || needed > vbufs) {
vbufs = needed;
- vbuf = xrealloc(vbuf, vbufs);
+ vbuf = (char *)xrealloc(vbuf, vbufs);
}
tp = vbuf;
buf++;
}
}
- *tp++ = '\0';
+ *tp = '\0';
return(vbuf);
}
/* env.c ends here */