/usr/include/libmpd-1.0/libmpd/libmpd.h is in libmpd-dev 0.20.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | /* libmpd (high level libmpdclient library)
* Copyright (C) 2004-2009 Qball Cow <qball@sarine.nl>
* Project homepage: http://gmpcwiki.sarine.nl/
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \example testcase.c
* A small example of a console client using libmpd.
*/
/** \defgroup 1Basic Basic
*/
/*@{*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MPD_LIB__
#define __MPD_LIB__
#ifdef WIN32
#define __REGEX_IMPORT__ 1
#define __W32API_USE_DLLIMPORT__ 1
#endif
#include "libmpdclient.h"
#ifndef TRUE
/** Defined for readability: True is 1. */
#define TRUE 1
#endif
#ifndef FALSE
/** Defined for readability: False is 0. */
#define FALSE 0
#endif
#include "libmpd-version.h"
extern char *libmpd_version;
/**
* Enum that represent the errors libmpd functions can return
*/
typedef enum {
/** Command/function completed succesfull */
MPD_OK = 0,
/** Error in the function's arguments */
MPD_ARGS_ERROR = -5,
/** Action failed because there is no connection to an mpd daemon */
MPD_NOT_CONNECTED = -10,
/** Failed to grab status*/
MPD_STATUS_FAILED = -20,
/** Connection is still locked */
MPD_LOCK_FAILED = -30,
/** Failed to grab status */
MPD_STATS_FAILED = -40,
/** Mpd server returned an error */
MPD_SERVER_ERROR = -50,
/** Mpd doesn't support this feature */
MPD_SERVER_NOT_SUPPORTED = -51,
/** The playlist already exists */
MPD_DATABASE_PLAYLIST_EXIST = -60,
/** Playlist is empty */
MPD_PLAYLIST_EMPTY = -70,
/** Playlist queue is empty */
MPD_PLAYLIST_QUEUE_EMPTY = -75,
/** Player isn't Playing */
MPD_PLAYER_NOT_PLAYING = -80,
/** Tag Item not found */
MPD_TAG_NOT_FOUND = -90,
/* MPD_PLALIST_LOAD_FAILED */
MPD_PLAYLIST_LOAD_FAILED = -100,
/** Fatal error, something I am not sure what todo with */
MPD_FATAL_ERROR = -1000
}MpdError;
/**
* The Main Mpd Object. Don't access any of the internal values directly, but use the provided functions.
*/
typedef struct _MpdObj MpdObj;
/**
*
* enum that represents the state of a command.
*/
typedef enum {
MPD_SERVER_COMMAND_ALLOWED = TRUE,
MPD_SERVER_COMMAND_NOT_ALLOWED = FALSE,
MPD_SERVER_COMMAND_NOT_SUPPORTED = -1,
MPD_SERVER_COMMAND_ERROR = -2
} MpdServerCommand;
/**
* \ingroup MpdData
* enumeration to determine what value the MpdData structure hold.
* The MpdData structure can hold only one type of value,
* but a list of MpdData structs can hold structs with different type of values.
* It's required to check every MpdData Structure.
*/
typedef enum {
/** The MpdData structure holds no value*/
MPD_DATA_TYPE_NONE,
/** Holds an Tag String. value->tag is filled value->tag_type defines what type of tag.*/
MPD_DATA_TYPE_TAG,
/** Holds an Directory String. value->directory is filled.*/
MPD_DATA_TYPE_DIRECTORY,
/** Holds an MpdSong Structure. value->song is valid.*/
MPD_DATA_TYPE_SONG,
/** Holds an Playlist String. value->playlist is filled.*/
MPD_DATA_TYPE_PLAYLIST,
/** Holds an MpdOutputDevice structure. value->output_dev is valid.*/
MPD_DATA_TYPE_OUTPUT_DEV
} MpdDataType;
/**
* \ingroup #MpdData
* A fast linked list that is used to pass data from libmpd to the client.
*/
typedef struct _MpdData {
/** a #MpdDataType */
MpdDataType type;
union {
struct {
/** a #mpd_TagItems defining what #tag contains */
int tag_type;
/** a string containing the tag*/
char *tag;
};
/** a directory */
char *directory;
/** a path to a playlist */
mpd_PlaylistFile *playlist;
/** a mpd_Song */
mpd_Song *song;
/** an output device entity */
mpd_OutputEntity *output_dev;
};
void *userdata;
void (*freefunc)(void *userdata);
} MpdData;
#include "libmpd-player.h"
#include "libmpd-status.h"
#include "libmpd-database.h"
#include "libmpd-playlist.h"
#include "libmpd-strfsong.h"
#include "libmpd-sticker.h"
/**
* mpd_new_default
*
* Create a new #MpdObj with default settings.
* Hostname will be set to "localhost".
* Port will be 6600.
*
* same as calling:
* @code
* mpd_new("localhost",6600,NULL);
* @endcode
*
* @returns the new #MpdObj
*/
MpdObj *mpd_new_default();
/**
* @param hostname The hostname to connect to
* @param port The port to connect to
* @param password The password to use for the connection, or NULL for no password
*
* Create a new #MpdObj with provided settings:
*
* @returns the new #MpdObj
*/
MpdObj *mpd_new(char *hostname, int port, char *password);
/**
*@param mi a #MpdObj
*@param hostname The new hostname to use
*
* set the hostname
*
* @returns a #MpdError. (#MPD_OK if everything went ok)
*/
int mpd_set_hostname(MpdObj * mi, char *hostname);
/**
* @param mi a #MpdObj
*
* gets the set hostname
*
* @returns a const char representing the hostname
*/
const char * mpd_get_hostname(MpdObj *mi);
/**
* @param mi a #MpdObj
* @param password The new password to use
*
* Set the password
*
* @returns a #MpdError. (#MPD_OK if everything went ok)
*/
int mpd_set_password(MpdObj * mi,const char *password);
/**
* @param mi a #MpdObj
* @param port The port to use. (Default: 6600)
*
* Set the Port number
*
*
* @returns a #MpdError. (#MPD_OK if everything went ok)
*/
int mpd_set_port(MpdObj * mi, int port);
/**
* @param mi a #MpdObj
* @param timeout: A timeout (in seconds)
*
* Set the timeout of the connection.
* If already connected the timeout of the running connection
*
* @returns a #MpdError. (MPD_OK if everything went ok)
*/
int mpd_set_connection_timeout(MpdObj * mi, float timeout);
int mpd_connect_real(MpdObj *mi,mpd_Connection *connection);
/**
* @param mi a #MpdObj
*
* Connect to the mpd daemon.
* Warning: mpd_connect connects anonymous, to authenticate use #mpd_send_password
*
* @returns returns a #MpdError, MPD_OK when successful
*/
int mpd_connect(MpdObj * mi);
/**
* @param mi The #MpdObj to disconnect
*
* Disconnect the current connection
* @returns MPD_OK (always)
*/
int mpd_disconnect(MpdObj * mi);
/**
* @param mi a #MpdObj
*
* Checks if #MpdObj is connected
* @returns True when connected
*/
int mpd_check_connected(MpdObj * mi);
/**
* @param mi a #MpdObj
*
* Checks if there was an error
* @returns True when there is an error
*/
int mpd_check_error(MpdObj * mi);
/**
* @param mi a #MpdObj
*
* Free the #MpdObj, when still connected the connection will be disconnected first
*/
void mpd_free(MpdObj * mi);
/**
* @param mi a #MpdObj
*
* Forces libmpd to re-authenticate itself.
*
* When successful it will trigger the "permission" changed signal.
*
* @returns: a #MpdError
*/
int mpd_send_password(MpdObj * mi);
/*
* signals
*/
/**
* Bitwise enumeration to determine what triggered the status_changed signals
* This is used in combination with the #StatusChangedCallback
* @code
* void status_changed_callback(MpdObj *mi, ChangedStatusType what)
* {
* if(what&MPD_CST_SONGID)
* {
* // act on song change
*
* }
* if(what&MPD_CST_RANDOM)
* {
* // act on random change
* }
* // etc.
* }
* @endcode
*/
typedef enum {
/** The playlist has changed */
MPD_CST_PLAYLIST = 0x0001,
/** The song position of the playing song has changed*/
MPD_CST_SONGPOS = 0x0002,
/** The songid of the playing song has changed */
MPD_CST_SONGID = 0x0004,
/** The database has changed. */
MPD_CST_DATABASE = 0x0008,
/** the state of updating the database has changed.*/
MPD_CST_UPDATING = 0x0010,
/** the volume has changed */
MPD_CST_VOLUME = 0x0020,
/** The total time of the currently playing song has changed*/
MPD_CST_TOTAL_TIME = 0x0040,
/** The elapsed time of the current song has changed.*/
MPD_CST_ELAPSED_TIME = 0x0080,
/** The crossfade time has changed. */
MPD_CST_CROSSFADE = 0x0100,
/** The random state is changed. */
MPD_CST_RANDOM = 0x0200,
/** repeat state is changed. */
MPD_CST_REPEAT = 0x0400,
/** Not implemented */
MPD_CST_AUDIO = 0x0800,
/** The state of the player has changed.*/
MPD_CST_STATE = 0x1000,
/** The permissions the client has, has changed.*/
MPD_CST_PERMISSION = 0x2000,
/** The bitrate of the playing song has changed. */
MPD_CST_BITRATE = 0x4000,
/** the audio format of the playing song changed.*/
MPD_CST_AUDIOFORMAT = 0x8000,
/** the queue has changed */
MPD_CST_STORED_PLAYLIST = 0x20000,
/** server error */
MPD_CST_SERVER_ERROR = 0x40000,
/** output changed */
MPD_CST_OUTPUT = 0x80000,
/** Sticker changed */
MPD_CST_STICKER = 0x100000,
/** Next song changed */
MPD_CST_NEXTSONG = 0x200000,
/** Single mode changed */
MPD_CST_SINGLE_MODE = 0x400000,
/** Consume mode changed */
MPD_CST_CONSUME_MODE = 0x800000,
/** Replaygain mode changed */
MPD_CST_REPLAYGAIN = 0x1000000
} ChangedStatusType;
/* callback typedef's */
/**
* @param mi a #MpdObj
* @param what a #ChangedStatusType that determines what changed triggered the signal. This is a bitmask.
* @param userdata user data set when the signal handler was connected.
*
* Signal that gets called when the state of mpd has changed. Look #ChangedStatusType to see the possible events.
*/
typedef void (*StatusChangedCallback) (MpdObj * mi, ChangedStatusType what, void *userdata);
/**
* @param mi a #MpdObj
* @param id The error Code.
* @param msg human-readable informative error message.
* @param userdata user data set when the signal handler was connected.
* This signal is called when an error has occurred in the communication with mpd.
*
* return: TRUE if libmpd should disconnect.
*/
typedef int (*ErrorCallback) (MpdObj * mi, int id, char *msg, void *userdata);
/**
* @param mi a #MpdObj
* @param connect 1 if you are now connected, 0 if you are disconnected.
* @param userdata user data set when the signal handler was connected.
* Signal is triggered when the connection state changes.
*/
typedef void (*ConnectionChangedCallback) (MpdObj * mi, int connect, void *userdata);
/* new style signal connectors */
/**
* @param mi a #MpdObj
* @param status_changed a #StatusChangedCallback
* @param userdata user data passed to the callback
*/
void mpd_signal_connect_status_changed(MpdObj * mi, StatusChangedCallback status_changed,
void *userdata);
/**
* @param mi a #MpdObj
* @param error a #ErrorCallback
* @param userdata user data passed to the callback
*/
void mpd_signal_connect_error(MpdObj * mi, ErrorCallback error, void *userdata);
/**
* @param mi a #MpdObj
* @param connection_changed a #ConnectionChangedCallback
* @param userdata user data passed to the callback
*/
void mpd_signal_connect_connection_changed(MpdObj * mi,
ConnectionChangedCallback connection_changed,
void *userdata);
/*@}*/
/**\defgroup MpdData Data Object
* This is a fast linked list implementation where data returned from mpd is stored in.
*/
/*@{*/
/**
* @param data a #MpdData
*
* Checks if the passed #MpdData is the last in a list
* @returns TRUE when data is the last in the list.
*/
int mpd_data_is_last(MpdData const *data);
/**
* @param data a #MpdData
*
* Free's a #MpdData List
*/
void mpd_data_free(MpdData * data);
/**
* @param data a #MpdData
*
* Returns the next #MpdData in the list.
* If it's the last item in the list, it will free the list.
*
* You can iterate through a list like this and have it freed afterwards.
* @code
* for(data = mpd_database_get_albums(mi);data != NULL; data = mpd_data_get_next(data))
* {
* // do your thing
* }
* @endcode
* @returns The next #MpdData or %NULL
*/
MpdData *mpd_data_get_next(MpdData * data);
/**
* @param data a #MpdData
*
* Returns the first #MpdData in the list.
*
* @returns The first #MpdData or %NULL
*/
MpdData *mpd_data_get_first(MpdData const *data);
/**
* @param data a #MpdData item
*
* removes the passed #MpdData from the underlying list, and returns the element before data
*
* @returns a #MpdData list
*/
MpdData *mpd_data_delete_item(MpdData * data);
/*@}*/
/** \defgroup Server Server
* Functions to get information about the mpd daemon and or modify it.
*/
/*@{*/
/**
* @param mi a #MpdObj
*
* Returns a list of audio output devices stored in a #MpdData list
*
* @returns a #MpdData
*/
MpdData *mpd_server_get_output_devices(MpdObj * mi);
/**
* @param mi a #MpdObj
* @param device_id The id of the output device
* @param state The state to change the output device to, 1 is enable, 0 is disable.
*
* Enable or Disable an audio output device
*
* @returns 0 if successful
*/
int mpd_server_set_output_device(MpdObj * mi, int device_id, int state);
/**
* @param mi a #MpdObj
*
* Gets a unix timestamp of the last time the database was updated.
*
* @returns unix Timestamp
*/
long unsigned mpd_server_get_database_update_time(MpdObj * mi);
/**
* @param mi a #MpdObj
* @param major the major version number
* @param minor the minor version number
* @param micro the micro version number
*
* Checks if the connected mpd server version is equal or higher.
*
* @returns #TRUE when version of mpd equals or is higher, else #FALSE
*/
int mpd_server_check_version(MpdObj * mi, int major, int minor, int micro);
/**
* @param mi a #MpdObj
*
* @return a string with version or NULL when not connected
*/
char *mpd_server_get_version(MpdObj *mi);
/**
* @param mi a #MpdObj
* @param command the command to check
*
* Checks if the user is allowed to execute the command and if the server supports it
*
* @returns Returns #MpdServerCommand
*/
int mpd_server_check_command_allowed(MpdObj * mi, const char *command);
/**
* @param mi a #MpdObj
*
* @returns an array with urlhandlers (NULL terminated). Result must be freed.
*/
char ** mpd_server_get_url_handlers(MpdObj *mi);
/**
* @param mi a #MpdObj
*
* @returns an array with supported tag types. (NULL Terminated). Result must be freed.
*/
char ** mpd_server_get_tag_types(MpdObj *mi);
/*@}*/
/** \defgroup Misc Misc
* Helper functions.
*/
/*@{*/
/**
* @param name a NULL terminated string
*
* gets the Matching #MpdDataType matching at the string
*
* @returns a #MpdDataType
*/
int mpd_misc_get_tag_by_name(char *name);
/*@}*/
/**
* @param mi a #MpdObj
*
* Reports if the connected mpd supports the idle command.
*
* @returns a boolean, TRUE if it has idle support
*/
int mpd_server_has_idle(MpdObj *mi);
/**
* @param mi a #MpdObj
* @param tag a #mpd_TagItems
*
* Returns if mpd supports this tag.
*
* return 1 if support 0 if not
*/
int mpd_server_tag_supported(MpdObj *mi, int tag);
typedef enum {
MPD_SERVER_REPLAYGAIN_MODE_OFF = 0,
MPD_SERVER_REPLAYGAIN_MODE_TRACK = 1,
MPD_SERVER_REPLAYGAIN_MODE_ALBUM = 2
}MpdServerReplaygainMode;
MpdServerReplaygainMode mpd_server_get_replaygain_mode(MpdObj *mi);
int mpd_server_set_replaygain_mode(MpdObj *mi, MpdServerReplaygainMode mode);
#endif
#ifdef __cplusplus
}
#endif
|