changeset 2002:c97cd4a8c470 trunk

[svn] - cleanup the controlsocket code. (nenolod + help from ticpu)
author nenolod
date Thu, 23 Nov 2006 23:14:03 -0800
parents 97e5147a6812
children 74f280120233
files ChangeLog libaudacious/beepctrl.c
diffstat 2 files changed, 35 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Nov 23 20:21:49 2006 -0800
+++ b/ChangeLog	Thu Nov 23 23:14:03 2006 -0800
@@ -1,3 +1,12 @@
+2006-11-24 04:21:49 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [2991]
+  - remove vfs_stdio.c
+  
+  trunk/libaudacious/Makefile    |    2 
+  trunk/libaudacious/vfs_stdio.c |  180 -----------------------------------------
+  2 files changed, 1 insertion(+), 181 deletions(-)
+
+
 2006-11-24 04:21:34 +0000  William Pitcock <nenolod@nenolod.net>
   revision [2989]
   - remove vfs_init(), it is no longer used.
--- a/libaudacious/beepctrl.c	Thu Nov 23 20:21:49 2006 -0800
+++ b/libaudacious/beepctrl.c	Thu Nov 23 23:14:03 2006 -0800
@@ -57,23 +57,27 @@
 #endif
 
 static gpointer
-remote_read_packet(gint fd, ServerPktHeader * pkt_hdr)
+remote_read_packet(gint fd)
 {
     gpointer data = NULL;
-
-    memset(pkt_hdr, '\0', sizeof(ServerPktHeader));
+    ServerPktHeader pkt_hdr = { 0, 0 };
 
-    if (read(fd, pkt_hdr, sizeof(ServerPktHeader)) ==
-        sizeof(ServerPktHeader)) {
-        if (pkt_hdr->data_length) {
-            size_t data_length = pkt_hdr->data_length;
+    if (read(fd, &pkt_hdr, sizeof(ServerPktHeader)) ==
+        sizeof(ServerPktHeader))
+    {
+        if (pkt_hdr.version == XMMS_PROTOCOL_VERSION && 
+		pkt_hdr.data_length > 0)
+        {
+            size_t data_length = pkt_hdr.data_length;
             data = g_malloc0(data_length);
-            if ((size_t)read(fd, data, data_length) < data_length) {
+            if ((size_t)read(fd, data, data_length) < data_length)
+            {
                 g_free(data);
                 data = NULL;
             }
         }
     }
+
     return data;
 }
 
@@ -81,11 +85,8 @@
 remote_read_ack(gint fd)
 {
     gpointer data;
-    ServerPktHeader pkt_hdr;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data)
         g_free(data);
 
@@ -173,17 +174,14 @@
 static gboolean
 remote_get_gboolean(gint session, gint cmd)
 {
-    ServerPktHeader pkt_hdr;
     gboolean ret = FALSE;
     gpointer data;
     gint fd;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, cmd, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gboolean *) data);
         g_free(data);
@@ -197,16 +195,13 @@
 static guint32
 remote_get_gint(gint session, gint cmd)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd, ret = 0;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, cmd, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gint *) data);
         g_free(data);
@@ -219,17 +214,14 @@
 static gfloat
 remote_get_gfloat(gint session, gint cmd)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd;
     gfloat ret = 0.0;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, cmd, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gfloat *) data);
         g_free(data);
@@ -242,16 +234,13 @@
 gchar *
 remote_get_string(gint session, gint cmd)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return NULL;
     remote_send_packet(fd, cmd, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     remote_read_ack(fd);
     close(fd);
     return data;
@@ -260,16 +249,13 @@
 gchar *
 remote_get_string_pos(gint session, gint cmd, guint32 pos)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return NULL;
     remote_send_packet(fd, cmd, &pos, sizeof(guint32));
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     remote_read_ack(fd);
     close(fd);
     return data;
@@ -618,17 +604,14 @@
 void
 xmms_remote_get_volume(gint session, gint * vl, gint * vr)
 {
-    ServerPktHeader pkt_hdr;
     gint fd;
     gpointer data;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return;
 
     remote_send_packet(fd, CMD_GET_VOLUME, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         *vl = ((guint32 *) data)[0];
         *vr = ((guint32 *) data)[1];
@@ -750,17 +733,14 @@
 gint
 xmms_remote_get_playlist_time(gint session, gint pos)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd, ret = 0;
     guint32 p = pos;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, CMD_GET_PLAYLIST_TIME, &p, sizeof(guint32));
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gint *) data);
         g_free(data);
@@ -773,16 +753,13 @@
 void
 xmms_remote_get_info(gint session, gint * rate, gint * freq, gint * nch)
 {
-    ServerPktHeader pkt_hdr;
     gint fd;
     gpointer data;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return;
     remote_send_packet(fd, CMD_GET_INFO, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         *rate = ((guint32 *) data)[0];
         *freq = ((guint32 *) data)[1];
@@ -981,17 +958,14 @@
 gboolean
 xmms_remote_playqueue_is_queued(gint session, gint pos)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd, ret = 0;
     guint32 p = pos;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, CMD_PLAYQUEUE_IS_QUEUED, &p, sizeof(guint32));
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gint *) data);
         g_free(data);
@@ -1004,17 +978,14 @@
 gint
 xmms_remote_get_playqueue_position(gint session, gint pos)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd, ret = 0;
     guint32 p = pos;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, CMD_PLAYQUEUE_GET_POS, &p, sizeof(guint32));
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gint *) data);
         g_free(data);
@@ -1027,17 +998,14 @@
 gint
 xmms_remote_get_playqueue_queue_position(gint session, gint pos)
 {
-    ServerPktHeader pkt_hdr;
     gpointer data;
     gint fd, ret = 0;
     guint32 p = pos;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return ret;
     remote_send_packet(fd, CMD_PLAYQUEUE_GET_QPOS, &p, sizeof(guint32));
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         ret = *((gint *) data);
         g_free(data);
@@ -1050,12 +1018,9 @@
 void
 xmms_remote_get_eq(gint session, gfloat * preamp, gfloat ** bands)
 {
-    ServerPktHeader pkt_hdr;
     gint fd;
     gpointer data;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if (preamp)
         *preamp = 0.0;
 
@@ -1065,16 +1030,14 @@
     if ((fd = xmms_connect_to_session(session)) == -1)
         return;
     remote_send_packet(fd, CMD_GET_EQ, NULL, 0);
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
-        if (pkt_hdr.data_length >= 11 * sizeof(gfloat)) {
             if (preamp)
                 *preamp = *((gfloat *) data);
             if (bands)
                 *bands =
                     (gfloat *) g_memdup((gfloat *) data + 1,
                                         10 * sizeof(gfloat));
-        }
         g_free(data);
     }
     remote_read_ack(fd);
@@ -1090,17 +1053,14 @@
 gfloat
 xmms_remote_get_eq_band(gint session, gint band)
 {
-    ServerPktHeader pkt_hdr;
     gint fd;
     gpointer data;
     gfloat val = 0.0;
 
-    memset(&pkt_hdr, '\0', sizeof(ServerPktHeader));
-
     if ((fd = xmms_connect_to_session(session)) == -1)
         return val;
     remote_send_packet(fd, CMD_GET_EQ_BAND, &band, sizeof(band));
-    data = remote_read_packet(fd, &pkt_hdr);
+    data = remote_read_packet(fd);
     if (data) {
         val = *((gfloat *) data);
         g_free(data);