mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Reformat ssh_hostport()
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
8152c6aba4
commit
1e22a089eb
20
src/misc.c
20
src/misc.c
@@ -318,17 +318,23 @@ char *ssh_lowercase(const char* str) {
|
|||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ssh_hostport(const char *host, int port){
|
char *ssh_hostport(const char *host, int port)
|
||||||
char *dest;
|
{
|
||||||
|
char *dest = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
if(host==NULL)
|
|
||||||
|
if (host == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* 3 for []:, 5 for 65536 and 1 for nul */
|
/* 3 for []:, 5 for 65536 and 1 for nul */
|
||||||
len=strlen(host) + 3 + 5 + 1;
|
len = strlen(host) + 3 + 5 + 1;
|
||||||
dest=malloc(len);
|
dest = malloc(len);
|
||||||
if(dest==NULL)
|
if (dest == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
snprintf(dest,len,"[%s]:%d",host,port);
|
}
|
||||||
|
snprintf(dest, len, "[%s]:%d", host, port);
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user