mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-01-05 06:19:35 -05:00
A main program is compiled.
git-svn-id: file:///svn/unbound/trunk@5 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
de65410649
commit
7edbc1a683
7 changed files with 174 additions and 12 deletions
51
Makefile.in
51
Makefile.in
|
|
@ -1,5 +1,17 @@
|
|||
# Standard installation pathnames
|
||||
# Copyright 2007 NLnet Labs
|
||||
# See the file LICENSE for the license
|
||||
#
|
||||
# Standard installation pathnames
|
||||
|
||||
QUIET=yes
|
||||
ifeq "$(QUIET)" "yes"
|
||||
Q=@
|
||||
INFO=@echo
|
||||
else
|
||||
Q=
|
||||
INFO=@:
|
||||
endif
|
||||
|
||||
SHELL=@SHELL@
|
||||
VERSION=@PACKAGE_VERSION@
|
||||
srcdir=@srcdir@
|
||||
|
|
@ -21,6 +33,9 @@ LIBOBJS=@LIBOBJS@
|
|||
RUNTIME_PATH=@RUNTIME_PATH@
|
||||
DATE=$(shell date +%Y%m%d)
|
||||
LIBTOOL=$(libtool)
|
||||
ifeq "$(QUIET)" "yes"
|
||||
LIBTOOL+=--quiet
|
||||
endif
|
||||
BUILD=build/
|
||||
|
||||
LINT=splint
|
||||
|
|
@ -28,24 +43,35 @@ LINTFLAGS=+quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned
|
|||
|
||||
INSTALL=$(srcdir)/install-sh
|
||||
|
||||
COMMON_SRC=$(wildcard *.c)
|
||||
COMMON_SRC=$(wildcard services/*.c util/*.c)
|
||||
COMMON_OBJ=$(addprefix $(BUILD),$(COMMON_SRC:.c=.o) $(LIBOBJS))
|
||||
ALL_SOURCES=$(COMMON_SRC)
|
||||
UNITTEST_SRC=$(wildcard testcode/*.c)
|
||||
UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.o))
|
||||
DAEMON_SRC=$(wildcard daemon/*.c)
|
||||
DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.o))
|
||||
ALL_SRC=$(COMMON_SRC) $(UNITTEST_SRC) $(DAEMON_SRC)
|
||||
ALL_OBJ=$(addprefix $(BUILD),$(ALL_SRC:.c=.o) $(LIBOBJS))
|
||||
|
||||
COMPILE=$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK=$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS)
|
||||
LINK_LIB=$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -release $(VERSION)
|
||||
|
||||
$(BUILD)%.o: $(srcdir)/%.c
|
||||
@if test ! -d $(BUILD); then mkdir $(BUILD); fi
|
||||
$(COMPILE) -c $< -o $@
|
||||
$(INFO) Build $<
|
||||
@if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
|
||||
$Q$(COMPILE) -c $< -o $@
|
||||
|
||||
.PHONY: clean realclean doc lint all
|
||||
|
||||
all: $(COMMON_OBJ) main
|
||||
all: $(COMMON_OBJ) unbound unittest
|
||||
|
||||
main: $(COMMON_OBJ)
|
||||
$(LINK) -o $@ $<
|
||||
unbound: $(COMMON_OBJ) $(DAEMON_OBJ)
|
||||
$(INFO) Link $@
|
||||
$Q$(LINK) -o $@ $^
|
||||
|
||||
unittest: $(COMMON_OBJ) $(UNITTEST_OBJ)
|
||||
$(INFO) Link $@
|
||||
$Q$(LINK) -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o *.d *.lo *~ tags
|
||||
|
|
@ -57,7 +83,7 @@ realclean: clean
|
|||
rm -f Makefile
|
||||
|
||||
lint:
|
||||
for i in $(SOURCES); do \
|
||||
for i in $(ALL_SRC); do \
|
||||
$(LINT) $(LINTFLAGS) -I. -I$(srcdir) $(srcdir)/$$i ; \
|
||||
if [ $$? -ne 0 ] ; then exit 1 ; fi ; \
|
||||
done
|
||||
|
|
@ -67,9 +93,10 @@ tags: $(srcdir)/*.c ldns/*.[ch]
|
|||
|
||||
# Automatic dependencies.
|
||||
$(BUILD)%.d: $(srcdir)/%.c
|
||||
@if test ! -d $(BUILD); then mkdir $(BUILD); fi
|
||||
$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
|
||||
$(INFO) Depend $<
|
||||
@if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi
|
||||
$Q$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
|
||||
| sed '\''s!\(.*\)\.o[ :]*!$(dir $@)\1.o $@ : !g'\'' > $@; \
|
||||
[ -s $@ ] || rm -f $@'
|
||||
|
||||
-include $(addprefix $(BUILD),$(ALL_SOURCES:.c=.d))
|
||||
-include $(addprefix $(BUILD),$(ALL_SRC:.c=.d))
|
||||
|
|
|
|||
17
configure.ac
17
configure.ac
|
|
@ -208,6 +208,8 @@ AC_ARG_WITH(ldns,
|
|||
|
||||
AC_CHECK_LIB(ldns, ldns_rr_new,, [AC_MSG_ERROR([Can't find ldns library])])
|
||||
|
||||
AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.])
|
||||
|
||||
AH_BOTTOM([
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -238,6 +240,21 @@ AH_BOTTOM([
|
|||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ATTR_FORMAT
|
||||
# define ATTR_FORMAT(archetype, string_index, first_to_check) \
|
||||
__attribute__ ((format (archetype, string_index, first_to_check)))
|
||||
#else /* !HAVE_ATTR_FORMAT */
|
||||
# define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
|
||||
#endif /* !HAVE_ATTR_FORMAT */
|
||||
#if defined(__cplusplus)
|
||||
# define ATTR_UNUSED(x)
|
||||
#elif defined(HAVE_ATTR_UNUSED)
|
||||
# define ATTR_UNUSED(x) x __attribute__((unused))
|
||||
#else /* !HAVE_ATTR_UNUSED */
|
||||
# define ATTR_UNUSED(x) x
|
||||
#endif /* !HAVE_ATTR_UNUSED */
|
||||
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
|
|
|||
24
daemon/unbound.c
Normal file
24
daemon/unbound.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* daemon/unbound.c - main program for unbound DNS resolver daemon.
|
||||
*
|
||||
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* See LICENSE for the license.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "util/log.h"
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
if(argc != 1) {
|
||||
printf("usage: %s\n", argv[0]);
|
||||
printf("\tstart unbound daemon DNS resolver.\n");
|
||||
return 1;
|
||||
}
|
||||
log_init();
|
||||
log_info("Start of %s.", PACKAGE_STRING);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
You need a ssh login. There is no https access yet.
|
||||
- Added LICENSE, the BSD license.
|
||||
- Added doc/README with compile help.
|
||||
- main program stub and quiet makefile.
|
||||
- minimal logging service (to stderr).
|
||||
|
||||
15 December 2006: Wouter
|
||||
- Created Makefile.in and configure.ac.
|
||||
|
|
|
|||
21
testcode/unitmain.c
Normal file
21
testcode/unitmain.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* testcode/unitmain.c - unit test main program for unbound.
|
||||
*
|
||||
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* See LICENSE for the license.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc != 1) {
|
||||
printf("usage: %s\n", argv[0]);
|
||||
printf("\tperforms unit tests.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Start of %s unit test.\n", PACKAGE_STRING);
|
||||
return 0;
|
||||
}
|
||||
38
util/log.c
Normal file
38
util/log.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* util/log.c - implementation of the log code
|
||||
*
|
||||
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* See LICENSE for the license.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "util/log.h"
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
log_init()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
log_vmsg(const char *format, va_list args)
|
||||
{
|
||||
char message[MAXSYSLOGMSGLEN];
|
||||
const char* ident="unbound";
|
||||
vsnprintf(message, sizeof(message), format, args);
|
||||
fprintf(stderr, "[%d] %s[%d]: %s\n",
|
||||
(int)time(NULL), ident, (int)getpid(), message);
|
||||
}
|
||||
|
||||
void
|
||||
log_info(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_vmsg(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
33
util/log.h
Normal file
33
util/log.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* util/log.h - logging service
|
||||
*
|
||||
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* See LICENSE for the license.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UTIL_LOG_H
|
||||
#define UTIL_LOG_H
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* call this to initialize logging services
|
||||
*/
|
||||
void log_init();
|
||||
|
||||
/**
|
||||
* Pass printf formatted arguments. No trailing newline is needed.
|
||||
*/
|
||||
void log_info(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
|
||||
|
||||
/**
|
||||
* va_list argument version of log_info.
|
||||
*/
|
||||
void log_vmsg(const char *format, va_list args);
|
||||
|
||||
#endif /* UTIL_LOG_H */
|
||||
Loading…
Reference in a new issue