1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

Allow service names in "set server"

This commit is contained in:
Brian Somers 1997-07-12 19:22:34 +00:00
parent d228e65cdc
commit 7cc60a7478
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27346

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.64 1997/06/28 01:34:02 brian Exp $
* $Id: command.c,v 1.65 1997/06/30 03:03:29 brian Exp $
*
*/
#include <sys/types.h>
@ -862,8 +862,20 @@ char **argv;
mask = m;
}
res = ServerLocalOpen(argv[0], mask);
} else if (strspn(argv[0], "0123456789") == strlen(argv[0]))
res = ServerTcpOpen(atoi(argv[0]));
} else {
int port;
if (strspn(argv[0], "0123456789") != strlen(argv[0])) {
struct servent *s;
if ((s = getservbyname(argv[0], "tcp")) == NULL) {
port = 0;
LogPrintf(LogWARN, "%s: Invalid port or service\n", argv[0]);
} else
port = ntohs(s->s_port);
} else
port = atoi(argv[0]);
if (port)
res = ServerTcpOpen(port);
}
return res;
}