6 #include <sys/socket.h> 15 if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &size,
sizeof(
int)) < 0)
16 INFO(
"(no sockopt/1: %m)");
20 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &size,
sizeof(
int)) < 0)
21 INFO(
"(no sockopt/2: %m)");
25 if (setsockopt(sock, IPPROTO_TCP, TCP_MAXSEG, &size,
sizeof(
int)) < 0)
26 INFO(
"(no sockopt/3: %m)");
33 strncpy(s1, s,
sizeof(s1));
34 if ((s2 = strstr(s,
"%m"))) {
35 strcpy(s1 + (s2 - s), strerror(errno));
37 strcpy(s1 + strlen(s1), s2);
41 else if ((s2 = strstr(s,
"%h"))) {
42 strcpy(s1 + (s2 - s), hstrerror(h_errno));
44 strcpy(s1 + strlen(s1), s2);
48 s1[
sizeof(s1)-1] =
'\0';
50 syslog(LOG_ERR,
"%s", s1);
51 syslog(LOG_ERR,
"Exiting.");
53 fprintf(stderr,
"Error: %s\nExiting.\n", s1);
56 void err(
const char *s) {
63 openlog(name, LOG_PID, LOG_DAEMON);
65 setvbuf(stdout, NULL, _IONBF, 0);
66 setvbuf(stderr, NULL, _IONBF, 0);
69 #ifdef WORDS_BIGENDIAN 75 u32 lo = a & 0xffffffff;
79 return ((u64) lo) << 32U | hi;
void setmysockopt(int sock)
void err_nonfatal(const char *s)
void logging(const char *name)