=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/misc.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- src/usr.bin/ssh/misc.c 2006/07/09 15:15:10 1.55 +++ src/usr.bin/ssh/misc.c 2006/07/10 12:46:51 1.56 @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.55 2006/07/09 15:15:10 stevesk Exp $ */ +/* $OpenBSD: misc.c,v 1.56 2006/07/10 12:46:51 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -41,6 +41,7 @@ #include "misc.h" #include "log.h" #include "xmalloc.h" +#include "ssh.h" /* remove newline at end of string */ char * @@ -324,6 +325,23 @@ } return total; +} + +/* + * Returns a standardized host+port identifier string. + * Caller must free returned string. + */ +char * +put_host_port(const char *host, u_short port) +{ + char *hoststr; + + if (port == 0 || port == SSH_DEFAULT_PORT) + return(xstrdup(host)); + if (asprintf(&hoststr, "[%s]:%d", host, (int)port) < 0) + fatal("put_host_port: asprintf: %s", strerror(errno)); + debug3("put_host_port: %s", hoststr); + return hoststr; } /*