-#define TEMP_STR_SIZE 256
-#define TEMP_STR_LEN (TEMP_STR_SIZE-1)
- static char temp_str[TEMP_STR_SIZE];
- size_t i;
- char * tp = temp_str;
- vlc_bool_t saw_control_prefix = false;
- size_t format_len = strlen(format_str);
-
- memset(temp_str, 0, TEMP_STR_SIZE);
-
- for (i=0; i<format_len; i++) {
-
- if (!saw_control_prefix && format_str[i] != '%') {
- *tp++ = format_str[i];
- saw_control_prefix = false;
- continue;
- }
-
- switch(format_str[i]) {
- case '%':
- if (saw_control_prefix) {
- *tp++ = '%';
- }
- saw_control_prefix = !saw_control_prefix;
- break;
-#ifdef HAVE_LIBCDDB
- case 'a':
- if (!p_cdda->i_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(p_cdda->cddb.disc->artist);
- break;
- case 'A':
- if (!p_cdda->i_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(p_cdda->cddb.disc->title);
- break;
- case 'C':
- if (!p_cdda->i_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(CDDB_CATEGORY[p_cdda->cddb.disc->category]);
- break;
- case 'G':
- if (!p_cdda->i_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(p_cdda->cddb.disc->genre);
- break;
- case 'I':
- if (!p_cdda->i_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_num_info(p_cdda->cddb.disc->discid, "%x");
- break;
- case 'Y':
- if (!p_cdda->i_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_num_info(p_cdda->cddb.disc->year, "%5d");
- break;
- case 't':
- if (p_cdda && p_cdda->i_cddb_enabled && p_cdda->cddb.disc) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
- if (t != NULL && t->title != NULL)
- add_format_str_info(t->title);
- } else goto not_special;
- break;
- case 'p':
- if (p_cdda->i_cddb_enabled && p_cdda->cddb.disc) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
- if (t != NULL && t->artist != NULL)
- add_format_str_info(t->artist);
- } else goto not_special;
- break;
- case 'e':
- if (p_cdda->i_cddb_enabled && p_cdda->cddb.disc) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
- if (t != NULL && t->ext_data != NULL)
- add_format_str_info(t->ext_data);
- } else goto not_special;
- break;
-#endif
-
- case 'M':
- add_format_str_info(mrl);
- break;
-
- case 'm':
- add_format_str_info(p_cdda->psz_mcn);
- break;
-
- case 'n':
- add_format_num_info(p_cdda->i_tracks, "%d");
- break;
-
- case 's':
- if (p_cdda->i_cddb_enabled) {
- char psz_buffer[MSTRTIME_MAX_SIZE];
- mtime_t i_duration =
- (p_cdda->p_lsns[i_track] - p_cdda->p_lsns[i_track-1])
- / CDIO_CD_FRAMES_PER_SEC;
- add_format_str_info(secstotimestr( psz_buffer, i_duration ) );
- } else goto not_special;
- break;
-
- case 'T':
- add_format_num_info(i_track, "%02d");
- break;
-#ifdef HAVE_LIBCDDB
- not_special:
-#endif
- default:
- *tp++ = '%';
- *tp++ = format_str[i];
- saw_control_prefix = false;
- }
- }
- return strdup(temp_str);