#include <netdb.h>
#endif /* HAVE_GETHOSTBYNAME */
#include <sys/types.h>
-#include <time.h>
#include "fetchmail.h"
#include "i18n.h"
#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS) && defined(HAVE_STRFTIME)
-#include <time.h>
#include <locale.h>
#endif
-extern char *getenv(); /* needed on sysV68 R3V7.1. */
-
-extern char *program_name;
+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) */
}
/* compute user's home directory */
- if (!(home = getenv("HOME")))
+ home = getenv("HOME_ETC");
+ if (!home && !(home = getenv("HOME")))
home = pwp->pw_dir;
/* compute fetchmail's home directory */
}
if (off >= 24 * 60) /* should be impossible */
off = 23 * 60 + 59; /* if not, insert silly value */
- sprintf(offset_string, "%c%02d%02d", sign, off / 60, off % 60);
+ snprintf(offset_string, sizeof(offset_string),
+ "%c%02d%02d", sign, off / 60, off % 60);
return (offset_string);
}
* weird multibyte i18n characters (such as kanji) from showing up
* in your Received headers.
*/
-#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS) && defined(HAVE_STRFTIME)
+#if defined(HAVE_SETLOCALE) && 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) && defined(HAVE_STRFTIME)
+#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS)
setlocale (LC_TIME, "");
#endif
strncpy(strstr(buf, "XXXXX"), tzoffset(&now), 5);
*tp++ = '\\'; *tp++ = '\\';
buf++;
}
- else if (isprint(*buf) || *buf == ' ')
+ else if (isprint((unsigned char)*buf) || *buf == ' ')
*tp++ = *buf++;
else if (*buf == '\n')
{
}
else
{
- (void) sprintf(tp, "\\0x%02x", *buf++);
- tp += strlen(tp);
+ const char hex[] = "0123456789abcdef";
+ *tp++ = '\\'; *tp++ = '0'; *tp++ = 'x';
+ *tp++ = hex[*buf >> 4];
+ *tp++ = hex[*buf & 0xf];
+ buf++;
}
}
*tp++ = '\0';