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

Michael Smith msmith at xiph.org
Sat Aug 3 19:29:14 PDT 2002



msmith      02/08/03 19:29:13

  Modified:    include/shout shout.h
               src      shout.c
  Log:
  Add shout_get_errno function

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

Index: shout.h
===================================================================
RCS file: /usr/local/cvsroot/libshout/include/shout/shout.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- shout.h	2002/03/31 15:17:28	1.7
+++ shout.h	2002/08/04 02:29:12	1.8
@@ -47,6 +47,9 @@
  * to occur.  Only valid until the next libshout call on this shout_t */
 const char *shout_get_error(shout_t *self);
 
+/* Return the error code (e.g. SHOUTERR_SOCKET) for this shout instance */
+int shout_get_errno(shout_t *self);
+
 /* Parameter manipulation functions.  libshout makes copies of all parameters,
  * the caller may free its copies after giving them to libshout.  May return
  * SHOUTERR_MALLOC */

<p><p>1.6       +16 -3     libshout/src/shout.c

Index: shout.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- shout.c	2002/01/23 03:11:50	1.5
+++ shout.c	2002/08/04 02:29:13	1.6
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 #include "shout.h"
 #include "shout_private.h"
@@ -143,16 +144,22 @@
 ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len)
 {
         ssize_t ret;
+    size_t remaining = len;
 
         if (!self)
                 return SHOUTERR_INSANE;
 
-	if (len) {
-		ret = sock_write_bytes(self->socket, data, len);
-		if (ret < 0 || (size_t)ret != len) {
+	while(remaining) {
+		ret = sock_write_bytes(self->socket, data, remaining);
+        if(ret < (ssize_t)remaining && errno == EINTR) {
+            remaining -= (remaining>0)?remaining:0;
+            continue;
+        }
+		if (ret < 0 || (size_t)ret != remaining) {
                         self->error = SHOUTERR_SOCKET;
                         return ret;
                 }
+        remaining = 0;
         }
 
         self->error = SHOUTERR_SUCCESS;
@@ -174,6 +181,12 @@
         if (sleep > 0)
                 timing_sleep(sleep);
 }
+
+int shout_get_errno(shout_t *self)
+{
+    return self->error;
+}
+
 
 const char *shout_get_error(shout_t *self)
 {

<p><p><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