summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index 2abb14051..a65b1fded 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.55 2006/07/09 15:15:10 stevesk Exp $ */ 1/* $OpenBSD: misc.c,v 1.56 2006/07/10 12:46:51 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -45,6 +45,7 @@
45#include "misc.h" 45#include "misc.h"
46#include "log.h" 46#include "log.h"
47#include "xmalloc.h" 47#include "xmalloc.h"
48#include "ssh.h"
48 49
49/* remove newline at end of string */ 50/* remove newline at end of string */
50char * 51char *
@@ -337,6 +338,23 @@ convtime(const char *s)
337} 338}
338 339
339/* 340/*
341 * Returns a standardized host+port identifier string.
342 * Caller must free returned string.
343 */
344char *
345put_host_port(const char *host, u_short port)
346{
347 char *hoststr;
348
349 if (port == 0 || port == SSH_DEFAULT_PORT)
350 return(xstrdup(host));
351 if (asprintf(&hoststr, "[%s]:%d", host, (int)port) < 0)
352 fatal("put_host_port: asprintf: %s", strerror(errno));
353 debug3("put_host_port: %s", hoststr);
354 return hoststr;
355}
356
357/*
340 * Search for next delimiter between hostnames/addresses and ports. 358 * Search for next delimiter between hostnames/addresses and ports.
341 * Argument may be modified (for termination). 359 * Argument may be modified (for termination).
342 * Returns *cp if parsing succeeds. 360 * Returns *cp if parsing succeeds.