comparison 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
comparison
equal deleted inserted replaced
75:653c9b0d1320 76:741291e14080
1 /*
2 * Create the SID-tune description string from the tune's information
3 * formatted by the user-specified format-string.
4 */
5 gchar *xs_make_filetitle(gchar *pcFileName, sidTuneInfo *pfInfo, gint iSubTune)
6 {
7 gint j, iLength;
8 gchar *pcStr, *pcResult;
9 #ifdef HAVE_XMMSEXTRA
10 TitleInput *ptInput;
11 #endif
12
13 /* FIXME FIXME: get STIL-information */
14
15
16 /* Check the info strings */
17 if (pfInfo->numberOfInfoStrings < 3)
18 {
19 if (pfInfo->numberOfInfoStrings < 1)
20 return 0;
21
22 return g_strdup(pfInfo->infoString[0]);
23 }
24
25 #ifdef HAVE_XMMSEXTRA
26 /* Check if the titles are overridden or not */
27 if (!xs_cfg.titleOverride)
28 {
29 /* Use generic XMMS titles */
30 /* XMMS_NEW_TITLEINPUT(ptInput);
31 * We duplicate and add typecast to the code here due to XMMS's braindead headers
32 */
33 ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput));
34 ptInput->__size = XMMS_TITLEINPUT_SIZE;
35 ptInput->__version = XMMS_TITLEINPUT_VERSION;
36
37 /* Create the input fields */
38 ptInput->file_name = pfInfo->dataFileName;
39 ptInput->file_ext = g_strdup("sid");
40 ptInput->file_path = pfInfo->path;
41
42 ptInput->track_name = pfInfo->infoString[0];
43 ptInput->track_number = iSubTune;
44 ptInput->album_name = NULL;
45 ptInput->performer = pfInfo->infoString[1];
46 ptInput->date = g_strdup((pfInfo->sidModel == SIDTUNE_SIDMODEL_6581) ? "6581" : "8580");
47
48 ptInput->year = 0;
49 ptInput->genre = g_strdup("SID-tune");
50 ptInput->comment = pfInfo->infoString[2];
51
52 /* Create the string */
53 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput);
54
55 /* Dispose all allocated memory */
56 g_free(ptInput->file_ext);
57 g_free(ptInput->date);
58 g_free(ptInput->genre);
59 g_free(ptInput);
60 }
61 else
62 #endif
63 {
64 /* Estimate the length of the string */
65 pcStr = xs_cfg.titleFormat;
66 iLength = 0;
67 while (*pcStr)
68 {
69 if (*pcStr == '%')
70 {
71 switch (*(++pcStr)) {
72 case '1': iLength += strlen(pfInfo->infoString[1]); break;
73 case '2': iLength += strlen(pfInfo->infoString[0]); break;
74 case '3': iLength += strlen(pfInfo->infoString[2]); break;
75 case '4': iLength += strlen(pfInfo->formatString); break;
76 case '%': iLength++;
77 }
78 } else
79 iLength++;
80
81 pcStr++;
82 }
83
84 /* Allocate memory */
85 pcResult = (gchar *) g_malloc(iLength + 2);
86 if (pcResult == NULL)
87 return g_strdup(pfInfo->infoString[0]);
88
89 /* Create the string */
90 pcStr = xs_cfg.titleFormat;
91 j = 0;
92 while (*pcStr)
93 {
94 if (*pcStr == '%')
95 {
96 switch (*(++pcStr)) {
97 case '1': xs_strpcat(pcResult, &j, pfInfo->infoString[1]); break;
98 case '2': xs_strpcat(pcResult, &j, pfInfo->infoString[0]); break;
99 case '3': xs_strpcat(pcResult, &j, pfInfo->infoString[2]); break;
100 case '4': xs_strpcat(pcResult, &j, pfInfo->formatString); break;
101 case '%': pcResult[j++] = '%'; break;
102 }
103 } else
104 pcResult[j++] = *pcStr;
105
106 pcStr++;
107 }
108
109 pcResult[j] = 0;
110 }
111
112 return pcResult;
113 }
114