* For license terms, see the file COPYING in this directory.
*/
-/* We need this for HAVE_STDARG_H, etc */
#include "config.h"
struct addrinfo;
#endif
/* error.c: Error reporting */
-#if defined(HAVE_STDARG_H)
void report_init(int foreground);
/** Flush partial message, suppress program name tag for next report printout. */
void report_flush(FILE *fp);
void report_at_line (FILE *fp, int, const char *, unsigned int, const char *, ...)
__attribute__ ((format (printf, 5, 6)))
;
-#else
-void report ();
-void report_build ();
-void report_complete ();
-void report_at_line ();
-#endif
/* driver.c -- main driver loop */
void set_timeout(int);
int num,
flag *suppress_readbody);
int readbody(int sock, struct query *ctl, flag forward, int len);
-#if defined(HAVE_STDARG_H)
void gen_send(int sock, const char *, ... )
__attribute__ ((format (printf, 2, 3)))
;
int gen_transact(int sock, const char *, ... )
__attribute__ ((format (printf, 2, 3)))
;
-#else
-void gen_send();
-int gen_recv();
-int gen_transact();
-#endif
extern struct msgblk msgblk;
/* use these to track what was happening when the nonresponse timer fired */
void release_sink(struct query *);
int close_sink(struct query *, struct msgblk *, flag);
int open_warning_by_mail(struct query *);
-#if defined(HAVE_STDARG_H)
void stuff_warning(const char *, struct query *, const char *, ... )
__attribute__ ((format (printf, 3, 4)))
;
-#else
-void stuff_warning();
-#endif
void close_warning_by_mail(struct query *, struct msgblk *);
/* rfc822.c: RFC822 header parsing */
#include "i18n.h"
#include "fetchmail.h"
-#if defined(HAVE_VPRINTF) || defined(HAVE_DOPRNT) || defined(_LIBC) || defined(HAVE_STDARG_H)
-# if HAVE_STDARG_H
# include <stdarg.h>
-# define VA_START(args, lastarg) va_start(args, lastarg)
-# else
-# include <varargs.h>
-# define VA_START(args, lastarg) va_start(args)
-# endif
-#else
-# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
-# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
-#endif
#define MALLOC(n) xmalloc(n)
#define REALLOC(n,s) xrealloc(n,s)
static unsigned unbuffered;
static unsigned int use_syslog;
-#ifdef _LIBC
-/* In the GNU C library, there is a predefined variable for this. */
-
-# define program_name program_invocation_name
-# include <errno.h>
-
-#else
-
-# if !HAVE_STRERROR && !defined(strerror)
-char *strerror (int errnum)
-{
- extern char *sys_errlist[];
- extern int sys_nerr;
-
- if (errnum > 0 && errnum <= sys_nerr)
- return sys_errlist[errnum];
- return GT_("Unknown system error");
-}
-# endif /* HAVE_STRERROR */
-#endif /* _LIBC */
-
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args. */
-/* VARARGS */
-void
-#ifdef HAVE_STDARG_H
-report (FILE *errfp, const char *message, ...)
-#else
-report (FILE *errfp, message, va_alist)
- const char *message;
- va_dcl
-#endif
+void report(FILE *errfp, const char *message, ...)
{
-#ifdef VA_START
va_list args;
-#endif
/* If a partially built message exists, print it now so it's not lost. */
if (partial_message_size_used != 0)
{
int priority;
-#ifdef VA_START
- VA_START (args, message);
-#endif
+ va_start (args, message);
priority = (errfp == stderr) ? LOG_ERR : LOG_INFO;
#ifdef HAVE_VSYSLOG
}
#endif
-#ifdef VA_START
va_end(args);
-#endif
}
else /* i. e. not using syslog */
#endif
fprintf (errfp, "%s: ", program_name);
partial_suppress_tag = 0;
-#ifdef VA_START
- VA_START (args, message);
-# if defined(HAVE_VPRINTF) || defined(_LIBC)
+ va_start (args, message);
vfprintf (errfp, message, args);
-# else
- _doprnt (message, args, errfp);
-# endif
va_end (args);
-#else
- fprintf (errfp, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
fflush (errfp);
}
}
}
#endif
-void
-#ifdef HAVE_STDARG_H
-report_build (FILE *errfp, const char *message, ...)
-#else
-report_build (FILE *errfp, message, va_alist)
- const char *message;
- va_dcl
-#endif
+void report_build (FILE *errfp, const char *message, ...)
{
-#ifdef VA_START
va_list args;
-#else
- int n;
-#endif
rep_ensuresize();
-#if defined(VA_START)
VA_START(args, message);
report_vbuild(message, args);
va_end(args);
-#else
- for ( ; ; )
- {
- n = snprintf (partial_message + partial_message_size_used,
- partial_message_size - partial_message_size_used,
- message, a1, a2, a3, a4, a5, a6, a7, a8);
-
- /* output error, f. i. EILSEQ */
- if (n < 0) break;
-
- if (n >= 0
- && (unsigned)n < partial_message_size - partial_message_size_used)
- {
- partial_message_size_used += n;
- break;
- }
-
- partial_message_size += 2048;
- partial_message = REALLOC (partial_message, partial_message_size);
- }
-#endif
if (unbuffered && partial_message_size_used != 0)
{
be empty.) The completed report message is then printed (and reset to
empty.) */
/* VARARGS */
-void
-#ifdef HAVE_STDARG_H
-report_complete (FILE *errfp, const char *message, ...)
-#else
-report_complete (FILE *errfp, message, va_alist)
- const char *message;
- va_dcl
-#endif
+void report_complete (FILE *errfp, const char *message, ...)
{
-#ifdef VA_START
va_list args;
-#endif
rep_ensuresize();
-#if defined(VA_START)
VA_START(args, message);
report_vbuild(message, args);
va_end(args);
-#else
- report_build(errfp, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
/* Finally... print it. */
partial_message_size_used = 0;
static int error_one_per_line;
/* If errnum is nonzero, print its corresponding system error message. */
-void
-#ifdef HAVE_STDARG_H
-report_at_line (FILE *errfp, int errnum, const char *file_name,
+void report_at_line (FILE *errfp, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
-#else
-report_at_line (FILE *errfp, errnum, file_name, line_number, message, va_alist)
- int errnum;
- const char *file_name;
- unsigned int line_number;
- const char *message;
- va_dcl
-#endif
{
-#ifdef VA_START
va_list args;
-#endif
if (error_one_per_line)
{
if (file_name != NULL)
fprintf (errfp, "%s:%u: ", file_name, line_number);
-#ifdef VA_START
- VA_START (args, message);
-# if defined(HAVE_VPRINTF) || defined(_LIBC)
+ va_start (args, message);
vfprintf (errfp, message, args);
-# else
- _doprnt (message, args, errfp);
-# endif
va_end (args);
-#else
- fprintf (errfp, message, a1, a2, a3, a4, a5, a6, a7, a8);
-#endif
if (errnum)
fprintf (errfp, ": %s", strerror (errnum));
#endif /* HAVE_MEMORY_H */
#include <stdlib.h>
#include <unistd.h>
-#if defined(HAVE_STDARG_H)
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
#include <limits.h>
#ifdef HAVE_NET_SOCKET_H
}
}
-#if defined(HAVE_STDARG_H)
void gen_send(int sock, const char *fmt, ... )
-#else
-void gen_send(sock, fmt, va_alist)
-int sock; /* socket to which server is connected */
-const char *fmt; /* printf-style format */
-va_dcl
-#endif
/* assemble command in printf(3) style and send to the server */
{
char buf [MSGBUFSIZE+1];
else
buf[0] = '\0';
-#if defined(HAVE_STDARG_H)
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
vsnprintf(buf + strlen(buf), sizeof(buf)-2-strlen(buf), fmt, ap);
va_end(ap);
}
}
-#if defined(HAVE_STDARG_H)
int gen_transact(int sock, const char *fmt, ... )
-#else
-int gen_transact(int sock, fmt, va_alist)
-int sock; /* socket to which server is connected */
-const char *fmt; /* printf-style format */
-va_dcl
-#endif
/* assemble command in printf(3) style, send to server, accept a response */
{
int ok;
else
buf[0] = '\0';
-#if defined(HAVE_STDARG_H)
va_start(ap, fmt) ;
-#else
- va_start(ap);
-#endif
vsnprintf(buf + strlen(buf), sizeof(buf)-2-strlen(buf), fmt, ap);
va_end(ap);