[xiph-cvs] cvs commit: vorbis-tools/vorbiscomment vcedit.c vcomment.c

Michael Smith msmith at xiph.org
Tue Jan 23 02:39:29 PST 2001



msmith      01/01/23 02:39:29

  Modified:    vorbiscomment vcedit.c vcomment.c
  Log:
  More cleanup/error checking.
  Should probably still add more (checking of return values from ogg and vorbis functions is missing in a fair number of places - similarly to the encoder and decoder examples.

Revision  Changes    Path
1.4       +19 -5     vorbis-tools/vorbiscomment/vcedit.c

Index: vcedit.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcedit.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- vcedit.c	2001/01/22 11:44:04	1.3
+++ vcedit.c	2001/01/23 10:39:29	1.4
@@ -6,7 +6,7 @@
  *
  * Comment editing backend, suitable for use by nice frontend interfaces.
  *
- * last modified: $Id: vcedit.c,v 1.3 2001/01/22 11:44:04 msmith Exp $
+ * last modified: $Id: vcedit.c,v 1.4 2001/01/23 10:39:29 msmith Exp $
  */
 
 
@@ -212,8 +212,10 @@
 
         while((result = ogg_stream_flush(&streamout, &ogout)))
         {
-		fwrite(ogout.header,1,ogout.header_len, out);
-		fwrite(ogout.body,1,ogout.body_len, out);
+		if(fwrite(ogout.header,1,ogout.header_len, out) != ogout.header_len)
+			goto cleanup;
+		if(fwrite(ogout.body,1,ogout.body_len, out) != ogout.body_len)
+			goto cleanup;
         }
 
         while(!(eosin && eosout))
@@ -243,8 +245,12 @@
                                                         int result = ogg_stream_pageout(&streamout, &ogout);
                                                         if(result==0)break;
         
-							fwrite(ogout.header,1,ogout.header_len, out);
-							fwrite(ogout.body,1,ogout.body_len, out);
+							if(fwrite(ogout.header,1,ogout.header_len, out) !=
+									ogout.header_len)
+								goto cleanup;
+							if(fwrite(ogout.body,1,ogout.body_len, out) !=
+									ogout.body_len)
+								goto cleanup;
         
                                                         if(ogg_page_eos(&ogout)) eosout = 1;
                                                 }
@@ -262,6 +268,7 @@
                 }
         }
 
+cleanup:
         ogg_stream_clear(&streamout);
         ogg_packet_clear(&header_comments);
 
@@ -269,6 +276,13 @@
         free(state->bookbuf);
 
         vcedit_clear_internals(state);
+	if(!(eosin && eosout))
+	{
+		fprintf(stderr, "Error writing stream to output.\n"
+				        "Output stream may be corrupted or truncated.\n");
+		return -1;
+	}
+
         return 0;
 }
         

1.5       +1 -1      vorbis-tools/vorbiscomment/vcomment.c

Index: vcomment.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcomment.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- vcomment.c	2001/01/22 11:44:05	1.4
+++ vcomment.c	2001/01/23 10:39:29	1.5
@@ -5,7 +5,7 @@
  * (c) 2001 Ralph Giles <giles at ashlu.bc.ca>
  *
  * Front end to show how to use vcedit;
- * note that it's not very useful on its own.
+ * Of limited usability on its own, but could be useful.
  */
 
 

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