summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Lilleengen <lulf@pvv.ntnu.no>2008-08-18 11:47:05 +0200
committerUlf Lilleengen <lulf@pvv.ntnu.no>2008-08-18 11:47:05 +0200
commit7df9a3059a231c4bdab35eede75deab6fc6671c6 (patch)
tree8027a6076b33a45fae8245153e0ff20915e1357a
parent6cd7869051529a159802409a8302fbd0d3d38195 (diff)
- s/warn/DEBUG.
- Add suggstions to TODO. - Change enum starting point.
-rw-r--r--TODO1
-rw-r--r--include/musicfs.h4
-rw-r--r--src/mfs_subr.c44
3 files changed, 26 insertions, 23 deletions
diff --git a/TODO b/TODO
index b12342c..d1a4de5 100644
--- a/TODO
+++ b/TODO
@@ -44,6 +44,7 @@ directory.
* Implement support for encoding/decoding when reading the data? (embedded
decoder in the file system, removing the need for encoder support in the
player).
+* Support for looking up tags to CDDB or something like that.
* Internal stuff/convenience
* Add proper debugging facilities.
diff --git a/include/musicfs.h b/include/musicfs.h
index ead8bb2..4e6aa37 100644
--- a/include/musicfs.h
+++ b/include/musicfs.h
@@ -30,7 +30,7 @@ int mfs_initscan();
* Functions traversing the underlying filesystem and do operations on the
* files, for instance scanning the collection.
*/
-typedef void traverse_fn_t(char *);
+typedef void traverse_fn_t(const char *);
void traverse_hierarchy(const char *, traverse_fn_t);
traverse_fn_t mfs_scan;
@@ -42,7 +42,7 @@ struct filler_data {
fuse_fill_dir_t filler;
};
-enum lookup_datatype { LIST_DATATYPE_STRING, LIST_DATATYPE_INT };
+enum lookup_datatype { LIST_DATATYPE_STRING = 1, LIST_DATATYPE_INT };
enum mfs_filetype { MFS_NOTFOUND, MFS_FILE, MFS_DIRECTORY };
diff --git a/src/mfs_subr.c b/src/mfs_subr.c
index 892b595..b83c75d 100644
--- a/src/mfs_subr.c
+++ b/src/mfs_subr.c
@@ -77,7 +77,7 @@ char *mfs_get_home_path(const char *extra)
* Insert a musicpath into the database.
*/
int
-mfs_insert_path(char *path, sqlite3 *handle)
+mfs_insert_path(const char *path, sqlite3 *handle)
{
int res;
sqlite3_stmt *st;
@@ -87,7 +87,7 @@ mfs_insert_path(char *path, sqlite3 *handle)
"SELECT path FROM path WHERE path LIKE ?",
-1, &st, NULL);
if (res != SQLITE_OK) {
- warnx("Error preparing stamtement: %s\n",
+ DEBUG("Error preparing statement: %s\n",
sqlite3_errmsg(handle));
return (-1);
}
@@ -102,7 +102,7 @@ mfs_insert_path(char *path, sqlite3 *handle)
"INSERT INTO path(path) VALUES(?)",
-1, &st, NULL);
if (res != SQLITE_OK) {
- warnx("Error preparing stamtement: %s\n",
+ DEBUG("Error preparing stamtement: %s\n",
sqlite3_errmsg(handle));
return (-1);
}
@@ -110,7 +110,7 @@ mfs_insert_path(char *path, sqlite3 *handle)
res = sqlite3_step(st);
sqlite3_finalize(st);
if (res != SQLITE_DONE) {
- warnx("Error inserting into database: %s\n",
+ DEBUG("Error inserting into database: %s\n",
sqlite3_errmsg(handle));
return (-1);
}
@@ -133,14 +133,14 @@ mfs_reload_config()
FILE *f = fopen(mfsrc, "r");
if (f == NULL) {
- warnx("Couldn't open configuration file %s\n",
+ DEBUG("Couldn't open configuration file %s\n",
mfsrc);
return (-1);
}
res = sqlite3_open(db_path, &handle);
if (res) {
- warnx("Can't open database: %s\n", sqlite3_errmsg(handle));
+ DEBUG("Can't open database: %s\n", sqlite3_errmsg(handle));
sqlite3_close(handle);
return (-1);
}
@@ -178,7 +178,7 @@ mfs_initscan()
/* Open database. */
error = sqlite3_open(db_path, &handle);
if (error) {
- warnx("Can't open database: %s\n", sqlite3_errmsg(handle));
+ DEBUG("Can't open database: %s\n", sqlite3_errmsg(handle));
sqlite3_close(handle);
return (-1);
}
@@ -238,7 +238,7 @@ traverse_hierarchy(const char *dirpath, traverse_fn_t fileop)
/* Scan the music initially. */
void
-mfs_scan(char *filepath)
+mfs_scan(const char *filepath)
{
TagLib_File *file;
TagLib_Tag *tag;
@@ -251,16 +251,18 @@ mfs_scan(char *filepath)
file = taglib_file_new(filepath);
/* XXX: errmsg. */
- if (file == NULL)
+ if (file == NULL) {
+ DEBUG("Unable to open file %s\n", filepath);
return;
+ }
tag = taglib_file_tag(file);
if (tag == NULL) {
- printf("error!\n");
+ DEBUG("Error getting tag from %s\n", filepath);
return;
}
if (stat(filepath, &fstat) < 0) {
- perror("stat");
+ DEBUG("Error getting file info: %s\n", strerror(errno));
return;
}
@@ -275,7 +277,7 @@ mfs_scan(char *filepath)
ret = sqlite3_prepare_v2(handle, "SELECT * FROM artist WHERE "
"name=?", -1, &st, NULL);
if (ret != SQLITE_OK) {
- warnx("Error preparing statement: %s\n",
+ DEBUG("Error preparing statement: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -289,7 +291,7 @@ mfs_scan(char *filepath)
ret = sqlite3_prepare_v2(handle, "INSERT INTO artist(name) "
"VALUES(?)", -1, &st, NULL);
if (ret != SQLITE_OK) {
- warnx("Error preparing statement: %s\n",
+ DEBUG("Error preparing statement: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -297,7 +299,7 @@ mfs_scan(char *filepath)
ret = sqlite3_step(st);
sqlite3_finalize(st);
if (ret != SQLITE_DONE) {
- warnx("Error inserting into database: %s\n",
+ DEBUG("Error inserting into database: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -312,7 +314,7 @@ mfs_scan(char *filepath)
ret = sqlite3_prepare_v2(handle, "SELECT * FROM genre WHERE "
"name=?", -1, &st, NULL);
if (ret != SQLITE_OK) {
- warnx("Error preparing statement: %s\n",
+ DEBUG("Error preparing statement: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -326,7 +328,7 @@ mfs_scan(char *filepath)
ret = sqlite3_prepare_v2(handle, "INSERT INTO genre(name) "
"VALUES(?)", -1, &st, NULL);
if (ret != SQLITE_OK) {
- warnx("Error preparing statement: %s\n",
+ DEBUG("Error preparing statement: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -334,7 +336,7 @@ mfs_scan(char *filepath)
ret = sqlite3_step(st);
sqlite3_finalize(st);
if (ret != SQLITE_DONE) {
- warnx("Error inserting into database: %s\n",
+ DEBUG("Error inserting into database: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -363,7 +365,7 @@ mfs_scan(char *filepath)
" AND song.album=?",
-1, &st, NULL);
if (ret != SQLITE_OK) {
- warnx("Error preparing statement: %s\n",
+ DEBUG("Error preparing statement: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -384,7 +386,7 @@ mfs_scan(char *filepath)
"mtime, extension) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)",
-1, &st, NULL);
if (ret != SQLITE_OK) {
- warnx("Error preparing insert statement: %s\n",
+ DEBUG("Error preparing insert statement: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -410,7 +412,7 @@ mfs_scan(char *filepath)
ret = sqlite3_step(st);
sqlite3_finalize(st);
if (ret != SQLITE_DONE) {
- warnx("Error inserting into database: %s\n",
+ DEBUG("Error inserting into database: %s\n",
sqlite3_errmsg(handle));
break;
}
@@ -438,7 +440,7 @@ mfs_lookup_start(int field, void *data, lookup_fn_t *fn, const char *query)
/* Open database. */
error = sqlite3_open(db_path, &lh->handle);
if (error) {
- warnx("Can't open database: %s\n", sqlite3_errmsg(lh->handle));
+ DEBUG("Can't open database: %s\n", sqlite3_errmsg(lh->handle));
sqlite3_close(lh->handle);
free(lh);
return (NULL);