summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-23 15:47:28 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-23 15:47:28 +0200
commit5afcd41752602f8c76faab8042a46e6b8c66bbb6 (patch)
tree39870e8e903490896b3f617e28b321ac78b4c83a
parent95df994be69a49a6e40a105fa349a553dd03a766 (diff)
downloadpianobar-windows-5afcd41752602f8c76faab8042a46e6b8c66bbb6.tar.gz
pianobar-windows-5afcd41752602f8c76faab8042a46e6b8c66bbb6.tar.bz2
pianobar-windows-5afcd41752602f8c76faab8042a46e6b8c66bbb6.zip
Be correct, use "const"
-rw-r--r--libpiano/src/crypt.c17
-rw-r--r--libpiano/src/crypt.h4
-rw-r--r--libpiano/src/http.c4
-rw-r--r--libpiano/src/http.h4
-rw-r--r--libpiano/src/main.c38
-rw-r--r--libpiano/src/piano.h27
-rw-r--r--libpiano/src/xml.c54
-rw-r--r--libpiano/src/xml.h19
-rw-r--r--libwardrobe/src/main.c32
-rw-r--r--libwardrobe/src/wardrobe.h4
-rw-r--r--src/main.c22
-rw-r--r--src/settings.c3
12 files changed, 124 insertions, 104 deletions
diff --git a/libpiano/src/crypt.c b/libpiano/src/crypt.c
index 9176408..7a17927 100644
--- a/libpiano/src/crypt.c
+++ b/libpiano/src/crypt.c
@@ -35,7 +35,8 @@ THE SOFTWARE.
* @param return size of array
* @return nothing, yet
*/
-void PianoHexToInts (char *strHex, unsigned int **retInts, size_t *retIntsN) {
+void PianoHexToInts (const char *strHex, unsigned int **retInts,
+ size_t *retIntsN) {
size_t i;
char hexInt[9];
unsigned int *arrInts = calloc (strlen (strHex) / 8, sizeof (*arrInts));
@@ -56,7 +57,7 @@ void PianoHexToInts (char *strHex, unsigned int **retInts, size_t *retIntsN) {
* @param decrypt-me-length
* @param return plain ints array
*/
-void PianoDecipherInts (unsigned int *cipherInts, size_t cipherIntsN,
+void PianoDecipherInts (const unsigned int *cipherInts, size_t cipherIntsN,
unsigned int **retPlainInts) {
unsigned int *plainInts = calloc (cipherIntsN, sizeof (*plainInts));
size_t i, j;
@@ -96,7 +97,7 @@ void PianoDecipherInts (unsigned int *cipherInts, size_t cipherIntsN,
* @param length of array
* @return the string
*/
-char *PianoIntsToString (unsigned int *arrInts, size_t arrIntsN) {
+char *PianoIntsToString (const unsigned int *arrInts, size_t arrIntsN) {
char *strDecoded = calloc (arrIntsN * 4 + 1, sizeof (*strDecoded));
size_t i;
unsigned int *tmp;
@@ -114,7 +115,7 @@ char *PianoIntsToString (unsigned int *arrInts, size_t arrIntsN) {
* @param hex string
* @return decrypted string
*/
-char *PianoDecryptString (char *strInput) {
+char *PianoDecryptString (const char *strInput) {
unsigned int *cipherInts, *plainInts;
size_t cipherIntsN;
char *strDecrypted;
@@ -135,7 +136,7 @@ char *PianoDecryptString (char *strInput) {
* @param returns size of int array
* @return nothing
*/
-void PianoBytesToInts (char *strInput, unsigned int **retArrInts,
+void PianoBytesToInts (const char *strInput, unsigned int **retArrInts,
size_t *retArrIntsN) {
size_t i, j, neededStrLen = strlen (strInput);
unsigned int *arrInts;
@@ -171,7 +172,7 @@ void PianoBytesToInts (char *strInput, unsigned int **retArrInts,
* @param how many ints
* @param returns crypted ints; memory is allocated by this function
*/
-void PianoEncipherInts (unsigned int *plainInts, size_t plainIntsN,
+void PianoEncipherInts (const unsigned int *plainInts, size_t plainIntsN,
unsigned int **retCipherInts) {
unsigned int *cipherInts = calloc (plainIntsN, sizeof (*cipherInts));
size_t i, j;
@@ -211,7 +212,7 @@ void PianoEncipherInts (unsigned int *plainInts, size_t plainIntsN,
* @param size of array
* @return string; memory is allocated here, don't forget to free it
*/
-char *PianoIntsToHexString (unsigned int *arrInts, size_t arrIntsN) {
+char *PianoIntsToHexString (const unsigned int *arrInts, size_t arrIntsN) {
/* 4 bytes as hex (= 8 chars) */
char *hexStr = calloc (arrIntsN * 4 * 2 + 1, sizeof (*hexStr));
size_t i;
@@ -226,7 +227,7 @@ char *PianoIntsToHexString (unsigned int *arrInts, size_t arrIntsN) {
* @param encrypt this
* @return encrypted, hex-encoded string
*/
-char *PianoEncryptString (char *strInput) {
+char *PianoEncryptString (const char *strInput) {
unsigned int *plainInts, *cipherInts;
size_t plainIntsN;
char *strHex;
diff --git a/libpiano/src/crypt.h b/libpiano/src/crypt.h
index 5b097f1..3694846 100644
--- a/libpiano/src/crypt.h
+++ b/libpiano/src/crypt.h
@@ -23,7 +23,7 @@ THE SOFTWARE.
#ifndef _CRYPH_H
#define _CRYPT_H
-char *PianoDecryptString (char *strInput);
-char *PianoEncryptString (char *strInput);
+char *PianoDecryptString (const char *strInput);
+char *PianoEncryptString (const char *strInput);
#endif /* _CRYPT_H */
diff --git a/libpiano/src/http.c b/libpiano/src/http.c
index ada1510..91941d9 100644
--- a/libpiano/src/http.c
+++ b/libpiano/src/http.c
@@ -58,7 +58,7 @@ size_t PianoCurlRetToVar (void *ptr, size_t size, size_t nmemb, void *stream) {
* @param put received data here, memory is allocated by this function
* @return nothing yet
*/
-PianoReturn_t PianoHttpPost (CURL *ch, char *url, char *postData,
+PianoReturn_t PianoHttpPost (CURL *ch, const char *url, const char *postData,
char **retData) {
struct curl_slist *headers = NULL;
/* Let's hope nothing will be bigger than this... */
@@ -96,7 +96,7 @@ PianoReturn_t PianoHttpPost (CURL *ch, char *url, char *postData,
* @param put received data here, memory is allocated by this function
* @return nothing yet
*/
-PianoReturn_t PianoHttpGet (CURL *ch, char *url, char **retData) {
+PianoReturn_t PianoHttpGet (CURL *ch, const char *url, char **retData) {
/* Let's hope nothing will be bigger than this... */
char curlRet[PIANO_HTTP_BUFFER_SIZE];
PianoReturn_t ret;
diff --git a/libpiano/src/http.h b/libpiano/src/http.h
index 9c13bc9..fdc93b2 100644
--- a/libpiano/src/http.h
+++ b/libpiano/src/http.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
#include "piano.h"
-PianoReturn_t PianoHttpPost (CURL *ch, char *url, char *postData,
+PianoReturn_t PianoHttpPost (CURL *ch, const char *url, const char *postData,
char **retData);
-PianoReturn_t PianoHttpGet (CURL *ch, char *url, char **retData);
+PianoReturn_t PianoHttpGet (CURL *ch, const char *url, char **retData);
#endif /* _HTTP_H */
diff --git a/libpiano/src/main.c b/libpiano/src/main.c
index 0a909b8..7215fae 100644
--- a/libpiano/src/main.c
+++ b/libpiano/src/main.c
@@ -41,8 +41,8 @@ THE SOFTWARE.
#define PIANO_SEND_BUFFER_SIZE 10000
/* prototypes */
-PianoReturn_t PianoAddFeedback (PianoHandle_t *, char *, char *, char *,
- char *, char *, PianoSongRating_t);
+PianoReturn_t PianoAddFeedback (PianoHandle_t *, const char *, const char *,
+ const char *, const char *, const char *, PianoSongRating_t);
/* more "secure" free version; only use this function, not original free ()
* in this library
@@ -189,8 +189,8 @@ void PianoDestroy (PianoHandle_t *ph) {
* @param use ssl when logging in (1 = on, 0 = off), note that the password
* is not hashed and will be sent as plain-text!
*/
-PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password,
- char secureLogin) {
+PianoReturn_t PianoConnect (PianoHandle_t *ph, const char *user,
+ const char *password, char secureLogin) {
char url[PIANO_URL_BUFFER_SIZE];
char *requestStr = PianoEncryptString ("<?xml version=\"1.0\"?>"
"<methodCall><methodName>misc.sync</methodName>"
@@ -266,7 +266,7 @@ PianoReturn_t PianoGetStations (PianoHandle_t *ph) {
* @param piano handle
* @param station id
*/
-PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, char *stationId) {
+PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, const char *stationId) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr;
PianoReturn_t ret;
@@ -328,8 +328,9 @@ PianoReturn_t PianoRateTrack (PianoHandle_t *ph, PianoSong_t *song,
* @param move here
* @param song to move
*/
-PianoReturn_t PianoMoveSong (PianoHandle_t *ph, PianoStation_t *stationFrom,
- PianoStation_t *stationTo, PianoSong_t *song) {
+PianoReturn_t PianoMoveSong (PianoHandle_t *ph,
+ const PianoStation_t *stationFrom, const PianoStation_t *stationTo,
+ const PianoSong_t *song) {
PianoReturn_t ret;
/* ban from current station */
@@ -351,9 +352,10 @@ PianoReturn_t PianoMoveSong (PianoHandle_t *ph, PianoStation_t *stationFrom,
* @param song focus trait id or NULL
* @param rating
*/
-PianoReturn_t PianoAddFeedback (PianoHandle_t *ph, char *stationId,
- char *songMusicId, char *songMatchingSeed, char *songUserSeed,
- char *songFocusTraitId, PianoSongRating_t rating) {
+PianoReturn_t PianoAddFeedback (PianoHandle_t *ph, const char *stationId,
+ const char *songMusicId, const char *songMatchingSeed,
+ const char *songUserSeed, const char *songFocusTraitId,
+ PianoSongRating_t rating) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr;
PianoReturn_t ret = PIANO_RET_ERR;
@@ -405,7 +407,7 @@ PianoReturn_t PianoAddFeedback (PianoHandle_t *ph, char *stationId,
* @return
*/
PianoReturn_t PianoRenameStation (PianoHandle_t *ph, PianoStation_t *station,
- char *newName) {
+ const char *newName) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr, *urlencodedNewName, *xmlencodedNewName;
PianoReturn_t ret = PIANO_RET_ERR;
@@ -500,8 +502,8 @@ PianoReturn_t PianoDeleteStation (PianoHandle_t *ph, PianoStation_t *station) {
* @param utf-8 search string
* @param return search result
*/
-PianoReturn_t PianoSearchMusic (PianoHandle_t *ph, char *searchStr,
- PianoSearchResult_t *searchResult) {
+PianoReturn_t PianoSearchMusic (const PianoHandle_t *ph,
+ const char *searchStr, PianoSearchResult_t *searchResult) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr, *xmlencodedSearchStr, *urlencodedSearchStr;
PianoReturn_t ret;
@@ -541,8 +543,8 @@ PianoReturn_t PianoSearchMusic (PianoHandle_t *ph, char *searchStr,
* shared station
* @param id
*/
-PianoReturn_t PianoCreateStation (PianoHandle_t *ph, char *type,
- char *id) {
+PianoReturn_t PianoCreateStation (PianoHandle_t *ph, const char *type,
+ const char *id) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr;
PianoReturn_t ret;
@@ -581,7 +583,7 @@ PianoReturn_t PianoCreateStation (PianoHandle_t *ph, char *type,
* @param music id; can be obtained with PianoSearchMusic ()
*/
PianoReturn_t PianoStationAddMusic (PianoHandle_t *ph,
- PianoStation_t *station, char *musicId) {
+ PianoStation_t *station, const char *musicId) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr;
PianoReturn_t ret;
@@ -616,7 +618,7 @@ PianoReturn_t PianoStationAddMusic (PianoHandle_t *ph,
* @param song to be banned
* @return _OK or error
*/
-PianoReturn_t PianoSongTired (PianoHandle_t *ph, PianoSong_t *song) {
+PianoReturn_t PianoSongTired (PianoHandle_t *ph, const PianoSong_t *song) {
char xmlSendBuf[PIANO_SEND_BUFFER_SIZE], url[PIANO_URL_BUFFER_SIZE];
char *requestStr, *retStr;
PianoReturn_t ret;
@@ -705,7 +707,7 @@ PianoReturn_t PianoSetQuickmix (PianoHandle_t *ph) {
}
PianoStation_t *PianoFindStationById (PianoStation_t *stations,
- char *searchStation) {
+ const char *searchStation) {
while (stations != NULL) {
if (strcmp (stations->id, searchStation) == 0) {
return stations;
diff --git a/libpiano/src/piano.h b/libpiano/src/piano.h
index 172c13d..0850517 100644
--- a/libpiano/src/piano.h
+++ b/libpiano/src/piano.h
@@ -159,29 +159,30 @@ void PianoInit (PianoHandle_t *);
void PianoDestroy (PianoHandle_t *);
void PianoDestroyPlaylist (PianoHandle_t *ph);
void PianoDestroySearchResult (PianoSearchResult_t *searchResult);
-PianoReturn_t PianoConnect (PianoHandle_t *ph, char *user, char *password,
- char secureLogin);
+PianoReturn_t PianoConnect (PianoHandle_t *ph, const char *user,
+ const char *password, char secureLogin);
PianoReturn_t PianoGetStations (PianoHandle_t *ph);
-PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, char *stationId);
+PianoReturn_t PianoGetPlaylist (PianoHandle_t *ph, const char *stationId);
PianoReturn_t PianoRateTrack (PianoHandle_t *ph, PianoSong_t *song,
PianoSongRating_t rating);
-PianoReturn_t PianoMoveSong (PianoHandle_t *ph, PianoStation_t *stationFrom,
- PianoStation_t *stationTo, PianoSong_t *song);
+PianoReturn_t PianoMoveSong (PianoHandle_t *ph,
+ const PianoStation_t *stationFrom, const PianoStation_t *stationTo,
+ const PianoSong_t *song);
PianoReturn_t PianoRenameStation (PianoHandle_t *ph, PianoStation_t *station,
- char *newName);
+ const char *newName);
PianoReturn_t PianoDeleteStation (PianoHandle_t *ph, PianoStation_t *station);
-PianoReturn_t PianoSearchMusic (PianoHandle_t *ph, char *searchStr,
- PianoSearchResult_t *searchResult);
-PianoReturn_t PianoCreateStation (PianoHandle_t *ph, char *type,
- char *id);
+PianoReturn_t PianoSearchMusic (const PianoHandle_t *ph,
+ const char *searchStr, PianoSearchResult_t *searchResult);
+PianoReturn_t PianoCreateStation (PianoHandle_t *ph, const char *type,
+ const char *id);
PianoReturn_t PianoStationAddMusic (PianoHandle_t *ph,
- PianoStation_t *station, char *musicId);
-PianoReturn_t PianoSongTired (PianoHandle_t *ph, PianoSong_t *song);
+ PianoStation_t *station, const char *musicId);
+PianoReturn_t PianoSongTired (PianoHandle_t *ph, const PianoSong_t *song);
PianoReturn_t PianoSetQuickmix (PianoHandle_t *ph);
PianoStation_t *PianoFindStationById (PianoStation_t *stations,
- char *searchStation);
+ const char *searchStation);
PianoReturn_t PianoGetGenreStations (PianoHandle_t *ph);
PianoReturn_t PianoTransformShared (PianoHandle_t *ph,
PianoStation_t *station);
diff --git a/libpiano/src/xml.c b/libpiano/src/xml.c
index 33c2dde..5f138ff 100644
--- a/libpiano/src/xml.c
+++ b/libpiano/src/xml.c
@@ -31,13 +31,14 @@ THE SOFTWARE.
#include "config.h"
#include "main.h"
-void PianoXmlStructParser (xmlNode *structRoot,
- void (*callback) (char *, xmlNode *, void *), void *data);
-char *PianoXmlGetNodeText (xmlNode *node);
+void PianoXmlStructParser (const xmlNode *structRoot,
+ void (*callback) (const char *, const xmlNode *, void *),
+ void *data);
+char *PianoXmlGetNodeText (const xmlNode *node);
/* parse fault and get fault type
*/
-void PianoXmlIsFaultCb (char *key, xmlNode *value, void *data) {
+void PianoXmlIsFaultCb (const char *key, const xmlNode *value, void *data) {
PianoReturn_t *ret = data;
char *valueStr = PianoXmlGetNodeText (value);
char *matchStart, *matchEnd, *matchStr;
@@ -77,7 +78,7 @@ void PianoXmlIsFaultCb (char *key, xmlNode *value, void *data) {
* @param document root of xml doc
* @return _RET_OK or fault code (_RET_*)
*/
-PianoReturn_t PianoXmlIsFault (xmlNode *docRoot) {
+PianoReturn_t PianoXmlIsFault (const xmlNode *docRoot) {
xmlNode *faultStruct;
PianoReturn_t ret;
@@ -110,8 +111,8 @@ PianoReturn_t PianoXmlIsFault (xmlNode *docRoot) {
* freed soon
* @param extra data for callback
*/
-void PianoXmlStructParser (xmlNode *structRoot,
- void (*callback) (char *, xmlNode *, void *), void *data) {
+void PianoXmlStructParser (const xmlNode *structRoot,
+ void (*callback) (const char *, const xmlNode *, void *), void *data) {
xmlNode *curNode, *memberNode, *valueNode;
xmlChar *key;
@@ -148,7 +149,8 @@ void PianoXmlStructParser (xmlNode *structRoot,
* @param returns document root
* @return _OK or error
*/
-PianoReturn_t PianoXmlInitDoc (char *xml, xmlDocPtr *doc, xmlNode **docRoot) {
+PianoReturn_t PianoXmlInitDoc (const char *xml, xmlDocPtr *doc,
+ xmlNode **docRoot) {
*doc = xmlReadDoc ((xmlChar *) xml, NULL, NULL, 0);
PianoReturn_t ret;
@@ -171,7 +173,7 @@ PianoReturn_t PianoXmlInitDoc (char *xml, xmlDocPtr *doc, xmlNode **docRoot) {
* or <int> subnodes, just ignore them
* @param xml node <value>
*/
-char *PianoXmlGetNodeText (xmlNode *node) {
+char *PianoXmlGetNodeText (const xmlNode *node) {
/* FIXME: this is not the correct way; we should check the node type
* as well */
if (node->content != NULL) {
@@ -189,7 +191,8 @@ char *PianoXmlGetNodeText (xmlNode *node) {
* @param pointer to userinfo structure
* @return nothing
*/
-void PianoXmlParseUserinfoCb (char *key, xmlNode *value, void *data) {
+void PianoXmlParseUserinfoCb (const char *key, const xmlNode *value,
+ void *data) {
PianoUserInfo_t *user = data;
char *valueStr = PianoXmlGetNodeText (value);
@@ -203,7 +206,8 @@ void PianoXmlParseUserinfoCb (char *key, xmlNode *value, void *data) {
}
}
-void PianoXmlParseStationsCb (char *key, xmlNode *value, void *data) {
+void PianoXmlParseStationsCb (const char *key, const xmlNode *value,
+ void *data) {
PianoStation_t *station = data;
char *valueStr = PianoXmlGetNodeText (value);
@@ -219,7 +223,8 @@ void PianoXmlParseStationsCb (char *key, xmlNode *value, void *data) {
}
/* FIXME: copy & waste */
-void PianoXmlParsePlaylistCb (char *key, xmlNode *value, void *data) {
+void PianoXmlParsePlaylistCb (const char *key, const xmlNode *value,
+ void *data) {
PianoSong_t *song = data;
char *valueStr = PianoXmlGetNodeText (value);
@@ -268,7 +273,7 @@ void PianoXmlParsePlaylistCb (char *key, xmlNode *value, void *data) {
* @param utf-8 string
* @return _RET_OK or error
*/
-PianoReturn_t PianoXmlParseUserinfo (PianoHandle_t *ph, char *xml) {
+PianoReturn_t PianoXmlParseUserinfo (PianoHandle_t *ph, const char *xml) {
xmlNode *docRoot;
xmlDocPtr doc;
PianoReturn_t ret;
@@ -290,7 +295,7 @@ PianoReturn_t PianoXmlParseUserinfo (PianoHandle_t *ph, char *xml) {
* @param xml returned by pandora
* @return _RET_OK or error
*/
-PianoReturn_t PianoXmlParseStations (PianoHandle_t *ph, char *xml) {
+PianoReturn_t PianoXmlParseStations (PianoHandle_t *ph, const char *xml) {
xmlNode *docRoot, *curNode;
xmlDocPtr doc;
PianoReturn_t ret;
@@ -329,7 +334,8 @@ PianoReturn_t PianoXmlParseStations (PianoHandle_t *ph, char *xml) {
* @param xml document
* @return nothing yet
*/
-PianoReturn_t PianoXmlParseCreateStation (PianoHandle_t *ph, char *xml) {
+PianoReturn_t PianoXmlParseCreateStation (PianoHandle_t *ph,
+ const char *xml) {
xmlNode *docRoot;
xmlDocPtr doc;
PianoStation_t *tmpStation;
@@ -365,7 +371,7 @@ PianoReturn_t PianoXmlParseCreateStation (PianoHandle_t *ph, char *xml) {
* @param xml document
* @param update this station
*/
-PianoReturn_t PianoXmlParseAddSeed (PianoHandle_t *ph, char *xml,
+PianoReturn_t PianoXmlParseAddSeed (PianoHandle_t *ph, const char *xml,
PianoStation_t *station) {
xmlNode *docRoot;
xmlDocPtr doc;
@@ -389,7 +395,7 @@ PianoReturn_t PianoXmlParseAddSeed (PianoHandle_t *ph, char *xml,
* @param piano handle
* @param xml document
*/
-PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml) {
+PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, const char *xml) {
xmlNode *docRoot, *curNode;
xmlDocPtr doc;
PianoReturn_t ret;
@@ -430,7 +436,7 @@ PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml) {
* @param xml string
* @return
*/
-PianoReturn_t PianoXmlParseSimple (char *xml) {
+PianoReturn_t PianoXmlParseSimple (const char *xml) {
xmlNode *docRoot;
xmlDocPtr doc;
PianoReturn_t ret;
@@ -453,7 +459,8 @@ PianoReturn_t PianoXmlParseSimple (char *xml) {
/* xml struct parser callback, used in PianoXmlParseSearchCb
*/
-void PianoXmlParseSearchArtistCb (char *key, xmlNode *value, void *data) {
+void PianoXmlParseSearchArtistCb (const char *key, const xmlNode *value,
+ void *data) {
PianoArtist_t *artist = data;
char *valueStr = PianoXmlGetNodeText (value);
@@ -467,7 +474,8 @@ void PianoXmlParseSearchArtistCb (char *key, xmlNode *value, void *data) {
/* callback for xml struct parser used in PianoXmlParseSearch, "switch" for
* PianoXmlParseSearchArtistCb and PianoXmlParsePlaylistCb
*/
-void PianoXmlParseSearchCb (char *key, xmlNode *value, void *data) {
+void PianoXmlParseSearchCb (const char *key, const xmlNode *value,
+ void *data) {
PianoSearchResult_t *searchResult = data;
if (strcmp ("artists", key) == 0) {
@@ -528,7 +536,7 @@ void PianoXmlParseSearchCb (char *key, xmlNode *value, void *data) {
* @param returns search result
* @return nothing yet
*/
-PianoReturn_t PianoXmlParseSearch (char *searchXml,
+PianoReturn_t PianoXmlParseSearch (const char *searchXml,
PianoSearchResult_t *searchResult) {
xmlNode *docRoot;
xmlDocPtr doc;
@@ -579,7 +587,7 @@ char *PianoXmlEncodeString (const char *s) {
}
PianoReturn_t PianoXmlParseGenreExplorer (PianoHandle_t *ph,
- char *xmlContent) {
+ const char *xmlContent) {
xmlNode *docRoot, *catNode, *genreNode, *attrNodeValue;
xmlDocPtr doc;
xmlAttr *attrNode;
@@ -667,7 +675,7 @@ PianoReturn_t PianoXmlParseGenreExplorer (PianoHandle_t *ph,
* @param xml doc
* @return _OK or error
*/
-PianoReturn_t PianoXmlParseTranformStation (char *searchXml) {
+PianoReturn_t PianoXmlParseTranformStation (const char *searchXml) {
xmlNode *docRoot;
xmlDocPtr doc;
PianoReturn_t ret;
diff --git a/libpiano/src/xml.h b/libpiano/src/xml.h
index 95d9d93..5ee7e7c 100644
--- a/libpiano/src/xml.h
+++ b/libpiano/src/xml.h
@@ -25,18 +25,19 @@ THE SOFTWARE.
#include "piano.h"
-PianoReturn_t PianoXmlParseUserinfo (PianoHandle_t *ph, char *xml);
-PianoReturn_t PianoXmlParseStations (PianoHandle_t *ph, char *xml);
-PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml);
-PianoReturn_t PianoXmlParseSearch (char *searchXml,
+PianoReturn_t PianoXmlParseUserinfo (PianoHandle_t *ph, const char *xml);
+PianoReturn_t PianoXmlParseStations (PianoHandle_t *ph, const char *xml);
+PianoReturn_t PianoXmlParsePlaylist (PianoHandle_t *ph, const char *xml);
+PianoReturn_t PianoXmlParseSearch (const char *searchXml,
PianoSearchResult_t *searchResult);
-PianoReturn_t PianoXmlParseSimple (char *xml);
-PianoReturn_t PianoXmlParseCreateStation (PianoHandle_t *ph, char *xml);
-PianoReturn_t PianoXmlParseAddSeed (PianoHandle_t *ph, char *xml,
+PianoReturn_t PianoXmlParseSimple (const char *xml);
+PianoReturn_t PianoXmlParseCreateStation (PianoHandle_t *ph,
+ const char *xml);
+PianoReturn_t PianoXmlParseAddSeed (PianoHandle_t *ph, const char *xml,
PianoStation_t *station);
PianoReturn_t PianoXmlParseGenreExplorer (PianoHandle_t *ph,
- char *xmlContent);
-PianoReturn_t PianoXmlParseTranformStation (char *searchXml);
+ const char *xmlContent);
+PianoReturn_t PianoXmlParseTranformStation (const char *searchXml);
char *PianoXmlEncodeString (const char *s);
diff --git a/libwardrobe/src/main.c b/libwardrobe/src/main.c
index 0a8a14e..1d8abb7 100644
--- a/libwardrobe/src/main.c
+++ b/libwardrobe/src/main.c
@@ -63,7 +63,7 @@ size_t WardrobeCurlRetToVar (void *ptr, size_t size, size_t nmemb,
* @param put received data here, memory is allocated by this function
* @return nothing yet
*/
-void WardrobeHttpGet (CURL *ch, char *url, char **retData) {
+void WardrobeHttpGet (CURL *ch, const char *url, char **retData) {
/* Let's hope nothing will be bigger than this... */
char curlRet[WARDROBE_HTTP_BUFFER_SIZE];
@@ -85,7 +85,8 @@ void WardrobeHttpGet (CURL *ch, char *url, char **retData) {
* @param put received data here, memory is allocated by this function
* @return nothing yet
*/
-void WardrobeHttpPost (CURL *ch, char *url, char *postData, char **retData) {
+void WardrobeHttpPost (CURL *ch, const char *url, const char *postData,
+ char **retData) {
/* Let's hope nothing will be bigger than this... */
char curlRet[WARDROBE_HTTP_BUFFER_SIZE];
@@ -206,7 +207,7 @@ WardrobeReturn_t WardrobeHandshake (WardrobeHandle_t *wh) {
* @return _OK or error
*/
WardrobeReturn_t WardrobeSendSong (WardrobeHandle_t *wh,
- WardrobeSong_t *ws) {
+ const WardrobeSong_t *ws) {
char postContent[10000];
char *urlencArtist, *urlencTitle, *urlencAlbum, *ret;
WardrobeReturn_t fRet = WARDROBE_RET_ERR;
@@ -242,7 +243,7 @@ WardrobeReturn_t WardrobeSendSong (WardrobeHandle_t *wh,
* @return _OK or error
*/
WardrobeReturn_t WardrobeSubmit (WardrobeHandle_t *wh,
- WardrobeSong_t *ws) {
+ const WardrobeSong_t *ws) {
size_t i;
WardrobeReturn_t fRet = WARDROBE_RET_ERR;
@@ -262,37 +263,40 @@ WardrobeReturn_t WardrobeSubmit (WardrobeHandle_t *wh,
return fRet;
}
-/* return dynamic allocated error string, don't forget to free it
+/* error string
* @param error int
* @return human readable error string or NULL on error
*/
-char *WardrobeErrorToString (WardrobeReturn_t ret) {
+const char *WardrobeErrorToString (WardrobeReturn_t ret) {
switch (ret) {
case WARDROBE_RET_ERR:
- return strdup ("Unknown error.\n");
+ return "Unknown error.";
break;
case WARDROBE_RET_OK:
- return strdup ("Everything's fine :)\n");
+ return "Everything's fine :)";
break;
case WARDROBE_RET_CLIENT_BANNED:
- return strdup ("Client banned. Try to update your software.\n");
+ return "Client banned. Try to update your software.";
break;
case WARDROBE_RET_BADAUTH:
- return strdup ("Wrong username or password.\n");
+ return "Wrong username or password.";
break;
case WARDROBE_RET_BADTIME:
- return strdup ("System time wrong. Check your system time and "
- "correct it.\n");
+ return "System time wrong. Check your system time and "
+ "correct it.";
break;
case WARDROBE_RET_BADSESSION:
- return strdup ("Bad session. Try to login again.\n");
+ return "Bad session. Try to login again.";
+ break;
+
+ default:
+ return "Unknown Error.";
break;
}
- return NULL;
}
diff --git a/libwardrobe/src/wardrobe.h b/libwardrobe/src/wardrobe.h
index 5662139..2e0fd14 100644
--- a/libwardrobe/src/wardrobe.h
+++ b/libwardrobe/src/wardrobe.h
@@ -49,5 +49,5 @@ void WardrobeSongInit (WardrobeSong_t *ws);
void WardrobeSongDestroy (WardrobeSong_t *ws);
void WardrobeDestroy (WardrobeHandle_t *wh);
WardrobeReturn_t WardrobeSubmit (WardrobeHandle_t *wh,
- WardrobeSong_t *ws);
-char *WardrobeErrorToString (WardrobeReturn_t ret);
+ const WardrobeSong_t *ws);
+const char *WardrobeErrorToString (WardrobeReturn_t ret);
diff --git a/src/main.c b/src/main.c
index ac8d862..5203fec 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,13 +40,19 @@ THE SOFTWARE.
#include "config.h"
#include "player.h"
-inline void BarUiMsg (char *msg);
+/* output message and flush stdout
+ * @param message
+ */
+inline void BarUiMsg (const char *msg) {
+ printf ("%s", msg);
+ fflush (stdout);
+}
/* check whether complete string is numeric
* @param the string
* @return 1 = yes, 0 = not numeric
*/
-char BarIsNumericStr (char *str) {
+char BarIsNumericStr (const char *str) {
while (*str != '\0') {
if (isdigit (*str) == 0) {
return 0;
@@ -61,7 +67,7 @@ char BarIsNumericStr (char *str) {
* @param returns integer
* @return 1 = success, 0 = failure (not an integer, ...)
*/
-char BarReadlineInt (char *prompt, int *retVal) {
+char BarReadlineInt (const char *prompt, int *retVal) {
char *buf;
char ret = 0;
@@ -80,7 +86,8 @@ char BarReadlineInt (char *prompt, int *retVal) {
* @param piano handle
* @return pointer to selected station or NULL
*/
-PianoStation_t *BarUiSelectStation (PianoHandle_t *ph, char *prompt) {
+PianoStation_t *BarUiSelectStation (PianoHandle_t *ph,
+ const char *prompt) {
PianoStation_t *curStation = NULL;
int i = 0;
@@ -156,7 +163,7 @@ PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist) {
* @param piano handle
* @return musicId or NULL on abort/error
*/
-char *BarUiSelectMusicId (PianoHandle_t *ph) {
+char *BarUiSelectMusicId (const PianoHandle_t *ph) {
char *musicId = NULL, *lineBuf;
char yesnoBuf;
PianoSearchResult_t searchResult;
@@ -221,11 +228,6 @@ inline float BarSamplesToSeconds (float samplerate, float channels,
return channels * 1000.0 * samples / samplerate;
}
-inline void BarUiMsg (char *msg) {
- printf ("%s", msg);
- fflush (stdout);
-}
-
/* browse genre stations and create shared station
* @param piano handle
*/
diff --git a/src/settings.c b/src/settings.c
index a691607..ae34078 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -34,7 +34,8 @@ THE SOFTWARE.
* @param but only up to this size
* @return nothing
*/
-void BarGetXdgConfigDir (char *filename, char *retDir, size_t retDirN) {
+void BarGetXdgConfigDir (const char *filename, char *retDir,
+ size_t retDirN) {
char *xdgConfigDir = NULL;
if ((xdgConfigDir = getenv ("XDG_CONFIG_HOME")) != NULL &&