[xiph-cvs] cvs commit: libshout/src shout.c shout_private.h

Michael Smith msmith at xiph.org
Fri Aug 16 08:47:06 PDT 2002



msmith      02/08/16 11:47:06

  Modified:    include/shout shout.h
               src      shout.c shout_private.h
  Log:
  Add ability to send a user-agent string to the server.

Revision  Changes    Path
1.10      +3 -0      libshout/include/shout/shout.h

Index: shout.h
===================================================================
RCS file: /usr/local/cvsroot/libshout/include/shout/shout.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- shout.h	16 Aug 2002 14:22:16 -0000	1.9
+++ shout.h	16 Aug 2002 15:47:06 -0000	1.10
@@ -80,6 +80,9 @@
 int shout_set_user(shout_t *self, const char *username);
 const char *shout_get_user(shout_t *self);
 
+int shout_set_agent(shout_t *self, const char *username);
+const char *shout_get_agent(shout_t *self);
+
 int shout_set_description(shout_t *self, const char *description);
 const char *shout_get_description(shout_t *self);
 

<p><p>1.8       +31 -0     libshout/src/shout.c

Index: shout.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- shout.c	16 Aug 2002 14:22:16 -0000	1.7
+++ shout.c	16 Aug 2002 15:47:06 -0000	1.8
@@ -53,6 +53,7 @@
         if (self->genre) free(self->genre);
         if (self->description) free(self->description);
         if (self->user) free(self->user);
+    if (self->useragent) free(self->useragent);
 
         free(self);
 }
@@ -396,6 +397,32 @@
         return self->genre;
 }
 
+int shout_set_agent(shout_t *self, const char *agent)
+{
+	if (!self)
+		return SHOUTERR_INSANE;
+
+	if (self->connected)
+		return self->error = SHOUTERR_CONNECTED;
+
+	if (self->useragent)
+		free(self->useragent);
+
+	if (! (self->useragent = util_strdup (agent)))
+		return self->error = SHOUTERR_MALLOC;
+
+	return self->error = SHOUTERR_SUCCESS;
+}
+
+const char *shout_get_agent(shout_t *self)
+{
+    if (!self)
+        return NULL;
+
+    return self->useragent;
+}
+
+
 int shout_set_user(shout_t *self, const char *username)
 {
         if (!self)
@@ -564,6 +591,10 @@
                 if (!sock_write(self->socket, "ice-description: %s\r\n", self->description))
                         return SHOUTERR_SOCKET;
         }
+    if (self->useragent) {
+        if (!sock_write(self->socket, "User-Agent: %s\r\n", self->useragent))
+            return SHOUTERR_SOCKET;
+    }
         if (self->format == SHOUT_FORMAT_VORBIS) {
                 if (!sock_write(self->socket, "Content-Type: application/x-ogg\r\n"))
                         return SHOUTERR_SOCKET;

<p><p>1.3       +2 -0      libshout/src/shout_private.h

Index: shout_private.h
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout_private.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- shout_private.h	16 Aug 2002 14:22:16 -0000	1.2
+++ shout_private.h	16 Aug 2002 15:47:06 -0000	1.3
@@ -48,6 +48,8 @@
         /* type of data being sent */
         unsigned int format;
 
+    /* user-agent to use when doing HTTP login */
+    char *useragent;
         /* mountpoint for this stream */
         char *mount;
         /* name of the stream */

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list