summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c96
1 files changed, 0 insertions, 96 deletions
diff --git a/src/network.c b/src/network.c
index 0903b4f..38569cc 100644
--- a/src/network.c
+++ b/src/network.c
@@ -389,99 +389,3 @@ readn(int fd, unsigned char* buf, int amount)
return amount;
}
-
-int
-send_message(char type, clifd fd, unsigned char* buf, int amount)
-{
- unsigned long clen;
- int length;
- static unsigned char bufor[9000];
- aflog(LOG_T_MAIN, LOG_I_DEBUG,
- "send_message: ssl:%s zlib:%s length:%d", (TYPE_IS_SSL(type))?"yes":"no",
- (TYPE_IS_ZLIB(type))?"yes":"no", amount);
- clen = 8995;
- length = amount - 5;
- if (TYPE_IS_ZLIB(type)) {
- memcpy(bufor, buf, 5);
- if (amount > 5) {
- compress(&bufor[5], &clen, &buf[5], length);
- if (clen < length) {
- length = clen;
- TYPE_SET_COMP(length);
- bufor[3] = length >> 8; /* high bits of message length */
- bufor[4] = length; /* low bits of message length */
- addtocg(amount-5 - clen);
- }
- }
- if (TYPE_IS_SSL(type)) {
- if (TYPE_IS_COMP(length)) {
- return SSL_writen(fd.ssl, bufor, clen+5);
- }
- else {
- return SSL_writen(fd.ssl, buf, amount);
- }
- }
- else {
- if (TYPE_IS_COMP(length)) {
- return writen(fd.commfd, bufor, clen+5);
- }
- else {
- return writen(fd.commfd, buf, amount);
- }
- }
- }
- else {
- if (TYPE_IS_SSL(type)) {
- return SSL_writen(fd.ssl, buf, amount);
- }
- else {
- return writen(fd.commfd, buf, amount);
- }
- }
-}
-
-int
-get_message(char type, clifd fd, unsigned char* buf, int amount)
-{
- int length;
- unsigned long elen;
- static unsigned char bufor[9000];
- aflog(LOG_T_MAIN, LOG_I_DEBUG,
- "get_message: ssl:%s zlib:%s length:%d", (TYPE_IS_SSL(type))?"yes":"no",
- (TYPE_IS_ZLIB(type))?"yes":"no", amount);
- if (amount == -5) {
- if (TYPE_IS_SSL(type)) {
- return SSL_read(fd.ssl, buf, 5);
- }
- else {
- return read(fd.commfd, buf, 5);
- }
- }
- if (TYPE_IS_ZLIB(type)) {
- if (TYPE_IS_SSL(type)) {
- length = SSL_readn(fd.ssl, bufor, amount&0xBFFF);
- }
- else {
- length = readn(fd.commfd, bufor, amount&0xBFFF);
- }
- if (length <= 0) return length;
- elen = 8096;
- if (TYPE_IS_COMP(amount)) {
- uncompress(buf, &elen, bufor, length);
- }
- else {
- memcpy(buf, bufor, length);
- elen = length;
- }
- return elen;
- }
- else
- {
- if (TYPE_IS_SSL(type)) {
- return SSL_readn(fd.ssl, buf, amount);
- }
- else {
- return readn(fd.commfd, buf, amount);
- }
- }
-}