aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* diretory: moved code to directory_save.c, directory_print.cMax Kellermann2008-10-111-0/+1
| | | | | | Remove clutter from directory.c. Everything which saves or loads to/from the hard disk goes to directory_save.c, and code which sends directory information to the client is moved into directory_print.c.
* database: renamed functions, "db_" prefix and no CamelCaseMax Kellermann2008-10-111-1/+1
| | | | Yet another CamelCase removal patch.
* database: removed printDirectoryInfo()Max Kellermann2008-10-111-1/+4
| | | | The same can be achieved with directory_print(db_get_directory()).
* directory: moved code to database.cMax Kellermann2008-10-111-0/+1
| | | | | | Taming the directory.c monster, part II: move the database management stuff to database. directory.c should only contain code which works on directory objects.
* directory: moved code to update.cMax Kellermann2008-10-111-0/+1
| | | | | | The source directory.c mixes several libraries: directory object management, database management and database update, resulting in a 1000+ line monster. Move the whole database update code to update.c.
* command: fix return statusEric Wong2008-10-051-16/+6
| | | | | | This got broken when listHandlerFunc was removed. Since we no longer need it and it's confusing, remove processCommandInternal and just use process_command.
* Merge commit 'box/directory' into ew/song-locksEric Wong2008-10-041-145/+73
|\ | | | | | | | | | | | | | | | | | | | | * commit 'box/directory': command: get rid of specialized list handlers directory: simplify list update handling logic main_notify: define main_task so we can use it for assertions directory: streamline deletes Conflicts: src/command.c
| * command: get rid of specialized list handlersEric Wong2008-10-031-106/+67
| | | | | | | | | | | | | | | | commands should really not behave differently if they're issued inside a command list or not; so stop having special handler functions to deal with them. "update" was the only command that used this functionality and I changed that in the last commit to serialize access.
| * directory: simplify list update handling logicEric Wong2008-10-031-37/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the "update" command can be issued multiple times regardless of whether the client is in list mode or not. We serialize the update tasks to prevent updates from trampling over each other and will spawn another update task once the current one is finished updating and reaped. Right now we cap the queue size to 32 which is probably enough (I bet most people usually run update with no argument anyways); but we can make it grow/shrink dynamically if needed. There'll still be a hard-coded limit to prevent DoS attacks, though.
* | Switch to C99 types (retaining compat with old compilers)Eric Wong2008-09-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the mind needs to retrain itself to skip over the first 4 tokens of a type to get to its meaning. So avoid having extra characters on my terminal to make it easier to follow code at 2:30 am in the morning. Please report any new issues you may come across on Free toolchains. I realize how difficult it can be to build/maintain cross-compiling toolchains and I have no intention of forcing people to upgrade their toolchains to build mpd. Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32.
* | Merge branch 'ew/directory'Eric Wong2008-09-291-13/+35
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ew/directory: directory: remove redundant sanitizePathDup update: move path sanitation up the stack to avoid extra copies clean up updateInit calling and error handling directory: isRootDirectory() is a one-liner directory: writeDirectoryInfo propagates errors directory: make it clear that DIRECTORY_MTIME is deprecated directory: remove "Mp3" references playlist: deleteASongFromPlaylist takes a const Song * songvec: songvec_delete takes a const Song pointer directory: remove shortname arguments everywhere path: add mpd_basename() function directory.h: remove directory_sigChldHandler decl directory: replace DirectoryList with dirvec directory: remove unused CPP defines songvec_free => songvec_destroy directory.c: kill unnecessary includes
| * update: move path sanitation up the stack to avoid extra copiesEric Wong2008-09-291-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove yet another use of our old malloc-happy linked list implementation and replace it with a simple array of strings. This also implements more eager error handling of invalid paths (still centralized in updateInit) so we can filter out bad paths before we spawn a thread. This also does its part to fix the "update" command inside list mode which lost its static variable in ada24f9a921ff95d874195acf253b5a9dd12213d (although it was broken and requires the fix in 769939b62f7557f8e7c483223d68a8b39af43e37, too).
| * clean up updateInit calling and error handlingEric Wong2008-09-281-4/+16
| | | | | | | | | | Move error reporting to command.c so directory.c does not deal with client error handling any more.
* | command: don't clobber next list value when preparsingEric Wong2008-09-291-3/+6
|/ | | | | | | This only breaks "update" under list command mode and no other commands. This can be done more optimally without the extra heap allocation via xstrdup(); but is uncommon enough to not matter.
* command: fix command "addid"Max Kellermann2008-09-261-1/+1
| | | | | | With patch 8d2830b3, I broke "addid": it did not return the id of the new song, because of a typo in the return condition (== instead of !=).
* directory: update do its work inside a threadEric Wong2008-09-221-14/+4
| | | | | | | | | A lot of the preparation was needed (and done in previous months) in making update thread-safe, but here it is. This was the first thing I made work inside a thread when I started mpd-uclinux many years ago, and also the last thing I've done in mainline mpd to work inside a thread, go figure.
* playlist: return -1 after assert(0)Max Kellermann2008-09-091-0/+1
| | | | | | | print_playlist_result() had an assert(0) at the end, in case there was an invalid result value. With NDEBUG, this resulted in a function not returning a value - add a dummy "return -1" at the end to keep gcc quiet.
* command: concatenate strings at compile timeMax Kellermann2008-09-091-27/+33
| | | | | | String literals (including those defined in CPP macros) can be concatenated at compile time. This saves some CPU cycles in vsnprintf() at run time.
* audio: don't pass "fd" to {en,dis}ableAudioDevice()Max Kellermann2008-09-091-4/+14
| | | | No protocol code in the audio output library.
* volume: don't pass "fd" to changeVolumeLevel()Max Kellermann2008-09-091-4/+16
| | | | | The "volume" library shouldn't talk to the client. Move error handling to command.c.
* directory: printDirectoryInfo() does not call commandError()Max Kellermann2008-09-091-1/+3
| | | | Move another ocurrence of error handling over to command.c.
* directory: don't pass fd to traverseAllIn()Max Kellermann2008-09-091-4/+43
| | | | | | | | This patch continues the work of the previous patch: don't pass a file descriptor at all to traverseAllIn(). Since this fd was only used to report "directory not found" errors, we can easily move that check to the caller. This is a great relief, since it removes the dependency on a client connection from a lot of enumeration functions.
* playlist: PlaylistInfo() does not call commandError()Max Kellermann2008-09-091-2/+14
| | | | | | Continuing the effort of removing protocol specific calls from the core libraries: let the command.c code call commandError() based on PlaylistInfo's return value.
* playlist: don't pass "fd" to storedPlaylist.c functionsMax Kellermann2008-09-091-8/+23
| | | | | Return an "enum playlist_result" value instead of calling commandError() in storedPlaylist.c.
* playlist: don't pass "fd" to playlist.c functionsMax Kellermann2008-09-091-36/+126
| | | | | | The playlist library shouldn't talk to the client if possible. Introduce the "enum playlist_result" type which the caller (i.e. command.c) may use to generate an error message.
* playlist: showPlaylist() and shufflePlaylist() cannot failMax Kellermann2008-09-091-2/+4
| | | | Make them both return void.
* playlist: moved "repeat" and "random" value checks to command.cMax Kellermann2008-09-091-2/+18
| | | | | | | | Client's input values should be validated by the command implementation, and the core libraries shouldn't talk to the client directly if possible. Thus, setPlaylistRepeatStatus() and setPlaylistRandomStatus() don't get the file descriptor, and cannot fail (return void).
* tag: renamed functions, no CamelCaseMax Kellermann2008-09-021-1/+1
|
* include cleanupMax Kellermann2008-08-311-0/+1
| | | | Only include headers which are really needed.
* playlist: eliminate unused fd parametersMax Kellermann2008-08-311-8/+12
| | | | | Again, remove file descriptor parameters, which are not actually used. These functions can also be converted to return void.
* moved struct AudioFormat to audio_format.hMax Kellermann2008-08-301-0/+1
| | | | | We want to expose the AudioFormat structure to plugins; remove some clutter by moving its declaration to a separate header file.
* enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann2008-08-301-69/+129
| | | | | | Also enable -Wunused-parameter - this forces us to add the gcc "unused" attribute to a lot of parameters (mostly library callback functions), but it's worth it during code refactorizations.
* core rewrite (decode,player,outputBuffer,playlist)Eric Wong2008-08-161-23/+27
| | | | | | | | | | | | | This is a huge refactoring of the core mpd process. The queueing/buffering mechanism is heavily reworked. The player.c code has been merged into outputBuffer (the actual ring buffering logic is handled by ringbuf.c); and decode.c actually handles decoding stuff. The end result is several hundreds of lines shorter, even though we still have a lot of DEBUG statements left in there for tracing and a lot of assertions, too.
* command.c: remove dead commented codeEric Wong2008-04-141-1/+0
| | | | | We have revision control for a reason :) git-svn-id: https://svn.musicpd.org/mpd/trunk@7357 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* clean up CPP includesMax Kellermann2008-04-121-1/+2
| | | | | | | | | Try to only include headers which are really needed. We should particularly check all "headers including other headers". The long-term goal is to have a manageable, small API for plugins (decoders, output) without so many mpd internals cluttering the namespace. git-svn-id: https://svn.musicpd.org/mpd/trunk@7319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* eliminated duplicate initializationMax Kellermann2008-03-261-2/+2
| | | | | | | Local variables which are never read before the first assignment don't need initialization. Saves a few bytes of text. Also don't reset variables which are never read until function return. git-svn-id: https://svn.musicpd.org/mpd/trunk@7199 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix -Wconst warningsMax Kellermann2008-02-051-6/+5
| | | | | | [ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Revert the queue implementation and commandsEric Wong2008-01-261-50/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's too ugly and broken (both technically and usability-wise) to be worth supporting in any stable release. In one sentence: The queue is a very crippled version of the playlist that takes precedence over the normal playlist. How is it crippled? * The "queueid" command only allows the queuing of songs ALREADY IN THE PLAYLIST! This promotes having the entire mpd database of songs in the playlist, which is a stupid practice to begin with. * It doesn't allow for meaningful rearranging and movement of songs within the queue. To move a song, you'd need to dequeue and requeue it (and other songs on the list). Why? The playlist already allows _all_ these features and shows everything a client needs to know about the ordering of songs in a _single_ command! * Random was a stupid idea to begin with and unfortunately we're stuck supporting it since we've always had it. Users should learn to use "shuffle" instead and not look at their playlists. Implementing queue because we have the problem of random is just a bandage fix and digging ourselves a new hole. This protocol addition was never in a stable release of mpd, so reverting it will only break things for people following trunk; which I'm not too worried about. I am however worried about long-term support of this misfeature, so I'm removing it. Additionally, there are other points: * It's trivially DoS-able: (while true; do echo queueid $song_id; done) | nc $MPD_HOST $MPD_PORT The above commands would cause the queue to become infinitely expanding, taking up all available memory in the system. The mpd playlist was implemented as an array with a fixed (but configurable) size limit for this reason. * It's not backwards-compatible. All clients would require upgrades (and additional complexity) to even know what the next song in the playlist is. mpd is a shared architecture, and we should not violate the principle of least astonishment here. This removes the following commands: queueid, dequeue, queueinfo Additionally, the status field of "playlistqueue: " is removed from the status command. While this DoS is trivial to fix, the design is simply too broken to ever support in a real release. The overloading of the "addid" command and the allowing of negative numbers to be used as offsets is far more flexible. This improved "addid" is completely backwards-compatible with all clients, and does not require clients to have UI changes or run additional commands to display the queue. git-svn-id: https://svn.musicpd.org/mpd/trunk@7155 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* command: allow "addid" command to take an optional second argument, positionEric Wong2008-01-261-2/+14
| | | | | | | | | | | This will allow "addid \"song_url\" <pos>" to atomically insert a song at any given playlist position. If the add succeeds, but the actual movement fails (due to invalid position), then the song_id will be deleted before the command returns back to the client, and the client will get an error response. git-svn-id: https://svn.musicpd.org/mpd/trunk@7151 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* command: cleanup integer argument validation for commandsEric Wong2008-01-261-214/+106
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7150 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* addToPlaylist/addSongToPlaylist: printId argument changed to added_idEric Wong2008-01-261-2/+7
| | | | | | | | | | | | Instead of printing out the Id from playlist.c, instead set the integer that added_id poitns to if added_id is non-NULL. This makes the API cleaner and will allow us to use additional commands to manipulate the newly-added song_id. Callers (handleAddId) that relied on printId to print it to the given fd have now been modified to print the ID at a higher-level; making playlist.c less-dependent on protocol details. git-svn-id: https://svn.musicpd.org/mpd/trunk@7149 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fixed -Wshadow warningsMax Kellermann2008-01-261-13/+13
| | | | | Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7143 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleanup #includes of standard system headers and put them in one placeEric Wong2008-01-031-6/+1
| | | | | | | | | | | | | This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Playlist queue patch (http://musicpd.org/mantis/view.php?id=1478) version 11.Qball Cow2007-09-261-0/+50
| | | | | | | | | | | | | This adds the following commands: * queueid <id> Add song <id> to the queue. * dequeue <pos> Remove song from <pos> from the queue * queueinfo List the queue To the statusfield it adds the following entry: playlistqueue: <uid> UID can be used by clients to track changes in the playlist queue. git-svn-id: https://svn.musicpd.org/mpd/trunk@6927 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Adding rename command, for renaming stored playlists.J. Alexander Treuman2007-05-241-0/+7
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6246 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't list playlists in lsinfo if the path isn't the root directory (theyJ. Alexander Treuman2007-05-241-11/+12
| | | | | can't be loaded anyway). git-svn-id: https://svn.musicpd.org/mpd/trunk@6244 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Committing pat's rewrite of the stored playlist code. This also adds twoJ. Alexander Treuman2007-05-161-0/+42
| | | | | new commands: playlistmove and playlistdelete. git-svn-id: https://svn.musicpd.org/mpd/trunk@6116 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Adding count command. It's usage is identical to find, but instead ofJ. Alexander Treuman2007-04-251-0/+23
| | | | | | returning a list of matching songs, the number of results and total play time of the results are returned. git-svn-id: https://svn.musicpd.org/mpd/trunk@5950 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* When calling commandError(STDERR_FILENO, ...), don't set current_command toJ. Alexander Treuman2007-04-081-1/+1
| | | | | | | NULL. Doing so would mean future calls to commandError with a socket as an argument will still write the error message to the error log, and not the socket. git-svn-id: https://svn.musicpd.org/mpd/trunk@5891 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* If current_command is NULL when calling commandError, print the errorJ. Alexander Treuman2007-04-081-5/+8
| | | | | | message and trailing new line to STDERR_FILENO along with the ACK, instead of sending them over the socket. git-svn-id: https://svn.musicpd.org/mpd/trunk@5890 09075e82-0dd4-0310-85a5-a0d7c8717e4f