1087
1087
* FLAC__metadata_object_application_set_data(), you will get an assertion
1090
* For convenience the FLAC__metadata_object_vorbiscomment_*() functions
1091
* maintain a trailing NUL on each Vorbis comment entry. This is not counted
1092
* toward the length or stored in the stream, but it can make working with plain
1093
* comments (those that don't contain embedded-NULs in the value) easier.
1094
* Entries passed into these functions have trailing NULs added if missing, and
1095
* returned entries are guaranteed to have a trailing NUL.
1097
* The FLAC__metadata_object_vorbiscomment_*() functions that take a Vorbis
1098
* comment entry/name/value will first validate that it complies with the Vorbis
1099
* comment specification and return false if it does not.
1090
1101
* There is no need to recalculate the length field on metadata blocks you
1091
1102
* have modified. They will be calculated automatically before they are
1092
1103
* written back to a file.
1327
1337
* \code object != NULL \endcode
1328
1338
* \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1329
1339
* \retval FLAC__bool
1330
* \c false if realloc fails, else \c true.
1340
* \c false if realloc() fails, else \c true.
1332
1342
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact);
1334
1344
/** Sets the vendor string in a VORBIS_COMMENT block.
1346
* For convenience, a trailing NUL is added to the entry if it doesn't have
1336
1349
* If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1337
* takes ownership of the \c entry->entry pointer. Returns \c false if
1338
* \a copy == \c true and malloc fails.
1350
* takes ownership of the \c entry.entry pointer.
1352
* \note If this function returns \c false, the caller still owns the
1340
1355
* \param object A pointer to an existing VORBIS_COMMENT object.
1341
1356
* \param entry The entry to set the vendor string to.
1344
1359
* \code object != NULL \endcode
1345
1360
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1346
* \code (entry->entry != NULL && entry->length > 0) ||
1347
* (entry->entry == NULL && entry->length == 0) \endcode
1361
* \code (entry.entry != NULL && entry.length > 0) ||
1362
* (entry.entry == NULL && entry.length == 0) \endcode
1348
1363
* \retval FLAC__bool
1349
* \c false if \a copy is \c true and malloc fails, else \c true.
1364
* \c false if memory allocation fails or \a entry does not comply with the
1365
* Vorbis comment specification, else \c true.
1351
1367
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1363
1379
* \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) ||
1364
1380
* (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode
1365
1381
* \retval FLAC__bool
1366
* \c false if memory allocation error, else \c true.
1382
* \c false if memory allocation fails, else \c true.
1368
1384
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments);
1370
1386
/** Sets a comment in a VORBIS_COMMENT block.
1388
* For convenience, a trailing NUL is added to the entry if it doesn't have
1372
1391
* If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1373
* takes ownership of the \c entry->entry pointer. Returns \c false if
1374
* \a copy == \c true and malloc fails.
1392
* takes ownership of the \c entry.entry pointer.
1394
* \note If this function returns \c false, the caller still owns the
1376
1397
* \param object A pointer to an existing VORBIS_COMMENT object.
1377
1398
* \param comment_num Index into comment array to set.
1381
1402
* \code object != NULL \endcode
1382
1403
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1383
1404
* \code comment_num < object->data.vorbis_comment.num_comments \endcode
1384
* \code (entry->entry != NULL && entry->length > 0) ||
1385
* (entry->entry == NULL && entry->length == 0) \endcode
1405
* \code (entry.entry != NULL && entry.length > 0) ||
1406
* (entry.entry == NULL && entry.length == 0) \endcode
1386
1407
* \retval FLAC__bool
1387
* \c false if \a copy is \c true and malloc fails, else \c true.
1408
* \c false if memory allocation fails or \a entry does not comply with the
1409
* Vorbis comment specification, else \c true.
1389
1411
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1391
1413
/** Insert a comment in a VORBIS_COMMENT block at the given index.
1415
* For convenience, a trailing NUL is added to the entry if it doesn't have
1393
1418
* If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1394
* takes ownership of the \c entry->entry pointer. Returns \c false if
1395
* \a copy == \c true and malloc fails.
1419
* takes ownership of the \c entry.entry pointer.
1421
* \note If this function returns \c false, the caller still owns the
1397
1424
* \param object A pointer to an existing VORBIS_COMMENT object.
1398
1425
* \param comment_num The index at which to insert the comment. The comments
1405
1432
* \code object != NULL \endcode
1406
1433
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1407
1434
* \code object->data.vorbis_comment.num_comments >= comment_num \endcode
1408
* \code (entry->entry != NULL && entry->length > 0) ||
1409
* (entry->entry == NULL && entry->length == 0 && copy == false) \endcode
1435
* \code (entry.entry != NULL && entry.length > 0) ||
1436
* (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
1410
1437
* \retval FLAC__bool
1411
* \c false if \a copy is \c true and malloc fails, else \c true.
1438
* \c false if memory allocation fails or \a entry does not comply with the
1439
* Vorbis comment specification, else \c true.
1413
1441
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1443
/** Appends a comment to a VORBIS_COMMENT block.
1445
* For convenience, a trailing NUL is added to the entry if it doesn't have
1448
* If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1449
* takes ownership of the \c entry.entry pointer.
1451
* \note If this function returns \c false, the caller still owns the
1454
* \param object A pointer to an existing VORBIS_COMMENT object.
1455
* \param entry The comment to insert.
1456
* \param copy See above.
1458
* \code object != NULL \endcode
1459
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1460
* \code (entry.entry != NULL && entry.length > 0) ||
1461
* (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
1462
* \retval FLAC__bool
1463
* \c false if memory allocation fails or \a entry does not comply with the
1464
* Vorbis comment specification, else \c true.
1466
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1468
/** Replaces comments in a VORBIS_COMMENT block with a new one.
1470
* For convenience, a trailing NUL is added to the entry if it doesn't have
1473
* Depending on the the value of \a all, either all or just the first comment
1474
* whose field name(s) match the given entry's name will be replaced by the
1475
* given entry. If no comments match, \a entry will simply be appended.
1477
* If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1478
* takes ownership of the \c entry.entry pointer.
1480
* \note If this function returns \c false, the caller still owns the
1483
* \param object A pointer to an existing VORBIS_COMMENT object.
1484
* \param entry The comment to insert.
1485
* \param all If \c true, all comments whose field name matches
1486
* \a entry's field name will be removed, and \a entry will
1487
* be inserted at the position of the first matching
1488
* comment. If \c false, only the first comment whose
1489
* field name matches \a entry's field name will be
1490
* replaced with \a entry.
1491
* \param copy See above.
1493
* \code object != NULL \endcode
1494
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1495
* \code (entry.entry != NULL && entry.length > 0) ||
1496
* (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
1497
* \retval FLAC__bool
1498
* \c false if memory allocation fails or \a entry does not comply with the
1499
* Vorbis comment specification, else \c true.
1501
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy);
1415
1503
/** Delete a comment in a VORBIS_COMMENT block at the given index.
1417
1505
* \param object A pointer to an existing VORBIS_COMMENT object.
1420
1508
* \code object != NULL \endcode
1421
1509
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1422
1510
* \code object->data.vorbis_comment.num_comments > comment_num \endcode
1423
* \code (entry->entry != NULL && entry->length > 0) ||
1424
* (entry->entry == NULL && entry->length == 0 && copy == false) \endcode
1425
1511
* \retval FLAC__bool
1426
* \c false if realloc fails, else \c true.
1512
* \c false if realloc() fails, else \c true.
1428
1514
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num);
1430
/*@@@@ add to unit tests */
1516
/** Creates a Vorbis comment entry from NUL-terminated name and value strings.
1518
* On return, the filled-in \a entry->entry pointer will point to malloc()ed
1519
* memory and shall be owned by the caller. For convenience the entry will
1520
* have a terminating NUL.
1522
* \param entry A pointer to a Vorbis comment entry. The entry's
1523
* \c entry pointer should not point to allocated
1524
* memory as it will be overwritten.
1525
* \param field_name The field name in ASCII, \c NUL terminated.
1526
* \param field_value The field value in UTF-8, \c NUL terminated.
1528
* \code entry != NULL \endcode
1529
* \code field_name != NULL \endcode
1530
* \code field_value != NULL \endcode
1531
* \retval FLAC__bool
1532
* \c false if malloc() fails, or if \a field_name or \a field_value does
1533
* not comply with the Vorbis comment specification, else \c true.
1535
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value);
1537
/** Splits a Vorbis comment entry into NUL-terminated name and value strings.
1539
* The returned pointers to name and value will be allocated by malloc()
1540
* and shall be owned by the caller.
1542
* \param entry An existing Vorbis comment entry.
1543
* \param field_name The address of where the returned pointer to the
1544
* field name will be stored.
1545
* \param field_value The address of where the returned pointer to the
1546
* field value will be stored.
1548
* \code (entry.entry != NULL && entry.length > 0) \endcode
1549
* \code memchr(entry.entry, '=', entry.length) != NULL \endcode
1550
* \code field_name != NULL \endcode
1551
* \code field_value != NULL \endcode
1552
* \retval FLAC__bool
1553
* \c false if memory allocation fails or \a entry does not comply with the
1554
* Vorbis comment specification, else \c true.
1556
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value);
1431
1558
/** Check if the given Vorbis comment entry's field name matches the given
1434
* \param entry A pointer to an existing Vorbis comment entry.
1561
* \param entry An existing Vorbis comment entry.
1435
1562
* \param field_name The field name to check.
1436
1563
* \param field_name_length The length of \a field_name, not including the
1437
* terminating \c NULL.
1564
* terminating \c NUL.
1439
* \code entry != NULL \endcode
1440
* \code (entry->entry != NULL && entry->length > 0) \endcode
1566
* \code (entry.entry != NULL && entry.length > 0) \endcode
1441
1567
* \retval FLAC__bool
1442
1568
* \c true if the field names match, else \c false
1444
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, unsigned field_name_length);
1570
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, unsigned field_name_length);
1446
/*@@@@ add to unit tests */
1447
1572
/** Find a Vorbis comment with the given field name.
1449
1574
* The search begins at entry number \a offset; use an offset of 0 to
1457
1582
* \code object != NULL \endcode
1458
1583
* \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1584
* \code field_name != NULL \endcode
1460
1586
* The offset in the comment array of the first comment whose field
1461
1587
* name matches \a field_name, or \c -1 if no match was found.
1463
1589
FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name);
1465
/*@@@@ add to unit tests */
1466
1591
/** Remove first Vorbis comment matching the given field name.
1468
1593
* \param object A pointer to an existing VORBIS_COMMENT object.
1644
1767
* \code (track->indices != NULL && track->num_indices > 0) ||
1645
1768
* (track->indices == NULL && track->num_indices == 0)
1646
1769
* \retval FLAC__bool
1647
* \c false if \a copy is \c true and malloc fails, else \c true.
1770
* \c false if \a copy is \c true and malloc() fails, else \c true.
1649
1772
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
1651
1774
/** Insert a track in a CUESHEET block at the given index.
1653
1776
* If \a copy is \c true, a copy of the track is stored; otherwise, the object
1654
* takes ownership of the \a track pointer. Returns \c false if
1655
* \a copy == \c true and malloc fails.
1777
* takes ownership of the \a track pointer.
1657
1779
* \param object A pointer to an existing CUESHEET object.
1658
1780
* \param track_num The index at which to insert the track. NOTE: this