annotate src/xs_stil.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 a8ceae9ae8e3
children b0743dc9165d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
324
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
422
d2e6682d3ef8 Copyright year update
Matti Hamalainen <ccr@tnsp.org>
parents: 412
diff changeset
7 (C) Copyright 1999-2007 Tecnic Software productions (TNSP)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
33 static gboolean xs_stildb_node_realloc(stil_node_t *node, gint nsubTunes)
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
34 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
35 if (!node) return FALSE;
429
a991d1fe7e94 Bugfixes
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
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 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
38 if (nsubTunes > node->nsubTunes) {
635
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
39 gint clearIndex, clearLength;
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
40
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
41 node->subTunes =
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
42 (stil_subnode_t **) g_realloc(node->subTunes,
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
43 (nsubTunes + 1) * sizeof(stil_subnode_t **));
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
44
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
45 if (!node->subTunes) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
46 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
47 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
48 }
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
49
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
50 /* Clear the newly allocated memory */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
51 if (node->nsubTunes == 0) {
635
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
52 clearIndex = 0;
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
53 clearLength = nsubTunes + 1;
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
54 } else {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
55 clearIndex = node->nsubTunes + 1;
635
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
56 clearLength = (nsubTunes - clearIndex + 1);
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
57 }
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
58 memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(stil_subnode_t **));
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
59
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
60 node->nsubTunes = nsubTunes;
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
61 }
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
62
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
63 /* Allocate memory for subTune */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
64 if (!node->subTunes[nsubTunes]) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
65 node->subTunes[nsubTunes] = (stil_subnode_t *)
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
66 g_malloc0(sizeof(stil_subnode_t));
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
67
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
68 if (!node->subTunes[nsubTunes]) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
69 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
70 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
71 }
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
72 }
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
73
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
74 return TRUE;
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
75 }
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
76
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
77
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
78 static void xs_stildb_node_free(stil_node_t *node)
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
79 {
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
80 gint i;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
81 stil_subnode_t *subnode;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
82
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
83 if (!node) return;
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
84
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
85 /* Free subtune information */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
86 for (i = 0; i <= node->nsubTunes; i++) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
87 subnode = node->subTunes[i];
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
88 if (subnode) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
89 g_free(subnode->name);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
90 g_free(subnode->author);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
91 g_free(subnode->info);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
92 g_free(subnode->title);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
93 g_free(subnode);
392
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 }
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
96 g_free(node->subTunes);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
97 g_free(node->filename);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
98 g_free(node);
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
99 }
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
100
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
101
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
102 static stil_node_t *xs_stildb_node_new(gchar *filename)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
103 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
104 stil_node_t *result;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
105
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
106 /* Allocate memory for new node */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
107 result = (stil_node_t *) g_malloc0(sizeof(stil_node_t));
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
108 if (!result)
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
109 return NULL;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
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 /* Allocate filename and initial space for one subtune */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
112 result->filename = g_strdup(filename);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
113 if (!result->filename || !xs_stildb_node_realloc(result, 1)) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
114 xs_stildb_node_free(result);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
115 return NULL;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
116 }
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
117
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
118 return result;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
119 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
120
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
121
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
122 /* 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
123 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
124 static void xs_stildb_node_insert(xs_stildb_t *db, stil_node_t *node)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
125 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
126 assert(db != NULL);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
127
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
128 if (db->nodes) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
129 /* The first node's pPrev points to last node */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
130 LPREV = db->nodes->prev; /* New node's prev = Previous last node */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
131 db->nodes->prev->next = node; /* Previous last node's next = New node */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
132 db->nodes->prev = node; /* New last node = New node */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
133 LNEXT = NULL; /* But next is NULL! */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
134 } else {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
135 db->nodes = node; /* First node ... */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
136 LPREV = node; /* ... it's also last */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
137 LNEXT = NULL; /* But next is NULL! */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
138 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
139 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
140
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
141
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
142 /* 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
143 */
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
144 #define XS_STILDB_MULTI \
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
145 if (isMulti) { \
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
146 isMulti = FALSE; \
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
147 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), "\n");\
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
148 }
240
f436e16fa6d9 Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
149
461
a1224c1f8670 STILdb handling glue moved to xmms-sid.c
Matti Hamalainen <ccr@tnsp.org>
parents: 453
diff changeset
150 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
151 {
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
152 va_list ap;
240
f436e16fa6d9 Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
153
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
154 va_start(ap, fmt);
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
155 xs_error(fmt, ap);
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
156 va_end(ap);
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
157
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
158 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
159 }
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
160
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
161 gint xs_stildb_read(xs_stildb_t *db, gchar *dbFilename)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
162 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
163 FILE *inFile;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
164 gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */
453
60eedde4c44f Cleanups
Matti Hamalainen <ccr@tnsp.org>
parents: 429
diff changeset
165 size_t lineNum;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
166 stil_node_t *tmnode;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
167 gboolean isError, isMulti;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
168 gint subEntry;
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
169 gchar *tmpLine = inLine;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
170 assert(db != NULL);
359
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 /* Try to open the file */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
173 if ((inFile = fopen(dbFilename, "ra")) == NULL) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
174 xs_error("Could not open STILDB '%s'\n", dbFilename);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
175 return -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
176 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
177
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
178 /* Read and parse the data */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
179 lineNum = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
180 isError = FALSE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
181 isMulti = FALSE;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
182 tmnode = NULL;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
183 subEntry = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
184
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
185 while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) {
591
acda6c2f10c8 Revert.
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
186 size_t linePos = 0, eolPos = 0;
acda6c2f10c8 Revert.
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
187 xs_findeol(inLine, &eolPos);
acda6c2f10c8 Revert.
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
188 inLine[eolPos] = 0;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
189 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
190
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
191 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
192
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
193 switch (tmpLine[0]) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
194 case '/':
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
195 /* Check if we are already parsing entry */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
196 isMulti = FALSE;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
197 if (tmnode) {
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
198 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
199 "New entry found before end of current ('%s')!\n",
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
200 tmnode->filename);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
201 xs_stildb_node_free(tmnode);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
202 }
109
578b71b62eeb Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
203
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
204 /* A new node */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
205 subEntry = 0;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
206 tmnode = xs_stildb_node_new(tmpLine);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
207 if (!tmnode) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
208 /* Allocation failed */
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
209 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
210 "Could not allocate new STILdb-node!\n");
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
211 isError = TRUE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
212 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
213 break;
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
214
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
215 case '(':
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
216 /* A new sub-entry */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
217 isMulti = FALSE;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
218 linePos++;
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
219 if (tmpLine[linePos] == '#') {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
220 linePos++;
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
221 if (isdigit(tmpLine[linePos])) {
473
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
diff changeset
222 size_t savePos = linePos;
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
223 xs_findnum(tmpLine, &linePos);
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
224 tmpLine[linePos] = 0;
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
225 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
226
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
227 /* Sanity check */
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
228 if (subEntry < 1) {
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
229 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
230 "Number of subEntry (%i) for '%s' is invalid\n",
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
231 subEntry, tmnode->filename);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
232 subEntry = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
233 }
473
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
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
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
diff changeset
236 "Syntax error, expected subEntry number.\n");
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
diff changeset
237 subEntry = 0;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
238 }
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
239 } else {
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
240 XS_STILDB_ERR(lineNum, tmpLine,
473
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
diff changeset
241 "Syntax error, expected '#' before subEntry number.\n");
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
diff changeset
242 subEntry = 0;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
243 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
244
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
245 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
246
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
247 case 0:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
248 case '#':
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
249 case '\n':
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
250 case '\r':
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
251 /* End of entry/field */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
252 isMulti = FALSE;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
253 if (tmnode) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
254 /* Insert to database */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
255 xs_stildb_node_insert(db, tmnode);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
256 tmnode = NULL;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
257 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
258 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
259
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
260 default:
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
261 /* Check if we are parsing an entry */
648
a8ceae9ae8e3 Parse certain STIL fields bit differently.
Matti Hamalainen <ccr@tnsp.org>
parents: 635
diff changeset
262 xs_findnext(tmpLine, &linePos);
a8ceae9ae8e3 Parse certain STIL fields bit differently.
Matti Hamalainen <ccr@tnsp.org>
parents: 635
diff changeset
263
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
264 if (!tmnode) {
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
265 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
266 "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
267 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
268 }
117
453ac1293f6a Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents: 110
diff changeset
269
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
270 if (!xs_stildb_node_realloc(tmnode, subEntry)) {
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
271 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
272 "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
273 isError = TRUE;
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
274 break;
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
275 }
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
276
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
277 /* Some other type */
635
dcd9d179e217 The reallocation function was buggy and subtune entries were not being stored at all, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
278 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
279 XS_STILDB_MULTI;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
280 g_free(tmnode->subTunes[subEntry]->name);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
281 tmnode->subTunes[subEntry]->name = g_strdup(&tmpLine[9]);
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
282 } else if (strncmp(tmpLine, " TITLE:", 8) == 0) {
473
f1a997715ef5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 461
diff changeset
283 XS_STILDB_MULTI;
648
a8ceae9ae8e3 Parse certain STIL fields bit differently.
Matti Hamalainen <ccr@tnsp.org>
parents: 635
diff changeset
284 isMulti = TRUE;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
285 if (!tmnode->subTunes[subEntry]->title)
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
286 tmnode->subTunes[subEntry]->title = g_strdup(&tmpLine[9]);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
287 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[2]);
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
288 } 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
289 XS_STILDB_MULTI;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
290 g_free(tmnode->subTunes[subEntry]->author);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
291 tmnode->subTunes[subEntry]->author = g_strdup(&tmpLine[9]);
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
292 } 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
293 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
294 isMulti = TRUE;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
295 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[1]);
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
296 } 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
297 XS_STILDB_MULTI;
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
298 isMulti = TRUE;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
299 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), tmpLine);
648
a8ceae9ae8e3 Parse certain STIL fields bit differently.
Matti Hamalainen <ccr@tnsp.org>
parents: 635
diff changeset
300 } else {
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
301 if (isMulti) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
302 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), " ");
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
303 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[linePos]);
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
304 } else {
550
4333288a0168 Some changes to accomodate for Audacious differences.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
305 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
306 "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
307 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
308 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
309 break;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
310 }
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
311
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
312 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
313
453
60eedde4c44f Cleanups
Matti Hamalainen <ccr@tnsp.org>
parents: 429
diff changeset
314 } /* while */
240
f436e16fa6d9 Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
315
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
316 /* Check if there is one remaining node */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
317 if (tmnode)
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
318 xs_stildb_node_insert(db, tmnode);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
319
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
320 /* Close the file */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
321 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
322
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
323 return 0;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
324 }
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
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
327 /* Compare two nodes
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
328 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
329 static gint xs_stildb_cmp(const void *node1, const void *node2)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
330 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
331 /* 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
332 return strcmp(
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
333 (*(stil_node_t **) node1)->filename,
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
334 (*(stil_node_t **) node2)->filename);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
335 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
336
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
337
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
338 /* (Re)create index
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
339 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
340 gint xs_stildb_index(xs_stildb_t *db)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
341 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
342 stil_node_t *curr;
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
343 size_t i;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
344
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
345 /* Free old index */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
346 if (db->pindex) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
347 g_free(db->pindex);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
348 db->pindex = NULL;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
349 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
350
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
351 /* Get size of db */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
352 curr = db->nodes;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
353 db->n = 0;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
354 while (curr) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
355 db->n++;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
356 curr = curr->next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
357 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
358
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
359 /* Check number of nodes */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
360 if (db->n > 0) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
361 /* Allocate memory for index-table */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
362 db->pindex = (stil_node_t **) g_malloc(sizeof(stil_node_t *) * db->n);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
363 if (!db->pindex)
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
364 return -1;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
365
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
366 /* Get node-pointers to table */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
367 i = 0;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
368 curr = db->nodes;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
369 while (curr && (i < db->n)) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
370 db->pindex[i++] = curr;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
371 curr = curr->next;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
372 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
373
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
374 /* Sort the indexes */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
375 qsort(db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
376 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
377
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
378 return 0;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
379 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
380
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
381
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
382 /* Free a given STIL database
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
383 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
384 void xs_stildb_free(xs_stildb_t *db)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
385 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
386 stil_node_t *curr, *next;
359
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 if (!db)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
389 return;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
390
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
391 /* Free the memory allocated for nodes */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
392 curr = db->nodes;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
393 while (curr) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
394 next = curr->next;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
395 xs_stildb_node_free(curr);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
396 curr = next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
397 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
398
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
399 db->nodes = NULL;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
400
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
401 /* Free memory allocated for index */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
402 if (db->pindex) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
403 g_free(db->pindex);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
404 db->pindex = NULL;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
405 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
406
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
407 /* Free structure */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
408 db->n = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
409 g_free(db);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
410 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
411
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
412
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
413 /* Get STIL information node from database
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
414 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
415 stil_node_t *xs_stildb_get_node(xs_stildb_t *db, gchar *filename)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
416 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
417 stil_node_t keyItem, *key, **item;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
418
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
419 /* Check the database pointers */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
420 if (!db || !db->nodes || !db->pindex)
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
421 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
422
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
423 /* Look-up index using binary search */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
424 keyItem.filename = filename;
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
425 key = &keyItem;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 648
diff changeset
426 item = bsearch(&key, db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp);
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
427 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
428 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
429 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
430 return NULL;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
431 }