1 /**************************************************************************
3 * Copyright (C) 1995 Silicon Graphics, Inc.
5 * These coded instructions, statements, and computer programs were
6 * developed by SGI for public use. If any changes are made to this code
7 * please try to get the changes back to the author. Feel free to make
8 * modifications and changes to the code and release it.
10 **************************************************************************/
12 /* errexit call for general error handling */
21 #include <sys/types.h>
27 #define VPRINTF(stderr, format, args) vfprintf((stderr), (format), (args))
30 #define VPRINTF(stderr, format, args) _doprnt((format), (args), (stderr))
31 #endif /* HAVE_DOPRNT */
32 #endif /* HAVE_VPRINTF */
34 /* print an error message and exit 1 */
36 errexit(const char *format
, ...)
39 char hostname
[64] = "";
43 gethostname(hostname
, sizeof(hostname
));
44 fprintf(stderr
, "%s PID %d: ", hostname
, PID
);
46 va_start(args
, format
);
47 VPRINTF(stderr
, format
, args
);
48 debug
&& VPRINTF(debugfile
, format
, args
);
55 /* print an error message and return -1 */
57 returnerr(const char *format
, ...)
60 char hostname
[64] = "";
64 gethostname(hostname
, sizeof(hostname
));
65 fprintf(stderr
, "%s PID %d: ", hostname
, PID
);
67 va_start(args
, format
);
68 VPRINTF(stderr
, format
, args
);
69 debug
&& VPRINTF(debugfile
, format
, args
);
72 debug
&& fflush(debugfile
);
77 /* print a debug message and then flush */
79 d_printf(const char *format
, ...)
83 va_start(args
, format
);
84 VPRINTF(debugfile
, format
, args
);
92 /* returns the last network error as a string */
93 char *neterrstr(void) {
97 sprintf(buf
, "WSAGetLastError() = %d", WSAGetLastError());
100 sprintf(buf
, "errno = %d: %s", errno
, strerror(errno
));