libmpdclient.h   libmpdclient.h 
/* libmpdclient /* libmpdclient
(c)2003-2004 by Warren Dukes (shank@mercury.chem.pitt.edu) (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
This project's homepage is: http://www.musicpd.org This project's homepage is: http://www.musicpd.org
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: are met:
- Redistributions of source code must retain the above copyright - Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright - Redistributions in binary form must reproduce the above copyright
skipping to change at line 31 skipping to change at line 31
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION O R A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION O R
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef LIBMPDCLIENT_H #ifndef LIBMPDCLIENT_H
#define LIBMPDCLIENT_H #define LIBMPDCLIENT_H
#include <sys/time.h> #ifdef WIN32
# define __W32API_USE_DLLIMPORT__ 1
#endif
#include <sys/time.h>
#include <stdarg.h>
#define MPD_BUFFER_MAX_LENGTH 50000 #define MPD_BUFFER_MAX_LENGTH 50000
#define MPD_WELCOME_MESSAGE "OK MPD " #define MPD_WELCOME_MESSAGE "OK MPD "
#define MPD_ERROR_TIMEOUT 10 /* timeout trying to talk to mpd */ #define MPD_ERROR_TIMEOUT 10 /* timeout trying to talk to mpd */
#define MPD_ERROR_SYSTEM 11 /* system error */ #define MPD_ERROR_SYSTEM 11 /* system error */
#define MPD_ERROR_UNKHOST 12 /* unknown host */ #define MPD_ERROR_UNKHOST 12 /* unknown host */
#define MPD_ERROR_CONNPORT 13 /* problems connecting to port on host */ #define MPD_ERROR_CONNPORT 13 /* problems connecting to port on host */
#define MPD_ERROR_NOTMPD 14 /* mpd not running on port at host */ #define MPD_ERROR_NOTMPD 14 /* mpd not running on port at host */
#define MPD_ERROR_NORESPONSE 15 /* no response on attempting to connect * / #define MPD_ERROR_NORESPONSE 15 /* no response on attempting to connect * /
#define MPD_ERROR_SENDING 16 /* error sending command */ #define MPD_ERROR_SENDING 16 /* error sending command */
skipping to change at line 74 skipping to change at line 77
#define MPD_ACK_ERROR_SYSTEM 52 #define MPD_ACK_ERROR_SYSTEM 52
#define MPD_ACK_ERROR_PLAYLIST_LOAD 53 #define MPD_ACK_ERROR_PLAYLIST_LOAD 53
#define MPD_ACK_ERROR_UPDATE_ALREADY 54 #define MPD_ACK_ERROR_UPDATE_ALREADY 54
#define MPD_ACK_ERROR_PLAYER_SYNC 55 #define MPD_ACK_ERROR_PLAYER_SYNC 55
#define MPD_ACK_ERROR_EXIST 56 #define MPD_ACK_ERROR_EXIST 56
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef enum mpd_TagItems
{
MPD_TAG_ITEM_ARTIST,
MPD_TAG_ITEM_ALBUM,
MPD_TAG_ITEM_TITLE,
MPD_TAG_ITEM_TRACK,
MPD_TAG_ITEM_NAME,
MPD_TAG_ITEM_GENRE,
MPD_TAG_ITEM_DATE,
MPD_TAG_ITEM_COMPOSER,
MPD_TAG_ITEM_PERFORMER,
MPD_TAG_ITEM_COMMENT,
MPD_TAG_ITEM_DISC,
MPD_TAG_ITEM_FILENAME,
MPD_TAG_NUM_OF_ITEM_TYPES
}mpd_TagItems;
extern char * mpdTagItemKeys[MPD_TAG_NUM_OF_ITEM_TYPES];
/* internal stuff don't touch this struct */ /* internal stuff don't touch this struct */
typedef struct _mpd_ReturnElement { typedef struct _mpd_ReturnElement {
char * name; char * name;
char * value; char * value;
} mpd_ReturnElement; } mpd_ReturnElement;
/* mpd_Connection /* mpd_Connection
* holds info about connection to mpd * holds info about connection to mpd
* use error, and errorStr to detect errors * use error, and errorStr to detect errors
*/ */
skipping to change at line 104 skipping to change at line 126
int sock; int sock;
char buffer[MPD_BUFFER_MAX_LENGTH+1]; char buffer[MPD_BUFFER_MAX_LENGTH+1];
int buflen; int buflen;
int bufstart; int bufstart;
int doneProcessing; int doneProcessing;
int listOks; int listOks;
int doneListOk; int doneListOk;
int commandList; int commandList;
mpd_ReturnElement * returnElement; mpd_ReturnElement * returnElement;
struct timeval timeout; struct timeval timeout;
char *request;
} mpd_Connection; } mpd_Connection;
/* mpd_newConnection /* mpd_newConnection
* use this to open a new connection * use this to open a new connection
* you should use mpd_closeConnection, when your done with the connection, * you should use mpd_closeConnection, when your done with the connection,
* even if an error has occurred * even if an error has occurred
* _timeout_ is the connection timeout period in seconds * _timeout_ is the connection timeout period in seconds
*/ */
mpd_Connection * mpd_newConnection(const char * host, int port, float timeo ut); mpd_Connection * mpd_newConnection(const char * host, int port, float timeo ut);
skipping to change at line 234 skipping to change at line 257
char * artist; char * artist;
/* title, maybe NULL if there is no tag */ /* title, maybe NULL if there is no tag */
char * title; char * title;
/* album, maybe NULL if there is no tag */ /* album, maybe NULL if there is no tag */
char * album; char * album;
/* track, maybe NULL if there is no tag */ /* track, maybe NULL if there is no tag */
char * track; char * track;
/* name, maybe NULL if there is no tag; it's the name of the current /* name, maybe NULL if there is no tag; it's the name of the current
* song, f.e. the icyName of the stream */ * song, f.e. the icyName of the stream */
char * name; char * name;
/* date */
char *date;
/* added by qball */
/* Genre */
char *genre;
/* Composer */
char *composer;
/* Disc */
char *disc;
/* Comment */
char *comment;
/* length of song in seconds, check that it is not MPD_SONG_NO_TIME */ /* length of song in seconds, check that it is not MPD_SONG_NO_TIME */
int time; int time;
/* if plchanges/playlistinfo/playlistid used, is the position of the /* if plchanges/playlistinfo/playlistid used, is the position of the
* song in the playlist */ * song in the playlist */
int pos; int pos;
/* song id for a song in the playlist */ /* song id for a song in the playlist */
int id; int id;
} mpd_Song; } mpd_Song;
/* mpd_newSong /* mpd_newSong
* use to allocate memory for a new mpd_Song * use to allocate memory for a new mpd_Song
* file, artist, etc all initialized to NULL * file, artist, etc all initialized to NULL
* if your going to assign values to file, artist, etc * if your going to assign values to file, artist, etc
* be sure to malloc or strdup the memory * be sure to malloc or strdup the memory
* use mpd_freeSong to free the memory for the mpd_Song, it will also * use mpd_freeSong to free the memory for the mpd_Song, it will also
* free memory for file, artist, etc, so don't do it yourself * free memory for file, artist, etc, so don't do it yourself
*/ */
mpd_Song * mpd_newSong(); mpd_Song * mpd_newSong(void);
/* mpd_freeSong /* mpd_freeSong
* use to free memory allocated by mpd_newSong * use to free memory allocated by mpd_newSong
* also it will free memory pointed to by file, artist, etc, so be careful * also it will free memory pointed to by file, artist, etc, so be careful
*/ */
void mpd_freeSong(mpd_Song * song); void mpd_freeSong(mpd_Song * song);
/* mpd_songDup /* mpd_songDup
* works like strDup, but for a mpd_Song * works like strDup, but for a mpd_Song
*/ */
skipping to change at line 277 skipping to change at line 313
* used to store info fro directory (right now that just the path) * used to store info fro directory (right now that just the path)
*/ */
typedef struct _mpd_Directory { typedef struct _mpd_Directory {
char * path; char * path;
} mpd_Directory; } mpd_Directory;
/* mpd_newDirectory /* mpd_newDirectory
* allocates memory for a new directory * allocates memory for a new directory
* use mpd_freeDirectory to free this memory * use mpd_freeDirectory to free this memory
*/ */
mpd_Directory * mpd_newDirectory (); mpd_Directory * mpd_newDirectory(void);
/* mpd_freeDirectory /* mpd_freeDirectory
* used to free memory allocated with mpd_newDirectory, and it frees * used to free memory allocated with mpd_newDirectory, and it frees
* path of mpd_Directory, so be careful * path of mpd_Directory, so be careful
*/ */
void mpd_freeDirectory(mpd_Directory * directory); void mpd_freeDirectory(mpd_Directory * directory);
/* mpd_directoryDup /* mpd_directoryDup
* works like strdup, but for mpd_Directory * works like strdup, but for mpd_Directory
*/ */
skipping to change at line 303 skipping to change at line 339
* stores info about playlist file returned by lsinfo * stores info about playlist file returned by lsinfo
*/ */
typedef struct _mpd_PlaylistFile { typedef struct _mpd_PlaylistFile {
char * path; char * path;
} mpd_PlaylistFile; } mpd_PlaylistFile;
/* mpd_newPlaylistFile /* mpd_newPlaylistFile
* allocates memory for new mpd_PlaylistFile, path is set to NULL * allocates memory for new mpd_PlaylistFile, path is set to NULL
* free this memory with mpd_freePlaylistFile * free this memory with mpd_freePlaylistFile
*/ */
mpd_PlaylistFile * mpd_newPlaylistFile(); mpd_PlaylistFile * mpd_newPlaylistFile(void);
/* mpd_freePlaylist /* mpd_freePlaylist
* free memory allocated for freePlaylistFile, will also free * free memory allocated for freePlaylistFile, will also free
* path, so be careful * path, so be careful
*/ */
void mpd_freePlaylistFile(mpd_PlaylistFile * playlist); void mpd_freePlaylistFile(mpd_PlaylistFile * playlist);
/* mpd_playlistFileDup /* mpd_playlistFileDup
* works like strdup, but for mpd_PlaylistFile * works like strdup, but for mpd_PlaylistFile
*/ */
skipping to change at line 341 skipping to change at line 377
*/ */
int type; int type;
/* the actual data you want, mpd_Song, mpd_Directory, etc */ /* the actual data you want, mpd_Song, mpd_Directory, etc */
union { union {
mpd_Directory * directory; mpd_Directory * directory;
mpd_Song * song; mpd_Song * song;
mpd_PlaylistFile * playlistFile; mpd_PlaylistFile * playlistFile;
} info; } info;
} mpd_InfoEntity; } mpd_InfoEntity;
mpd_InfoEntity * mpd_newInfoEntity(); mpd_InfoEntity * mpd_newInfoEntity(void);
void mpd_freeInfoEntity(mpd_InfoEntity * entity); void mpd_freeInfoEntity(mpd_InfoEntity * entity);
/* INFO COMMANDS AND STUFF */ /* INFO COMMANDS AND STUFF */
/* use this function to loop over after calling Info/Listall functions */ /* use this function to loop over after calling Info/Listall functions */
mpd_InfoEntity * mpd_getNextInfoEntity(mpd_Connection * connection); mpd_InfoEntity * mpd_getNextInfoEntity(mpd_Connection * connection);
/* fetches the currently seeletect song (the song referenced by status->son g /* fetches the currently seeletect song (the song referenced by status->son g
* and status->songid*/ * and status->songid*/
void mpd_sendCurrentSongCommand(mpd_Connection * connection); void mpd_sendCurrentSongCommand(mpd_Connection * connection);
/* songNum of -1, means to display the whole list */ /* songNum of -1, means to display the whole list */
void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songNum); void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songNum);
/* songId of -1, means to display the whole list */
void mpd_sendPlaylistIdCommand(mpd_Connection * connection, int songId);
/* use this to get the changes in the playlist since version _playlist_ */ /* use this to get the changes in the playlist since version _playlist_ */
void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playli st); void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playli st);
/**
* @param connection: A valid and connected mpd_Connection.
* @param playlist: The playlist version you want the diff with.
* A more bandwidth efficient version of the mpd_sendPlChangesCommand.
* It only returns the pos+id of the changes song.
*/
void mpd_sendPlChangesPosIdCommand(mpd_Connection * connection, long long p
laylist);
/* recursivel fetches all songs/dir/playlists in "dir* (no metadata is /* recursivel fetches all songs/dir/playlists in "dir* (no metadata is
* returned) */ * returned) */
void mpd_sendListallCommand(mpd_Connection * connection, const char * dir); void mpd_sendListallCommand(mpd_Connection * connection, const char * dir);
/* same as sendListallCommand, but also metadata is returned */ /* same as sendListallCommand, but also metadata is returned */
void mpd_sendListallInfoCommand(mpd_Connection * connection, const char * d ir); void mpd_sendListallInfoCommand(mpd_Connection * connection, const char * d ir);
/* non-recursive version of ListallInfo */ /* non-recursive version of ListallInfo */
void mpd_sendLsInfoCommand(mpd_Connection * connection, const char * dir); void mpd_sendLsInfoCommand(mpd_Connection * connection, const char * dir);
skipping to change at line 390 skipping to change at line 437
/* LIST TAG COMMANDS */ /* LIST TAG COMMANDS */
/* use this function fetch next artist entry, be sure to free the returned /* use this function fetch next artist entry, be sure to free the returned
* string. NULL means there are no more. Best used with sendListArtists * string. NULL means there are no more. Best used with sendListArtists
*/ */
char * mpd_getNextArtist(mpd_Connection * connection); char * mpd_getNextArtist(mpd_Connection * connection);
char * mpd_getNextAlbum(mpd_Connection * connection); char * mpd_getNextAlbum(mpd_Connection * connection);
char * mpd_getNextTag(mpd_Connection *connection, int table);
/* list artist or albums by artist, arg1 should be set to the artist if /* list artist or albums by artist, arg1 should be set to the artist if
* listing albums by a artist, otherwise NULL for listing all artists or al bums * listing albums by a artist, otherwise NULL for listing all artists or al bums
*/ */
void mpd_sendListCommand(mpd_Connection * connection, int table, void mpd_sendListCommand(mpd_Connection * connection, int table,
const char * arg1); const char * arg1);
/* SIMPLE COMMANDS */ /* SIMPLE COMMANDS */
void mpd_sendAddCommand(mpd_Connection * connection, const char * file); void mpd_sendAddCommand(mpd_Connection * connection, const char * file);
skipping to change at line 476 skipping to change at line 525
void mpd_sendCommandListOkBegin(mpd_Connection * connection); void mpd_sendCommandListOkBegin(mpd_Connection * connection);
void mpd_sendCommandListEnd(mpd_Connection * connection); void mpd_sendCommandListEnd(mpd_Connection * connection);
/* advance to the next listOk /* advance to the next listOk
* returns 0 if advanced to the next list_OK, * returns 0 if advanced to the next list_OK,
* returns -1 if it advanced to an OK or ACK */ * returns -1 if it advanced to an OK or ACK */
int mpd_nextListOkCommand(mpd_Connection * connection); int mpd_nextListOkCommand(mpd_Connection * connection);
typedef struct _mpd_OutputEntity {
int id;
char * name;
int enabled;
} mpd_OutputEntity;
void mpd_sendOutputsCommand(mpd_Connection * connection);
mpd_OutputEntity * mpd_getNextOutput(mpd_Connection * connection);
void mpd_sendEnableOutputCommand(mpd_Connection * connection, int outputId)
;
void mpd_sendDisableOutputCommand(mpd_Connection * connection, int outputId
);
void mpd_freeOutputElement(mpd_OutputEntity * output);
/**
* @param connection a #mpd_Connection
*
* Queries mpd for the allowed commands
*/
void mpd_sendCommandsCommand(mpd_Connection * connection);
/**
* @param connection a #mpd_Connection
*
* Queries mpd for the not allowed commands
*/
void mpd_sendNotCommandsCommand(mpd_Connection * connection);
/**
* @param connection a #mpd_Connection
*
* returns the next supported command.
*
* @returns a string, needs to be free'ed
*/
char *mpd_getNextCommand(mpd_Connection *connection);
/**
* @param connection a MpdConnection
* @param path the path to the playlist.
*
* List the content, with full metadata, of a stored playlist.
*
*/
void mpd_sendListPlaylistInfoCommand(mpd_Connection *connection, char *path
);
/**
* @param connection a MpdConnection
* @param path the path to the playlist.
*
* List the content of a stored playlist.
*
*/
void mpd_sendListPlaylistCommand(mpd_Connection *connection, char *path);
/**
* @param connection a #mpd_Connection
* @param exact if to match exact
*
* starts a search, use mpd_addConstraintSearch to add
* a constraint to the search, and mpd_commitSearch to do the actual search
*/
void mpd_startSearch(mpd_Connection * connection,int exact);
/**
* @param connection a #mpd_Connection
* @param field
* @param name
*
*/
void mpd_addConstraintSearch(mpd_Connection *connection, int field, char *n
ame);
/**
* @param connection a #mpd_Connection
*
*/
void mpd_commitSearch(mpd_Connection *connection);
/**
* @param connection a #mpd_Connection
* @param field The field to search
*
* starts a search for fields... f.e. get a list of artists would be:
* mpd_startFieldSearch(connection, MPD_TAG_ITEM_ARTIST);
* mpd_commitSearch(connection);
*
* or get a list of artist in genre "jazz" would be:
* @code
* mpd_startFieldSearch(connection, MPD_TAG_ITEM_ARTIST);
* mpd_addConstraintSearch(connection, MPD_TAG_ITEM_GENRE, "jazz")
* mpd_commitSearch(connection);
* @endcode
*
* mpd_startSearch will return a list of songs (and you need mpd_getNextIn
foEntity)
* this one will return a list of only one field (the field specified with
field) and you need
* mpd_getNextTag to get the results
*/
void mpd_startFieldSearch(mpd_Connection * connection,int field);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 15 change blocks. 
7 lines changed or deleted 159 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/