Mercurial > hg > xmms-sid
annotate src/xs_stil.c @ 117:453ac1293f6a
Fixed severe bug in xs_strmcat()
Finalized the STIL-parser, should now work if not for any unfound bug(s).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Jan 2004 01:55:04 +0000 |
parents | 582d32db824b |
children | 4162a5370b9e |
rev | line source |
---|---|
1 | 1 /* |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
1 | 3 |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
4 STIL-database handling functions |
1 | 5 |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org> |
1 | 7 |
8 This program is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation; either version 2 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program; if not, write to the Free Software | |
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 */ | |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
22 #include "xs_stil.h" |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
23 #include "xs_support.h" |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
24 #include "xs_config.h" |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
25 #include <stdlib.h> |
1 | 26 #include <stdio.h> |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
27 #include <ctype.h> |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
28 #include <string.h> |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
29 |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
30 |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
31 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
32 * Pointer to database in memory |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
33 */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
34 static t_xs_stil_node *xs_stildb = NULL; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
35 static t_xs_stil_node **xs_stildbi = NULL; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
36 static gint xs_stildbn = 0; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
37 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
38 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
39 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
40 * Hash-database handling functions |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
41 */ |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
42 t_xs_stil_node *xs_stildb_node_new(void) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
43 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
44 t_xs_stil_node *pResult; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
45 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
46 /* Allocate memory for new node */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
47 pResult = (t_xs_stil_node *) g_malloc0(sizeof(t_xs_stil_node)); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
48 return pResult; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
49 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
50 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
51 |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
52 void xs_stildb_node_free(t_xs_stil_node *pNode) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
53 { |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
54 gint i; |
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
55 |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
56 if (pNode) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
57 { |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
58 for (i = 0; i < XS_STIL_MAXENTRY; i++) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
59 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
60 g_free(pNode->subTune[i].pName); |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
61 g_free(pNode->subTune[i].pAuthor); |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
62 g_free(pNode->subTune[i].pInfo); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
63 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
64 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
65 g_free(pNode->pcFilename); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
66 g_free(pNode); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
67 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
68 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
69 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
70 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
71 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
72 * Insert given node to db linked list |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
73 */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
74 #define LPREV (pNode->pPrev) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
75 #define LTHIS (pNode) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
76 #define LNEXT (pNode->pNext) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
77 |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
78 void xs_stildb_node_insert(t_xs_stil_node *pNode) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
79 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
80 if (xs_stildb) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
81 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
82 /* The first node's pPrev points to last node */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
83 LPREV = xs_stildb->pPrev; /* New node's prev = Previous last node */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
84 xs_stildb->pPrev->pNext = pNode; /* Previous last node's next = New node */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
85 xs_stildb->pPrev = pNode; /* New last node = New node */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
86 LNEXT = NULL; /* But next is NULL! */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
87 } else { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
88 xs_stildb = pNode; /* First node ... */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
89 LPREV = pNode; /* ... it's also last */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
90 LNEXT = NULL; /* But next is NULL! */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
91 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
92 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
93 |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
94 gint xs_strmcat(gchar **ppResult, gchar *pStr) |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
95 { |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
96 assert(ppResult); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
97 |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
98 /* Check the string pointers */ |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
99 if (!pStr) return -1; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
100 |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
101 if (*ppResult != NULL) |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
102 { |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
103 *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
104 if (*ppResult == NULL) return -1; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
105 strcat(*ppResult, pStr); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
106 } else |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
107 { |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
108 *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
109 if (*ppResult == NULL) return -1; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
110 strcpy(*ppResult, pStr); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
111 } |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
112 |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
113 return 0; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
114 } |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
115 |
94
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 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
118 * Read database to memory |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
119 */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
120 gint xs_stildb_read(gchar *dbFilename) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
121 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
122 FILE *inFile; |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
123 gchar inLine[XS_BUFSIZE + 10]; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
124 guint lineNum, linePos, eolPos; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
125 t_xs_stil_node *tmpNode; |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
126 gboolean isError; |
110 | 127 gint subEntry; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
128 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
129 /* Try to open the file */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
130 if ((inFile = fopen(dbFilename, "ra")) == NULL) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
131 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
132 XSERR("Could not open STILDB '%s'\n", dbFilename); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
133 return -1; |
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 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
136 /* Read and parse the data */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
137 lineNum = 0; |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
138 isError = FALSE; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
139 tmpNode = NULL; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
140 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
141 while (!feof(inFile) && !isError) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
142 { |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
143 fgets(inLine, XS_BUFSIZE, inFile); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
144 linePos = eolPos = 0; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
145 xs_findeol(inLine, &eolPos); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
146 inLine[eolPos] = 0; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
147 lineNum++; |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
148 |
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
149 switch (inLine[0]) { |
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
150 case '/': |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
151 /* Check if we are already parsing entry */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
152 if (tmpNode) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
153 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
154 XSERR("New entry ('%s') before end of current ('%s')! Possibly malformed STIL-file!\n", |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
155 inLine, tmpNode->pcFilename); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
156 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
157 xs_stildb_node_free(tmpNode); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
158 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
159 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
160 /* A new node */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
161 tmpNode = xs_stildb_node_new(); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
162 if (tmpNode) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
163 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
164 /* Initialize the node */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
165 tmpNode->pcFilename = g_strdup(inLine); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
166 subEntry = 0; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
167 } else |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
168 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
169 /* Allocation failed */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
170 XSERR("Could not allocate new STILdb-node for '%s'!\n", inLine); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
171 isError = TRUE; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
172 } |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
173 break; |
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
174 |
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
175 case '(': |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
176 /* A new sub-entry */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
177 linePos++; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
178 if (inLine[linePos] == '#') |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
179 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
180 linePos++; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
181 if (inLine[linePos]) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
182 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
183 xs_findnum(inLine, &linePos); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
184 inLine[linePos] = 0; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
185 subEntry = atol(&inLine[2]); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
186 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
187 /* Sanity check */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
188 if ((subEntry < 1) || (subEntry >= XS_STIL_MAXENTRY)) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
189 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
190 XSERR("Number of subEntry (%i) for '%s' is invalid\n", subEntry, tmpNode->pcFilename); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
191 subEntry = 0; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
192 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
193 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
194 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
195 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
196 break; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
197 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
198 case 0: |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
199 case '#': |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
200 case '\n': |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
201 case '\r': |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
202 /* End of entry/field */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
203 if (tmpNode) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
204 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
205 /* Insert to database */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
206 xs_stildb_node_insert(tmpNode); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
207 tmpNode = NULL; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
208 } |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
209 break; |
101 | 210 |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
211 default: |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
212 /* Check if we are parsing an entry */ |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
213 if (!tmpNode) |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
214 { |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
215 XSERR("Entry data encountered outside of entry!\n"); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
216 break; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
217 } |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
218 |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
219 /* Some other type */ |
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 if (strncmp(inLine, " NAME:", 8) == 0) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
221 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
222 g_free(tmpNode->subTune[subEntry].pName); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
223 tmpNode->subTune[subEntry].pName = g_strdup(&inLine[9]); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
224 } else |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
225 if (strncmp(inLine, " AUTHOR:", 8) == 0) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
226 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
227 g_free(tmpNode->subTune[subEntry].pAuthor); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
228 tmpNode->subTune[subEntry].pAuthor = g_strdup(&inLine[9]); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
229 } else |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
230 if (strncmp(inLine, " TITLE:", 8) == 0) |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
231 { |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
232 inLine[eolPos++] = '\n'; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
233 inLine[eolPos++] = 0; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
234 xs_strmcat(&(tmpNode->subTune[subEntry].pInfo), &inLine[2]); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
235 } else |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
236 if (strncmp(inLine, " ARTIST:", 8) == 0) |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
237 { |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
238 inLine[eolPos++] = '\n'; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
239 inLine[eolPos++] = 0; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
240 xs_strmcat(&(tmpNode->subTune[subEntry].pInfo), &inLine[1]); |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
241 } else |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
242 if (strncmp(inLine, "COMMENT:", 8) == 0) |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
243 xs_strmcat(&(tmpNode->subTune[subEntry].pInfo), inLine); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
244 else |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
245 if (strncmp(inLine, " ", 8) == 0) |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
246 xs_strmcat(&(tmpNode->subTune[subEntry].pInfo), &inLine[8]); |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
247 break; |
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
248 } |
101 | 249 |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
250 } /* while */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
251 |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
252 /* Check if there is one remaining node */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
253 if (tmpNode) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
254 xs_stildb_node_free(tmpNode); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
255 |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
256 /* Close the file */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
257 fclose(inFile); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
258 return 0; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
259 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
260 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
261 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
262 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
263 * Compare two nodes' hashes |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
264 */ |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
265 gint xs_stildb_cmp(const void *pNode1, const void *pNode2) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
266 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
267 /* We assume here that we never ever get NULL-pointers or similar */ |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
268 return strcmp((*(t_xs_stil_node **) pNode1)->pcFilename, |
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
269 (*(t_xs_stil_node **) pNode2)->pcFilename); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
270 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
271 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
272 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
273 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
274 * Initialize the song-length system |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
275 */ |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
276 gint xs_stil_init(void) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
277 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
278 t_xs_stil_node *pCurr; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
279 gint i; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
280 |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
281 XSDEBUG("stil_init()\n"); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
282 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
283 /* Read the database */ |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
284 if (!xs_cfg.stilDBPath) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
285 return -10; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
286 |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
287 if (xs_stildb_read(xs_cfg.stilDBPath) < 0) |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
288 return -9; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
289 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
290 XSDEBUG("indexing...\n"); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
291 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
292 /* Get size of db */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
293 pCurr = xs_stildb; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
294 xs_stildbn = 0; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
295 while (pCurr) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
296 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
297 xs_stildbn++; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
298 pCurr = pCurr->pNext; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
299 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
300 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
301 /* Check number of nodes */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
302 if (xs_stildbn > 0) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
303 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
304 /* Allocate memory for index-table */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
305 xs_stildbi = (t_xs_stil_node **) g_malloc(sizeof(t_xs_stil_node *) * xs_stildbn); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
306 if (!xs_stildbi) return -6; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
307 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
308 /* Get node-pointers to table */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
309 i = 0; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
310 pCurr = xs_stildb; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
311 while (pCurr) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
312 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
313 xs_stildbi[i++] = pCurr; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
314 pCurr = pCurr->pNext; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
315 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
316 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
317 /* Sort the indexes */ |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
318 qsort(xs_stildbi, xs_stildbn, sizeof(t_xs_stil_node *), xs_stildb_cmp); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
319 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
320 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
321 /* OK */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
322 XSDEBUG("init ok.\n"); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
323 return 0; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
324 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
325 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
326 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
327 /* |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
328 * Close song-length system |
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 void xs_stil_close(void) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
331 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
332 t_xs_stil_node *pCurr, *pNext; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
333 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
334 /* Free the memory allocated for database */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
335 XSDEBUG("stildb_close()\n"); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
336 pCurr = xs_stildb; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
337 while (pCurr) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
338 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
339 pNext = pCurr->pNext; |
99
2bc56809ec0b
STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
340 xs_stildb_node_free(pCurr); |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
341 pCurr = pNext; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
342 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
343 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
344 xs_stildb = NULL; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
345 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
346 /* Free memory allocated for indexes */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
347 if (xs_stildbi) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
348 { |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
349 g_free(xs_stildbi); |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
350 xs_stildbi = NULL; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
351 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
352 } |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
353 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
354 |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
355 /* |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
356 * Get STIL information from database |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
357 */ |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
358 t_xs_stil_node * xs_stil_get(gchar *pcFilename) |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
359 { |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
360 gint iStartNode, iEndNode, iQNode, r, i; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
361 gchar *tmpFilename; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
362 gboolean iFound; |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
363 t_xs_stil_node *pResult; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
364 |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
365 /* Check the database pointers */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
366 if (!xs_stildb || !xs_stildbi || !xs_cfg.stilDBEnable || !xs_cfg.hvscPath) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
367 return NULL; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
368 |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
369 /* Remove postfixed directory separator from HVSC-path */ |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
370 tmpFilename = strrchr(xs_cfg.hvscPath, '/'); |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
371 if (tmpFilename && (tmpFilename[1] == 0)) |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
372 tmpFilename[0] = 0; |
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
373 |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
374 /* Remove HVSC location-prefix from filename */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
375 tmpFilename = strstr(pcFilename, xs_cfg.hvscPath); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
376 if (tmpFilename) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
377 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
378 tmpFilename += strlen(xs_cfg.hvscPath); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
379 } else |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
380 tmpFilename = pcFilename; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
381 |
117
453ac1293f6a
Fixed severe bug in xs_strmcat()
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
382 XSDEBUG("'%s', '%s'\n", xs_cfg.hvscPath, tmpFilename); |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
383 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
384 /* Look-up via index using binary search */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
385 pResult = NULL; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
386 iStartNode = 0; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
387 iEndNode = (xs_stildbn - 1); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
388 iQNode = (iEndNode / 2); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
389 iFound = FALSE; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
390 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
391 while ((!iFound) && ((iEndNode - iStartNode) > 128)) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
392 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
393 r = strcmp(tmpFilename, xs_stildbi[iQNode]->pcFilename); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
394 if (r < 0) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
395 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
396 /* Hash was in the <- LEFT side */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
397 iEndNode = iQNode; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
398 iQNode = iStartNode + ((iEndNode - iStartNode) / 2); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
399 } else |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
400 if (r > 0) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
401 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
402 /* Hash was in the RIGHT -> side */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
403 iStartNode = iQNode; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
404 iQNode = iStartNode + ((iEndNode - iStartNode) / 2); |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
405 } else |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
406 iFound = TRUE; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
407 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
408 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
409 /* If not found already */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
410 if (!iFound) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
411 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
412 /* Search the are linearly */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
413 iFound = FALSE; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
414 i = iStartNode; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
415 while ((i <= iEndNode) && (!iFound)) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
416 { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
417 if (strcmp(tmpFilename, xs_stildbi[i]->pcFilename) == 0) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
418 iFound = TRUE; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
419 else |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
420 i++; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
421 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
422 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
423 /* Check the result */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
424 if (iFound) |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
425 pResult = xs_stildbi[i]; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
426 |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
427 } else { |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
428 /* Found via binary search */ |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
429 pResult = xs_stildbi[iQNode]; |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
430 } |
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
431 |
94
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
432 return pResult; |
086681f70910
Start of re-write of STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
433 } |
109
578b71b62eeb
Fileinfo now basically working, STIL COMMENT-fields are not yet parsed or shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
434 |