diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-10-06 08:54:43 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-10-06 08:54:43 +0000 |
commit | e3222d807a6178e0a4a5254b8443c3432b663efb (patch) | |
tree | 9e404aedec15a6154b5f7ed891b7465181c91f9e /src/command.c | |
parent | 1a51bfb84a9d3eb6c1ae891403ab237ee24a3b12 (diff) | |
download | mpd-e3222d807a6178e0a4a5254b8443c3432b663efb.tar.gz mpd-e3222d807a6178e0a4a5254b8443c3432b663efb.tar.xz mpd-e3222d807a6178e0a4a5254b8443c3432b663efb.zip |
Revert buffer2array() behavior back to tried and true 0.11.x version
Warren's fix in r4872 made phpMp work again, but also broke
the unit tests completely (they work in this version).
The version in 0.12.0 is far too buggy (it was from mpd-ke, what
do you expect?). This one passes all the unit tests that the
mpd-ke one passed, and should also work with phpMp when used
with PHP magic quotes.
This also means we can search on 100 (or more) tags at once, so
no more arbitrary limits other than system memory.
To run the unit tests, just do this:
gcc -o t -DUNIT_TEST=1 src/buffer2array.c && ./t && echo OK
git-svn-id: https://svn.musicpd.org/mpd/trunk@4874 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/command.c b/src/command.c index f1b98a9f3..41fdbd716 100644 --- a/src/command.c +++ b/src/command.c @@ -108,13 +108,6 @@ #define COMMAND_STATUS_AUDIO "audio" #define COMMAND_STATUS_UPDATING_DB "updating_db" -/* - * The most we ever use is for search/find, and that limits it to the - * number of tags we can have. Add one for the command, and one extra - * to catch errors clients may send us - */ -#define COMMAND_ARGV_MAX (2+(TAG_NUM_OF_ITEM_TYPES*2)) - typedef struct _CommandEntry CommandEntry; typedef int (*CommandHandlerFunction) (int, int *, int, char **); @@ -1059,28 +1052,27 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(int fd, static CommandEntry *getCommandEntryFromString(char *string, int *permission) { CommandEntry *cmd = NULL; - char *argv[COMMAND_ARGV_MAX] = { NULL }; - int argc = buffer2array(string, argv, COMMAND_ARGV_MAX); + char **argv; + int argc = buffer2array(string, &argv); if (0 == argc) return NULL; cmd = getCommandEntryAndCheckArgcAndPermission(0, permission, argc, argv); + freeArgArray(argv, argc); return cmd; } static int processCommandInternal(int fd, int *permission, - char *commandString, struct strnode *cmdnode) + char *string, struct strnode *cmdnode) { - int argc; - char *argv[COMMAND_ARGV_MAX] = { NULL }; + char **argv; + int argc = buffer2array(string, &argv); CommandEntry *cmd; int ret = -1; - argc = buffer2array(commandString, argv, COMMAND_ARGV_MAX); - if (argc == 0) return 0; @@ -1094,6 +1086,8 @@ static int processCommandInternal(int fd, int *permission, } } + freeArgArray(argv, argc); + current_command = NULL; return ret; |