summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvuton Olrich <avuton@gmail.com>2006-07-15 03:34:48 +0000
committerAvuton Olrich <avuton@gmail.com>2006-07-15 03:34:48 +0000
commit6b4fea8d5ccbdcfb379da2ec512a1d238f459673 (patch)
treee16a44ef1ec9d7b13e649172cbf65a7a4c14742d
parentd0c08c52186cd248614585ecee1fe468d5a8417c (diff)
[CLEANUP] Cleanup whitespace->tabs
Remove dead code Static where possible git-svn-id: https://svn.musicpd.org/mpd/trunk@4345 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/tagTracker.c40
-rw-r--r--src/tagTracker.h4
-rw-r--r--src/tree.c70
-rw-r--r--src/tree.h71
-rw-r--r--src/utils.c43
-rw-r--r--src/volume.c60
6 files changed, 58 insertions, 230 deletions
diff --git a/src/tagTracker.c b/src/tagTracker.c
index 81824b49c..2d361fef0 100644
--- a/src/tagTracker.c
+++ b/src/tagTracker.c
@@ -40,7 +40,7 @@ typedef struct tagTrackerItem {
mpd_sint8 visited;
} TagTrackerItem;
-int keyCompare(const void *a, const void *b, void *data) {
+static int keyCompare(const void *a, const void *b, void *data) {
return strcmp(a,b);
}
@@ -49,9 +49,6 @@ char * getTagItemString(int type, char * string) {
TagTrackerItem ** itemPointer = &item;
char *key;
char **keyPointer = &key;
-
-
- /*if(type == TAG_ITEM_TITLE) return strdup(string);*/
if(tagLists[type] == NULL) {
tagLists[type] = g_tree_new_full(keyCompare, NULL, free, free);
@@ -66,8 +63,6 @@ char * getTagItemString(int type, char * string) {
item->visited = 0;
key = strdup(string);
g_tree_insert(tagLists[type], key, item);
-
-
}
return key;
@@ -97,7 +92,7 @@ void removeTagItemString(int type, char * string) {
void destroyTagTracker() {
int type;
- for (type=0; type < TAG_NUM_OF_ITEM_TYPES; type ++)
+ for (type=0; type < TAG_NUM_OF_ITEM_TYPES; type ++)
if (tagLists[type])
g_tree_destroy(tagLists[type]);
}
@@ -107,7 +102,8 @@ int getNumberOfTagItems(int type) {
return g_tree_nnodes(tagLists[type]);
}
-int calcSavedMemory(char *key, TagTrackerItem* value, int* sum) {
+
+static int calcSavedMemory(char *key, TagTrackerItem* value, int* sum) {
*sum -= sizeof(int) + 4*sizeof(void*); /* sizeof(_GTreeNode) */
*sum -= sizeof(TagTrackerItem);
*sum += (strlen(key)+1)*value->count;
@@ -128,23 +124,11 @@ void printMemorySavedByTagTracker() {
DEBUG("saved memory from tags: %li\n", (long)sum);
}
-void sortTagTrackerInfo() {
- /* implicit sorting
- int i;
-
- for(i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) {
- if(!tagLists[i]) continue;
-
- DEBUG("sorting %s info\n", mpdTagItemKeys[i]);
-
- sortList(tagLists[i]);
- }*/
-}
-
-int resetVisitedFlag(char *key, TagTrackerItem *value, void *data) {
+static int resetVisitedFlag(char *key, TagTrackerItem *value, void *data) {
value->visited = 0;
return FALSE;
}
+
void resetVisitedFlagsInTagTracker(int type) {
if(!tagLists[type]) return;
@@ -152,16 +136,6 @@ void resetVisitedFlagsInTagTracker(int type) {
g_tree_foreach(tagLists[type], (GTraverseFunc)resetVisitedFlag, NULL);
}
-int wasVisitedInTagTracker(int type, char * str) {
- TagTrackerItem * item;
-
- if(!tagLists[type]) return 0;
-
- if(!(item = g_tree_lookup(tagLists[type], str))) return 0;
-
- return item->visited;
-}
-
void visitInTagTracker(int type, char * str) {
TagTrackerItem * item;
@@ -177,7 +151,7 @@ struct _PrintVisitedUserdata {
char *type;
};
-int printVisitedFlag(char *key, TagTrackerItem* value, struct _PrintVisitedUserdata *data) {
+static int printVisitedFlag(char *key, TagTrackerItem* value, struct _PrintVisitedUserdata *data) {
if(value->visited) myfprintf(data->fp, "%s: %s\n", data->type, key);
return FALSE;
}
diff --git a/src/tagTracker.h b/src/tagTracker.h
index 7cb9fa49a..51b195192 100644
--- a/src/tagTracker.h
+++ b/src/tagTracker.h
@@ -30,11 +30,7 @@ int getNumberOfTagItems(int type);
void printMemorySavedByTagTracker();
-void sortTagTrackerInfo();
-
void resetVisitedFlagsInTagTracker(int type);
-
-int wasVisitedInTagTracker(int type, char * str);
void visitInTagTracker(int type, char * str);
diff --git a/src/tree.c b/src/tree.c
deleted file mode 100644
index 74dcb48d9..000000000
--- a/src/tree.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* the Music Player Daemon (MPD)
- * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
- * This project's homepage is: http://www.musicpd.org
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "tree.h"
-
-static inline TreeNode * newTreeNode() {
- TreeNode * ret = malloc(sizeof(TreeNode));
-
- ret->data[0] = NULL;
- ret->data[1] = NULL;
-
- ret->children[0] = NULL;
- ret->children[1] = NULL;
- ret->children[2] = NULL;
-
- return ret;
-}
-
-static inline void freeTreeNode(TreeNode * node) {
- free(node);
-}
-
-Tree * newTree(TreeFreeDataFunc * freeFunc, TreeCompareDataFunc * compareFunc) {
- Tree * ret = malloc(sizeof(Tree));
-
- ret->headNode = NULL;
- ret->freeFunc = freeFunc;
- ret->compareFunc = compareFunc;
-
- return ret;
-}
-
-void freeTree(Tree * tree) {
- TreeIterator * iter = newTreeIterator(tree, POSTORDER);
-
- TreeNode * node;
-
- if(data->freeFunc) {
- void * data;
-
- while( ( data = nextTreeIterator(iter) ) ) {
-
- }
-
- freeTreeIterator(iter);
-
- iter = newTreeIterator(tree, POSTORDER);
- }
-
- while( ( node = nextNodeTreeIterator(iter) ) ) {
- freeTreeNode(node);
- }
-
- freeTreeIterator(iter);
-}
diff --git a/src/tree.h b/src/tree.h
deleted file mode 100644
index 7976cac8c..000000000
--- a/src/tree.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* the Music Player Daemon (MPD)
- * (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
- * This project's homepage is: http://www.musicpd.org
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef TREE_H
-#define TREE_H
-
-typedef struct _TreeNode {
- void * data[2];
- struct _TreeNode * children[3];
- struct _TreeNode * parent;
-} TreeNode;
-
-typedef struct _Tree {
- TreeNode headNode;
- TreeFreeDataFunc * freeFunc;
- TreeCompareDataFunc * compareFunc;
-} Tree;
-
-typedef enum _TreeIteratorType {
- PREORDER,
- INORDER,
- POSTORDER
-} TreeIteratorType;
-
-typedef struct _TreeIterator {
- Data * data;
- /* private data */
- TreeIteratorType type;
- TreeNode * currentNode;
- int pos;
-} TreeIterator;
-
-typedef int TreeCompareDataFunc(void * left, void * right);
-
-typedef int TreeFreeDataFunc(void * data);
-
-Tree * newTree(TreeFreeDataFunc * freeFunc, TreeCompareDataFunc * compareFunc);
-
-void freeTree(Tree * tree);
-
-int insertInTree(Tree * tree, void * data);
-
-int deleteFromTree(Tree * tree, void * needle);
-
-void * findInTree(Tree * tree, void * needle);
-
-TreeIterator * newTreeIterator(Tree * tree, TreeIteratorType type);
-
-/* will return the same pointer passed in on success
- * if NULL is returned, this indicates the end of tree
- */
-data * nextTreeIterator(TreeIterator * iter);
-
-void freeTreeIterator(TreeIterator * iter);
-
-#endif /* TREE_H */
diff --git a/src/utils.c b/src/utils.c
index 6cc66e379..7dbe88833 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -41,9 +41,9 @@ char * myFgets(char * buffer, int bufferSize, FILE * fp) {
char * strDupToUpper(char * str) {
char * ret = strdup(str);
int i;
-
+
for(i=0;i<strlen(str);i++) ret[i] = toupper((int)ret[i]);
-
+
return ret;
}
@@ -74,29 +74,28 @@ int ipv6Supported() {
}
char * appendToString(char * dest, const char * src) {
- int destlen;
- int srclen = strlen(src);
-
- if(dest == NULL) {
- dest = malloc(srclen+1);
- memset(dest, 0, srclen+1);
- destlen = 0;
- }
- else {
- destlen = strlen(dest);
- dest = realloc(dest, destlen+srclen+1);
- }
-
- memcpy(dest+destlen, src, srclen);
- dest[destlen+srclen] = '\0';
-
- return dest;
+ int destlen;
+ int srclen = strlen(src);
+
+ if(dest == NULL) {
+ dest = malloc(srclen+1);
+ memset(dest, 0, srclen+1);
+ destlen = 0;
+ }
+ else {
+ destlen = strlen(dest);
+ dest = realloc(dest, destlen+srclen+1);
+ }
+
+ memcpy(dest+destlen, src, srclen);
+ dest[destlen+srclen] = '\0';
+
+ return dest;
}
unsigned long readLEuint32(const unsigned char *p)
{
return ((unsigned long) p[0] << 0) |
- ((unsigned long) p[1] << 8) |
- ((unsigned long) p[2] << 16) | ((unsigned long) p[3] << 24);
+ ((unsigned long) p[1] << 8) |
+ ((unsigned long) p[2] << 16) | ((unsigned long) p[3] << 24);
}
-
diff --git a/src/volume.c b/src/volume.c
index c3de951d1..512b7f157 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -58,28 +58,28 @@
#endif
#endif
-int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT;
-char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
+static int volume_mixerType = VOLUME_MIXER_TYPE_DEFAULT;
+static char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
-int volume_softwareSet = 100;
+static int volume_softwareSet = 100;
#ifdef HAVE_OSS
-int volume_ossFd;
-int volume_ossControl = SOUND_MIXER_PCM;
+static int volume_ossFd;
+static int volume_ossControl = SOUND_MIXER_PCM;
#endif
#ifdef HAVE_ALSA
-snd_mixer_t * volume_alsaMixerHandle = NULL;
-snd_mixer_elem_t * volume_alsaElem;
-long volume_alsaMin;
-long volume_alsaMax;
-int volume_alsaSet = -1;
+static snd_mixer_t * volume_alsaMixerHandle = NULL;
+static snd_mixer_elem_t * volume_alsaElem;
+static long volume_alsaMin;
+static long volume_alsaMax;
+static int volume_alsaSet = -1;
#endif
#ifdef HAVE_OSS
-int prepOssMixer(char * device) {
+static int prepOssMixer(char * device) {
int devmask = 0;
- ConfigParam * param;
+ ConfigParam * param;
if((volume_ossFd = open(device,O_RDONLY))<0) {
WARNING("unable to open oss mixer \"%s\"\n",device);
@@ -130,11 +130,11 @@ int prepOssMixer(char * device) {
return 0;
}
-void closeOssMixer() {
+static void closeOssMixer() {
close(volume_ossFd);
}
-int getOssVolumeLevel() {
+static int getOssVolumeLevel() {
int left, right, level;
if(ioctl(volume_ossFd,MIXER_READ(volume_ossControl),&level) < 0) {
@@ -153,7 +153,7 @@ int getOssVolumeLevel() {
return left;
}
-int changeOssVolumeLevel(FILE * fp, int change, int rel) {
+static int changeOssVolumeLevel(FILE * fp, int change, int rel) {
int current;
int new;
int level;
@@ -185,7 +185,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
#endif
#ifdef HAVE_ALSA
-int prepAlsaMixer(char * card) {
+static int prepAlsaMixer(char * card) {
int err;
snd_mixer_elem_t * elem;
char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
@@ -195,14 +195,14 @@ int prepAlsaMixer(char * card) {
WARNING("problems opening alsa mixer: %s\n",snd_strerror(err));
return -1;
}
-
+
if((err = snd_mixer_attach(volume_alsaMixerHandle,card))<0) {
snd_mixer_close(volume_alsaMixerHandle);
WARNING("problems problems attaching alsa mixer: %s\n",
snd_strerror(err));
return -1;
}
-
+
if((err = snd_mixer_selem_register(volume_alsaMixerHandle,NULL,NULL))<0) {
snd_mixer_close(volume_alsaMixerHandle);
WARNING("problems snd_mixer_selem_register'ing: %s\n",
@@ -219,7 +219,7 @@ int prepAlsaMixer(char * card) {
elem = snd_mixer_first_elem(volume_alsaMixerHandle);
- param = getConfigParam(CONF_MIXER_CONTROL);
+ param = getConfigParam(CONF_MIXER_CONTROL);
if(param) {
controlName = param->value;
@@ -250,11 +250,11 @@ int prepAlsaMixer(char * card) {
return -1;
}
-void closeAlsaMixer() {
+static void closeAlsaMixer() {
snd_mixer_close(volume_alsaMixerHandle);
}
-int getAlsaVolumeLevel() {
+static int getAlsaVolumeLevel() {
int ret;
long level;
long max = volume_alsaMax;
@@ -280,7 +280,7 @@ int getAlsaVolumeLevel() {
return ret;
}
-int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
+static int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
float vol;
long level;
long test;
@@ -329,7 +329,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
}
#endif
-int prepMixer(char * device) {
+static int prepMixer(char * device) {
switch(volume_mixerType) {
#ifdef HAVE_ALSA
case VOLUME_MIXER_TYPE_ALSA:
@@ -360,9 +360,9 @@ void finishVolume() {
}
void initVolume() {
- ConfigParam * param = getConfigParam(CONF_MIXER_TYPE);
+ ConfigParam * param = getConfigParam(CONF_MIXER_TYPE);
- if(param) {
+ if(param) {
if(0);
#ifdef HAVE_ALSA
else if(strcmp(param->value, VOLUME_MIXER_ALSA)==0) {
@@ -388,7 +388,7 @@ void initVolume() {
}
param = getConfigParam(CONF_MIXER_DEVICE);
-
+
if(param) {
volume_mixerDevice = param->value;
}
@@ -401,7 +401,7 @@ void openVolumeDevice() {
}
}
-int getSoftwareVolume() {
+static int getSoftwareVolume() {
return volume_softwareSet;
}
@@ -422,7 +422,7 @@ int getVolumeLevel() {
}
}
-int changeSoftwareVolume(FILE * fp, int change, int rel) {
+static int changeSoftwareVolume(FILE * fp, int change, int rel) {
int new = change;
if(rel) new+=volume_softwareSet;
@@ -455,7 +455,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case VOLUME_MIXER_TYPE_SOFTWARE:
return changeSoftwareVolume(fp,change,rel);
default:
- return 0;
- break;
+ return 0;
+ break;
}
}