# HG changeset patch # User Matti Hamalainen # Date 1063624322 0 # Node ID 741291e14080890d337784039847270eb75e8398 # Parent 653c9b0d1320f2a0b6ff40784c5a66e9fe11cecd Added missing header diff -r 653c9b0d1320 -r 741291e14080 src/xs_sidplay.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/xs_sidplay.h Mon Sep 15 11:12:02 2003 +0000 @@ -0,0 +1,114 @@ +/* + * 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; +} +