Changed name of debug output function to avoid name collision with opt flag variable
kod_management.c:
Changed from fgets to fscanf (easier data extraction)
bk: 48862c5eW1GYMr0q-evEaH8KVflhxw
build_triplet = i386-unknown-freebsd7.0
host_triplet = i386-unknown-freebsd7.0
bin_PROGRAMS = sntp$(EXEEXT)
-DIST_COMMON = $(am__configure_deps) $(srcdir)/../config.guess \
- $(srcdir)/../config.sub $(srcdir)/../depcomp \
- $(srcdir)/../install-sh $(srcdir)/../ltmain.sh \
- $(srcdir)/../missing $(srcdir)/Makefile.am \
+DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/bincheck.mf \
$(srcdir)/config.h.in $(top_srcdir)/configure config.guess \
- config.sub
+ config.sub depcomp install-sh ltmain.sh missing
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
sntp_LDADD = $(LDADD)
sntp_DEPENDENCIES =
DEFAULT_INCLUDES = -I.
-depcomp = $(SHELL) $(top_srcdir)/../depcomp
+depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
-ACLOCAL = ${SHELL} /home/Amidamaru/projects/sntp/dev/missing --run aclocal-1.10
-AMTAR = ${SHELL} /home/Amidamaru/projects/sntp/dev/missing --run tar
+ACLOCAL = ${SHELL} /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/missing --run aclocal-1.10
+AMTAR = ${SHELL} /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/missing --run tar
AR = ar
-AUTOCONF = ${SHELL} /home/Amidamaru/projects/sntp/dev/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/Amidamaru/projects/sntp/dev/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/Amidamaru/projects/sntp/dev/missing --run automake-1.10
+AUTOCONF = ${SHELL} /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/missing --run autoconf
+AUTOHEADER = ${SHELL} /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/missing --run autoheader
+AUTOMAKE = ${SHELL} /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/missing --run automake-1.10
AWK = gawk
BINSUBDIR = bin
CC = gcc
LIBTOOL = $(SHELL) $(top_builddir)/libtool
LN_S = ln -s
LTLIBOBJS =
-MAKEINFO = ${SHELL} /home/Amidamaru/projects/sntp/dev/missing --run makeinfo
-MKDIR_P = ./../install-sh -c -d
+MAKEINFO = ${SHELL} /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/missing --run makeinfo
+MKDIR_P = ./install-sh -c -d
NMEDIT =
OBJEXT = o
PACKAGE = msntp
SHELL = /usr/local/bin/bash
STRIP = strip
VERSION = 1.6
-abs_builddir = /home/Amidamaru/projects/sntp/dev/sntp
-abs_srcdir = /home/Amidamaru/projects/sntp/dev/sntp
-abs_top_builddir = /home/Amidamaru/projects/sntp/dev/sntp
-abs_top_srcdir = /home/Amidamaru/projects/sntp/dev/sntp
+abs_builddir = /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp
+abs_srcdir = /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp
+abs_top_builddir = /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp
+abs_top_srcdir = /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp
ac_ct_CC = gcc
ac_ct_CXX = g++
ac_ct_F77 = f77
htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
-install_sh = $(SHELL) /home/Amidamaru/projects/sntp/dev/install-sh
+install_sh = $(SHELL) /geom_mobile/home/Amidamaru/projects/sntp/repo/gsoc_sntp/install-sh
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
localstatedir = ${prefix}/var
mandir = ${datarootdir}/man
-mkdir_p = $(top_builddir)/./../install-sh -c -d
+mkdir_p = $(top_builddir)/./install-sh -c -d
oldincludedir = /usr/include
pdfdir = ${docdir}
prefix = /usr/local
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = sntp$(EXEEXT)
-DIST_COMMON = $(am__configure_deps) $(srcdir)/../config.guess \
- $(srcdir)/../config.sub $(srcdir)/../depcomp \
- $(srcdir)/../install-sh $(srcdir)/../ltmain.sh \
- $(srcdir)/../missing $(srcdir)/Makefile.am \
+DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/bincheck.mf \
$(srcdir)/config.h.in $(top_srcdir)/configure config.guess \
- config.sub
+ config.sub depcomp install-sh ltmain.sh missing
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
sntp_LDADD = $(LDADD)
sntp_DEPENDENCIES =
DEFAULT_INCLUDES = -I.@am__isrc@
-depcomp = $(SHELL) $(top_srcdir)/../depcomp
+depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
return resc;
}
-
void
add_entry (
char *hostname,
{
if(kod_init) {
struct kod_entry *new_entry = (struct kod_entry *) malloc(sizeof(struct kod_entry));
- new_entry->hostname = hostname;
+ strcpy(new_entry->hostname, hostname);
strlcpy(new_entry->type, type, 4);
new_entry->next = NULL;
}
}
}
-
-
-
void
write_kod_db (
register int a, b;
- char *fbuf = (char *) malloc(sizeof(char) * 80);
+ /* Max. of 255 characters for hostname, 10 for timestamp, 4 for kisscode, 2 for format : and 1 for \n */
+ char *fbuf = (char *) malloc(sizeof(char) * 272);
char *obuf = fbuf;
+ char error = 0;
+
db_s = fopen(db_file, "r");
snprintf(msg, 80, "Cannot open KOD db file %s", db_file);
if(debug)
- debug(msg);
+ debug_msg(msg);
log_msg(msg, 2);
}
/* First let's see how many entries there are and check for right syntax */
- while(fread(&fbuf, 80, sizeof(char), db_s) != 0) {
+ while(fgets(fbuf, 272, db_s) != 0) {
int sepc = 0;
for(a=0; a<strlen(fbuf); a++) {
if(fbuf[a] == ':')
if(fbuf[a] == '\n') {
if(sepc != 2) {
char msg[80];
- snprintf(msg, 80, "Syntax error in KOD db file %s in line %i", db_file, (entryc + 1));
+ snprintf(msg, 80, "Syntax error in KOD db file %s in line %i (missing :)", db_file, (entryc + 1));
if(debug)
- debug(msg);
+ debug_msg(msg);
log_msg(msg, 1);
kod_db = (struct kod_entry *) malloc(sizeof(struct kod_entry) * entryc);
-
/* Read contents of file and make a linked list */
for(b=0; (!feof(db_s) || !ferror(db_s)) && b<entryc; b++) {
- fbuf = obuf;
- fgets(fbuf, 80, db_s);
-
- char fstart = 0;
- int limit = strlen(fbuf);
- char argn;
-
- for(a=0; a<limit; a++) {
- argn = 0;
-
- if(fbuf[a] == ':' || fbuf[a] == '\n' || fbuf[a] == '\0') {
- char *tmp;
- switch(argn) {
- case 0:
- kod_db[b].hostname = (char *) malloc(sizeof(char) * a);
- strlcpy(kod_db[b].hostname, fbuf, a);
- break;
-
- case 1:
- tmp = (char *) malloc(sizeof(char) * a);
- strlcpy(tmp, fbuf, a);
- kod_db[b].timestamp = atoi(tmp);
- free(tmp);
- break;
-
- case 2:
- tmp = (char *) malloc(sizeof(char) * a);
- strlcpy(tmp, fbuf, a);
- strlcpy(kod_db[b].type, tmp, 4);
- free(tmp);
- break;
-
- }
-
- fstart = a+1;
- fbuf = &fbuf[fstart];
- limit -= fstart;
- a = 0;
- argn++;
- }
+ if(!fscanf(db_s,
+ "%s:%u:%s", kod_db[a].hostname,
+ kod_db[a].timestamp,
+ kod_db[a].type)) {
+ b = entryc;
+ error = 1;
+ }
+ else {
+ if(b > 0)
+ kod_db[b-1].next = &kod_db[b];
}
- if(b > 0)
- kod_db[b-1].next = &kod_db[b];
-
}
- if(ferror(db_s)) {
+ if(ferror(db_s) || error) {
char msg[80];
- snprintf(msg, 80, "ferror indicates an error after parsing KOD db file %s", db_file);
+ snprintf(msg, 80, "An error occured while parsing the KOD db file %s", db_file);
if(debug)
- debug(msg);
+ debug_msg(msg);
log_msg(msg, 2);
#define KOD_MANAGEMENT_H
struct kod_entry {
- char *hostname;
+ char hostname[255];
unsigned int timestamp;
char type[4];
struct kod_entry *next;
}
}
-void debug(char *message) {
+void debug_msg(char *message) {
if(HAVE_OPT(FILELOG)) {
fprintf(stderr, message);
}
#include <stdarg.h>
void log_msg(char *message, char type);
-void debug(char *message);
+void debug_msg(char *message);
char init = 0;
FILE *log_file;
#include "log.h"
-int resolve_hosts (char **hosts, int hostc, struct addrinfo **res) {
+int
+resolve_hosts (
+ char **hosts,
+ int hostc,
+ struct addrinfo **res
+ )
+{
register unsigned int a, b;
unsigned int entryc = 0;
}
/* Send a packet */
-static void
+void
sendpkt (
- struct sockaddr_storage *dest,
- struct pkt *pkt,
- int len
+ struct sockaddr_storage *dest,
+ struct pkt *pkt,
+ int len
)
{
int sock;
/* Do authentication stuff here */
/* Left for now, finishin other stuff. I think I might want that somewhere else,
- * don't want this function to do on-wire tasks. Sanity checks are right here I think
+ * don't want this function to do on-wire stuff. Sanity checks are right here I think
*
server->leap = PKT_LEAP(rpkt->li_vn_mode);
server->stratum = PKT_TO_STRATUM(rpkt->stratum);
* (non-blocking).
*/
int
-is_reachable (struct addrinfo *dst)
+is_reachable (
+ struct addrinfo *dst
+ )
{
SOCKET sockfd;
for(a=0; a<filter_elements; a++)
cpyres[a] = res[index[a]];
-
-
+
+
for(a=0, b=0; a<resc; a++) {
if(a == index[b])
b++;
else
freeaddrinfo(res[a]);
}
-
+
res = cpyres;
-
+
return filter_elements;
}
int resc
)
{
+ return 0;
}
/* FIXME, see portability issue 1 */ /* irrelevant for now */
#ifndef SYS_WINNT
-# define SOCKET int
-# define INVALID_SOCKET -1
-# define SOCKET_ERROR -1
-# define closesocket close
+#define SOCKET int
+#define INVALID_SOCKET -1
+#define SOCKET_ERROR -1
+#define closesocket close
#endif
/* Check if necessary or not */