Commit 4eddf3fc authored by conrad's avatar conrad

add oggz_run() call; equivalent to calling oggz_read() or oggz_write() in a

loop, but only returns upon completion or error


git-svn-id: http://svn.annodex.net/liboggz/trunk@2026 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 578fd9c5
......@@ -476,6 +476,18 @@ OGGZ * oggz_open_stdio (FILE * file, int flags);
*/
int oggz_flush (OGGZ * oggz);
/**
* Run an OGGZ until completion, or error
* \param oggz An OGGZ handle previously opened for either reading or writing
* \retval 0 Success
* \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
* \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
* \retval OGGZ_ERR_SYSTEM System error; check errno for details
* \retval OGGZ_ERR_RECURSIVE_WRITE Attempt to initiate writing from
* within an OggzHungry callback
*/
long oggz_run (OGGZ * oggz);
/**
* Close an OGGZ handle
* \param oggz An OGGZ handle
......
......@@ -16,6 +16,8 @@
oggz_get_bos;
oggz_get_eos;
oggz_run;
oggz_set_read_callback;
oggz_set_read_page;
oggz_read;
......
......@@ -53,6 +53,10 @@
#include "oggz_private.h"
#include "oggz_vector.h"
/* Definitions for oggz_run() */
long oggz_read (OGGZ * oggz, long n);
long oggz_write (OGGZ * oggz, long n);
/*#define DEBUG*/
static int
......@@ -234,6 +238,22 @@ oggz_tell_units (OGGZ * oggz)
}
}
long
oggz_run (OGGZ * oggz)
{
long n = OGGZ_ERR_DISABLED;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) {
while ((n = oggz_write (oggz, 1024)) > 0);
} else if (OGGZ_CONFIG_READ) {
while ((n = oggz_read (oggz, 1024)) > 0);
}
return n;
}
/******** oggz_stream management ********/
static int
......
......@@ -657,7 +657,7 @@ main (int argc, char ** argv)
}
}
while ((n = oggz_read (oggz, 1024)) > 0);
oggz_run (oggz);
oggz_close (oggz);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment