Commit ba99f9cc authored by imalone's avatar imalone

Provide oggz_comment_set_vendor for users, change the internal function to...

Provide oggz_comment_set_vendor for users, change the internal function to _oggz_comment_set_vendor.
Add the three new functions to Version-Script.in for export.


git-svn-id: http://svn.annodex.net/liboggz/trunk@2582 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 0b7481cc
......@@ -77,9 +77,10 @@
* \section comments_set Writing comments
*
* For writing, Oggz contains API methods for adding comments
* (oggz_comment_add() and oggz_comment_add_byname()
* and for removing comments
* (oggz_comment_remove() and oggz_comment_remove_byname()).
* (oggz_comment_add() and oggz_comment_add_byname()),
* for removing comments
* (oggz_comment_remove() and oggz_comment_remove_byname())
* and for setting the vendor string (oggz_comment_set_vendor()).
*/
#include <oggz/oggz.h>
......@@ -111,6 +112,21 @@ extern "C" {
const char *
oggz_comment_get_vendor (OGGZ * oggz, long serialno);
/**
* Set the vendor string
* \param oggz A OGGZ* handle
* \param serialno Identify a logical bitstream within \a oggz
* \param vendor_string The contents of the vendor string to add
* \retval 0 Success
* \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle
* \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
* \note The vendor string should identify the library used to produce
* the stream, e.g. libvorbis 1.0 used "Xiph.Org libVorbis I 20020717".
* If copying a bitstream it should be the same as the source.
*/
int
oggz_comment_set_vendor (OGGZ * oggz, long serialno,
const char * vendor_string);
/**
* Retrieve the first comment.
......
......@@ -69,6 +69,7 @@
oggz_table_nth;
oggz_comment_get_vendor;
oggz_comment_set_vendor;
oggz_comment_first;
oggz_comment_first_byname;
oggz_comment_next;
......@@ -77,6 +78,8 @@
oggz_comment_add_byname;
oggz_comment_remove;
oggz_comment_remove_byname;
oggz_comment_generate;
oggz_packet_destroy;
local:
*;
......
......@@ -217,6 +217,24 @@ oggz_comment_cmp (const OggzComment * comment1, const OggzComment * comment2)
return 1;
}
static int
_oggz_comment_set_vendor (OGGZ * oggz, long serialno,
const char * vendor_string)
{
oggz_stream_t * stream;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
if (stream->vendor) oggz_free (stream->vendor);
stream->vendor = oggz_strdup (vendor_string);
return 0;
}
/* Public API */
const char *
......@@ -236,19 +254,25 @@ int
oggz_comment_set_vendor (OGGZ * oggz, long serialno, const char * vendor_string)
{
oggz_stream_t * stream;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
stream = oggz_get_stream (oggz, serialno);
if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;
if (stream == NULL) stream = oggz_add_stream (oggz, serialno);
if (stream->vendor) oggz_free (stream->vendor);
if (oggz->flags & OGGZ_WRITE) {
if (OGGZ_CONFIG_WRITE) {
stream->vendor = oggz_strdup (vendor_string);
return _oggz_comment_set_vendor (oggz, serialno, vendor_string);
return 0;
} else {
return OGGZ_ERR_DISABLED;
}
} else {
return OGGZ_ERR_INVALID;
}
}
const OggzComment *
oggz_comment_first (OGGZ * oggz, long serialno)
{
......@@ -502,7 +526,7 @@ oggz_comments_decode (OGGZ * oggz, long serialno,
/* Vendor */
nvalue = oggz_strdup_len (c, len);
if (!nvalue) return -1;
oggz_comment_set_vendor (oggz, serialno, nvalue);
_oggz_comment_set_vendor (oggz, serialno, nvalue);
if (nvalue) oggz_free (nvalue);
#ifdef DEBUG
fwrite(c, 1, len, stderr); fputc ('\n', stderr);
......
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