aboutsummaryrefslogtreecommitdiffstats
path: root/src/command.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-09-07playlist: return -1 after assert(0)Max Kellermann1-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.
2008-09-07command: use client_[gs]et_permission()Max Kellermann1-78/+83
Don't pass a pointer to client->permission to processCommand(), better let the code in command.c use the new permission getter/setter functions.
2008-09-07command: don't pass permission as pointer where appropriateMax Kellermann1-6/+6
Some functions don't want to modify a client's permission set. Pass the permissions to them by value, not by reference.
2008-09-07audio: don't pass "fd" to printAudioDevices()Max Kellermann1-1/+1
Pass the client struct instead.
2008-09-07stats: don't pass "fd" to printStats()Max Kellermann1-1/+1
Pass the client struct instead of the raw file descriptor.
2008-09-07playlist: don't pass "fd" to showPlaylist(), playlistChangesPosId()Max Kellermann1-2/+2
Pass the client struct instead of the raw file descriptor.
2008-09-07ls: don't pass "fd" to lsPlaylists(), printRemoteUrlHandlers()Max Kellermann1-2/+2
Pass the client struct instead of the raw file descriptor.
2008-09-07command: concatenate strings at compile timeMax Kellermann1-27/+27
String literals (including those defined in CPP macros) can be concatenated at compile time. This saves some CPU cycles in vsnprintf() at run time.
2008-09-07command: removed commandError()Max Kellermann1-25/+0
commandError() has been superseded by command_error(), and is not being used anymore. Remove it.
2008-09-07playlist: pass struct client to loadPlaylist()Max Kellermann1-1/+1
The function loadPlaylist() wants to report incremental errors to the client, for this reason we cannot remove its protocol dependency right now. Instead, make it use the client struct instead of the raw file descriptor.
2008-09-07pass "struct client" to dbUtils.c, song.c, tag_print.cMax Kellermann1-16/+16
Don't pass the raw file descriptor around. This migration patch is rather large, because all of the sources have inter dependencies - we have to change all of them at the same time.
2008-09-07command: pass struct client to all commandsMax Kellermann1-248/+259
Pass the client struct to CommandHandlerFunction and CommandListHandlerFunction. Most commands cannot take real advantage of that yet, since most of them still work with the raw file descriptor.
2008-09-07command: pass struct client to getCommandEntryAnd...()Max Kellermann1-26/+21
Instead of passing the file descriptor, pass the client struct to getCommandEntryAndCheckArgcAndPermission().
2008-09-07command: added command_success() and command_error()Max Kellermann1-0/+28
These two functions take a client struct instead of the file descriptor. We will now begin passing the client struct around instead of a raw file descriptor (which needed a linear lookup in the client list to be useful).
2008-09-07audio: don't pass "fd" to {en,dis}ableAudioDevice()Max Kellermann1-4/+14
No protocol code in the audio output library.
2008-09-07volume: don't pass "fd" to changeVolumeLevel()Max Kellermann1-4/+16
The "volume" library shouldn't talk to the client. Move error handling to command.c.
2008-09-07directory: don't pass "fd" to updateInit()Max Kellermann1-5/+43
Again, move error handling to command.c.
2008-09-07directory: printDirectoryInfo() does not call commandError()Max Kellermann1-1/+3
Move another ocurrence of error handling over to command.c.
2008-09-07directory: don't pass fd to traverseAllIn()Max Kellermann1-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.
2008-09-07playlist: PlaylistInfo() does not call commandError()Max Kellermann1-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.
2008-09-07playlist: don't pass "fd" to storedPlaylist.c functionsMax Kellermann1-8/+23
Return an "enum playlist_result" value instead of calling commandError() in storedPlaylist.c.
2008-09-07playlist: don't pass "fd" to playlist.c functionsMax Kellermann1-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.
2008-09-07playlist: showPlaylist() and shufflePlaylist() cannot failMax Kellermann1-2/+4
Make them both return void.
2008-09-07playlist: moved "repeat" and "random" value checks to command.cMax Kellermann1-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).
2008-09-07tag: moved code to tag_print.cMax Kellermann1-0/+1
Move everything which dumps a tag to a file descriptor to tag_print.c. This relaxes dependencies and splits the code into smaller parts.
2008-09-07client: added client_write() and client_puts()Max Kellermann1-2/+1
client_write() writes a buffer to the client and buffers it if required. client_puts() does the same for a C string. The next patch will add more tools which will replace fdprintf() later.
2008-09-06include cleanupMax Kellermann1-0/+1
As usual, include only headers which are really needed.
2008-08-29tag: renamed functions, no CamelCaseMax Kellermann1-1/+1
2008-08-29export the function client_is_expired()Max Kellermann1-2/+2
Instead of passing the pointer to the "expired" flag to processListOfCommands(), this function should use the client API to check this flag. We can now remove the "global_expired" hack introduced recently.
2008-08-29client: pass the client struct to processCommand()Max Kellermann1-5/+9
Start exporting the client struct as an opaque struct. For now, pass it only to processCommand() and processListOfCommands(), and provide a function to extract the socket handle. Later, we will propagate the pointer to all command implementations, and of course to client_print() etc.
2008-08-28include cleanupMax Kellermann1-0/+1
Only include headers which are really needed.
2008-08-26renamed player.c to player_control.cMax Kellermann1-1/+1
Give player.c a better name, meaning that the code is used to control the player thread.
2008-08-26playlist: eliminate unused fd parametersMax Kellermann1-8/+12
Again, remove file descriptor parameters, which are not actually used. These functions can also be converted to return void.
2008-08-26player: no "fd" and no return valueMax Kellermann1-2/+5
Most player*() functions do not actually use the file descriptor, and always return 0 (success). Eliminate them to get a leaner interface.
2008-08-26moved struct AudioFormat to audio_format.hMax Kellermann1-0/+1
We want to expose the AudioFormat structure to plugins; remove some clutter by moving its declaration to a separate header file.
2008-08-26enable -Wpointer-arith, -Wstrict-prototypesMax Kellermann1-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.
2008-04-14command.c: remove dead commented codeEric Wong1-1/+0
We have revision control for a reason :) git-svn-id: https://svn.musicpd.org/mpd/trunk@7357 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-04-12clean up CPP includesMax Kellermann1-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
2008-03-26eliminated duplicate initializationMax Kellermann1-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
2008-02-05fix -Wconst warningsMax Kellermann1-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
2008-01-26Revert the queue implementation and commandsEric Wong1-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
2008-01-26command: allow "addid" command to take an optional second argument, positionEric Wong1-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
2008-01-26command: cleanup integer argument validation for commandsEric Wong1-214/+106
git-svn-id: https://svn.musicpd.org/mpd/trunk@7150 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2008-01-26addToPlaylist/addSongToPlaylist: printId argument changed to added_idEric Wong1-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
2008-01-26fixed -Wshadow warningsMax Kellermann1-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
2008-01-03Cleanup #includes of standard system headers and put them in one placeEric Wong1-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
2007-09-26Playlist queue patch (http://musicpd.org/mantis/view.php?id=1478) version 11.Qball Cow1-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
2007-05-24Adding rename command, for renaming stored playlists.J. Alexander Treuman1-0/+7
git-svn-id: https://svn.musicpd.org/mpd/trunk@6246 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-05-24Don't list playlists in lsinfo if the path isn't the root directory (theyJ. Alexander Treuman1-11/+12
can't be loaded anyway). git-svn-id: https://svn.musicpd.org/mpd/trunk@6244 09075e82-0dd4-0310-85a5-a0d7c8717e4f
2007-05-16Committing pat's rewrite of the stored playlist code. This also adds twoJ. Alexander Treuman1-0/+42
new commands: playlistmove and playlistdelete. git-svn-id: https://svn.musicpd.org/mpd/trunk@6116 09075e82-0dd4-0310-85a5-a0d7c8717e4f