2 * Dolda Connect - Modular multiuser Direct Connect-style client
3 * Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Note: This code is still ugly, since I copied it almost verbatim
22 * from the daemon's parser. It would need serious cleanups, but at
23 * least it works for now.
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
47 #include <arpa/nameser.h>
51 #include <doldaconnect/uilib.h>
54 #define DOLCON_SRV_NAME "_dolcon._tcp"
65 struct respclass *next;
75 struct respclass *classes;
85 int (*callback)(struct dc_response *resp);
89 void dc_uimisc_disconnected(void);
91 /* The first command must be the nameless connect command and second
92 * the notification command. */
93 static struct command *commands = NULL;
94 static struct qcmd *queue = NULL, *queueend = NULL;
95 static struct dc_response *respqueue = NULL, *respqueueend = NULL;
96 static int state = -1;
98 static iconv_t ichandle;
99 static int resetreader = 1;
100 static struct addrinfo *hostlist = NULL, *curhost = NULL;
108 static void message(int bits, char *format, ...)
117 if((v = getenv("LIBDCUI_MSG")) != NULL)
118 hb = strtol(v, NULL, 0) & 65535;
122 va_start(args, format);
123 vfprintf(stderr, format, args);
128 static char *formataddress(struct sockaddr *arg, socklen_t arglen)
130 struct sockaddr_in *ipv4;
132 struct sockaddr_in6 *ipv6;
134 static char *ret = NULL;
140 switch(arg->sa_family)
143 ret = sprintf2("Unix socket (%s)", ((struct sockaddr_un *)arg)->sun_path);
146 ipv4 = (struct sockaddr_in *)arg;
147 if(inet_ntop(AF_INET, &ipv4->sin_addr, buf, sizeof(buf)) == NULL)
149 ret = sprintf2("%s:%i", buf, (int)ntohs(ipv4->sin_port));
153 ipv6 = (struct sockaddr_in6 *)arg;
154 if(inet_ntop(AF_INET6, &ipv6->sin6_addr, buf, sizeof(buf)) == NULL)
156 ret = sprintf2("[%s]:%i", buf, (int)ntohs(ipv6->sin6_port));
160 errno = EPFNOSUPPORT;
165 static struct dc_response *makeresp(void)
167 struct dc_response *new;
169 new = smalloc(sizeof(*new));
182 static void freeqcmd(struct qcmd *qcmd)
184 if(qcmd->buf != NULL)
189 static void unlinkqueue(void)
193 if((qcmd = queue) == NULL)
201 static struct qcmd *makeqcmd(wchar_t *name)
211 for(cmd = commands; cmd != NULL; cmd = cmd->next)
213 if((cmd->name != NULL) && !wcscmp(cmd->name, name))
217 errno = ENOSYS; /* Bleh */
221 new = smalloc(sizeof(*new));
226 new->callback = NULL;
231 queue = queueend = new;
233 queueend->next = new;
239 static wchar_t *quoteword(wchar_t *word)
241 wchar_t *wp, *buf, *bp;
251 for(wp = word; *wp != L'\0'; wp++)
253 if(!dq && iswspace(*wp))
255 if((*wp == L'\\') || (*wp == L'\"'))
262 bp = buf = smalloc(sizeof(wchar_t) * (numc + numbs + (dq?2:0) + 1));
265 for(wp = word; *wp != L'\0'; wp++)
267 if((*wp == L'\\') || (*wp == L'\"'))
277 static struct command *makecmd(wchar_t *name)
281 new = smalloc(sizeof(*new));
284 new->next = commands;
289 static struct respclass *addresp(struct command *cmd, int code, ...)
291 struct respclass *new;
296 va_start(args, code);
298 while((resps[i++] = va_arg(args, int)) != RESP_END);
301 new = smalloc(sizeof(*new));
306 new->wordt = smalloc(sizeof(int) * i);
307 memcpy(new->wordt, resps, sizeof(int) * i);
311 new->next = cmd->classes;
316 #include "initcmds.h"
320 if((ichandle = iconv_open("wchar_t", "utf-8")) == (iconv_t)-1)
322 dc_srv_local = sstrdup("");
327 void dc_cleanup(void)
329 iconv_close(ichandle);
332 void dc_disconnect(void)
334 struct dc_response *resp;
342 while((resp = dc_getresp()) != NULL)
344 dc_uimisc_disconnected();
345 if(servinfo.hostname != NULL)
346 free(servinfo.hostname);
347 memset(&servinfo, 0, sizeof(servinfo));
350 void dc_freeresp(struct dc_response *resp)
354 for(i = 0; i < resp->numlines; i++)
356 for(o = 0; o < resp->rlines[i].argc; o++)
357 free(resp->rlines[i].argv[o]);
358 free(resp->rlines[i].argv);
364 struct dc_response *dc_getresp(void)
366 struct dc_response *ret;
368 if((ret = respqueue) == NULL)
370 respqueue = ret->next;
371 if(respqueue == NULL)
374 respqueue->prev = NULL;
378 struct dc_response *dc_gettaggedresp(int tag)
380 struct dc_response *resp;
382 for(resp = respqueue; resp != NULL; resp = resp->next)
386 if(resp->prev != NULL)
387 resp->prev->next = resp->next;
388 if(resp->next != NULL)
389 resp->next->prev = resp->prev;
390 if(resp == respqueue)
391 respqueue = resp->next;
392 if(resp == respqueueend)
393 respqueueend = resp->prev;
400 struct dc_response *dc_gettaggedrespsync(int tag)
403 struct dc_response *resp;
405 while((resp = dc_gettaggedresp(tag)) == NULL)
410 pfd.events |= POLLOUT;
411 if(poll(&pfd, 1, -1) < 0)
413 if((pfd.revents & POLLIN) && dc_handleread())
415 if((pfd.revents & POLLOUT) && dc_handlewrite())
421 int dc_wantwrite(void)
426 if((queue != NULL) && (queue->buflen > 0))
433 int dc_getstate(void)
438 int dc_queuecmd(int (*callback)(struct dc_response *), void *data, ...)
446 wchar_t *part, *tpart;
447 size_t bufsize, bufdata;
450 bufsize = bufdata = 0;
453 while((part = va_arg(al, wchar_t *)) != NULL)
455 if(!wcscmp(part, L"%a"))
457 for(toks = va_arg(al, wchar_t **); *toks != NULL; toks++)
461 if((tpart = quoteword(part)) != NULL)
467 bufcat(buf, part, wcslen(part));
476 if(!wcscmp(tpart, L"i"))
479 part = swprintf2(L"%i", va_arg(al, int));
480 } else if(!wcscmp(tpart, L"s")) {
482 part = icmbstowcs(sarg = va_arg(al, char *), NULL);
489 } else if(!wcscmp(tpart, L"ls")) {
490 part = va_arg(al, wchar_t *);
491 } else if(!wcscmp(tpart, L"ll")) {
493 part = swprintf2(L"%lli", va_arg(al, long long));
494 } else if(!wcscmp(tpart, L"f")) {
496 part = swprintf2(L"%f", va_arg(al, double));
497 } else if(!wcscmp(tpart, L"x")) {
499 part = swprintf2(L"%x", va_arg(al, int));
509 if((tpart = quoteword(part)) != NULL)
520 if((qcmd = makeqcmd(part)) == NULL)
528 qcmd->callback = callback;
532 bufcat(buf, part, wcslen(part));
538 bufcat(buf, L"\r\n\0", 3);
539 if((final = icwcstombs(buf, "utf-8")) == NULL)
547 qcmd->buflen = strlen(final);
551 int dc_handleread(void)
558 /* Ewww... this really is soo ugly. I need to clean this up some day. */
559 static int pstate = 0;
560 static char inbuf[128];
561 static size_t inbufdata = 0;
562 static wchar_t *cbuf = NULL;
563 static size_t cbufsize = 0, cbufdata = 0;
564 static wchar_t *pptr = NULL;
565 static wchar_t **argv = NULL;
567 static size_t args = 0;
568 static wchar_t *cw = NULL;
569 static size_t cwsize = 0, cwdata = 0;
570 static struct dc_response *curresp = NULL;
572 static int unlink = 0;
579 optlen = sizeof(ret);
580 getsockopt(fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
585 message(2, "could not connect to %s: %s\n", formataddress(curhost->ai_addr, curhost->ai_addrlen), strerror(ret));
586 for(curhost = curhost->ai_next; curhost != NULL; curhost = curhost->ai_next)
588 if((newfd = socket(curhost->ai_family, curhost->ai_socktype, curhost->ai_protocol)) < 0)
597 fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
598 message(4, "connecting to %s\n", formataddress(curhost->ai_addr, curhost->ai_addrlen));
599 if(connect(fd, (struct sockaddr *)curhost->ai_addr, curhost->ai_addrlen))
601 if(errno == EINPROGRESS)
603 message(2, "could not connect to %s: %s\n", formataddress(curhost->ai_addr, curhost->ai_addrlen), strerror(ret));
615 if(curhost->ai_canonname != NULL)
616 servinfo.hostname = sstrdup(curhost->ai_canonname);
617 servinfo.family = curhost->ai_family;
631 dc_freeresp(curresp);
636 ret = read(fd, inbuf + inbufdata, 128 - inbufdata);
639 if((errno == EAGAIN) || (errno == EINTR))
645 } else if(ret == 0) {
654 if(cbufsize == cbufdata)
658 if((cbuf = realloc(cbuf, sizeof(wchar_t) * (cbufsize += 256))) == NULL)
668 p2 = (char *)(cbuf + cbufdata);
669 len = sizeof(wchar_t) * (cbufsize - cbufdata);
670 ret = iconv(ichandle, &p1, &inbufdata, &p2, &len);
671 memmove(inbuf, p1, inbufdata);
672 cbufdata = cbufsize - (len / sizeof(wchar_t));
678 /* XXX Is this really OK? */
700 while(!done && (pptr - cbuf < cbufdata))
709 if(pptr == cbuf + cbufdata - 1)
714 if(*(++pptr) == L'\n')
718 curresp = makeresp();
719 if((argc > 0) && ((curresp->code = wcstol(argv[0], NULL, 10)) >= 600))
721 curresp->cmdname = L".notify";
722 curresp->internal = commands->next;
726 if((curresp->cmdname = queue->cmd->name) == NULL)
727 curresp->cmdname = L".connect";
728 curresp->data = queue->data;
729 curresp->tag = queue->tag;
730 curresp->internal = (void *)(queue->cmd);
734 sizebuf(&curresp->rlines, &curresp->linessize, curresp->numlines + 1, sizeof(*(curresp->rlines)), 1);
735 curresp->rlines[curresp->numlines].argc = argc;
736 curresp->rlines[curresp->numlines].argv = argv;
742 if((curresp->code >= 600) || (queue == NULL) || (queue->callback == NULL))
745 ret = queue->callback(curresp);
748 if(respqueue == NULL)
750 respqueue = respqueueend = curresp;
752 curresp->next = NULL;
753 curresp->prev = respqueueend;
754 respqueueend->next = curresp;
755 respqueueend = curresp;
757 } else if(ret == 1) {
758 dc_freeresp(curresp);
764 wmemmove(cbuf, pptr, cbufdata -= (pptr - cbuf));
778 if(iswspace(*pptr) || ((argc == 0) && (*pptr == L'-')))
791 sizebuf(&argv, &args, argc + 1, sizeof(*argv), 1);
796 } else if(*pptr == L'\"') {
799 } else if(*pptr == L'\\') {
800 if(pptr == cbuf + cbufdata - 1)
805 addtobuf(cw, *(++pptr));
808 addtobuf(cw, *(pptr++));
815 } else if(*pptr == L'\\') {
816 addtobuf(cw, *(++pptr));
829 #if UNIX_AUTH_STYLE == 1
830 static void mkcreds(struct msghdr *msg)
833 static char buf[CMSG_SPACE(sizeof(*ucred))];
834 struct cmsghdr *cmsg;
836 msg->msg_control = buf;
837 msg->msg_controllen = sizeof(buf);
838 cmsg = CMSG_FIRSTHDR(msg);
839 cmsg->cmsg_level = SOL_SOCKET;
840 cmsg->cmsg_type = SCM_CREDENTIALS;
841 cmsg->cmsg_len = CMSG_LEN(sizeof(*ucred));
842 ucred = (struct ucred *)CMSG_DATA(cmsg);
843 ucred->pid = getpid();
844 ucred->uid = getuid();
845 ucred->gid = getgid();
846 msg->msg_controllen = cmsg->cmsg_len;
850 int dc_handlewrite(void)
860 if(queue->buflen > 0)
862 memset(&msg, 0, sizeof(msg));
863 msg.msg_iov = &bufvec;
865 bufvec.iov_base = queue->buf;
866 bufvec.iov_len = queue->buflen;
867 #if UNIX_AUTH_STYLE == 1
868 if((servinfo.family == PF_UNIX) && !servinfo.sentcreds)
871 servinfo.sentcreds = 1;
874 ret = sendmsg(fd, &msg, MSG_NOSIGNAL | MSG_DONTWAIT);
877 if((errno == EAGAIN) || (errno == EINTR))
885 memmove(queue->buf, queue->buf + ret, queue->buflen -= ret);
894 * It kind of sucks that libresolv doesn't have any DNS parsing
895 * routines. We'll have to do it manually.
897 static char *readname(unsigned char *msg, unsigned char *eom, unsigned char **p)
901 size_t namesize, namedata, len;
904 namesize = namedata = 0;
912 } else if(len == 0xc0) {
913 tp = msg + *((*p)++);
914 if((tname = readname(msg, eom, &tp)) == NULL)
920 bufcat(name, tname, strlen(tname));
924 } else if(*p + len >= eom) {
929 bufcat(name, *p, len);
935 static int skipname(unsigned char *msg, unsigned char *eom, unsigned char **p)
945 } else if(len == 0xc0) {
948 } else if(*p + len >= eom) {
955 static int getsrvrr(char *name, char **host, int *port)
958 char *name2, *rrname;
959 unsigned char *eom, *p;
960 unsigned char buf[1024];
961 int flags, num, class, type;
965 if(!(_res.options & RES_INIT))
970 /* res_querydomain doesn't work for some reason */
971 if(name[strlen(name) - 1] == '.')
972 name2 = sprintf2("%s.%s", DOLCON_SRV_NAME, name);
974 name2 = sprintf2("%s.%s.", DOLCON_SRV_NAME, name);
975 ret = res_query(name2, C_IN, T_SRV, buf, sizeof(buf));
983 * Assume transaction ID is correct.
985 * Flags check: FA0F masks in request/response flag, opcode,
986 * truncated flag and status code, and ignores authoritativeness,
987 * recursion flags and DNSSEC and reserved bits.
989 flags = (buf[2] << 8) + buf[3];
990 if((flags & 0xfa0f) != 0x8000)
995 /* Skip the query entries */
996 num = (buf[4] << 8) + buf[5];
998 for(i = 0; i < num; i++)
1000 if(skipname(buf, eom, &p))
1005 p += 4; /* Type and class */
1008 num = (buf[6] << 8) + buf[7];
1009 for(i = 0; i < num; i++)
1011 if((rrname = readname(buf, eom, &p)) == NULL)
1018 class = *(p++) << 8;
1023 if((class == C_IN) && (type == T_SRV) && !strcmp(rrname, name2))
1027 /* Noone will want to have alternative DC servers, so
1028 * don't care about priority and weigth */
1034 *port = *(p++) << 8;
1039 if((rrname = readname(buf, eom, &p)) == NULL)
1052 static int getsrvrr(char *name, char **host, int *port)
1059 static struct addrinfo *gaicat(struct addrinfo *l1, struct addrinfo *l2)
1065 for(p = l1; p->ai_next != NULL; p = p->ai_next);
1070 /* This isn't actually correct, in any sense of the word. It only
1071 * works on systems whose getaddrinfo implementation saves the
1072 * sockaddr in the same malloc block as the struct addrinfo. Those
1073 * systems include at least FreeBSD and glibc-based systems, though,
1074 * so it should not be any immediate threat, and it allows me to not
1075 * implement a getaddrinfo wrapper. It can always be changed, should
1076 * the need arise. */
1077 static struct addrinfo *unixgai(int type, char *path)
1080 struct addrinfo *ai;
1081 struct sockaddr_un *un;
1083 buf = smalloc(sizeof(*ai) + sizeof(*un));
1084 memset(buf, 0, sizeof(*ai) + sizeof(*un));
1085 ai = (struct addrinfo *)buf;
1086 un = (struct sockaddr_un *)(buf + sizeof(*ai));
1088 ai->ai_family = AF_UNIX;
1089 ai->ai_socktype = type;
1090 ai->ai_protocol = 0;
1091 ai->ai_addrlen = sizeof(*un);
1092 ai->ai_addr = (struct sockaddr *)un;
1093 ai->ai_canonname = NULL;
1095 un->sun_family = PF_UNIX;
1096 strncpy(un->sun_path, path, sizeof(un->sun_path) - 1);
1100 static struct addrinfo *resolvtcp(char *name, int port)
1102 struct addrinfo hint, *ret;
1105 memset(&hint, 0, sizeof(hint));
1106 hint.ai_socktype = SOCK_STREAM;
1107 hint.ai_flags = AI_NUMERICSERV | AI_CANONNAME;
1108 snprintf(tmp, sizeof(tmp), "%i", port);
1109 if(!getaddrinfo(name, tmp, &hint, &ret))
1114 static struct addrinfo *resolvsrv(char *name)
1116 struct addrinfo *ret;
1120 if(getsrvrr(name, &realname, &port))
1122 message(4, "SRV RR resolved: %s -> %s\n", name, realname);
1123 ret = resolvtcp(realname, port);
1128 static struct addrinfo *resolvhost(char *host)
1131 struct addrinfo *ret;
1134 if(strchr(host, '/'))
1135 return(unixgai(SOCK_STREAM, host));
1136 if((strchr(host, ':') == NULL) && ((ret = resolvsrv(host)) != NULL))
1139 if((*host == '[') && ((p = strchr(host, ']')) != NULL))
1141 hp = memcpy(smalloc(p - host), host + 1, (p - host) - 1);
1142 hp[(p - host) - 1] = 0;
1143 if(strchr(hp, ':') != NULL) {
1149 ret = resolvtcp(hp, port);
1157 if((p = strrchr(hp, ':')) != NULL) {
1163 ret = resolvtcp(hp, port);
1170 static struct addrinfo *getlocalai(void)
1172 struct addrinfo *ret;
1177 if((getuid() != 0) && ((pwd = getpwuid(getuid())) != NULL))
1179 tmp = sprintf2("/tmp/doldacond-%s", pwd->pw_name);
1180 ret = unixgai(SOCK_STREAM, tmp);
1183 ret = gaicat(ret, unixgai(SOCK_STREAM, "/var/run/doldacond.sock"));
1187 static struct addrinfo *defaulthost(void)
1189 struct addrinfo *ret;
1193 if(((tmp = getenv("DCSERVER")) != NULL) && *tmp) {
1194 message(4, "using DCSERVER: %s\n", tmp);
1195 return(resolvhost(tmp));
1198 ret = gaicat(ret, resolvtcp("localhost", 1500));
1199 if(!getdomainname(dn, sizeof(dn)) && *dn && strcmp(dn, "(none)"))
1200 ret = gaicat(ret, resolvsrv(dn));
1204 static int dc_connectai(struct addrinfo *hosts, struct qcmd **cnctcmd)
1212 if(hostlist != NULL)
1213 freeaddrinfo(hostlist);
1215 for(curhost = hostlist; curhost != NULL; curhost = curhost->ai_next)
1217 if((fd = socket(curhost->ai_family, curhost->ai_socktype, curhost->ai_protocol)) < 0)
1220 freeaddrinfo(hostlist);
1225 fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
1226 message(4, "connecting to %s\n", formataddress(curhost->ai_addr, curhost->ai_addrlen));
1227 if(connect(fd, (struct sockaddr *)curhost->ai_addr, curhost->ai_addrlen))
1229 if(errno == EINPROGRESS)
1234 message(2, "could not connect to %s: %s\n", formataddress(curhost->ai_addr, curhost->ai_addrlen), strerror(errno));
1238 if(curhost->ai_canonname != NULL)
1239 servinfo.hostname = sstrdup(curhost->ai_canonname);
1240 servinfo.family = curhost->ai_family;
1247 qcmd = makeqcmd(NULL);
1258 static int dc_connect2(char *host, struct qcmd **cnctcmd)
1260 struct addrinfo *ai;
1264 if(host == dc_srv_local) {
1265 message(4, "connect start: Unix\n");
1267 } else if(!host || !*host) {
1268 message(4, "connect start: default\n");
1271 message(4, "connect start: host %s\n", host);
1272 ai = resolvhost(host);
1276 ret = dc_connectai(ai, &qcmd);
1277 if((ret >= 0) && (cnctcmd != NULL))
1282 int dc_connect(char *host)
1284 return(dc_connect2(host, NULL));
1287 int dc_connectsync(char *host, struct dc_response **respbuf)
1291 struct dc_response *resp;
1293 if((ret = dc_connect2(host, &cc)) < 0)
1295 resp = dc_gettaggedrespsync(cc->tag);
1307 int dc_connectsync2(char *host, int rev)
1310 struct dc_response *resp;
1312 if((ret = dc_connectsync(host, &resp)) < 0)
1314 if(dc_checkprotocol(resp, rev))
1318 errno = EPROTONOSUPPORT;
1325 struct dc_intresp *dc_interpret(struct dc_response *resp)
1328 struct dc_intresp *iresp;
1329 struct command *cmd;
1330 struct respclass *cls;
1334 if((resp->numlines == 0) || (resp->rlines[0].argc == 0) || (resp->curline >= resp->numlines))
1336 code = wcstol(resp->rlines[0].argv[0], NULL, 10);
1337 cmd = (struct command *)(resp->internal);
1338 for(cls = cmd->classes; cls != NULL; cls = cls->next)
1340 if(cls->code == code)
1345 if(cls->nwords >= resp->rlines[resp->curline].argc)
1347 iresp = smalloc(sizeof(*iresp));
1352 for(i = 0; i < cls->nwords; i++)
1354 switch(cls->wordt[i])
1359 sizebuf(&(iresp->argv), &args, iresp->argc + 1, sizeof(*(iresp->argv)), 1);
1360 iresp->argv[iresp->argc].val.str = swcsdup(resp->rlines[resp->curline].argv[i + 1]);
1361 iresp->argv[iresp->argc].type = cls->wordt[i];
1365 sizebuf(&(iresp->argv), &args, iresp->argc + 1, sizeof(*(iresp->argv)), 1);
1366 iresp->argv[iresp->argc].val.num = wcstol(resp->rlines[resp->curline].argv[i + 1], NULL, 0);
1367 iresp->argv[iresp->argc].type = cls->wordt[i];
1371 sizebuf(&(iresp->argv), &args, iresp->argc + 1, sizeof(*(iresp->argv)), 1);
1372 iresp->argv[iresp->argc].val.flnum = wcstod(resp->rlines[resp->curline].argv[i + 1], NULL);
1373 iresp->argv[iresp->argc].type = cls->wordt[i];
1377 sizebuf(&(iresp->argv), &args, iresp->argc + 1, sizeof(*(iresp->argv)), 1);
1378 iresp->argv[iresp->argc].val.lnum = wcstoll(resp->rlines[resp->curline].argv[i + 1], NULL, 0);
1379 iresp->argv[iresp->argc].type = cls->wordt[i];
1388 void dc_freeires(struct dc_intresp *ires)
1392 for(i = 0; i < ires->argc; i++)
1394 if(ires->argv[i].type == RESP_STR)
1395 free(ires->argv[i].val.str);
1401 int dc_checkprotocol(struct dc_response *resp, int revision)
1403 struct dc_intresp *ires;
1406 if(resp->code != 201)
1409 if((ires = dc_interpret(resp)) == NULL)
1411 low = ires->argv[0].val.num;
1412 high = ires->argv[1].val.num;
1414 if((revision < low) || (revision > high))
1419 const char *dc_gethostname(void)
1421 return(servinfo.hostname);