diff options
-rw-r--r-- | src/slist.c | 13 | ||||
-rw-r--r-- | src/slist.h | 1 | ||||
-rw-r--r-- | src/tcpproxy.c | 8 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/slist.c b/src/slist.c index 8dd1963..24da141 100644 --- a/src/slist.c +++ b/src/slist.c @@ -115,3 +115,16 @@ void slist_clear(slist_t* lst) lst->first_ = NULL; } + +int slist_length(slist_t* lst) +{ + if(!lst || !lst->first_) + return 0; + + int len = 0; + slist_element_t* tmp; + for(tmp = lst->first_; tmp; tmp = tmp->next_) + len++; + + return len; +} diff --git a/src/slist.h b/src/slist.h index 4812192..f036bf3 100644 --- a/src/slist.h +++ b/src/slist.h @@ -46,5 +46,6 @@ int slist_init(slist_t* lst, void (*delete_element)(void*)); slist_element_t* slist_add(slist_t* lst, void* data); void slist_remove(slist_t* lst, void* data); void slist_clear(slist_t* lst); +int slist_length(slist_t* lst); #endif diff --git a/src/tcpproxy.c b/src/tcpproxy.c index ef71cb4..57d86b3 100644 --- a/src/tcpproxy.c +++ b/src/tcpproxy.c @@ -171,6 +171,14 @@ int main(int argc, char* argv[]) yyinit(&opt, &listeners); yyparse(); + + if(!slist_length(&listeners)) { + log_printf(ERROR, "no listeners defined in config file %s", opt.config_file_); + listener_clear(&listeners); + options_clear(&opt); + log_close(); + exit(-1); + } } priv_info_t priv; |