]> Pileus Git - ~andy/fetchmail/blobdiff - env.c
Merge branch 'legacy_63'
[~andy/fetchmail] / env.c
diff --git a/env.c b/env.c
index 2ac5a6222c30349a51b6aee26e7abdbd41ebc526..7d03ae170a463502476d59b13bfae242fbd49a54 100644 (file)
--- a/env.c
+++ b/env.c
@@ -8,30 +8,21 @@
 #include "config.h"
 #include <stdio.h>
 #include <ctype.h>
-#if defined(STDC_HEADERS)
 #include <stdlib.h>
-#endif
-#if defined(HAVE_UNISTD_H)
 #include <unistd.h>
-#endif
 #include <pwd.h>
 #include <string.h>
-#ifdef HAVE_NET_SOCKET_H
-#include <net/socket.h>
-#endif
 #include <netdb.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include "fetchmail.h"
 #include "getaddrinfo.h"
 
-#include "i18n.h"
-#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS) && defined(HAVE_STRFTIME)
+#include "gettext.h"
+#if defined(ENABLE_NLS)
 #include <locale.h>
 #endif
 
-extern char *getenv(const char *);     /* needed on sysV68 R3V7.1. */
-
 void envquery(int argc, char **argv)
 /* set up basic stuff from the environment (including the rc file name) */
 {
@@ -105,6 +96,8 @@ void envquery(int argc, char **argv)
        user = xstrdup(pwp->pw_name);
     }
 
+    endpwent();
+
     /* compute user's home directory */
     home = getenv("HOME_ETC");
     if (!home && !(home = getenv("HOME")))
@@ -222,7 +215,6 @@ char *rfc822timestamp(void)
     static char buf[50];
 
     time(&now);
-#ifdef HAVE_STRFTIME
     /*
      * Conform to RFC822.  We generate a 4-digit year here, avoiding
      * Y2K hassles.  Max length of this timestamp in an English locale
@@ -231,25 +223,15 @@ char *rfc822timestamp(void)
      * weird multibyte i18n characters (such as kanji) from showing up
      * in your Received headers.
      */
-#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS)
+#if defined(ENABLE_NLS)
     setlocale (LC_TIME, "C");
 #endif
     strftime(buf, sizeof(buf)-1, 
             "%a, %d %b %Y %H:%M:%S XXXXX (%Z)", localtime(&now));
-#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS)
+#if defined(ENABLE_NLS)
     setlocale (LC_TIME, "");
 #endif
     strncpy(strstr(buf, "XXXXX"), tzoffset(&now), 5);
-#else
-    /*
-     * This is really just a portability fallback, as the
-     * date format ctime(3) emits is not RFC822
-     * conformant.
-     */
-    strlcpy(buf, ctime(&now), sizeof(buf));
-    buf[strlen(buf)-1] = '\0'; /* remove trailing \n */
-#endif /* HAVE_STRFTIME */
-
     return(buf);
 }
 
@@ -259,13 +241,8 @@ const char *showproto(int proto)
     switch (proto)
     {
     case P_AUTO: return("auto");
-#ifdef POP2_ENABLE
-    case P_POP2: return("POP2");
-#endif /* POP2_ENABLE */
 #ifdef POP3_ENABLE
     case P_POP3: return("POP3");
-    case P_APOP: return("APOP");
-    case P_RPOP: return("RPOP");
 #endif /* POP3_ENABLE */
 #ifdef IMAP_ENABLE
     case P_IMAP: return("IMAP");
@@ -290,7 +267,7 @@ char *visbuf(const char *buf)
 
     needed = strlen(buf) * 5 + 1; /* worst case: HEX, plus NUL byte */
 
-    if (needed > vbufs) {
+    if (!vbuf || needed > vbufs) {
        vbufs = needed;
        vbuf = (char *)xrealloc(vbuf, vbufs);
     }