]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
kill STRINGSIZE macro
authorAndre Noll <maan@systemlinux.org>
Sun, 11 Feb 2007 16:49:50 +0000 (17:49 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 11 Feb 2007 16:49:50 +0000 (17:49 +0100)
It's kind of silly. Just open code the desired value.

command.c
gui.c
gui_common.c
para.h

index d0d9047b7d3d97dc1061a6c52db158e500d4969c..6f6fad7c4028e0f10833cc30033402e126731d66 100644 (file)
--- a/command.c
+++ b/command.c
@@ -34,6 +34,9 @@
 #include "user_list.h"
 #include "server_command_list.h"
 
 #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];
 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;
 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;
        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;
        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))) {
                        goto err_out;
                command = para_strcat(command, buf);
                if ((p = strstr(command, EOC_MSG))) {
diff --git a/gui.c b/gui.c
index 7588f2b2ec7f7136962c4d5b4b7b086ff1648b17..d2a5fdccc5c1ccd1f92ada797302ffa566c13702 100644 (file)
--- 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;
        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:
        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,
        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 {
                if (cp_numread >= 0)
                        cbo += cp_numread;
                else {
index 87676986719c326340d1612ec85763349d2225be..26c3d61b73feacd5b77d45e86767944ef5680564 100644 (file)
@@ -3,7 +3,6 @@
 
 extern const char *status_item_list[NUM_STAT_ITEMS];
 
 
 extern const char *status_item_list[NUM_STAT_ITEMS];
 
-
 int para_open_audiod_pipe(char *cmd)
 {
        int fds[3] = {0, 1, 0};
 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 *) )
 {
 
 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;
        const ssize_t bufsize = sizeof(buf) - 1;
        static ssize_t loaded;
        ssize_t ret;
diff --git a/para.h b/para.h
index 10931aaf08461cef768d95720a833e0f86f8139e..ee7134de86624db46a14eab74693e7dbed56ee5d 100644 (file)
--- a/para.h
+++ b/para.h
@@ -38,8 +38,7 @@
 #include <string.h>
 #include "gcc-compat.h"
 
 #include <string.h>
 #include "gcc-compat.h"
 
-/* some internal constants */
-#define STRINGSIZE 4096
+/** used in various contexts */
 #define MAXLINE 255
 
 
 #define MAXLINE 255