Commit 8211d82b authored by Dustin Lundquist's avatar Dustin Lundquist

Autotools

parent a474fa91
sni_proxy
a.out
*.o
*/core
.deps
depcomp
core
autoscan.log
aclocal.m4
autom4te.cache
configure
install-sh
missing
Makefile
Makefile.in
config.status
config.log
Copyright (c) 2011 - 2013, Dustin Lundquist <dustin@null-ptr.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
export CC = gcc
export CFLAGS = -std=c99 -Wall -Wextra -Wfatal-errors -pedantic-errors -O3 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L $(include_dirs) $(lib_dirs)
all:
${MAKE} -C src all
.PHONY: clean all test
clean:
${MAKE} -C src clean
${MAKE} -C tests clean
test: all
${MAKE} -C tests test
SUBDIRS = src \
tests
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([https-sni-proxy], [0.1])
AC_CONFIG_SRCDIR([src/sni_proxy.c])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
AC_CHECK_LIB([pcre], [pcre_exec])
# Checks for header files.
AC_FUNC_ALLOCA
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stddef.h stdlib.h string.h strings.h sys/socket.h sys/time.h syslog.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memset select socket strcasecmp strdup strerror strncasecmp])
AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile])
AC_OUTPUT
LIBS += -lpcre
MODULES = sni_proxy.o \
config.o \
cfg_parser.o \
cfg_tokenizer.o \
util.o \
server.o \
listener.o \
table.o \
backend.o \
connection.o \
buffer.o \
tls.o \
http.o
all: sni_proxy
%.o: %.c %.h
$(CC) $(CFLAGS) -c $<
sni_proxy: $(MODULES)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
.PHONY: clean all
clean:
rm -f *.o core sni_proxy
sbin_PROGRAMS = sni_proxy
sni_proxy_SOURCES = sni_proxy.c \
config.c \
cfg_parser.c \
cfg_tokenizer.c \
util.c \
server.c \
listener.c \
table.c \
backend.c \
connection.c \
buffer.c \
tls.c \
http.c
sni_proxy_LDADD = -lpcre
......@@ -82,6 +82,7 @@ struct Config *
init_config(const char *filename) {
FILE *file;
struct Config *config;
int i;
config = malloc(sizeof(struct Config));
if (config == NULL) {
......@@ -115,7 +116,7 @@ init_config(const char *filename) {
fprintf(stderr, "error parsing %s at %ld near:\n", filename, whence);
fseek(file, -20, SEEK_CUR);
for (int i = 0; i < 5; i++)
for (i = 0; i < 5; i++)
fprintf(stderr, "%ld\t%s", ftell(file), fgets(buffer, sizeof(buffer), file));
free_config(config);
......
*.test
http_test
tls_test
buffer_test
cfg_tokenizer_test
config_test
CFLAGS += -g -I ../src -L ../src
TESTS = http.test \
tls.test \
config.test \
buffer.test \
cfg_tokenizer.test
all: ${TESTS}
config.test: config.o ../src/config.o ../src/cfg_parser.o ../src/cfg_tokenizer.o ../src/util.o ../src/backend.o ../src/table.o ../src/listener.o ../src/connection.o ../src/buffer.o ../src/tls.o ../src/http.o
$(CC) $(CFLAGS) -o $@ $^ -l pcre
%.test: %.o ../src/%.o
$(CC) $(CFLAGS) -o $@ $^
%.o: %.c %.h
$(CC) $(CFLAGS) -o $@ -c $<
.PHONY: clean all
clean:
rm -f *.o core ${TESTS}
test: all
./run_tests.sh
AM_CPPFLAGS = -I$(top_srcdir)/src
TESTS = http_test \
tls_test \
buffer_test \
cfg_tokenizer_test \
config_test
check_PROGRAMS = http_test \
tls_test \
buffer_test \
cfg_tokenizer_test \
config_test
http_test_SOURCES = http_test.c \
../src/http.c
tls_test_SOURCES = tls_test.c \
../src/tls.c
buffer_test_SOURCES = buffer_test.c \
../src/buffer.c
cfg_tokenizer_test_SOURCES = cfg_tokenizer_test.c \
../src/cfg_tokenizer.c
config_test_SOURCES = config_test.c \
../src/config.c \
../src/cfg_parser.c \
../src/cfg_tokenizer.c \
../src/util.c \
../src/backend.c \
../src/table.c \
../src/listener.c \
../src/buffer.c \
../src/tls.c \
../src/http.c
......@@ -45,6 +45,8 @@ int main() {
FILE *cfg;
char buffer[256];
enum Token token;
struct Test *test;
int i;
cfg = tmpfile();
if (cfg == NULL) {
......@@ -52,11 +54,11 @@ int main() {
return 1;
}
for (struct Test *test = tests; test->config; test++) {
for (test = tests; test->config; test++) {
fprintf(cfg, "%s", test->config);
rewind(cfg);
for (int i = 0; i < test->len; i++) {
for (i = 0; i < test->len; i++) {
token = next_token(cfg, buffer, sizeof(buffer));
assert(token == test->results[i].type);
if (test->results[i].value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment