diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2022-05-24 22:46:19 +0200 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2022-05-24 22:46:19 +0200 |
commit | c540a6a96defc6120b28c78357eb289b4d40ec47 (patch) | |
tree | ee71ea3209efa341973d8a63ef7b5896e06e213f /vchat-connection.c | |
parent | 10ee4cff7e498a7c31a2cbfc1916f7d795c7aca2 (diff) |
Make static buffers scoped
Diffstat (limited to 'vchat-connection.c')
-rw-r--r-- | vchat-connection.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/vchat-connection.c b/vchat-connection.c index 7c204fd..a030bbe 100644 --- a/vchat-connection.c +++ b/vchat-connection.c | |||
@@ -35,6 +35,9 @@ | |||
35 | static int serverfd = -1; | 35 | static int serverfd = -1; |
36 | unsigned int want_tcp_keepalive = 0; | 36 | unsigned int want_tcp_keepalive = 0; |
37 | 37 | ||
38 | #define STAGING_SIZE 16384 | ||
39 | #define RECEIVEBUF_SIZE 4096 | ||
40 | |||
38 | /* Generic tcp connector, blocking */ | 41 | /* Generic tcp connector, blocking */ |
39 | static int connect_tcp_socket(const char *server, const char *port) { | 42 | static int connect_tcp_socket(const char *server, const char *port) { |
40 | struct addrinfo hints, *res, *res0; | 43 | struct addrinfo hints, *res, *res0; |
@@ -176,19 +179,18 @@ void vc_disconnect() { | |||
176 | loggedin = 0; | 179 | loggedin = 0; |
177 | } | 180 | } |
178 | 181 | ||
179 | #define STAGINGSIZE 16384 | ||
180 | static char _staging[STAGINGSIZE]; | ||
181 | void vc_sendmessage(const char *msg) { | 182 | void vc_sendmessage(const char *msg) { |
182 | size_t sent, len = snprintf(_staging, sizeof(_staging), "%s\r\n", msg); | 183 | static char staging[STAGING_SIZE]; |
184 | size_t sent, len = snprintf(staging, sizeof(staging), "%s\r\n", msg); | ||
183 | #ifdef DEBUG | 185 | #ifdef DEBUG |
184 | /* debugging? log network output! */ | 186 | /* debugging? log network output! */ |
185 | fprintf(dumpfile, ">| (%zd) %s\n", len - 2, msg); | 187 | fprintf(dumpfile, ">| (%zd) %s\n", len - 2, msg); |
186 | #endif | 188 | #endif |
187 | 189 | ||
188 | if (getintoption(CF_USESSL)) | 190 | if (getintoption(CF_USESSL)) |
189 | sent = vc_tls_sendmessage(_staging, len); | 191 | sent = vc_tls_sendmessage(staging, len); |
190 | else | 192 | else |
191 | sent = write(serverfd, _staging, len); | 193 | sent = write(serverfd, staging, len); |
192 | if (sent != len) | 194 | if (sent != len) |
193 | writecf(FS_ERR, "Message sending fuzzy."); | 195 | writecf(FS_ERR, "Message sending fuzzy."); |
194 | } | 196 | } |
@@ -197,7 +199,7 @@ void vc_sendmessage(const char *msg) { | |||
197 | /* get data from servers connection */ | 199 | /* get data from servers connection */ |
198 | void vc_receive(void) { | 200 | void vc_receive(void) { |
199 | /* offset in buffer (for linebreaks at packet borders) */ | 201 | /* offset in buffer (for linebreaks at packet borders) */ |
200 | static char buf[4096]; | 202 | static char buf[RECEIVEBUF_SIZE]; |
201 | static size_t buf_fill; | 203 | static size_t buf_fill; |
202 | char *endmsg; | 204 | char *endmsg; |
203 | size_t freebytes = sizeof(buf) - buf_fill; | 205 | size_t freebytes = sizeof(buf) - buf_fill; |