Mercurial > hg > xmms-sid
diff src/xs_title.c @ 660:b0743dc9165d
Change tabs to 4 spaces, everywhere.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Apr 2008 22:10:05 +0300 |
parents | acaba070cf49 |
children | c8648efaebba |
line wrap: on
line diff
--- a/src/xs_title.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_title.c Wed Apr 02 22:10:05 2008 +0300 @@ -27,195 +27,195 @@ static void xs_path_split(gchar *path, gchar **tmpFilename, gchar **tmpFilePath, gchar **tmpFileExt) { - gchar *tmpStr; - - /* Split the filename into path */ - *tmpFilePath = g_strdup(path); - tmpStr = xs_strrchr(*tmpFilePath, '/'); - if (tmpStr) tmpStr[1] = 0; + gchar *tmpStr; + + /* Split the filename into path */ + *tmpFilePath = g_strdup(path); + tmpStr = xs_strrchr(*tmpFilePath, '/'); + if (tmpStr) tmpStr[1] = 0; - /* Filename */ - *tmpFilename = xs_strrchr(path, '/'); - if (*tmpFilename) - *tmpFilename = g_strdup(*tmpFilename + 1); - else - *tmpFilename = g_strdup(path); + /* Filename */ + *tmpFilename = xs_strrchr(path, '/'); + if (*tmpFilename) + *tmpFilename = g_strdup(*tmpFilename + 1); + else + *tmpFilename = g_strdup(path); - tmpStr = xs_strrchr(*tmpFilename, '.'); - tmpStr[0] = 0; + tmpStr = xs_strrchr(*tmpFilename, '.'); + tmpStr[0] = 0; - /* Extension */ - *tmpFileExt = xs_strrchr(path, '.'); + /* Extension */ + *tmpFileExt = xs_strrchr(path, '.'); } /* Create a title string based on given information and settings. */ -#define VPUTCH(MCH) \ - if (index < XS_BUF_SIZE) tmpBuf[index++] = MCH; +#define VPUTCH(MCH) \ + if (index < XS_BUF_SIZE) tmpBuf[index++] = MCH; -#define VPUTSTR(MSTR) { \ - if (MSTR) { \ - if ((index + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ - strcpy(&tmpBuf[index], MSTR); \ - index += strlen(MSTR); \ - } else \ - index = XS_BUF_SIZE; \ - } \ +#define VPUTSTR(MSTR) { \ + if (MSTR) { \ + if ((index + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ + strcpy(&tmpBuf[index], MSTR); \ + index += strlen(MSTR); \ + } else \ + index = XS_BUF_SIZE; \ + } \ } gchar *xs_make_titlestring(xs_tuneinfo_t *p, gint subTune) { - gchar *tmpFilename, *tmpFilePath, *tmpFileExt, - *str, *result, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; - xs_subtuneinfo_t *subInfo; - gint index; + gchar *tmpFilename, *tmpFilePath, *tmpFileExt, + *str, *result, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; + xs_subtuneinfo_t *subInfo; + gint index; - /* Get filename parts */ - xs_path_split(p->sidFilename, &tmpFilename, - &tmpFilePath, &tmpFileExt); - - /* Get sub-tune information */ - if ((subTune > 0) && (subTune <= p->nsubTunes)) { - subInfo = &(p->subTunes[subTune - 1]); - } else - subInfo = NULL; + /* Get filename parts */ + xs_path_split(p->sidFilename, &tmpFilename, + &tmpFilePath, &tmpFileExt); + + /* Get sub-tune information */ + if ((subTune > 0) && (subTune <= p->nsubTunes)) { + subInfo = &(p->subTunes[subTune - 1]); + } else + subInfo = NULL; - /* Check if the titles are overridden or not */ + /* Check if the titles are overridden or not */ #ifdef HAVE_XMMSEXTRA - if (!xs_cfg.titleOverride) { - TitleInput *pTuple; - - pTuple = (TitleInput *) g_malloc0(sizeof(TitleInput)); - pTuple->__size = XMMS_TITLEINPUT_SIZE; - pTuple->__version = XMMS_TITLEINPUT_VERSION; - - /* Create the input fields */ - pTuple->file_name = tmpFilename; - pTuple->file_ext = tmpFileExt; - pTuple->file_path = tmpFilePath; + if (!xs_cfg.titleOverride) { + TitleInput *pTuple; + + pTuple = (TitleInput *) g_malloc0(sizeof(TitleInput)); + pTuple->__size = XMMS_TITLEINPUT_SIZE; + pTuple->__version = XMMS_TITLEINPUT_VERSION; + + /* Create the input fields */ + pTuple->file_name = tmpFilename; + pTuple->file_ext = tmpFileExt; + pTuple->file_path = tmpFilePath; - pTuple->track_name = g_strdup(p->sidName); - pTuple->track_number = subTune; - pTuple->album_name = NULL; - pTuple->performer = g_strdup(p->sidComposer); - pTuple->date = g_strdup((p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"); + pTuple->track_name = g_strdup(p->sidName); + pTuple->track_number = subTune; + pTuple->album_name = NULL; + pTuple->performer = g_strdup(p->sidComposer); + pTuple->date = g_strdup((p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"); - pTuple->year = 0; - pTuple->genre = g_strdup("SID-tune"); - pTuple->comment = g_strdup(p->sidCopyright); + pTuple->year = 0; + pTuple->genre = g_strdup("SID-tune"); + pTuple->comment = g_strdup(p->sidCopyright); - result = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); + result = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); - g_free(pTuple->track_name); - g_free(pTuple->album_name); - g_free(pTuple->performer); - g_free(pTuple->date); - g_free(pTuple->genre); - g_free(pTuple->comment); - g_free(pTuple); - } else + g_free(pTuple->track_name); + g_free(pTuple->album_name); + g_free(pTuple->performer); + g_free(pTuple->date); + g_free(pTuple->genre); + g_free(pTuple->comment); + g_free(pTuple); + } else #endif - { - /* Create the string */ - str = xs_cfg.titleFormat; - index = 0; - while (*str && (index < XS_BUF_SIZE)) { - if (*str == '%') { - str++; - switch (*str) { - case '%': - VPUTCH('%'); - break; - case 'f': - VPUTSTR(tmpFilename); - break; - case 'F': - VPUTSTR(tmpFilePath); - break; - case 'e': - VPUTSTR(tmpFileExt); - break; - case 'p': - VPUTSTR(p->sidComposer); - break; - case 't': - VPUTSTR(p->sidName); - break; - case 'c': - VPUTSTR(p->sidCopyright); - break; - case 's': - VPUTSTR(p->sidFormat); - break; - case 'm': - switch (p->sidModel) { - case XS_SIDMODEL_6581: - VPUTSTR("6581"); - break; - case XS_SIDMODEL_8580: - VPUTSTR("8580"); - break; - case XS_SIDMODEL_ANY: - VPUTSTR("ANY"); - break; - default: - VPUTSTR("?"); - break; - } - break; - case 'C': - if (subInfo && (subInfo->tuneSpeed > 0)) { - switch (subInfo->tuneSpeed) { - case XS_CLOCK_PAL: - VPUTSTR("PAL"); - break; - case XS_CLOCK_NTSC: - VPUTSTR("NTSC"); - break; - case XS_CLOCK_ANY: - VPUTSTR("ANY"); - break; - case XS_CLOCK_VBI: - VPUTSTR("VBI"); - break; - case XS_CLOCK_CIA: - VPUTSTR("CIA"); - break; - default: - g_snprintf(tmpStr, XS_BUF_SIZE, - "%iHz", subInfo->tuneSpeed); - VPUTSTR(tmpStr); - } - } else - VPUTSTR("?"); - break; - case 'n': - g_snprintf(tmpStr, XS_BUF_SIZE, "%i", subTune); - VPUTSTR(tmpStr); - break; - case 'N': - g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); - VPUTSTR(tmpStr); - break; - } - } else - VPUTCH(*str); + { + /* Create the string */ + str = xs_cfg.titleFormat; + index = 0; + while (*str && (index < XS_BUF_SIZE)) { + if (*str == '%') { + str++; + switch (*str) { + case '%': + VPUTCH('%'); + break; + case 'f': + VPUTSTR(tmpFilename); + break; + case 'F': + VPUTSTR(tmpFilePath); + break; + case 'e': + VPUTSTR(tmpFileExt); + break; + case 'p': + VPUTSTR(p->sidComposer); + break; + case 't': + VPUTSTR(p->sidName); + break; + case 'c': + VPUTSTR(p->sidCopyright); + break; + case 's': + VPUTSTR(p->sidFormat); + break; + case 'm': + switch (p->sidModel) { + case XS_SIDMODEL_6581: + VPUTSTR("6581"); + break; + case XS_SIDMODEL_8580: + VPUTSTR("8580"); + break; + case XS_SIDMODEL_ANY: + VPUTSTR("ANY"); + break; + default: + VPUTSTR("?"); + break; + } + break; + case 'C': + if (subInfo && (subInfo->tuneSpeed > 0)) { + switch (subInfo->tuneSpeed) { + case XS_CLOCK_PAL: + VPUTSTR("PAL"); + break; + case XS_CLOCK_NTSC: + VPUTSTR("NTSC"); + break; + case XS_CLOCK_ANY: + VPUTSTR("ANY"); + break; + case XS_CLOCK_VBI: + VPUTSTR("VBI"); + break; + case XS_CLOCK_CIA: + VPUTSTR("CIA"); + break; + default: + g_snprintf(tmpStr, XS_BUF_SIZE, + "%iHz", subInfo->tuneSpeed); + VPUTSTR(tmpStr); + } + } else + VPUTSTR("?"); + break; + case 'n': + g_snprintf(tmpStr, XS_BUF_SIZE, "%i", subTune); + VPUTSTR(tmpStr); + break; + case 'N': + g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); + VPUTSTR(tmpStr); + break; + } + } else + VPUTCH(*str); - str++; - } + str++; + } - tmpBuf[index] = 0; + tmpBuf[index] = 0; - /* Make resulting string */ - result = g_strdup(tmpBuf); - } + /* Make resulting string */ + result = g_strdup(tmpBuf); + } - /* Free temporary strings */ - g_free(tmpFilename); - g_free(tmpFilePath); + /* Free temporary strings */ + g_free(tmpFilename); + g_free(tmpFilePath); - return result; + return result; }