Switch to the new afs.
[paraslash.git] / playlist_selector.c
index c40976d4635f1fb04fd0ebae422410e4c6651b23..2d076ee63728e4383892d93a0daba96dceb8baed 100644 (file)
@@ -1,29 +1,22 @@
 /*
  * Copyright (C) 2006-2007 Andre Noll <maan@systemlinux.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, USA.
+ * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
 /** \file playlist_selector.c The playlist audio file selector of paraslash  */
 
-#include "server.h"
-#include "db.h"
+#include <signal.h>
+#include "para.h"
 #include "error.h"
-#include "net.h"
 #include "string.h"
+#include "afh.h"
+#include "afs.h"
+#include "server.h"
+#include "afs_common.h"
+#include "net.h"
 #include "ipc.h"
+#include "list.h"
 #include "user_list.h"
 #include "playlist_selector_command_list.h"
 
@@ -65,7 +58,7 @@ static struct audio_file_selector *self;
 
 extern struct misc_meta_data *mmd;
 
-static void playlist_add(char *path)
+static int playlist_add(char *path, __a_unused void *data)
 {
        if (playlist_len >= playlist_size) {
                playlist_size = 2 * playlist_size + 1;
@@ -73,6 +66,7 @@ static void playlist_add(char *path)
        }
        PARA_DEBUG_LOG("adding #%d/%d: %s\n", playlist_len, playlist_size, path);
        playlist[playlist_len++] = para_strdup(path);
+       return 1;
 }
 
 static int send_playlist_to_server(const char *buf, size_t size)
@@ -118,7 +112,7 @@ out:
        return ret;
 }
 
-int com_lpl(int fd, __a_unused int argc, __a_unused char *argv[])
+int com_lpl(int fd, __a_unused int argc, __a_unused char * const * const argv)
 {
        unsigned loaded = 0;
        size_t bufsize = 4096; /* guess that's enough */
@@ -149,7 +143,7 @@ out:
        return ret;
 }
 
-int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[])
+int com_ppl(int fd, __a_unused int argc, __a_unused char * const * const argv)
 {
        unsigned i;
 
@@ -224,7 +218,7 @@ static void pls_post_select(__a_unused fd_set *rfds, __a_unused fd_set *wfds)
                goto out;
        }
        PARA_DEBUG_LOG("loading new playlist (%zd bytes)\n", pcd->size);
-       ret = for_each_line((char *)shm, pcd->size, &playlist_add);
+       ret = for_each_line((char *)shm, pcd->size, &playlist_add, NULL);
        shm_detach(shm);
        PARA_NOTICE_LOG("new playlist (%d entries)\n", playlist_len);
        sprintf(mmd->selector_info, "dbinfo1:new playlist: %d files\n"
@@ -245,7 +239,7 @@ static size_t string_offset(const char *str, size_t max)
        return l - max;
 }
 
-void pls_update_audio_file(char *audio_file)
+static void pls_update_audio_file(char *audio_file)
 {
        unsigned i;
        char *dir = para_dirname(audio_file),
@@ -279,25 +273,27 @@ void pls_update_audio_file(char *audio_file)
 /**
  * the init function for the playlist selector
  *
- * Init all function pointers of \a db
+ * \param afs pointer to the struct to initialize
+ *
+ * Init all function pointers of \a afs
  *
  * \sa struct audio_file_selector, misc_meta_data::selector_info, mysql.c
  * random_selector.c.
  */
-int playlist_selector_init(struct audio_file_selector *db)
+int playlist_selector_init(struct audio_file_selector *afs)
 {
        int ret;
        struct private_pls_data *ppd = NULL;
        void *shm = NULL;
 
-       self = db;
-       db->cmd_list = playlist_selector_cmds;
-       db->get_audio_file_list = pls_get_audio_file_list;
-       db->shutdown = pls_shutdown;
-       db->post_select = pls_post_select;
-       db->update_audio_file = pls_update_audio_file;
+       self = afs;
+       afs->cmd_list = playlist_selector_cmds;
+       afs->get_audio_file_list = pls_get_audio_file_list;
+       afs->shutdown = pls_shutdown;
+       afs->post_select = pls_post_select;
+       afs->update_audio_file = pls_update_audio_file;
        ppd = para_calloc(sizeof(struct private_pls_data));
-       db->private_data = ppd;
+       afs->private_data = ppd;
 
        ppd->client_mutex = -1;
        ppd->server_mutex = -1;