mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-29 00:23:23 -05:00
[filescanner] Add some const's and various fixup
This commit is contained in:
parent
78dd8c89b6
commit
1070f507a2
@ -10,14 +10,14 @@ int
|
||||
scan_metadata_ffmpeg(const char *file, struct media_file_info *mfi);
|
||||
|
||||
void
|
||||
scan_playlist(char *file, time_t mtime, int dir_id);
|
||||
scan_playlist(const char *file, time_t mtime, int dir_id);
|
||||
|
||||
void
|
||||
scan_smartpl(char *file, time_t mtime, int dir_id);
|
||||
scan_smartpl(const char *file, time_t mtime, int dir_id);
|
||||
|
||||
#ifdef ITUNES
|
||||
void
|
||||
scan_itunes_itml(char *file);
|
||||
scan_itunes_itml(const char *file);
|
||||
#endif
|
||||
|
||||
const char *
|
||||
|
@ -688,7 +688,7 @@ ignore_pl(plist_t pl, char *name)
|
||||
}
|
||||
|
||||
static void
|
||||
process_pls(plist_t playlists, char *file)
|
||||
process_pls(plist_t playlists, const char *file)
|
||||
{
|
||||
plist_t pl;
|
||||
plist_t items;
|
||||
@ -730,7 +730,6 @@ process_pls(plist_t playlists, char *file)
|
||||
}
|
||||
|
||||
pli = db_pl_fetch_bytitlepath(name, file);
|
||||
|
||||
if (pli)
|
||||
{
|
||||
pl_id = pli->id;
|
||||
@ -754,19 +753,18 @@ process_pls(plist_t playlists, char *file)
|
||||
|
||||
if (pl_id == 0)
|
||||
{
|
||||
pli = (struct playlist_info *)malloc(sizeof(struct playlist_info));
|
||||
pli = calloc(1, sizeof(struct playlist_info));
|
||||
if (!pli)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Out of memory\n");
|
||||
|
||||
return;
|
||||
}
|
||||
memset(pli, 0, sizeof(struct playlist_info));
|
||||
|
||||
pli->type = PL_PLAIN;
|
||||
pli->title = strdup(name);
|
||||
pli->path = strdup(file);
|
||||
snprintf(virtual_path, PATH_MAX, "/file:%s", file);
|
||||
snprintf(virtual_path, sizeof(virtual_path), "/file:%s", file);
|
||||
pli->virtual_path = strdup(virtual_path);
|
||||
|
||||
ret = db_pl_add(pli, &pl_id);
|
||||
@ -790,15 +788,13 @@ process_pls(plist_t playlists, char *file)
|
||||
|
||||
|
||||
void
|
||||
scan_itunes_itml(char *file)
|
||||
scan_itunes_itml(const char *file)
|
||||
{
|
||||
struct stat sb;
|
||||
char *itml_xml;
|
||||
char *ptr;
|
||||
plist_t itml;
|
||||
plist_t node;
|
||||
int fd;
|
||||
int size;
|
||||
int ret;
|
||||
|
||||
DPRINTF(E_LOG, L_SCAN, "Processing iTunes library: %s\n", file);
|
||||
@ -871,8 +867,7 @@ scan_itunes_itml(char *file)
|
||||
return;
|
||||
}
|
||||
|
||||
size = ID_MAP_SIZE * sizeof(struct itml_to_db_map *);
|
||||
id_map = malloc(size);
|
||||
id_map = calloc(ID_MAP_SIZE, sizeof(struct itml_to_db_map *));
|
||||
if (!id_map)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_SCAN, "iTunes library parser could not allocate ID map\n");
|
||||
@ -880,19 +875,6 @@ scan_itunes_itml(char *file)
|
||||
plist_free(itml);
|
||||
return;
|
||||
}
|
||||
memset(id_map, 0, size);
|
||||
|
||||
ptr = strrchr(file, '/');
|
||||
if (!ptr)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_SCAN, "Invalid filename\n");
|
||||
|
||||
id_map_free();
|
||||
plist_free(itml);
|
||||
return;
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
|
||||
ret = process_tracks(node);
|
||||
if (ret <= 0)
|
||||
@ -904,8 +886,6 @@ scan_itunes_itml(char *file)
|
||||
return;
|
||||
}
|
||||
|
||||
*ptr = '/';
|
||||
|
||||
DPRINTF(E_INFO, L_SCAN, "Loaded %d tracks from iTunes library\n", ret);
|
||||
|
||||
/* Playlists */
|
||||
|
@ -121,7 +121,7 @@ process_url(int pl_id, const char *path, time_t mtime, int extinf, struct media_
|
||||
if (!mfi->title)
|
||||
mfi->title = strdup(mfi->fname);
|
||||
|
||||
snprintf(virtual_path, PATH_MAX, "/http:/%s", mfi->title);
|
||||
snprintf(virtual_path, sizeof(virtual_path), "/http:/%s", mfi->title);
|
||||
mfi->virtual_path = strdup(virtual_path);
|
||||
|
||||
library_add_media(mfi);
|
||||
@ -171,7 +171,7 @@ process_regular_file(int pl_id, char *path)
|
||||
|
||||
winner = NULL;
|
||||
score = 0;
|
||||
while (((ret = db_query_fetch_string(&qp, &dbpath)) == 0) && (dbpath))
|
||||
while ((db_query_fetch_string(&qp, &dbpath) == 0) && dbpath)
|
||||
{
|
||||
if (qp.results == 1)
|
||||
{
|
||||
@ -188,7 +188,7 @@ process_regular_file(int pl_id, char *path)
|
||||
{
|
||||
free(winner);
|
||||
winner = strdup(dbpath);
|
||||
score = ret;
|
||||
score = i;
|
||||
}
|
||||
else if (i == score)
|
||||
{
|
||||
@ -214,7 +214,7 @@ process_regular_file(int pl_id, char *path)
|
||||
}
|
||||
|
||||
void
|
||||
scan_playlist(char *file, time_t mtime, int dir_id)
|
||||
scan_playlist(const char *file, time_t mtime, int dir_id)
|
||||
{
|
||||
FILE *fp;
|
||||
struct media_file_info mfi;
|
||||
@ -230,7 +230,6 @@ scan_playlist(char *file, time_t mtime, int dir_id)
|
||||
int pl_format;
|
||||
int counter;
|
||||
int ret;
|
||||
char virtual_path[PATH_MAX];
|
||||
|
||||
ptr = strrchr(file, '.');
|
||||
if (!ptr)
|
||||
@ -278,8 +277,8 @@ scan_playlist(char *file, time_t mtime, int dir_id)
|
||||
pli->title = strip_extension(filename);
|
||||
|
||||
pli->path = strdup(file);
|
||||
snprintf(virtual_path, PATH_MAX, "/file:%s", file);
|
||||
pli->virtual_path = strip_extension(virtual_path);
|
||||
snprintf(buf, sizeof(buf), "/file:%s", file);
|
||||
pli->virtual_path = strip_extension(buf);
|
||||
|
||||
pli->directory_id = dir_id;
|
||||
|
||||
|
@ -170,7 +170,7 @@ smartpl_parse_file(const char *file, struct playlist_info *pli)
|
||||
}
|
||||
|
||||
void
|
||||
scan_smartpl(char *file, time_t mtime, int dir_id)
|
||||
scan_smartpl(const char *file, time_t mtime, int dir_id)
|
||||
{
|
||||
struct playlist_info *pli;
|
||||
int pl_id;
|
||||
|
Loading…
Reference in New Issue
Block a user