From 6a878d00ccfe153d8b7b3950f34accc8c82bc4a2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 13 May 2006 21:50:50 +0000 Subject: merge patch from "TFKyle", which fixes the parsing of ServerName directives when port numbers are specified git-svn-id: file:///home/lennart/svn/public/mod_dnssd/trunk@56 634eccf8-0006-0410-930e-e16565b0b7de --- src/mod_dnssd.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/mod_dnssd.c b/src/mod_dnssd.c index 21edb42..c715045 100644 --- a/src/mod_dnssd.c +++ b/src/mod_dnssd.c @@ -141,10 +141,22 @@ static void assemble_services(struct runtime_data *r) { for (v = ap_conftree; v; v = v->next) { const char *a = v->args; - if (strcasecmp(v->directive, "ServerName") == 0) - default_host_name = ap_getword_conf(t, &a); - - else if (strcasecmp(v->directive, "Listen") == 0) { + if (strcasecmp(v->directive, "ServerName") == 0) { + const char *tdhn = NULL; + char *colon; + tdhn = ap_getword_conf(t, &a); + colon = strrchr(tdhn, ':'); + if (colon) { + apr_size_t sz; + if (!default_port) { + default_port = (uint16_t) atoi(colon+1); + } + sz = colon - tdhn; + default_host_name = apr_pstrndup(t, tdhn, sz); + } else { + default_host_name = tdhn; + } + } else if (strcasecmp(v->directive, "Listen") == 0) { char *sp; if (!default_port) { @@ -178,8 +190,21 @@ static void assemble_services(struct runtime_data *r) { /* ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->main_server, "VHOST_INTERNAL %s | %s | %s | %s", l->directive, l->args, vname, vtypes); */ - if (strcasecmp(l->directive, "ServerName") == 0) - host_name = ap_getword_conf(t, &a); + if (strcasecmp(l->directive, "ServerName") == 0) { + const char *thn = NULL; + thn = ap_getword_conf(t, &a); + colon = strrchr(thn, ':'); + if (colon) { + apr_size_t sz; + if (!vport) { + vport = (uint16_t) atoi(colon+1); + } + sz = colon - thn; + host_name = apr_pstrndup(t, thn, sz); + } else { + host_name = thn; + } + } else if (strcasecmp(l->directive, "DNSSDServiceName") == 0) vname = ap_getword_conf(t, &a); else if (strcasecmp(l->directive, "DNSSDServiceTypes") == 0) @@ -853,3 +878,4 @@ module AP_MODULE_DECLARE_DATA dnssd_module = { register_hooks /* register hooks */ }; +/* vim:set expandtab: */ -- cgit