diff options
Diffstat (limited to 'src/directory.c')
-rw-r--r-- | src/directory.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/src/directory.c b/src/directory.c index b5c5e67c2..75dae22dd 100644 --- a/src/directory.c +++ b/src/directory.c @@ -40,11 +40,11 @@ #define DIRECTORY_MPD_VERSION "mpd_version: " #define DIRECTORY_FS_CHARSET "fs_charset: " -static Directory *music_root; +static struct directory *music_root; static time_t directory_dbModTime; -static void deleteEmptyDirectoriesInDirectory(Directory * directory); +static void deleteEmptyDirectoriesInDirectory(struct directory * directory); static char *getDbFile(void) { @@ -56,12 +56,12 @@ static char *getDbFile(void) return param->value; } -Directory * -newDirectory(const char *dirname, Directory * parent) +struct directory * +newDirectory(const char *dirname, struct directory * parent) { - Directory *directory; + struct directory *directory; - directory = xcalloc(1, sizeof(Directory)); + directory = xcalloc(1, sizeof(*directory)); if (dirname && strlen(dirname)) directory->path = xstrdup(dirname); @@ -71,7 +71,7 @@ newDirectory(const char *dirname, Directory * parent) } void -freeDirectory(Directory * directory) +freeDirectory(struct directory * directory) { dirvec_destroy(&directory->children); songvec_destroy(&directory->songs); @@ -82,7 +82,7 @@ freeDirectory(Directory * directory) /*getDirectoryPath(NULL); */ } -static void deleteEmptyDirectoriesInDirectory(Directory * directory) +static void deleteEmptyDirectoriesInDirectory(struct directory * directory) { int i; struct dirvec *dv = &directory->children; @@ -106,7 +106,7 @@ int isRootDirectory(const char *name) return (!name || name[0] == '\0' || !strcmp(name, "/")); } -Directory * +struct directory * directory_get_root(void) { assert(music_root != NULL); @@ -114,10 +114,11 @@ directory_get_root(void) return music_root; } -static Directory *getSubDirectory(Directory * directory, const char *name) +static struct directory * +getSubDirectory(struct directory * directory, const char *name) { - Directory *cur = directory; - Directory *found = NULL; + struct directory *cur = directory; + struct directory *found = NULL; char *duplicated; char *locate; @@ -144,7 +145,7 @@ static Directory *getSubDirectory(Directory * directory, const char *name) return found; } -Directory * +struct directory * getDirectory(const char *name) { return getSubDirectory(music_root, name); @@ -164,7 +165,7 @@ static int printDirectoryList(struct client *client, struct dirvec *dv) int printDirectoryInfo(struct client *client, const char *name) { - Directory *directory; + struct directory *directory; if ((directory = getDirectory(name)) == NULL) return -1; @@ -176,7 +177,8 @@ int printDirectoryInfo(struct client *client, const char *name) } /* TODO error checking */ -static int writeDirectoryInfo(FILE * fp, Directory * directory) +static int +writeDirectoryInfo(FILE * fp, struct directory * directory) { struct dirvec *children = &directory->children; size_t i; @@ -190,7 +192,7 @@ static int writeDirectoryInfo(FILE * fp, Directory * directory) } for (i = 0; i < children->nr; ++i) { - Directory *cur = children->base[i]; + struct directory *cur = children->base[i]; const char *base = mpd_basename(cur->path); retv = fprintf(fp, DIRECTORY_DIR "%s\n", base); @@ -209,7 +211,8 @@ static int writeDirectoryInfo(FILE * fp, Directory * directory) return 0; } -static void readDirectoryInfo(FILE * fp, Directory * directory) +static void +readDirectoryInfo(FILE * fp, struct directory * directory) { char buffer[MPD_PATH_MAX * 2]; int bufferSize = MPD_PATH_MAX * 2; @@ -219,7 +222,7 @@ static void readDirectoryInfo(FILE * fp, Directory * directory) while (myFgets(buffer, bufferSize, fp) && prefixcmp(buffer, DIRECTORY_END)) { if (!prefixcmp(buffer, DIRECTORY_DIR)) { - Directory *subdir; + struct directory *subdir; strcpy(key, &(buffer[strlen(DIRECTORY_DIR)])); if (!myFgets(buffer, bufferSize, fp)) @@ -248,7 +251,7 @@ static void readDirectoryInfo(FILE * fp, Directory * directory) } void -sortDirectory(Directory * directory) +sortDirectory(struct directory * directory) { int i; struct dirvec *dv = &directory->children; @@ -443,10 +446,11 @@ int readDirectoryDB(void) return 0; } -static int traverseAllInSubDirectory(Directory * directory, - int (*forEachSong) (Song *, void *), - int (*forEachDir) (Directory *, void *), - void *data) +static int +traverseAllInSubDirectory(struct directory * directory, + int (*forEachSong) (Song *, void *), + int (*forEachDir) (struct directory *, void *), + void *data) { struct dirvec *dv = &directory->children; int err = 0; @@ -468,11 +472,12 @@ static int traverseAllInSubDirectory(Directory * directory, return err; } -int traverseAllIn(const char *name, - int (*forEachSong) (Song *, void *), - int (*forEachDir) (Directory *, void *), void *data) +int +traverseAllIn(const char *name, + int (*forEachSong) (Song *, void *), + int (*forEachDir) (struct directory *, void *), void *data) { - Directory *directory; + struct directory *directory; if ((directory = getDirectory(name)) == NULL) { Song *song; @@ -497,7 +502,7 @@ void directory_init(void) Song *getSongFromDB(const char *file) { Song *song = NULL; - Directory *directory; + struct directory *directory; char *dir = NULL; char *duplicated = xstrdup(file); char *shortname = strrchr(duplicated, '/'); |