- int i;
- for( i = 0; i < p_meta->i_meta; i++ )
- {
- bo_t *box = NULL;
-
- if( !strcmp( p_meta->name[i], VLC_META_TITLE ) )
- box = box_new( "\251nam" );
- else if( !strcmp( p_meta->name[i], VLC_META_AUTHOR ) )
- box = box_new( "\251aut" );
- else if( !strcmp( p_meta->name[i], VLC_META_ARTIST ) )
- box = box_new( "\251ART" );
- else if( !strcmp( p_meta->name[i], VLC_META_GENRE ) )
- box = box_new( "\251gen" );
- else if( !strcmp( p_meta->name[i], VLC_META_COPYRIGHT ) )
- box = box_new( "\251cpy" );
- else if( !strcmp( p_meta->name[i], VLC_META_DESCRIPTION ) )
- box = box_new( "\251des" );
- else if( !strcmp( p_meta->name[i], VLC_META_DATE ) )
- box = box_new( "\251day" );
- else if( !strcmp( p_meta->name[i], VLC_META_URL ) )
- box = box_new( "\251url" );
-
- if( box )
- {
- bo_add_16be( box, strlen( p_meta->value[i] ) );
- bo_add_16be( box, 0 );
- bo_add_mem( box, strlen( p_meta->value[i] ),
- p_meta->value[i] );
- box_fix( box );
- box_gather( udta, box );
- }
- }
+#define ADD_META_BOX( type, box_string ) { \
+ bo_t *box = NULL; \
+ if( p_meta->psz_##type ) box = box_new( "\251" box_string ); \
+ if( box ) \
+ { \
+ bo_add_16be( box, strlen( p_meta->psz_##type ) ); \
+ bo_add_16be( box, 0 ); \
+ bo_add_mem( box, strlen( p_meta->psz_##type ), \
+ (uint8_t*)(p_meta->psz_##type ) ); \
+ box_fix( box ); \
+ box_gather( udta, box ); \
+ } }
+
+ ADD_META_BOX( title, "nam" );
+ ADD_META_BOX( artist, "ART" );
+ ADD_META_BOX( genre, "gen" );
+ ADD_META_BOX( copyright, "cpy" );
+ ADD_META_BOX( description, "des" );
+ ADD_META_BOX( date, "day" );
+ ADD_META_BOX( url, "url" );
+#undef ADD_META_BOX