Mercurial > hg > xmms-sid
comparison src/xs_title.c @ 657:acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Apr 2008 19:46:59 +0300 |
parents | ddae043e8e47 |
children | b0743dc9165d |
comparison
equal
deleted
inserted
replaced
656:e9257f006f41 | 657:acaba070cf49 |
---|---|
50 | 50 |
51 | 51 |
52 /* Create a title string based on given information and settings. | 52 /* Create a title string based on given information and settings. |
53 */ | 53 */ |
54 #define VPUTCH(MCH) \ | 54 #define VPUTCH(MCH) \ |
55 if (iIndex < XS_BUF_SIZE) tmpBuf[iIndex++] = MCH; | 55 if (index < XS_BUF_SIZE) tmpBuf[index++] = MCH; |
56 | 56 |
57 #define VPUTSTR(MSTR) { \ | 57 #define VPUTSTR(MSTR) { \ |
58 if (MSTR) { \ | 58 if (MSTR) { \ |
59 if ((iIndex + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ | 59 if ((index + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ |
60 strcpy(&tmpBuf[iIndex], MSTR); \ | 60 strcpy(&tmpBuf[index], MSTR); \ |
61 iIndex += strlen(MSTR); \ | 61 index += strlen(MSTR); \ |
62 } else \ | 62 } else \ |
63 iIndex = XS_BUF_SIZE; \ | 63 index = XS_BUF_SIZE; \ |
64 } \ | 64 } \ |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 gchar *xs_make_titlestring(t_xs_tuneinfo *p, gint subTune) | 68 gchar *xs_make_titlestring(xs_tuneinfo_t *p, gint subTune) |
69 { | 69 { |
70 gchar *tmpFilename, *tmpFilePath, *tmpFileExt, | 70 gchar *tmpFilename, *tmpFilePath, *tmpFileExt, |
71 *pcStr, *pcResult, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; | 71 *str, *result, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; |
72 t_xs_subtuneinfo *subInfo; | 72 xs_subtuneinfo_t *subInfo; |
73 gint iIndex; | 73 gint index; |
74 | 74 |
75 /* Get filename parts */ | 75 /* Get filename parts */ |
76 xs_path_split(p->sidFilename, &tmpFilename, | 76 xs_path_split(p->sidFilename, &tmpFilename, |
77 &tmpFilePath, &tmpFileExt); | 77 &tmpFilePath, &tmpFileExt); |
78 | 78 |
105 | 105 |
106 pTuple->year = 0; | 106 pTuple->year = 0; |
107 pTuple->genre = g_strdup("SID-tune"); | 107 pTuple->genre = g_strdup("SID-tune"); |
108 pTuple->comment = g_strdup(p->sidCopyright); | 108 pTuple->comment = g_strdup(p->sidCopyright); |
109 | 109 |
110 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); | 110 result = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); |
111 | 111 |
112 g_free(pTuple->track_name); | 112 g_free(pTuple->track_name); |
113 g_free(pTuple->album_name); | 113 g_free(pTuple->album_name); |
114 g_free(pTuple->performer); | 114 g_free(pTuple->performer); |
115 g_free(pTuple->date); | 115 g_free(pTuple->date); |
118 g_free(pTuple); | 118 g_free(pTuple); |
119 } else | 119 } else |
120 #endif | 120 #endif |
121 { | 121 { |
122 /* Create the string */ | 122 /* Create the string */ |
123 pcStr = xs_cfg.titleFormat; | 123 str = xs_cfg.titleFormat; |
124 iIndex = 0; | 124 index = 0; |
125 while (*pcStr && (iIndex < XS_BUF_SIZE)) { | 125 while (*str && (index < XS_BUF_SIZE)) { |
126 if (*pcStr == '%') { | 126 if (*str == '%') { |
127 pcStr++; | 127 str++; |
128 switch (*pcStr) { | 128 switch (*str) { |
129 case '%': | 129 case '%': |
130 VPUTCH('%'); | 130 VPUTCH('%'); |
131 break; | 131 break; |
132 case 'f': | 132 case 'f': |
133 VPUTSTR(tmpFilename); | 133 VPUTSTR(tmpFilename); |
200 g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); | 200 g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); |
201 VPUTSTR(tmpStr); | 201 VPUTSTR(tmpStr); |
202 break; | 202 break; |
203 } | 203 } |
204 } else | 204 } else |
205 VPUTCH(*pcStr); | 205 VPUTCH(*str); |
206 | 206 |
207 pcStr++; | 207 str++; |
208 } | 208 } |
209 | 209 |
210 tmpBuf[iIndex] = 0; | 210 tmpBuf[index] = 0; |
211 | 211 |
212 /* Make resulting string */ | 212 /* Make resulting string */ |
213 pcResult = g_strdup(tmpBuf); | 213 result = g_strdup(tmpBuf); |
214 } | 214 } |
215 | 215 |
216 /* Free temporary strings */ | 216 /* Free temporary strings */ |
217 g_free(tmpFilename); | 217 g_free(tmpFilename); |
218 g_free(tmpFilePath); | 218 g_free(tmpFilePath); |
219 | 219 |
220 return pcResult; | 220 return result; |
221 } | 221 } |