Mercurial > hg > xmms-sid
view src/xs_sidplay.h @ 76:741291e14080 dev-0-8-0b1
Added missing header
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 15 Sep 2003 11:12:02 +0000 |
parents | |
children | 94497283affa |
line wrap: on
line source
/* * Create the SID-tune description string from the tune's information * formatted by the user-specified format-string. */ gchar *xs_make_filetitle(gchar *pcFileName, sidTuneInfo *pfInfo, gint iSubTune) { gint j, iLength; gchar *pcStr, *pcResult; #ifdef HAVE_XMMSEXTRA TitleInput *ptInput; #endif /* FIXME FIXME: get STIL-information */ /* Check the info strings */ if (pfInfo->numberOfInfoStrings < 3) { if (pfInfo->numberOfInfoStrings < 1) return 0; return g_strdup(pfInfo->infoString[0]); } #ifdef HAVE_XMMSEXTRA /* Check if the titles are overridden or not */ if (!xs_cfg.titleOverride) { /* Use generic XMMS titles */ /* XMMS_NEW_TITLEINPUT(ptInput); * We duplicate and add typecast to the code here due to XMMS's braindead headers */ ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput)); ptInput->__size = XMMS_TITLEINPUT_SIZE; ptInput->__version = XMMS_TITLEINPUT_VERSION; /* Create the input fields */ ptInput->file_name = pfInfo->dataFileName; ptInput->file_ext = g_strdup("sid"); ptInput->file_path = pfInfo->path; ptInput->track_name = pfInfo->infoString[0]; ptInput->track_number = iSubTune; ptInput->album_name = NULL; ptInput->performer = pfInfo->infoString[1]; ptInput->date = g_strdup((pfInfo->sidModel == SIDTUNE_SIDMODEL_6581) ? "6581" : "8580"); ptInput->year = 0; ptInput->genre = g_strdup("SID-tune"); ptInput->comment = pfInfo->infoString[2]; /* Create the string */ pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput); /* Dispose all allocated memory */ g_free(ptInput->file_ext); g_free(ptInput->date); g_free(ptInput->genre); g_free(ptInput); } else #endif { /* Estimate the length of the string */ pcStr = xs_cfg.titleFormat; iLength = 0; while (*pcStr) { if (*pcStr == '%') { switch (*(++pcStr)) { case '1': iLength += strlen(pfInfo->infoString[1]); break; case '2': iLength += strlen(pfInfo->infoString[0]); break; case '3': iLength += strlen(pfInfo->infoString[2]); break; case '4': iLength += strlen(pfInfo->formatString); break; case '%': iLength++; } } else iLength++; pcStr++; } /* Allocate memory */ pcResult = (gchar *) g_malloc(iLength + 2); if (pcResult == NULL) return g_strdup(pfInfo->infoString[0]); /* Create the string */ pcStr = xs_cfg.titleFormat; j = 0; while (*pcStr) { if (*pcStr == '%') { switch (*(++pcStr)) { case '1': xs_strpcat(pcResult, &j, pfInfo->infoString[1]); break; case '2': xs_strpcat(pcResult, &j, pfInfo->infoString[0]); break; case '3': xs_strpcat(pcResult, &j, pfInfo->infoString[2]); break; case '4': xs_strpcat(pcResult, &j, pfInfo->formatString); break; case '%': pcResult[j++] = '%'; break; } } else pcResult[j++] = *pcStr; pcStr++; } pcResult[j] = 0; } return pcResult; }