annotate src/xs_stil.c @ 980:1cd7dead1b56

Add dedication to Taneli, as well. :(
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 28 Mar 2013 15:09:47 +0200
parents f8e1de328ac1
children
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>
723
9321ffa2ea7e Update copyright years.
Matti Hamalainen <ccr@tnsp.org>
parents: 682
diff changeset
7 (C) Copyright 1999-2009 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"
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
25
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
26
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
27 /* Database handling functions
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
28 */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
29 static gboolean xs_stildb_node_realloc(XSSTILNode *node, gint nsubTunes)
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
30 {
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
31 if (!node) return FALSE;
429
a991d1fe7e94 Bugfixes
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
32
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
33 /* Re-allocate subTune structure if needed */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
34 if (nsubTunes > node->nsubTunes) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
35 gint clearIndex, clearLength;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
36
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
37 node->subTunes =
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
38 (XSSTILSubNode **) g_realloc(node->subTunes,
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
39 (nsubTunes + 1) * sizeof(XSSTILSubNode **));
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
40
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
41 if (!node->subTunes) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
42 xs_error("SubTune pointer structure realloc failed.\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
43 return FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
44 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
45
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
46 /* Clear the newly allocated memory */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
47 if (node->nsubTunes == 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
48 clearIndex = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
49 clearLength = nsubTunes + 1;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
50 } else {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
51 clearIndex = node->nsubTunes + 1;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
52 clearLength = (nsubTunes - clearIndex + 1);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
53 }
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
54 memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(XSSTILSubNode **));
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
55
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
56 node->nsubTunes = nsubTunes;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
57 }
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 395
diff changeset
58
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
59 /* Allocate memory for subTune */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
60 if (!node->subTunes[nsubTunes]) {
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
61 node->subTunes[nsubTunes] = (XSSTILSubNode *)
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
62 g_malloc0(sizeof(XSSTILSubNode));
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
63
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
64 if (!node->subTunes[nsubTunes]) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
65 xs_error("SubTune structure malloc failed!\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
66 return FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
67 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
68 }
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
69
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
70 return TRUE;
392
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
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
73
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
74 static void xs_stildb_node_free(XSSTILNode *node)
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
75 {
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
76 gint i;
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
77 XSSTILSubNode *subnode;
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
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
79 if (!node) return;
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
80
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
81 /* Free subtune information */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
82 for (i = 0; i <= node->nsubTunes; i++) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
83 subnode = node->subTunes[i];
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
84 if (subnode) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
85 g_free(subnode->name);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
86 g_free(subnode->author);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
87 g_free(subnode->info);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
88 g_free(subnode->title);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
89 g_free(subnode);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
90 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
91 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
92 g_free(node->subTunes);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
93 g_free(node->filename);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
94 g_free(node);
392
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
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
97
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
98 static XSSTILNode *xs_stildb_node_new(gchar *filename)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
99 {
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
100 XSSTILNode *result;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
101
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
102 /* Allocate memory for new node */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
103 result = (XSSTILNode *) g_malloc0(sizeof(XSSTILNode));
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
104 if (!result)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
105 return NULL;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
106
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
107 /* Allocate filename and initial space for one subtune */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
108 result->filename = g_strdup(filename);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
109 if (!result->filename || !xs_stildb_node_realloc(result, 1)) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
110 xs_stildb_node_free(result);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
111 return NULL;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
112 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
113
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
114 return result;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
115 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
116
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
117
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
118 /* 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
119 */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
120 static void xs_stildb_node_insert(XSSTILDB *db, XSSTILNode *node)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
121 {
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
122 assert(db != NULL);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
123
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
124 if (db->nodes) {
783
37ab2fba30c8 More cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 782
diff changeset
125 node->prev = db->nodes->prev;
782
64352e85113e Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 751
diff changeset
126 db->nodes->prev->next = node;
64352e85113e Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 751
diff changeset
127 db->nodes->prev = node;
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
128 } else {
782
64352e85113e Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 751
diff changeset
129 db->nodes = node;
783
37ab2fba30c8 More cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 782
diff changeset
130 node->prev = node;
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
131 }
783
37ab2fba30c8 More cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 782
diff changeset
132 node->next = NULL;
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 */
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
138 #define XS_STILDB_MULTI \
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
139 if (isMulti) { \
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
140 isMulti = FALSE; \
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
141 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), "\n");\
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
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 {
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
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
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
148 va_start(ap, fmt);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
149 xs_error(fmt, ap);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
150 va_end(ap);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
151
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
152 fprintf(stderr, "#%d: '%s'\n", lineNum, inLine);
392
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
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
155 gint xs_stildb_read(XSSTILDB *db, gchar *dbFilename)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
156 {
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
157 FILE *inFile;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
158 gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
159 size_t lineNum;
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
160 XSSTILNode *tmnode;
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
161 gboolean isError, isMulti;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
162 gint subEntry;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
163 gchar *tmpLine = inLine;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
164 assert(db != NULL);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
165
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
166 /* Try to open the file */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
167 if ((inFile = fopen(dbFilename, "ra")) == NULL) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
168 xs_error("Could not open STILDB '%s'\n", dbFilename);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
169 return -1;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
170 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
171
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
172 /* Read and parse the data */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
173 lineNum = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
174 isError = FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
175 isMulti = FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
176 tmnode = NULL;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
177 subEntry = 0;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
178
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
179 while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
180 size_t linePos = 0, eolPos = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
181 xs_findeol(inLine, &eolPos);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
182 inLine[eolPos] = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
183 lineNum++;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
184
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
185 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
186
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
187 switch (tmpLine[0]) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
188 case '/':
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
189 /* Check if we are already parsing entry */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
190 isMulti = FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
191 if (tmnode) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
192 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
193 "New entry found before end of current ('%s')!\n",
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
194 tmnode->filename);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
195 xs_stildb_node_free(tmnode);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
196 }
109
578b71b62eeb Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
197
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
198 /* A new node */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
199 subEntry = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
200 tmnode = xs_stildb_node_new(tmpLine);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
201 if (!tmnode) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
202 /* Allocation failed */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
203 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
204 "Could not allocate new STILdb-node!\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
205 isError = TRUE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
206 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
207 break;
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
208
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
209 case '(':
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
210 /* A new sub-entry */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
211 isMulti = FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
212 linePos++;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
213 if (tmpLine[linePos] == '#') {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
214 linePos++;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
215 if (isdigit(tmpLine[linePos])) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
216 size_t savePos = linePos;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
217 xs_findnum(tmpLine, &linePos);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
218 tmpLine[linePos] = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
219 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
220
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
221 /* Sanity check */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
222 if (subEntry < 1) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
223 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
224 "Number of subEntry (%i) for '%s' is invalid\n",
682
81b9a81b99f2 Fixed a rare null-pointer dereference, discovered via zzuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 660
diff changeset
225 subEntry, tmnode ? tmnode->filename : "");
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
226 subEntry = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
227 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
228 } else {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
229 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
230 "Syntax error, expected subEntry number.\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
231 subEntry = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
232 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
233 } else {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
234 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
235 "Syntax error, expected '#' before subEntry number.\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
236 subEntry = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
237 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
238
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
239 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
240
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
241 case 0:
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
242 case '#':
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
243 case '\n':
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
244 case '\r':
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
245 /* End of entry/field */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
246 isMulti = FALSE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
247 if (tmnode) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
248 /* Insert to database */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
249 xs_stildb_node_insert(db, tmnode);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
250 tmnode = NULL;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
251 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
252 break;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
253
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
254 default:
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
255 /* Check if we are parsing an entry */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
256 xs_findnext(tmpLine, &linePos);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
257
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
258 if (!tmnode) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
259 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
260 "Entry data encountered outside of entry or syntax error!\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
261 break;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
262 }
117
453ac1293f6a Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents: 110
diff changeset
263
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
264 if (!xs_stildb_node_realloc(tmnode, subEntry)) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
265 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
266 "Could not (re)allocate memory for subEntries!\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
267 isError = TRUE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
268 break;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
269 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
270
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
271 /* Some other type */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
272 if (strncmp(tmpLine, " NAME:", 8) == 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
273 XS_STILDB_MULTI;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
274 g_free(tmnode->subTunes[subEntry]->name);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
275 tmnode->subTunes[subEntry]->name = g_strdup(&tmpLine[9]);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
276 } else if (strncmp(tmpLine, " TITLE:", 8) == 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
277 XS_STILDB_MULTI;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
278 isMulti = TRUE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
279 if (!tmnode->subTunes[subEntry]->title)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
280 tmnode->subTunes[subEntry]->title = g_strdup(&tmpLine[9]);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
281 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[2]);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
282 } else if (strncmp(tmpLine, " AUTHOR:", 8) == 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
283 XS_STILDB_MULTI;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
284 g_free(tmnode->subTunes[subEntry]->author);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
285 tmnode->subTunes[subEntry]->author = g_strdup(&tmpLine[9]);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
286 } else if (strncmp(tmpLine, " ARTIST:", 8) == 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
287 XS_STILDB_MULTI;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
288 isMulti = TRUE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
289 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[1]);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
290 } else if (strncmp(tmpLine, "COMMENT:", 8) == 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
291 XS_STILDB_MULTI;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
292 isMulti = TRUE;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
293 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), tmpLine);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
294 } else {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
295 if (isMulti) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
296 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), " ");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
297 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[linePos]);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
298 } else {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
299 XS_STILDB_ERR(lineNum, tmpLine,
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
300 "Entry continuation found when isMulti == FALSE.\n");
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
301 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
302 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
303 break;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
304 }
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
305
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
306 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
307
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
308 } /* while */
240
f436e16fa6d9 Fixed cosmetic bug in handling of multi-line fields (COMMENT).
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
309
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
310 /* Check if there is one remaining node */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
311 if (tmnode)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
312 xs_stildb_node_insert(db, tmnode);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
313
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
314 /* Close the file */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
315 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
316
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
317 return 0;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
318 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
319
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
320
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
321 /* Compare two nodes
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
322 */
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
323 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
324 {
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
325 /* We assume here that we never ever get NULL-pointers or similar */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
326 return strcmp(
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
327 (*(XSSTILNode **) node1)->filename,
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
328 (*(XSSTILNode **) node2)->filename);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
329 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
330
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
331
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
332 /* (Re)create index
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
333 */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
334 gint xs_stildb_index(XSSTILDB *db)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
335 {
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
336 XSSTILNode *curr;
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
337 size_t i;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
338
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
339 /* Free old index */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
340 if (db->pindex) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
341 g_free(db->pindex);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
342 db->pindex = NULL;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
343 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
344
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
345 /* Get size of db */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
346 curr = db->nodes;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
347 db->n = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
348 while (curr) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
349 db->n++;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
350 curr = curr->next;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
351 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
352
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
353 /* Check number of nodes */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
354 if (db->n > 0) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
355 /* Allocate memory for index-table */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
356 db->pindex = (XSSTILNode **) g_malloc(sizeof(XSSTILNode *) * db->n);
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
357 if (!db->pindex)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
358 return -1;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
359
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
360 /* Get node-pointers to table */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
361 i = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
362 curr = db->nodes;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
363 while (curr && (i < db->n)) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
364 db->pindex[i++] = curr;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
365 curr = curr->next;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
366 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
367
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
368 /* Sort the indexes */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
369 qsort(db->pindex, db->n, sizeof(XSSTILNode *), xs_stildb_cmp);
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
370 }
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
371
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
372 return 0;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
373 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
374
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
375
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
376 /* Free a given STIL database
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
377 */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
378 void xs_stildb_free(XSSTILDB *db)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
379 {
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
380 XSSTILNode *curr, *next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
381
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
382 if (!db)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
383 return;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
384
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
385 /* Free the memory allocated for nodes */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
386 curr = db->nodes;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
387 while (curr) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
388 next = curr->next;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
389 xs_stildb_node_free(curr);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
390 curr = next;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
391 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
392
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
393 db->nodes = NULL;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
394
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
395 /* Free memory allocated for index */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
396 if (db->pindex) {
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
397 g_free(db->pindex);
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
398 db->pindex = NULL;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
399 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 330
diff changeset
400
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
401 /* Free structure */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
402 db->n = 0;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
403 g_free(db);
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
404 }
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
405
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
406
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
407 /* Get STIL information node from database
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
408 */
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
409 XSSTILNode *xs_stildb_get_node(XSSTILDB *db, gchar *filename)
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
410 {
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
411 XSSTILNode keyItem, *key, **item;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
412
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
413 /* Check the database pointers */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
414 if (!db || !db->nodes || !db->pindex)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
415 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
416
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
417 /* Look-up index using binary search */
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
418 keyItem.filename = filename;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
419 key = &keyItem;
751
55eea3fa8868 Rename some structures.
Matti Hamalainen <ccr@tnsp.org>
parents: 723
diff changeset
420 item = bsearch(&key, db->pindex, db->n, sizeof(XSSTILNode *), xs_stildb_cmp);
660
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
421 if (item)
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
422 return *item;
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
423 else
b0743dc9165d Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 657
diff changeset
424 return NULL;
94
086681f70910 Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents: 62
diff changeset
425 }