Mercurial > hg > xmms-sid
annotate src/xs_stil.c @ 626:248aa59cb6a3
XS_SIGNAL_CONNECT() macro added and used.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 03 Sep 2007 02:41:04 +0000 |
parents | d7389ea52113 |
children | dcd9d179e217 |
rev | line source |
---|---|
1 | 1 /* |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
1 | 3 |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
4 STIL-database handling functions |
1 | 5 |
324 | 6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
422 | 7 (C) Copyright 1999-2007 Tecnic Software productions (TNSP) |
1 | 8 |
9 This program is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
412
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
19 You should have received a copy of the GNU General Public License along |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
20 with this program; if not, write to the Free Software Foundation, Inc., |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
1 | 22 */ |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
23 #include "xs_stil.h" |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
24 #include "xs_support.h" |
1 | 25 #include <stdio.h> |
223
16e3b2446a73
On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents:
214
diff
changeset
|
26 #include <stdlib.h> |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
27 #include <ctype.h> |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
28 #include <stdarg.h> |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
29 |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
30 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
31 /* Database handling functions |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
32 */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
33 static gboolean xs_stildb_node_realloc(t_xs_stil_node *pNode, gint nsubTunes) |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
34 { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
35 if (!pNode) return FALSE; |
429 | 36 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
37 /* Re-allocate subTune structure if needed */ |
473 | 38 if (nsubTunes > pNode->nsubTunes) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
39 pNode->subTunes = |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
40 (t_xs_stil_subnode **) g_realloc(pNode->subTunes, |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
41 (nsubTunes + 1) * sizeof(t_xs_stil_subnode **)); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
42 |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
43 if (!pNode->subTunes) { |
424
faf12767a6f1
Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents:
422
diff
changeset
|
44 xs_error(_("SubTune pointer structure realloc failed.\n")); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
45 return FALSE; |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
46 } |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
47 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
48 /* Clear the newly allocated memory */ |
395
b571000e1f8c
Use xs_memset() instead of memset()
Matti Hamalainen <ccr@tnsp.org>
parents:
392
diff
changeset
|
49 xs_memset(&(pNode->subTunes[pNode->nsubTunes]), 0, |
429 | 50 (nsubTunes - pNode->nsubTunes + 1) * sizeof(t_xs_stil_subnode **)); |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
51 |
429 | 52 pNode->nsubTunes = nsubTunes; |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
53 } |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
54 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
55 /* Allocate memory for subTune */ |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
56 if (!pNode->subTunes[nsubTunes]) { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
57 pNode->subTunes[nsubTunes] = (t_xs_stil_subnode *) |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
58 g_malloc0(sizeof(t_xs_stil_subnode)); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
59 |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
60 if (!pNode->subTunes[nsubTunes]) { |
424
faf12767a6f1
Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents:
422
diff
changeset
|
61 xs_error(_("SubTune structure malloc failed!\n")); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
62 return FALSE; |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
63 } |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
64 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
65 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
66 return TRUE; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
67 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
68 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
69 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
70 static void xs_stildb_node_free(t_xs_stil_node *pNode) |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
71 { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
72 gint i; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
73 t_xs_stil_subnode *pSub; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
74 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
75 if (pNode) { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
76 /* Free subtune information */ |
429 | 77 for (i = 0; i <= pNode->nsubTunes; i++) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
78 pSub = pNode->subTunes[i]; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
79 if (pSub) { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
80 g_free(pSub->pName); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
81 g_free(pSub->pAuthor); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
82 g_free(pSub->pInfo); |
473 | 83 g_free(pSub->pTitle); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
84 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
85 g_free(pSub); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
86 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
87 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
88 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
89 g_free(pNode->subTunes); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
90 g_free(pNode->pcFilename); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
91 g_free(pNode); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
92 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
93 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
94 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
95 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
96 static t_xs_stil_node *xs_stildb_node_new(gchar *pcFilename) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
97 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
98 t_xs_stil_node *pResult; |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
99 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
100 /* Allocate memory for new node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
101 pResult = (t_xs_stil_node *) g_malloc0(sizeof(t_xs_stil_node)); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
102 if (!pResult) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
103 return NULL; |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
104 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
105 /* Allocate filename and initial space for one subtune */ |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
106 pResult->pcFilename = g_strdup(pcFilename); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
107 if (!pResult->pcFilename || !xs_stildb_node_realloc(pResult, 1)) { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
108 xs_stildb_node_free(pResult); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
109 return NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
110 } |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
111 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
112 return pResult; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
113 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
114 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
115 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
116 /* Insert given node to db linked list |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
117 */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
118 static void xs_stildb_node_insert(t_xs_stildb *db, t_xs_stil_node *pNode) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
119 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
120 assert(db); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
121 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
122 if (db->pNodes) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
123 /* The first node's pPrev points to last node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
124 LPREV = db->pNodes->pPrev; /* New node's prev = Previous last node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
125 db->pNodes->pPrev->pNext = pNode; /* Previous last node's next = New node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
126 db->pNodes->pPrev = pNode; /* New last node = New node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
127 LNEXT = NULL; /* But next is NULL! */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
128 } else { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
129 db->pNodes = pNode; /* First node ... */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
130 LPREV = pNode; /* ... it's also last */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
131 LNEXT = NULL; /* But next is NULL! */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
132 } |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
133 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
134 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
135 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
136 /* Read database (additively) to given db-structure |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
137 */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
138 #define XS_STILDB_MULTI \ |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
139 if (isMulti) { \ |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
140 isMulti = FALSE; \ |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
141 xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), "\n");\ |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
142 } |
240
f436e16fa6d9
Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
143 |
461
a1224c1f8670
STILdb handling glue moved to xmms-sid.c
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
144 static void XS_STILDB_ERR(gint lineNum, gchar *inLine, const char *fmt, ...) |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
145 { |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
146 va_list ap; |
240
f436e16fa6d9
Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
147 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
148 va_start(ap, fmt); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
149 xs_error(fmt, ap); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
150 va_end(ap); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
151 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
152 fprintf(stderr, "#%d: '%s'\n", lineNum, inLine); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
153 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
154 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
155 gint xs_stildb_read(t_xs_stildb *db, gchar *dbFilename) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
156 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
157 FILE *inFile; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
158 gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */ |
453 | 159 size_t lineNum; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
160 t_xs_stil_node *tmpNode; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
161 gboolean isError, isMulti; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
162 gint subEntry; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
163 gchar *tmpLine = inLine; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
164 assert(db); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
165 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
166 /* Try to open the file */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
167 if ((inFile = fopen(dbFilename, "ra")) == NULL) { |
424
faf12767a6f1
Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents:
422
diff
changeset
|
168 xs_error(_("Could not open STILDB '%s'\n"), |
faf12767a6f1
Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents:
422
diff
changeset
|
169 dbFilename); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
170 return -1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
171 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
172 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
173 /* Read and parse the data */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
174 lineNum = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
175 isError = FALSE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
176 isMulti = FALSE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
177 tmpNode = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
178 subEntry = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
179 |
509
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
180 while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { |
591 | 181 size_t linePos = 0, eolPos = 0; |
182 xs_findeol(inLine, &eolPos); | |
183 inLine[eolPos] = 0; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
184 lineNum++; |
622
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
185 |
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
186 tmpLine = XS_CS_STIL(inLine); |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
187 |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
188 switch (tmpLine[0]) { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
189 case '/': |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
190 /* Check if we are already parsing entry */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
191 isMulti = FALSE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
192 if (tmpNode) { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
193 XS_STILDB_ERR(lineNum, tmpLine, |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
194 "New entry found before end of current ('%s')!\n", |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
195 tmpNode->pcFilename); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
196 xs_stildb_node_free(tmpNode); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
197 } |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
198 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
199 /* A new node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
200 subEntry = 0; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
201 tmpNode = xs_stildb_node_new(tmpLine); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
202 if (!tmpNode) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
203 /* Allocation failed */ |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
204 XS_STILDB_ERR(lineNum, tmpLine, |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
205 "Could not allocate new STILdb-node!\n"); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
206 isError = TRUE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
207 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
208 break; |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
209 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
210 case '(': |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
211 /* A new sub-entry */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
212 isMulti = FALSE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
213 linePos++; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
214 if (tmpLine[linePos] == '#') { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
215 linePos++; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
216 if (isdigit(tmpLine[linePos])) { |
473 | 217 size_t savePos = linePos; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
218 xs_findnum(tmpLine, &linePos); |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
219 tmpLine[linePos] = 0; |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
220 subEntry = atol(&tmpLine[savePos]); |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
221 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
222 /* Sanity check */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
223 if (subEntry < 1) { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
224 XS_STILDB_ERR(lineNum, tmpLine, |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
225 "Number of subEntry (%i) for '%s' is invalid\n", |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
226 subEntry, tmpNode->pcFilename); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
227 subEntry = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
228 } |
473 | 229 } else { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
230 XS_STILDB_ERR(lineNum, tmpLine, |
473 | 231 "Syntax error, expected subEntry number.\n"); |
232 subEntry = 0; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
233 } |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
234 } else { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
235 XS_STILDB_ERR(lineNum, tmpLine, |
473 | 236 "Syntax error, expected '#' before subEntry number.\n"); |
237 subEntry = 0; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
238 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
239 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
240 break; |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
241 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
242 case 0: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
243 case '#': |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
244 case '\n': |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
245 case '\r': |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
246 /* End of entry/field */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
247 isMulti = FALSE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
248 if (tmpNode) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
249 /* Insert to database */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
250 xs_stildb_node_insert(db, tmpNode); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
251 tmpNode = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
252 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
253 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
254 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
255 default: |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
256 /* Check if we are parsing an entry */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
257 if (!tmpNode) { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
258 XS_STILDB_ERR(lineNum, tmpLine, |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
259 "Entry data encountered outside of entry or syntax error!\n"); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
260 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
261 } |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
262 |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
263 if (!xs_stildb_node_realloc(tmpNode, subEntry)) { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
264 XS_STILDB_ERR(lineNum, tmpLine, |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
265 "Could not (re)allocate memory for subEntries!\n"); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
266 isError = TRUE; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
267 break; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
268 } |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
269 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
270 /* Some other type */ |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
271 if (strncmp(tmpLine, " NAME:", 8) == 0) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
272 XS_STILDB_MULTI; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
273 g_free(tmpNode->subTunes[subEntry]->pName); |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
274 tmpNode->subTunes[subEntry]->pName = g_strdup(&tmpLine[9]); |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
275 } else if (strncmp(tmpLine, " TITLE:", 8) == 0) { |
473 | 276 XS_STILDB_MULTI; |
277 g_free(tmpNode->subTunes[subEntry]->pTitle); | |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
278 tmpNode->subTunes[subEntry]->pTitle = g_strdup(&tmpLine[9]); |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
279 } else if (strncmp(tmpLine, " AUTHOR:", 8) == 0) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
280 XS_STILDB_MULTI; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
281 g_free(tmpNode->subTunes[subEntry]->pAuthor); |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
282 tmpNode->subTunes[subEntry]->pAuthor = g_strdup(&tmpLine[9]); |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
283 } else if (strncmp(tmpLine, " ARTIST:", 8) == 0) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
284 XS_STILDB_MULTI; |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
395
diff
changeset
|
285 isMulti = TRUE; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
286 xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &tmpLine[1]); |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
287 } else if (strncmp(tmpLine, "COMMENT:", 8) == 0) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
288 XS_STILDB_MULTI; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
289 isMulti = TRUE; |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
290 xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), tmpLine); |
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
291 } else if (strncmp(tmpLine, " ", 8) == 0) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
292 if (isMulti) { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
293 xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &tmpLine[8]); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
294 } else { |
550
4333288a0168
Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents:
509
diff
changeset
|
295 XS_STILDB_ERR(lineNum, tmpLine, |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
296 "Entry continuation found when isMulti == FALSE.\n"); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
297 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
298 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
299 break; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
300 } |
622
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
301 |
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
302 XS_CS_FREE(tmpLine); |
240
f436e16fa6d9
Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
303 |
453 | 304 } /* while */ |
240
f436e16fa6d9
Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
305 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
306 /* Check if there is one remaining node */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
307 if (tmpNode) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
308 xs_stildb_node_insert(db, tmpNode); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
309 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
310 /* Close the file */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
311 fclose(inFile); |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
312 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
313 return 0; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
314 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
315 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
316 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
317 /* Compare two nodes |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
318 */ |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
319 static gint xs_stildb_cmp(const void *pNode1, const void *pNode2) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
320 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
321 /* We assume here that we never ever get NULL-pointers or similar */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
322 return strcmp( |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
323 (*(t_xs_stil_node **) pNode1)->pcFilename, |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
324 (*(t_xs_stil_node **) pNode2)->pcFilename); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
325 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
326 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
327 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
328 /* (Re)create index |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
329 */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
330 gint xs_stildb_index(t_xs_stildb *db) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
331 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
332 t_xs_stil_node *pCurr; |
509
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
333 size_t i; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
334 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
335 /* Free old index */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
336 if (db->ppIndex) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
337 g_free(db->ppIndex); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
338 db->ppIndex = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
339 } |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
340 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
341 /* Get size of db */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
342 pCurr = db->pNodes; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
343 db->n = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
344 while (pCurr) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
345 db->n++; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
346 pCurr = pCurr->pNext; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
347 } |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
348 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
349 /* Check number of nodes */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
350 if (db->n > 0) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
351 /* Allocate memory for index-table */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
352 db->ppIndex = (t_xs_stil_node **) g_malloc(sizeof(t_xs_stil_node *) * db->n); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
353 if (!db->ppIndex) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
354 return -1; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
355 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
356 /* Get node-pointers to table */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
357 i = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
358 pCurr = db->pNodes; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
359 while (pCurr && (i < db->n)) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
360 db->ppIndex[i++] = pCurr; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
361 pCurr = pCurr->pNext; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
362 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
363 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
364 /* Sort the indexes */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
365 qsort(db->ppIndex, db->n, sizeof(t_xs_stil_node *), xs_stildb_cmp); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
366 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
367 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
368 return 0; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
369 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
370 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
371 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
372 /* Free a given STIL database |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
373 */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
374 void xs_stildb_free(t_xs_stildb *db) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
375 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
376 t_xs_stil_node *pCurr, *pNext; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
377 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
378 if (!db) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
379 return; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
380 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
381 /* Free the memory allocated for nodes */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
382 pCurr = db->pNodes; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
383 while (pCurr) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
384 pNext = pCurr->pNext; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
385 xs_stildb_node_free(pCurr); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
386 pCurr = pNext; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
387 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
388 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
389 db->pNodes = NULL; |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
390 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
391 /* Free memory allocated for index */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
392 if (db->ppIndex) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
393 g_free(db->ppIndex); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
394 db->ppIndex = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
395 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
396 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
397 /* Free structure */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
398 db->n = 0; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
399 g_free(db); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
400 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
401 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
402 |
227
92bad4c7b998
Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents:
224
diff
changeset
|
403 /* Get STIL information node from database |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
404 */ |
461
a1224c1f8670
STILdb handling glue moved to xmms-sid.c
Matti Hamalainen <ccr@tnsp.org>
parents:
453
diff
changeset
|
405 t_xs_stil_node *xs_stildb_get_node(t_xs_stildb *db, gchar *pcFilename) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
406 { |
509
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
407 t_xs_stil_node keyItem, *key, **item; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
408 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
409 /* Check the database pointers */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
410 if (!db || !db->pNodes || !db->ppIndex) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
330
diff
changeset
|
411 return NULL; |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
412 |
509
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
413 /* Look-up index using binary search */ |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
414 keyItem.pcFilename = pcFilename; |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
415 key = &keyItem; |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
416 item = bsearch(&key, db->ppIndex, db->n, sizeof(t_xs_stil_node *), xs_stildb_cmp); |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
417 if (item) |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
418 return *item; |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
419 else |
81756f412b43
Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents:
473
diff
changeset
|
420 return NULL; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
421 } |