From d861cb0fd3591d712041661d43722ff652bc2612 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 27 Jul 2006 21:05:15 +0000 Subject: [PATCH] Use of constants for min/max DCC blocksize --- src/common/weeconfig.c | 2 +- src/irc/irc-dcc.c | 4 ++-- src/irc/irc.h | 3 +++ weechat/src/common/weeconfig.c | 2 +- weechat/src/irc/irc-dcc.c | 4 ++-- weechat/src/irc/irc.h | 3 +++ 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index 11d05ce70..cb8449539 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -825,7 +825,7 @@ t_config_option weechat_options_dcc[] = NULL, NULL, &cfg_dcc_timeout, NULL, &config_change_noop }, { "dcc_blocksize", N_("block size for dcc packets"), N_("block size for dcc packets in bytes (default: 65536)"), - OPTION_TYPE_INT, 1024, 102400, 65536, + OPTION_TYPE_INT, DCC_MIN_BLOCKSIZE, DCC_MAX_BLOCKSIZE, 65536, NULL, NULL, &cfg_dcc_blocksize, NULL, &config_change_noop }, { "dcc_port_range", N_("allowed ports for outgoing dcc"), N_("restricts outgoing dcc to use only ports in the given range " diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c index c51b6cb12..b35ecc459 100644 --- a/src/irc/irc-dcc.c +++ b/src/irc/irc-dcc.c @@ -1294,7 +1294,7 @@ dcc_handle () { t_irc_dcc *ptr_dcc; int num_read, num_sent; - static char buffer[102400]; + static char buffer[DCC_MAX_BLOCKSIZE]; uint32_t pos; fd_set read_fd; static struct timeval timeout; @@ -1453,7 +1453,7 @@ dcc_handle () gui_printf (NULL, _("%s DCC failed because blocksize is too " "big. Check value of \"dcc_blocksize\" option, " "max is %d.\n"), - sizeof (buffer)); + WEECHAT_ERROR, DCC_MAX_BLOCKSIZE); dcc_close (ptr_dcc, DCC_FAILED); dcc_redraw (HOTLIST_MSG); continue; diff --git a/src/irc/irc.h b/src/irc/irc.h index f1b9ee3f9..ede0d6668 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -248,6 +248,9 @@ struct t_irc_message #define DCC_FAILED 4 /* DCC failed */ #define DCC_ABORTED 5 /* DCC aborted by user */ +#define DCC_MIN_BLOCKSIZE 1024 /* min DCC block size when sending file */ +#define DCC_MAX_BLOCKSIZE 102400 /* max DCC block size when sending file */ + #define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) #define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) #define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV)) diff --git a/weechat/src/common/weeconfig.c b/weechat/src/common/weeconfig.c index 11d05ce70..cb8449539 100644 --- a/weechat/src/common/weeconfig.c +++ b/weechat/src/common/weeconfig.c @@ -825,7 +825,7 @@ t_config_option weechat_options_dcc[] = NULL, NULL, &cfg_dcc_timeout, NULL, &config_change_noop }, { "dcc_blocksize", N_("block size for dcc packets"), N_("block size for dcc packets in bytes (default: 65536)"), - OPTION_TYPE_INT, 1024, 102400, 65536, + OPTION_TYPE_INT, DCC_MIN_BLOCKSIZE, DCC_MAX_BLOCKSIZE, 65536, NULL, NULL, &cfg_dcc_blocksize, NULL, &config_change_noop }, { "dcc_port_range", N_("allowed ports for outgoing dcc"), N_("restricts outgoing dcc to use only ports in the given range " diff --git a/weechat/src/irc/irc-dcc.c b/weechat/src/irc/irc-dcc.c index c51b6cb12..b35ecc459 100644 --- a/weechat/src/irc/irc-dcc.c +++ b/weechat/src/irc/irc-dcc.c @@ -1294,7 +1294,7 @@ dcc_handle () { t_irc_dcc *ptr_dcc; int num_read, num_sent; - static char buffer[102400]; + static char buffer[DCC_MAX_BLOCKSIZE]; uint32_t pos; fd_set read_fd; static struct timeval timeout; @@ -1453,7 +1453,7 @@ dcc_handle () gui_printf (NULL, _("%s DCC failed because blocksize is too " "big. Check value of \"dcc_blocksize\" option, " "max is %d.\n"), - sizeof (buffer)); + WEECHAT_ERROR, DCC_MAX_BLOCKSIZE); dcc_close (ptr_dcc, DCC_FAILED); dcc_redraw (HOTLIST_MSG); continue; diff --git a/weechat/src/irc/irc.h b/weechat/src/irc/irc.h index f1b9ee3f9..ede0d6668 100644 --- a/weechat/src/irc/irc.h +++ b/weechat/src/irc/irc.h @@ -248,6 +248,9 @@ struct t_irc_message #define DCC_FAILED 4 /* DCC failed */ #define DCC_ABORTED 5 /* DCC aborted by user */ +#define DCC_MIN_BLOCKSIZE 1024 /* min DCC block size when sending file */ +#define DCC_MAX_BLOCKSIZE 102400 /* max DCC block size when sending file */ + #define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) #define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) #define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV))