summaryrefslogtreecommitdiff
path: root/vchat-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'vchat-connection.c')
-rw-r--r--vchat-connection.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/vchat-connection.c b/vchat-connection.c
index 06ea187..60dc81f 100644
--- a/vchat-connection.c
+++ b/vchat-connection.c
@@ -190,31 +190,23 @@ vc_disconnect () {
190 loggedin = 0; 190 loggedin = 0;
191} 191}
192 192
193#define STAGINGSIZE 16384
194static char _staging[STAGINGSIZE];
193void 195void
194vc_sendmessage (const char *msg) 196vc_sendmessage (const char *msg)
195{ 197{
198 size_t sent, len = snprintf(_staging, sizeof(_staging), "%s\r\n", msg);
196#ifdef DEBUG 199#ifdef DEBUG
197 /* debugging? log network output! */ 200 /* debugging? log network output! */
198 fprintf (dumpfile, ">| %s (%zd)\n", msg, strlen(msg)); 201 fprintf (dumpfile, ">| (%zd) %s\n", len - 2, msg);
199#endif 202#endif
200 203
201 if (getintoption(CF_USESSL)) { 204 if (getintoption(CF_USESSL))
202 /* send data to server */ 205 sent = vc_tls_sendmessage (_staging, len);
203 if (vc_tls_sendmessage (msg, strlen (msg)) != strlen (msg)) 206 else
204 writecf (FS_ERR,"Message sending fuzzy."); 207 sent = write (serverfd, _staging, len);
205 208 if (sent != len)
206 /* send line termination to server */ 209 writecf (FS_ERR,"Message sending fuzzy.");
207 if (vc_tls_sendmessage ("\r\n", 2) != 2)
208 writecf (FS_ERR,"Message sending fuzzy.");
209 } else {
210 /* send data to server */
211 if (write (serverfd, msg, strlen (msg)) != strlen (msg))
212 writecf (FS_ERR,"Message sending fuzzy.");
213
214 /* send line termination to server */
215 if (write (serverfd, "\r\n", 2) != 2)
216 writecf (FS_ERR,"Message sending fuzzy.");
217 }
218} 210}
219 211
220/* offset in buffer (for linebreaks at packet borders) */ 212/* offset in buffer (for linebreaks at packet borders) */