]> andersk Git - openssh.git/blobdiff - misc.c
- (tim) [configure.ac] Move CHECK_HEADERS test before platform specific
[openssh.git] / misc.c
diff --git a/misc.c b/misc.c
index b7316519d82a045953c0039208ef7bc8c690143c..78bca2faefa77c782b7968ccaa67b771c7cbdd3f 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.54 2006/07/06 16:03:53 stevesk Exp $ */
+/* $OpenBSD: misc.c,v 1.64 2006/08/03 03:34:42 deraadt Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2005,2006 Damien Miller.  All rights reserved.
 
 #include "includes.h"
 
-#include <sys/ioctl.h>
 #include <sys/types.h>
+#include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <sys/param.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
+#include <errno.h>
+#include <fcntl.h>
 #ifdef HAVE_PATHS_H
 # include <paths.h>
 #include <pwd.h>
 #include <net/if.h>
 #endif
 
+#include "xmalloc.h"
 #include "misc.h"
 #include "log.h"
-#include "xmalloc.h"
+#include "ssh.h"
 
 /* remove newline at end of string */
 char *
@@ -335,6 +345,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 0.081059 seconds and 4 git commands to generate.