From: Andre Noll Date: Sun, 11 Feb 2007 16:49:50 +0000 (+0100) Subject: kill STRINGSIZE macro X-Git-Tag: v0.2.15~24 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;ds=sidebyside;h=48107fb4b9ad286edc38bc336a8703eea7048f88;p=paraslash.git kill STRINGSIZE macro It's kind of silly. Just open code the desired value. --- diff --git a/command.c b/command.c index d0d9047b..6f6fad7c 100644 --- a/command.c +++ b/command.c @@ -34,6 +34,9 @@ #include "user_list.h" #include "server_command_list.h" +/** commands including options must be shorter than this */ +#define MAX_COMMAND_LEN 4096 + static RC4_KEY rc4_recv_key; static RC4_KEY rc4_send_key; static unsigned char rc4_buf[2 * RC4_KEY_LEN]; @@ -788,7 +791,7 @@ static void rc4_send(unsigned long len, const unsigned char *indata, int handle_connect(int fd, struct sockaddr_in *addr) { int numbytes, ret, argc, use_rc4 = 0; - char buf[STRINGSIZE]; + char buf[4096]; unsigned char crypt_buf[MAXLINE]; struct user u; struct server_command *cmd = NULL; @@ -872,7 +875,7 @@ int handle_connect(int fd, struct sockaddr_in *addr) while ((numbytes = recv_buffer(fd, buf, sizeof(buf))) > 0) { // PARA_INFO_LOG("recvd: %s (%d)\n", buf, numbytes); ret = -E_COMMAND_SYNTAX; - if (command && numbytes + strlen(command) > STRINGSIZE) /* DOS */ + if (command && numbytes + strlen(command) > MAX_COMMAND_LEN) /* DOS */ goto err_out; command = para_strcat(command, buf); if ((p = strstr(command, EOC_MSG))) { diff --git a/gui.c b/gui.c index 7588f2b2..d2a5fdcc 100644 --- a/gui.c +++ b/gui.c @@ -875,7 +875,7 @@ static int do_select(int mode) fd_set rfds; int ret; int max_fileno, cp_numread = 1; - char command_buf[STRINGSIZE] = ""; + char command_buf[4096] = ""; int cbo = 0; /* command buf offset */ struct timeval tv; repeat: @@ -907,7 +907,7 @@ repeat: if (command_pipe >= 0 && mode == COMMAND_MODE && FD_ISSET(command_pipe, &rfds)) { cp_numread = read(command_pipe, command_buf + cbo, - STRINGSIZE - 1 - cbo); + sizeof(command_buf) - 1 - cbo); if (cp_numread >= 0) cbo += cp_numread; else { diff --git a/gui_common.c b/gui_common.c index 87676986..26c3d61b 100644 --- a/gui_common.c +++ b/gui_common.c @@ -3,7 +3,6 @@ extern const char *status_item_list[NUM_STAT_ITEMS]; - int para_open_audiod_pipe(char *cmd) { int fds[3] = {0, 1, 0}; @@ -20,7 +19,7 @@ int para_open_audiod_pipe(char *cmd) int read_audiod_pipe(int fd, void (*line_handler)(char *) ) { - static char buf[STRINGSIZE]; + static char buf[4096]; const ssize_t bufsize = sizeof(buf) - 1; static ssize_t loaded; ssize_t ret; diff --git a/para.h b/para.h index 10931aaf..ee7134de 100644 --- a/para.h +++ b/para.h @@ -38,8 +38,7 @@ #include #include "gcc-compat.h" -/* some internal constants */ -#define STRINGSIZE 4096 +/** used in various contexts */ #define MAXLINE 255