- int conn;
- if ((conn = accept(sock_fd, (struct sockaddr *) &sunx,
- &addrLength)) < 0) {
- perror ("accept");
- exit (FALSE); /* #### ??? */
- }
- FD_SET (conn, &readfds);
- }
- else {
-#define BUFSIZE 1024 + 1
- char buf[BUFSIZE];
- char *q, *p;
- int n_read;
-
- n_read = read (fd, buf, BUFSIZE);
-
- if (n_read < 0) {
- // FIXME .. fd isn't set
- perror ("read error");
- goto close_fd;
- }
- else if (n_read > 0) {
- char line[BUFSIZE];
- unsigned char c;
- int pri = (LOG_USER | LOG_NOTICE);
-
- memset (line, 0, sizeof(line));
- p = buf;
- q = line;
- while (p && (c = *p) && q < &line[sizeof(line) - 1]) {
- if (c == '<') {
- /* Parse the magic priority number */
- pri = 0;
- while (isdigit(*(++p))) {
- pri = 10 * pri + (*p - '0');
- }
- if (pri & ~(LOG_FACMASK | LOG_PRIMASK))
- pri = (LOG_USER | LOG_NOTICE);
- } else if (c == '\n') {
- *q++ = ' ';
- } else if (iscntrl(c) && (c < 0177)) {
- *q++ = '^';
- *q++ = c ^ 0100;
- } else {
- *q++ = c;
- }
- p++;
- }
- *q = '\0';
-
- /* Now log it */
- logMessage(pri, line);
-
- close_fd:
- close (fd);
- FD_CLR (fd, &readfds);
+
+ int conn;
+ pid_t pid;
+
+ if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
+ fatalError ("accept error: %s\n", strerror (errno));