annotate src/sid/xs_stil.c @ 2593:f4dce14ed238

Indentation cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 21 May 2008 00:46:06 +0300
parents 09879415c666
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 STIL-database handling functions
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
7 (C) Copyright 1999-2007 Tecnic Software productions (TNSP)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
19 You should have received a copy of the GNU General Public License along
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
20 with this program; if not, write to the Free Software Foundation, Inc.,
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 #include "xs_stil.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24 #include "xs_support.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 #include <stdio.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 #include <ctype.h>
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
28 #include <stdarg.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 /* Database handling functions
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32 */
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
33 static gboolean xs_stildb_node_realloc(stil_node_t *node, gint nsubTunes)
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
34 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
35 if (!node) return FALSE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
36
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
37 /* Re-allocate subTune structure if needed */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
38 if (nsubTunes > node->nsubTunes) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
39 gint clearIndex, clearLength;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
40
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
41 node->subTunes =
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
42 (stil_subnode_t **) g_realloc(node->subTunes,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
43 (nsubTunes + 1) * sizeof(stil_subnode_t **));
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
44
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
45 if (!node->subTunes) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
46 xs_error("SubTune pointer structure realloc failed.\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
47 return FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
48 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
49
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
50 /* Clear the newly allocated memory */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
51 if (node->nsubTunes == 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
52 clearIndex = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
53 clearLength = nsubTunes + 1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
54 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
55 clearIndex = node->nsubTunes + 1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
56 clearLength = (nsubTunes - clearIndex + 1);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
57 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
58 memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(stil_subnode_t **));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
59
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
60 node->nsubTunes = nsubTunes;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
61 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
62
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
63 /* Allocate memory for subTune */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
64 if (!node->subTunes[nsubTunes]) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
65 node->subTunes[nsubTunes] = (stil_subnode_t *)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
66 g_malloc0(sizeof(stil_subnode_t));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
67
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
68 if (!node->subTunes[nsubTunes]) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
69 xs_error("SubTune structure malloc failed!\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
70 return FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
71 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
72 }
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
73
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
74 return TRUE;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
75 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
76
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
77
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
78 static void xs_stildb_node_free(stil_node_t *node)
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
79 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
80 gint i;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
81 stil_subnode_t *subnode;
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
82
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
83 if (!node) return;
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
84
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
85 /* Free subtune information */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
86 for (i = 0; i <= node->nsubTunes; i++) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
87 subnode = node->subTunes[i];
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
88 if (subnode) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
89 g_free(subnode->name);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
90 g_free(subnode->author);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
91 g_free(subnode->info);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
92 g_free(subnode->title);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
93 g_free(subnode);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
94 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
95 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
96 g_free(node->subTunes);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
97 g_free(node->filename);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
98 g_free(node);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
99 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
100
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
101
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
102 static stil_node_t *xs_stildb_node_new(gchar *filename)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
103 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
104 stil_node_t *result;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
105
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
106 /* Allocate memory for new node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
107 result = (stil_node_t *) g_malloc0(sizeof(stil_node_t));
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
108 if (!result)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
109 return NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
110
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
111 /* Allocate filename and initial space for one subtune */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
112 result->filename = g_strdup(filename);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
113 if (!result->filename || !xs_stildb_node_realloc(result, 1)) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
114 xs_stildb_node_free(result);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
115 return NULL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
116 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
117
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
118 return result;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
119 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
120
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
121
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
122 /* Insert given node to db linked list
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
123 */
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
124 static void xs_stildb_node_insert(xs_stildb_t *db, stil_node_t *node)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
125 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
126 assert(db != NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
127
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
128 if (db->nodes) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
129 /* The first node's pPrev points to last node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
130 LPREV = db->nodes->prev; /* New node's prev = Previous last node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
131 db->nodes->prev->next = node; /* Previous last node's next = New node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
132 db->nodes->prev = node; /* New last node = New node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
133 LNEXT = NULL; /* But next is NULL! */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
134 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
135 db->nodes = node; /* First node ... */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
136 LPREV = node; /* ... it's also last */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
137 LNEXT = NULL; /* But next is NULL! */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
138 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
139 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
140
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
141
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
142 /* Read database (additively) to given db-structure
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
143 */
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
144 #define XS_STILDB_MULTI \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
145 if (isMulti) { \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
146 isMulti = FALSE; \
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
147 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), "\n");\
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
148 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
149
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
150 static void XS_STILDB_ERR(gint lineNum, gchar *inLine, const char *fmt, ...)
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
151 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
152 va_list ap;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
153
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
154 va_start(ap, fmt);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
155 xs_error(fmt, ap);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
156 va_end(ap);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
157
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
158 fprintf(stderr, "#%d: '%s'\n", lineNum, inLine);
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
159 }
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
160
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
161 gint xs_stildb_read(xs_stildb_t *db, gchar *dbFilename)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
162 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
163 FILE *inFile;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
164 gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
165 size_t lineNum;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
166 stil_node_t *tmnode;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
167 gboolean isError, isMulti;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
168 gint subEntry;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
169 gchar *tmpLine = inLine;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
170 assert(db != NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
171
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
172 /* Try to open the file */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
173 if ((inFile = fopen(dbFilename, "ra")) == NULL) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
174 xs_error("Could not open STILDB '%s'\n", dbFilename);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
175 return -1;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
176 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
177
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
178 /* Read and parse the data */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
179 lineNum = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
180 isError = FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
181 isMulti = FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
182 tmnode = NULL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
183 subEntry = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
184
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
185 while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
186 size_t linePos = 0, eolPos = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
187 xs_findeol(inLine, &eolPos);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
188 inLine[eolPos] = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
189 lineNum++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
190
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
191 tmpLine = XS_CS_STIL(inLine);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
192
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
193 switch (tmpLine[0]) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
194 case '/':
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
195 /* Check if we are already parsing entry */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
196 isMulti = FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
197 if (tmnode) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
198 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
199 "New entry found before end of current ('%s')!\n",
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
200 tmnode->filename);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
201 xs_stildb_node_free(tmnode);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
202 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
204 /* A new node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
205 subEntry = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
206 tmnode = xs_stildb_node_new(tmpLine);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
207 if (!tmnode) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
208 /* Allocation failed */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
209 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
210 "Could not allocate new STILdb-node!\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
211 isError = TRUE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
212 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
213 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
215 case '(':
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
216 /* A new sub-entry */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
217 isMulti = FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
218 linePos++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
219 if (tmpLine[linePos] == '#') {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
220 linePos++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
221 if (isdigit(tmpLine[linePos])) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
222 size_t savePos = linePos;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
223 xs_findnum(tmpLine, &linePos);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
224 tmpLine[linePos] = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
225 subEntry = atol(&tmpLine[savePos]);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
227 /* Sanity check */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
228 if (subEntry < 1) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
229 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
230 "Number of subEntry (%i) for '%s' is invalid\n",
2578
09879415c666 Fixed a rare null-pointer dereference in Audacious-SID, discovered via zzuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 2509
diff changeset
231 subEntry, tmnode ? tmnode->filename : "");
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
232 subEntry = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
233 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
234 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
235 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
236 "Syntax error, expected subEntry number.\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
237 subEntry = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
238 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
239 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
240 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
241 "Syntax error, expected '#' before subEntry number.\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
242 subEntry = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
243 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
244
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
245 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
247 case 0:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
248 case '#':
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
249 case '\n':
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
250 case '\r':
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
251 /* End of entry/field */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
252 isMulti = FALSE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
253 if (tmnode) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
254 /* Insert to database */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
255 xs_stildb_node_insert(db, tmnode);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
256 tmnode = NULL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
257 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
258 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
260 default:
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
261 /* Check if we are parsing an entry */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
262 xs_findnext(tmpLine, &linePos);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
263
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
264 if (!tmnode) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
265 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
266 "Entry data encountered outside of entry or syntax error!\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
267 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
268 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
269
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
270 if (!xs_stildb_node_realloc(tmnode, subEntry)) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
271 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
272 "Could not (re)allocate memory for subEntries!\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
273 isError = TRUE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
274 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
275 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
276
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
277 /* Some other type */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
278 if (strncmp(tmpLine, " NAME:", 8) == 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
279 XS_STILDB_MULTI;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
280 g_free(tmnode->subTunes[subEntry]->name);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
281 tmnode->subTunes[subEntry]->name = g_strdup(&tmpLine[9]);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
282 } else if (strncmp(tmpLine, " TITLE:", 8) == 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
283 XS_STILDB_MULTI;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
284 isMulti = TRUE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
285 if (!tmnode->subTunes[subEntry]->title)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
286 tmnode->subTunes[subEntry]->title = g_strdup(&tmpLine[9]);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
287 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[2]);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
288 } else if (strncmp(tmpLine, " AUTHOR:", 8) == 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
289 XS_STILDB_MULTI;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
290 g_free(tmnode->subTunes[subEntry]->author);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
291 tmnode->subTunes[subEntry]->author = g_strdup(&tmpLine[9]);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
292 } else if (strncmp(tmpLine, " ARTIST:", 8) == 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
293 XS_STILDB_MULTI;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
294 isMulti = TRUE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
295 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[1]);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
296 } else if (strncmp(tmpLine, "COMMENT:", 8) == 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
297 XS_STILDB_MULTI;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
298 isMulti = TRUE;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
299 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), tmpLine);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
300 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
301 if (isMulti) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
302 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), " ");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
303 xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[linePos]);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
304 } else {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
305 XS_STILDB_ERR(lineNum, tmpLine,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
306 "Entry continuation found when isMulti == FALSE.\n");
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
307 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
308 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
309 break;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
310 }
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
311
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
312 XS_CS_FREE(tmpLine);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
313
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
314 } /* while */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
315
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
316 /* Check if there is one remaining node */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
317 if (tmnode)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
318 xs_stildb_node_insert(db, tmnode);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
320 /* Close the file */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
321 fclose(inFile);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
323 return 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
324 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
325
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
327 /* Compare two nodes
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328 */
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
329 static gint xs_stildb_cmp(const void *node1, const void *node2)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
331 /* We assume here that we never ever get NULL-pointers or similar */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
332 return strcmp(
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
333 (*(stil_node_t **) node1)->filename,
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
334 (*(stil_node_t **) node2)->filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 /* (Re)create index
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339 */
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
340 gint xs_stildb_index(xs_stildb_t *db)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
342 stil_node_t *curr;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
343 size_t i;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
345 /* Free old index */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
346 if (db->pindex) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
347 g_free(db->pindex);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
348 db->pindex = NULL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
349 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
350
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
351 /* Get size of db */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
352 curr = db->nodes;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
353 db->n = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
354 while (curr) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
355 db->n++;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
356 curr = curr->next;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
357 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
358
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
359 /* Check number of nodes */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
360 if (db->n > 0) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
361 /* Allocate memory for index-table */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
362 db->pindex = (stil_node_t **) g_malloc(sizeof(stil_node_t *) * db->n);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
363 if (!db->pindex)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
364 return -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
365
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
366 /* Get node-pointers to table */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
367 i = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
368 curr = db->nodes;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
369 while (curr && (i < db->n)) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
370 db->pindex[i++] = curr;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
371 curr = curr->next;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
372 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
373
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
374 /* Sort the indexes */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
375 qsort(db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
376 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
377
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
378 return 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
379 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
380
735
6c3c7b841382 [svn] - sync audacious-sid with latest xmms-sid, from Matti Hamalainen (ccr).
nenolod
parents: 12
diff changeset
381
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
382 /* Free a given STIL database
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
383 */
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
384 void xs_stildb_free(xs_stildb_t *db)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
385 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
386 stil_node_t *curr, *next;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
387
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
388 if (!db)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
389 return;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
390
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
391 /* Free the memory allocated for nodes */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
392 curr = db->nodes;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
393 while (curr) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
394 next = curr->next;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
395 xs_stildb_node_free(curr);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
396 curr = next;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
397 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
398
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
399 db->nodes = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
400
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
401 /* Free memory allocated for index */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
402 if (db->pindex) {
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
403 g_free(db->pindex);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
404 db->pindex = NULL;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
405 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
406
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
407 /* Free structure */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
408 db->n = 0;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
409 g_free(db);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
410 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
411
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
412
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
413 /* Get STIL information node from database
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
414 */
2507
251336bee085 Cosmetic cleanups, synchronized from XMMS-SID.
Matti Hamalainen <ccr@tnsp.org>
parents: 2478
diff changeset
415 stil_node_t *xs_stildb_get_node(xs_stildb_t *db, gchar *filename)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
416 {
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
417 stil_node_t keyItem, *key, **item;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
418
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
419 /* Check the database pointers */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
420 if (!db || !db->nodes || !db->pindex)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
421 return NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
422
2509
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
423 /* Look-up index using binary search */
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
424 keyItem.filename = filename;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
425 key = &keyItem;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
426 item = bsearch(&key, db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp);
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
427 if (item)
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
428 return *item;
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
429 else
1223e8510d8a Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 2507
diff changeset
430 return NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
431 }