EXTRA_OBJS=@EXTRA_OBJECTS@
CLI_OBJS = client.o md5.o nameserv.o getdate.o cmdparse.o \
- pktlength.o
+ pktlength.o util.o
SRCS = $(patsubst %.o,%.c,$(OBJS))
EXTRA_SRCS = $(patsubst %.o,%.c,$(EXTRA_OBJS))
#include "cmdparse.h"
#include "pktlength.h"
#include "memory.h"
+#include "util.h"
#ifdef FEAT_READLINE
#ifdef USE_EDITLINE
return buffer;
}
-/* ================================================== */
-
-static char *
-UTI_RefidToString(unsigned long ref_id)
-{
- unsigned int a, b, c, d;
- static char result[64];
- a = (ref_id>>24) & 0xff;
- b = (ref_id>>16) & 0xff;
- c = (ref_id>> 8) & 0xff;
- d = (ref_id>> 0) & 0xff;
- snprintf(result, sizeof(result), "%c%c%c%c", a, b, c, d);
- return result;
-}
-
-static char *
-UTI_IPToDottedQuad(unsigned long ip)
-{
- unsigned long a, b, c, d;
- static char result[64];
- a = (ip>>24) & 0xff;
- b = (ip>>16) & 0xff;
- c = (ip>> 8) & 0xff;
- d = (ip>> 0) & 0xff;
- snprintf(result, sizeof(result), "%ld.%ld.%ld.%ld", a, b, c, d);
- return result;
-}
-
/* ================================================== */
/* Read a single line of commands from standard input. Eventually we
might want to use the GNU readline library. */
#include "memory.h"
#include "reports.h"
#include "util.h"
+#include "logging.h"
/* Number of bits of address per layer of the table. This value has
been chosen on the basis that a server will predominantly be serving
}
/* ================================================== */
+/* Force a core dump and exit without doing abort() or assert(0).
+ These do funny things with the call stack in the core file that is
+ generated, which makes diagnosis difficult. */
+
+int
+croak(const char *file, int line, const char *msg)
+{
+ int a;
+ LOG(LOGS_ERR, LOGF_Util, "Unexpected condition [%s] at %s:%d, core dumped",
+ msg, file, line);
+ a = * (int *) 0;
+ return a; /* Can't happen - this stops the optimiser optimising the
+ line above */
+}
+
+/* ================================================== */
#define LOG_FATAL LOG_Position(__FILE__, __LINE__, ""); LOG_Fatal_Function
#endif /* defined (__GNUC__) */
+/* Like assert(0) */
+
+#if defined(LINUX) && defined(__alpha__)
+#define CROAK(message) assert(0) /* Added JGH Feb 24 2001 FIXME */
+#else
+extern int croak(const char *file, int line, const char *msg);
+#define CROAK(message) croak(__FILE__, __LINE__, message);
+#endif
+
#endif /* GOT_LOGGING_H */
#include "sysincl.h"
#include "util.h"
-#include "logging.h"
/* ================================================== */
} else if (a->tv_sec > b->tv_sec) {
return +1;
} else {
- if (a->tv_sec != b->tv_sec) {
- CROAK("a->tv_sec != b->tv_sec");
- }
if (a->tv_usec < b->tv_usec) {
return -1;
} else if (a->tv_usec > b->tv_usec) {
return +1;
} else {
- if (a->tv_usec != b->tv_usec) {
- CROAK("a->tv_usec != b->tv_usec");
- }
return 0;
}
}
- CROAK("Impossible"); /* Shouldn't be able to fall through. */
}
/* ================================================== */
}
/* ================================================== */
-/* Force a core dump and exit without doing abort() or assert(0).
- These do funny things with the call stack in the core file that is
- generated, which makes diagnosis difficult. */
-
-int
-croak(const char *file, int line, const char *msg)
-{
- int a;
- LOG(LOGS_ERR, LOGF_Util, "Unexpected condition [%s] at %s:%d, core dumped",
- msg, file, line);
- a = * (int *) 0;
- return a; /* Can't happen - this stops the optimiser optimising the
- line above */
-}
-
-/* ================================================== */
extern void UTI_Int64ToTimeval(NTP_int64 *src, struct timeval *dest);
-/* Like assert(0) */
-
-#if defined(LINUX) && defined(__alpha__)
-#define CROAK(message) assert(0) /* Added JGH Feb 24 2001 FIXME */
-#else
-extern int croak(const char *file, int line, const char *msg);
-#define CROAK(message) croak(__FILE__, __LINE__, message);
-#endif
-
#if defined (INLINE_UTILITIES)
#define INLINE_STATIC inline static
#include "util.c"