| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2005, 2006 Stephen F. Booth <me@sbooth.org> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #import "FLACHelperFunctions.h" |
|---|
| 22 | |
|---|
| 23 | void |
|---|
| 24 | truncateVorbisComments(FLAC__StreamMetadata *block) |
|---|
| 25 | { |
|---|
| 26 | if(NO == FLAC__metadata_object_vorbiscomment_resize_comments(block, 0)) { |
|---|
| 27 | @throw [NSException exceptionWithName:@"MallocException" reason:NSLocalizedStringFromTable(@"Unable to allocate memory.", @"Errors", @"") userInfo:nil]; |
|---|
| 28 | } |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | void |
|---|
| 32 | addVorbisComment(FLAC__StreamMetadata *block, |
|---|
| 33 | NSString *key, |
|---|
| 34 | NSString *value) |
|---|
| 35 | { |
|---|
| 36 | FLAC__StreamMetadata_VorbisComment_Entry entry; |
|---|
| 37 | FLAC__bool result; |
|---|
| 38 | |
|---|
| 39 | result = FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, [key cStringUsingEncoding:NSASCIIStringEncoding], [value UTF8String]); |
|---|
| 40 | NSCAssert1(YES == result, NSLocalizedStringFromTable(@"The call to %@ failed.", @"Exceptions", @""), @"FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair"); |
|---|
| 41 | |
|---|
| 42 | result = FLAC__metadata_object_vorbiscomment_append_comment(block, entry, NO); |
|---|
| 43 | NSCAssert1(YES == result, NSLocalizedStringFromTable(@"The call to %@ failed.", @"Exceptions", @""), @"FLAC__metadata_object_vorbiscomment_append_comment"); |
|---|
| 44 | } |
|---|