From ca20286c6b482d0e1297f7b745d177e3e8bc3790 Mon Sep 17 00:00:00 2001 From: idk Date: Tue, 24 Nov 2020 12:01:34 -0500 Subject: [PATCH] do the checkIsSilent better --- src/libsam3/libsam3.c | 14 +++++--------- src/libsam3/libsam3.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libsam3/libsam3.c b/src/libsam3/libsam3.c index 3ebce57..99d94af 100644 --- a/src/libsam3/libsam3.c +++ b/src/libsam3/libsam3.c @@ -949,11 +949,9 @@ Sam3Connection *sam3StreamConnect(Sam3Session *ses, const char *destkey) { strcpyerr(ses, "IO_ERROR_SK"); goto error; } - char silent[] = "false"; - checkIsSilent(ses, silent); if (sam3tcpPrintf(conn->fd, "STREAM CONNECT ID=%s DESTINATION=%s SILENT=%s\n", - ses->channel, destkey, silent) < 0) { + ses->channel, destkey, checkIsSilent(ses)) < 0) { strcpyerr(ses, "IO_ERROR"); goto error; } @@ -1056,11 +1054,11 @@ Sam3Connection *sam3StreamAccept(Sam3Session *ses) { return NULL; } -void checkIsSilent(Sam3Session *ses, char *str) { +const char *checkIsSilent(Sam3Session *ses) { if (ses->silent == true) { - str = "true "; + return "true"; } else { - str = "false"; + return "false"; } } @@ -1084,11 +1082,9 @@ int sam3StreamForward(Sam3Session *ses, const char *hostname, int port) { strcpyerr(ses, "IO_ERROR_SK"); goto error; } - char silent[] = "false"; - checkIsSilent(ses, silent); if (sam3tcpPrintf(ses->fwd_fd, "STREAM FORWARD ID=%s PORT=%d HOST=%s SILENT=%s\n", - ses->channel, port, hostname, silent) < 0) { + ses->channel, port, hostname, checkIsSilent(ses)) < 0) { strcpyerr(ses, "IO_ERROR_PF"); goto error; } diff --git a/src/libsam3/libsam3.h b/src/libsam3/libsam3.h index e0f9ebf..16942f5 100644 --- a/src/libsam3/libsam3.h +++ b/src/libsam3/libsam3.h @@ -205,7 +205,7 @@ extern int sam3CloseSession(Sam3Session *ses); * characters for use with sam3tcpPrintf() checkIsSilent */ -void checkIsSilent(Sam3Session *ses, char *str); +const char *checkIsSilent(Sam3Session *ses); /* * Check to make sure that the destination in use is of a valid length, returns