]> andersk Git - openssh.git/blobdiff - misc.c
- dtucker@cvs.openbsd.org 2006/07/10 12:46:51
[openssh.git] / misc.c
diff --git a/misc.c b/misc.c
index 2abb14051aafa54184c965616b1db23ec143a7a3..a65b1fdedf3b22b5f2150278feb9e83150c85d0e 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -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.
@@ -45,6 +45,7 @@
 #include "misc.h"
 #include "log.h"
 #include "xmalloc.h"
+#include "ssh.h"
 
 /* remove newline at end of string */
 char *
@@ -336,6 +337,23 @@ convtime(const char *s)
        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;
+}
+
 /*
  * Search for next delimiter between hostnames/addresses and ports.
  * Argument may be modified (for termination).
This page took 1.600682 seconds and 4 git commands to generate.