From: fredrik Date: Wed, 11 Apr 2007 03:17:48 +0000 (+0000) Subject: Nicify SRV name generation. X-Git-Tag: 0.3~52 X-Git-Url: http://git.dolda2000.com/gitweb/?p=doldaconnect.git;a=commitdiff_plain;h=4d487bad97fd2efc3192a8042bd53009d96fc42b Nicify SRV name generation. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@885 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/lib/uilib.c b/lib/uilib.c index c67410e..4901966 100644 --- a/lib/uilib.c +++ b/lib/uilib.c @@ -49,6 +49,8 @@ #include #include +#define DOLCON_SRV_NAME "_dolcon._tcp" + #define RESP_END -1 #define RESP_DSC 0 #define RESP_STR 1 @@ -858,15 +860,10 @@ static int getsrvrr(char *name, char **host, int *port) return(-1); } /* res_querydomain doesn't work for some reason */ - name2 = smalloc(strlen("_dolcon._tcp.") + strlen(name) + 2); - strcpy(name2, "_dolcon._tcp."); - strcat(name2, name); - len = strlen(name2); - if(name2[len - 1] != '.') - { - name2[len] = '.'; - name2[len + 1] = 0; - } + if(name[strlen(name) - 1] == '.') + name2 = sprintf2("%s.%s", DOLCON_SRV_NAME, name); + else + name2 = sprintf2("%s.%s.", DOLCON_SRV_NAME, name); ret = res_query(name2, C_IN, T_SRV, buf, sizeof(buf)); if(ret < 0) {