#endif
#ifdef _AIX
-#include <ulimit.h>
+# include <ulimit.h>
#endif /* _AIX */
#ifdef SCO5_CLOCK
-#include <sys/ci/ciioctl.h>
+# include <sys/ci/ciioctl.h>
#endif
/*
* Signals which terminate us gracefully.
*/
#ifndef SYS_WINNT
-#define SIGDIE1 SIGHUP
-#define SIGDIE3 SIGQUIT
-#define SIGDIE2 SIGINT
-#define SIGDIE4 SIGTERM
+# define SIGDIE1 SIGHUP
+# define SIGDIE3 SIGQUIT
+# define SIGDIE2 SIGINT
+# define SIGDIE4 SIGTERM
#endif /* SYS_WINNT */
#if defined SYS_WINNT
/*
* Scheduling priority we run at
*/
-# define NTPD_PRIO (-12)
+#define NTPD_PRIO (-12)
/*
* Debugging flag
++done;
#endif
-# if defined(HAVE_SCHED_SETSCHEDULER)
+#if defined(HAVE_SCHED_SETSCHEDULER)
if (!done) {
extern int config_priority_override, config_priority;
int pmax, pmin;
else
++done;
}
-# endif /* HAVE_SCHED_SETSCHEDULER */
-# if defined(HAVE_RTPRIO)
-# ifdef RTP_SET
+#endif /* HAVE_SCHED_SETSCHEDULER */
+#if defined(HAVE_RTPRIO)
+# ifdef RTP_SET
if (!done) {
struct rtprio srtp;
else
++done;
}
-# else /* not RTP_SET */
+# else /* not RTP_SET */
if (!done) {
if (rtprio(0, 120) < 0)
msyslog(LOG_ERR, "rtprio() error: %m");
else
++done;
}
-# endif /* not RTP_SET */
-# endif /* HAVE_RTPRIO */
-# if defined(NTPD_PRIO) && NTPD_PRIO != 0
-# ifdef HAVE_ATT_NICE
+# endif /* not RTP_SET */
+#endif /* HAVE_RTPRIO */
+#if defined(NTPD_PRIO) && NTPD_PRIO != 0
+# ifdef HAVE_ATT_NICE
if (!done) {
errno = 0;
if (-1 == nice (NTPD_PRIO) && errno != 0)
else
++done;
}
-# endif /* HAVE_ATT_NICE */
-# ifdef HAVE_BSD_NICE
+# endif /* HAVE_ATT_NICE */
+# ifdef HAVE_BSD_NICE
if (!done) {
if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO))
msyslog(LOG_ERR, "setpriority() error: %m");
else
++done;
}
-# endif /* HAVE_BSD_NICE */
-# endif /* NTPD_PRIO && NTPD_PRIO != 0 */
+# endif /* HAVE_BSD_NICE */
+#endif /* NTPD_PRIO && NTPD_PRIO != 0 */
if (!done)
msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
}
# endif /* DEBUG */
{
# ifndef SYS_WINNT
-# ifdef HAVE_DAEMON
+# ifdef HAVE_DAEMON
daemon(0, 0);
-# else /* not HAVE_DAEMON */
+# else /* not HAVE_DAEMON */
if (fork()) /* HMS: What about a -1? */
exit(0);
msyslog(LOG_ERR, "ntpd: failed to close open files(): %m");
#else /* not F_CLOSEM */
-#if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
+# if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
max_fd = sysconf(_SC_OPEN_MAX);
-#else /* HAVE_SYSCONF && _SC_OPEN_MAX */
+# else /* HAVE_SYSCONF && _SC_OPEN_MAX */
max_fd = getdtablesize();
-#endif /* HAVE_SYSCONF && _SC_OPEN_MAX */
+# endif /* HAVE_SYSCONF && _SC_OPEN_MAX */
for (s = 0; s < max_fd; s++)
(void) close((int)s);
#endif /* not F_CLOSEM */
(void) sigaction(SIGDANGER, &sa, NULL);
#endif /* _AIX */
}
-#endif /* not HAVE_DAEMON */
-#else /* SYS_WINNT */
+# endif /* not HAVE_DAEMON */
+# else /* SYS_WINNT */
{
SERVICE_TABLE_ENTRY dispatchTable[] = {
ExitProcess(2);
}
}
-#endif /* SYS_WINNT */
+# endif /* SYS_WINNT */
}
-#endif /* NODETACH */
-#if defined(SYS_WINNT) && !defined(NODETACH)
+# endif /* NODETACH */
+# if defined(SYS_WINNT) && !defined(NODETACH)
else
service_main(argc, argv);
return 0; /* must return a value */
}
} /* debug */
-#endif /* defined(SYS_WINNT) && !defined(NODETACH) */
+# endif /* defined(SYS_WINNT) && !defined(NODETACH) */
#endif /* VMS */
/*
if (plock(PROCLOCK) < 0)
msyslog(LOG_ERR, "plock(PROCLOCK): %m");
# else /* not PROCLOCK */
-# ifdef TXTLOCK
+# ifdef TXTLOCK
/*
* Lock text into ram
*/
if (plock(TXTLOCK) < 0)
msyslog(LOG_ERR, "plock(TXTLOCK) error: %m");
-# else /* not TXTLOCK */
+# else /* not TXTLOCK */
msyslog(LOG_ERR, "plock() - don't know what to lock!");
-# endif /* not TXTLOCK */
+# endif /* not TXTLOCK */
# endif /* not PROCLOCK */
# endif /* HAVE_PLOCK */
#endif /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
# if defined(DEBUG)
if(!debug)
{
-#endif
+# endif
/* report to the service control manager that the service is running */
ssStatus.dwCurrentState = SERVICE_RUNNING;
ssStatus.dwWin32ExitCode = NO_ERROR;
}
# if defined(DEBUG)
}
-#endif
+# endif
#endif
/*
* and - lacking a hardware reference clock - I have
* yet to learn about anything else that is.
*/
-# if defined(HAVE_IO_COMPLETION_PORT)
+#if defined(HAVE_IO_COMPLETION_PORT)
WaitHandles[0] = CreateEvent(NULL, FALSE, FALSE, NULL); /* exit reques */
WaitHandles[1] = get_timer_handle();
} /* switch */
rbuflist = getrecvbufs(); /* get received buffers */
-# else /* normal I/O */
+#else /* normal I/O */
was_alarmed = 0;
rbuflist = (struct recvbuf *)0;
for (;;)
{
-# if !defined(HAVE_SIGNALED_IO)
+# if !defined(HAVE_SIGNALED_IO)
extern fd_set activefds;
extern int maxactivefd;
fd_set rdfdes;
int nfound;
-# elif defined(HAVE_SIGNALED_IO)
+# elif defined(HAVE_SIGNALED_IO)
block_io_and_alarm();
-# endif
+# endif
rbuflist = getrecvbufs(); /* get received buffers */
if (alarm_flag) /* alarmed? */
/*
* Nothing to do. Wait for something.
*/
-#ifndef HAVE_SIGNALED_IO
+# ifndef HAVE_SIGNALED_IO
rdfdes = activefds;
-# if defined(VMS) || defined(SYS_VXWORKS)
+# if defined(VMS) || defined(SYS_VXWORKS)
/* make select() wake up after one second */
{
struct timeval t1;
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
(fd_set *)0, &t1);
}
-# else
+# else
nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
(fd_set *)0, (struct timeval *)0);
-# endif /* VMS */
+# endif /* VMS */
if (nfound > 0)
{
l_fp ts;
else if (debug > 2) {
msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
}
-# else /* HAVE_SIGNALED_IO */
+# else /* HAVE_SIGNALED_IO */
wait_for_signal();
-# endif /* HAVE_SIGNALED_IO */
+# endif /* HAVE_SIGNALED_IO */
if (alarm_flag) /* alarmed? */
{
was_alarmed = 1;
was_alarmed = 0;
}
-# endif /* HAVE_IO_COMPLETION_PORT */
+#endif /* HAVE_IO_COMPLETION_PORT */
/*
* Call the data procedure to handle each received
* packet.
(rbuf->receiver)(rbuf);
freerecvbuf(rbuf);
}
-# if defined DEBUG && defined SYS_WINNT
+#if defined DEBUG && defined SYS_WINNT
if (debug > 4)
printf("getrecvbufs: %ld handler interrupts, %ld frames\n",
handler_calls, handler_pkts);
-# endif
+#endif
/*
* Go around again
switch (sig)
{
-#ifdef SIGBUS
+# ifdef SIGBUS
case SIGBUS:
printf("\nfinish(SIGBUS)\n");
exit(0);
-#endif
+# endif
case 0: /* Should never happen... */
return;
default: