diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-05-04 22:21:39 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-05-04 22:21:39 +0100 |
commit | 417edbce2abde566e94d8986b487293d55e173c0 (patch) | |
tree | 133db23e0c58704f06447a77e8a1e964bf98be2c /sock_conn.c | |
parent | 0a24537719de7cab1b4df46e7d6a22564f66ec6a (diff) | |
download | agni-417edbce2abde566e94d8986b487293d55e173c0.tar.gz agni-417edbce2abde566e94d8986b487293d55e173c0.zip |
Added new commands CMD,SHA1. Added support of params for commands. Fixed some bugs with uninitialised buffers
Diffstat (limited to 'sock_conn.c')
-rw-r--r-- | sock_conn.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sock_conn.c b/sock_conn.c index 37c8892..42cb3a6 100644 --- a/sock_conn.c +++ b/sock_conn.c @@ -81,10 +81,18 @@ int __irc_buf_drain_io(irc_buf *ib) return 0; } + //BUG + //here is hope that server will send 512/1024 bytes that will be terminated with "\r\n" + //but this could be false hope if someone gona abuse it, buffer will fill up and will + //not be able to give back new lines + //FIX + //just add more logic pal to handle this "special" case + + //lets from in buffer put as much as possible to out buffer i = ib->in_size-1; j = ib->out_size; - //PRINT("in_size=%d out_size=%d\n",ib->in_size, ib->out_size); + PRINT("in_size=%d out_size=%d\n",ib->in_size, ib->out_size); cnt = 0; while ((j<ib->max_out_size)&&(i>=0)) //buffers ar full or empty { @@ -93,7 +101,7 @@ int __irc_buf_drain_io(irc_buf *ib) { if (((ib->buf_out[j-3]=='\r')&&(ib->buf_out[j-2]=='\n')))//bufferunderflow { - //PRINT("READY\n"); + PRINT("READY\n"); ib->ready = 1; //PNL(); break; @@ -105,20 +113,20 @@ int __irc_buf_drain_io(irc_buf *ib) cnt++; } //update - //PRINT("Copied %d bytes\n", cnt); + PRINT("Copied %d bytes\n", cnt); ib->in_size = i+1; //i can end up as -1 ib->out_size = j; // - //PRINT("in_size=%d out_size=%d\n",ib->in_size, ib->out_size); + PRINT("in_size=%d out_size=%d\n",ib->in_size, ib->out_size); //if out buffer full and its doesnt have proper ending if (ib->out_size >= 2) if ((ib->buf_out[ib->out_size-1]=='\n')&&(ib->buf_out[ib->out_size-2]=='\r')) { - //PRINT("READY\n"); + PRINT("READY\n"); ib->ready = 1; return cnt; } - //PRINT("%d\n",cnt); + PRINT("%d\n",cnt); return cnt; } |