From b8ea620f7a1fdec7d67907ea36c134ea565b7c3c Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Fri, 22 May 2015 00:19:00 +0200 Subject: [PATCH] Default to port 8000 --- src/cfg.c | 2 +- src/cfg_private.h | 1 + tests/check_cfg.c | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index 2851f77..a88b9be 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -613,7 +613,7 @@ cfg_get_server_hostname(void) unsigned int cfg_get_server_port(void) { - return (cfg.server.port); + return (cfg.server.port ? cfg.server.port : DEFAULT_PORT); } const char * diff --git a/src/cfg_private.h b/src/cfg_private.h index b56e659..31b759f 100644 --- a/src/cfg_private.h +++ b/src/cfg_private.h @@ -27,6 +27,7 @@ #define EXTENSIONS_MAX 16 #define UCREDS_SIZE 256 +#define DEFAULT_PORT 8000 #define DEFAULT_USER "source" struct cfg { diff --git a/tests/check_cfg.c b/tests/check_cfg.c index 9f1e8ce..790bae0 100644 --- a/tests/check_cfg.c +++ b/tests/check_cfg.c @@ -231,6 +231,8 @@ START_TEST(test_server_port) { const char *errstr2; + ck_assert_uint_eq(cfg_get_server_port(), DEFAULT_PORT); + TEST_EMPTYSTR(cfg_set_server_port, cfg_get_server_port); errstr2 = NULL; @@ -241,8 +243,8 @@ START_TEST(test_server_port) ck_assert_int_eq(cfg_set_server_port("65536", &errstr2), -1); ck_assert_ptr_ne(errstr2, NULL); - ck_assert_int_eq(cfg_set_server_port("8000", NULL), 0); - ck_assert_uint_eq(cfg_get_server_port(), 8000); + ck_assert_int_eq(cfg_set_server_port("8008", NULL), 0); + ck_assert_uint_eq(cfg_get_server_port(), 8008); } END_TEST