annotate src/xs_length.c @ 657:acaba070cf49

Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 02 Apr 2008 19:46:59 +0300
parents 20cb21c4cb3c
children b0743dc9165d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
332
961212302eb9 Comment
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
4 Get song length from SLDB for PSID/RSID files
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
324
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
422
d2e6682d3ef8 Copyright year update
Matti Hamalainen <ccr@tnsp.org>
parents: 419
diff changeset
7 (C) Copyright 1999-2007 Tecnic Software productions (TNSP)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
412
7f694e5a1493 Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 402
diff changeset
19 You should have received a copy of the GNU General Public License along
7f694e5a1493 Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 402
diff changeset
20 with this program; if not, write to the Free Software Foundation, Inc.,
7f694e5a1493 Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 402
diff changeset
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
39
85a7753e2a9a Lots of new code
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
23 #include "xs_length.h"
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
24 #include "xs_support.h"
223
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
25 #include <stdio.h>
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 #include <stdlib.h>
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #include <ctype.h>
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #include <string.h>
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
30
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
31 /* Free memory allocated for given SLDB node
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
33 static void xs_sldb_node_free(sldb_node_t *node)
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
34 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
35 if (node) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
36 /* Nothing much to do here ... */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
37 g_free(node->lengths);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
38 g_free(node);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
39 }
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
40 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
41
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
42
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
43 /* Insert given node to db linked list
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
44 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
45 static void xs_sldb_node_insert(xs_sldb_t *db, sldb_node_t *node)
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
46 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
47 assert(db);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
48
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
49 if (db->nodes) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
50 /* The first node's prev points to last node */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
51 LPREV = db->nodes->prev; /* New node's prev = Previous last node */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
52 db->nodes->prev->next = node; /* Previous last node's next = New node */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
53 db->nodes->prev = node; /* New last node = New node */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
54 LNEXT = NULL; /* But next is NULL! */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
55 } else {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
56 db->nodes = node; /* First node ... */
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
57 LPREV = node; /* ... it's also last */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
58 LNEXT = NULL; /* But next is NULL! */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
59 }
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
60 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
61
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
62
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
63 /* Parse a time-entry in SLDB format
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
64 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
65 static gint xs_sldb_gettime(gchar *str, size_t *pos)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
67 gint result, tmp;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
69 /* Check if it starts with a digit */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
70 if (isdigit(str[*pos])) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
71 /* Get minutes-field */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
72 result = 0;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
73 while (isdigit(str[*pos]))
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
74 result = (result * 10) + (str[(*pos)++] - '0');
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
75
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
76 result *= 60;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
78 /* Check the field separator char */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
79 if (str[*pos] == ':') {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
80 /* Get seconds-field */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
81 (*pos)++;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
82 tmp = 0;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
83 while (isdigit(str[*pos])) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
84 tmp = (tmp * 10) + (str[(*pos)++] - '0');
385
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
85 }
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
87 result += tmp;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 } else
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
89 result = -2;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 } else
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
91 result = -1;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
93 /* Ignore and skip the possible attributes */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
94 while (str[*pos] && !isspace(str[*pos]))
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
95 (*pos)++;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
96
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
97 return result;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
101 /* Parse one SLDB definition line, return SLDB node
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
102 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
103 sldb_node_t * xs_sldb_read_entry(gchar *inLine)
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
104 {
449
230a9d79dd84 Type cleanups/fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
105 size_t linePos;
230a9d79dd84 Type cleanups/fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
106 gint i;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
107 gboolean isOK;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
108 sldb_node_t *tmnode;
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
109
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
110 /* Allocate new node */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
111 tmnode = (sldb_node_t *) g_malloc0(sizeof(sldb_node_t));
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
112 if (!tmnode) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
113 xs_error("Error allocating new node. Fatal error.\n");
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
114 return NULL;
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
115 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
116
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
117 /* Get hash value */
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
118 linePos = 0;
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
119 for (i = 0; i < XS_MD5HASH_LENGTH; i++, linePos += 2) {
419
bf4664ed897d sscanf() was used in unaligned access, causing problems on Sparc (and
Matti Hamalainen <ccr@tnsp.org>
parents: 418
diff changeset
120 gint tmpu;
bf4664ed897d sscanf() was used in unaligned access, causing problems on Sparc (and
Matti Hamalainen <ccr@tnsp.org>
parents: 418
diff changeset
121 sscanf(&inLine[linePos], "%2x", &tmpu);
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
122 tmnode->md5Hash[i] = tmpu;
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
123 }
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
124
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
125 /* Get playtimes */
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
126 if (inLine[linePos] != 0) {
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
127 if (inLine[linePos] != '=') {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
128 xs_error("'=' expected on column #%d.\n", linePos);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
129 xs_sldb_node_free(tmnode);
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
130 return NULL;
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
131 } else {
449
230a9d79dd84 Type cleanups/fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
132 size_t tmpLen, savePos;
230a9d79dd84 Type cleanups/fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
133
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
134 /* First playtime is after '=' */
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
135 savePos = ++linePos;
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
136 tmpLen = strlen(inLine);
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
137
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
138 /* Get number of sub-tune lengths */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
139 isOK = TRUE;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
140 while ((linePos < tmpLen) && isOK) {
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
141 xs_findnext(inLine, &linePos);
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 392
diff changeset
142
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
143 if (xs_sldb_gettime(inLine, &linePos) >= 0)
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
144 tmnode->nlengths++;
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
145 else
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
146 isOK = FALSE;
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
147 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
148
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
149 /* Allocate memory for lengths */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
150 if (tmnode->nlengths > 0) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
151 tmnode->lengths = (gint *) g_malloc0(tmnode->nlengths * sizeof(gint));
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
152 if (!tmnode->lengths) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
153 xs_error("Could not allocate memory for node.\n");
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
154 xs_sldb_node_free(tmnode);
472
3f02945a0c48 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 469
diff changeset
155 return NULL;
3f02945a0c48 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 469
diff changeset
156 }
3f02945a0c48 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 469
diff changeset
157 } else {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
158 xs_sldb_node_free(tmnode);
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
159 return NULL;
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
160 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
161
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
162 /* Read lengths in */
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
163 i = 0;
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
164 linePos = savePos;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
165 isOK = TRUE;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
166 while ((linePos < tmpLen) && (i < tmnode->nlengths) && isOK) {
449
230a9d79dd84 Type cleanups/fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
167 gint l;
230a9d79dd84 Type cleanups/fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
168
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
169 xs_findnext(inLine, &linePos);
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
170
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 392
diff changeset
171 l = xs_sldb_gettime(inLine, &linePos);
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 392
diff changeset
172 if (l >= 0)
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
173 tmnode->lengths[i] = l;
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 392
diff changeset
174 else
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
175 isOK = FALSE;
402
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 392
diff changeset
176
f997b79a7251 More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents: 392
diff changeset
177 i++;
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
178 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
179
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
180 if (!isOK) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
181 xs_sldb_node_free(tmnode);
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
182 return NULL;
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
183 } else
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
184 return tmnode;
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
185 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
186 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
187
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
188 return NULL;
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
189 }
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
190
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
191
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
192 /* Read database to memory
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
194 gint xs_sldb_read(xs_sldb_t *db, const gchar *dbFilename)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
196 FILE *inFile;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
197 gchar inLine[XS_BUF_SIZE];
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
198 size_t lineNum;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
199 sldb_node_t *tmnode;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
200 assert(db);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
201
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
202 /* Try to open the file */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
203 if ((inFile = fopen(dbFilename, "ra")) == NULL) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
204 xs_error("Could not open SongLengthDB '%s'\n", dbFilename);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
205 return -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
206 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
207
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
208 /* Read and parse the data */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
209 lineNum = 0;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
211 while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL) {
584
20cb21c4cb3c Optimizations.
Matti Hamalainen <ccr@tnsp.org>
parents: 509
diff changeset
212 size_t linePos = 0;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
213 lineNum++;
424
faf12767a6f1 Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
214
faf12767a6f1 Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
215 xs_findnext(inLine, &linePos);
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
217 /* Check if it is datafield */
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
218 if (isxdigit(inLine[linePos])) {
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
219 /* Check the length of the hash */
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
220 gint hashLen;
418
226627246616 Another fix for the fix, which was invalid. :P
Matti Hamalainen <ccr@tnsp.org>
parents: 417
diff changeset
221 for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++);
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
222
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
223 if (hashLen != XS_MD5HASH_LENGTH_CH) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
224 xs_error("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n",
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
225 dbFilename, lineNum);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
226 } else {
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
227 /* Parse and add node to db */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
228 if ((tmnode = xs_sldb_read_entry(inLine)) != NULL) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
229 xs_sldb_node_insert(db, tmnode);
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
230 } else {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
231 xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n",
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
232 dbFilename, lineNum);
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
233 }
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 }
424
faf12767a6f1 Preparing for internationalization.
Matti Hamalainen <ccr@tnsp.org>
parents: 422
diff changeset
235 } else if ((inLine[linePos] != ';') && (inLine[linePos] != '[') && (inLine[linePos] != 0)) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
236 xs_error("Invalid line in SongLengthDB file '%s' line #%d\n",
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
237 dbFilename, lineNum);
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
238 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
239
389
3c239e4160d5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 385
diff changeset
240 }
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
242 /* Close the file */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
243 fclose(inFile);
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
245 return 0;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
249 /* Compare two given MD5-hashes.
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
250 * Return: 0 if equal
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
251 * negative if testHash1 < testHash2
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
252 * positive if testHash1 > testHash2
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
253 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
254 static gint xs_sldb_cmphash(xs_md5hash_t testHash1, xs_md5hash_t testHash2)
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
255 {
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
256 gint i, d;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
257
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
258 /* Compute difference of hashes */
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
259 for (i = 0, d = 0; (i < XS_MD5HASH_LENGTH) && !d; i++)
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
260 d = (testHash1[i] - testHash2[i]);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
261
392
b09d74eb71e6 Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents: 389
diff changeset
262 return d;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
263 }
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
264
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
265
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
266 /* Compare two nodes
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
267 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
268 static gint xs_sldb_cmp(const void *node1, const void *node2)
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
269 {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
270 /* We assume here that we never ever get NULL-pointers or similar */
385
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
271 return xs_sldb_cmphash(
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
272 (*(sldb_node_t **) node1)->md5Hash,
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
273 (*(sldb_node_t **) node2)->md5Hash);
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
274 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
275
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
276
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
277 /* (Re)create index
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
279 gint xs_sldb_index(xs_sldb_t * db)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
281 sldb_node_t *pCurr;
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
282 size_t i;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
283 assert(db);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
284
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
285 /* Free old index */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
286 if (db->pindex) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
287 g_free(db->pindex);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
288 db->pindex = NULL;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
289 }
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
290
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
291 /* Get size of db */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
292 pCurr = db->nodes;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
293 db->n = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
294 while (pCurr) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
295 db->n++;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
296 pCurr = pCurr->next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
297 }
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
298
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
299 /* Check number of nodes */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
300 if (db->n > 0) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
301 /* Allocate memory for index-table */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
302 db->pindex = (sldb_node_t **) g_malloc(sizeof(sldb_node_t *) * db->n);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
303 if (!db->pindex)
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
304 return -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
305
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
306 /* Get node-pointers to table */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
307 i = 0;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
308 pCurr = db->nodes;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
309 while (pCurr && (i < db->n)) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
310 db->pindex[i++] = pCurr;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
311 pCurr = pCurr->next;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
312 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
313
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
314 /* Sort the indexes */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
315 qsort(db->pindex, db->n, sizeof(sldb_node_t *), xs_sldb_cmp);
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
316 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
317
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
318 return 0;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
319 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
320
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
321
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
322 /* Free a given song-length database
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
323 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
324 void xs_sldb_free(xs_sldb_t * db)
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
325 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
326 sldb_node_t *pCurr, *next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
327
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
328 if (!db)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
329 return;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
330
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
331 /* Free the memory allocated for nodes */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
332 pCurr = db->nodes;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
333 while (pCurr) {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
334 next = pCurr->next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
335 xs_sldb_node_free(pCurr);
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
336 pCurr = next;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
337 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
338
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
339 db->nodes = NULL;
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
340
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
341 /* Free memory allocated for index */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
342 if (db->pindex) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
343 g_free(db->pindex);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
344 db->pindex = NULL;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
345 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
346
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
347 /* Free structure */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
348 db->n = 0;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
349 g_free(db);
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 }
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
353 /* Compute md5hash of given SID-file
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
355 typedef struct {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
356 gchar magicID[4]; /* "PSID" / "RSID" magic identifier */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
357 guint16 version, /* Version number */
385
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
358 dataOffset, /* Start of actual c64 data in file */
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
359 loadAddress, /* Loading address */
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
360 initAddress, /* Initialization address */
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
361 playAddress, /* Play one frame */
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
362 nSongs, /* Number of subsongs */
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
363 startSong; /* Default starting song */
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
364 guint32 speed; /* Speed */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
365 gchar sidName[32]; /* Descriptive text-fields, ASCIIZ */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
366 gchar sidAuthor[32];
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
367 gchar sidCopyright[32];
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
368 } psidv1_header_t;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
369
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
371 typedef struct {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
372 guint16 flags; /* Flags */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
373 guint8 startPage, pageLength;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
374 guint16 reserved;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
375 } psidv2_header_t;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
376
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
377
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
378 static gint xs_get_sid_hash(const gchar *filename, xs_md5hash_t hash)
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
379 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
380 xs_file_t *inFile;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
381 xs_md5state_t inState;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
382 psidv1_header_t psidH;
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
383 psidv2_header_t psidH2;
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
384 guint8 *songData;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
385 guint8 ib8[2], i8;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
386 gint index, result;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
387
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
388 /* Try to open the file */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
389 if ((inFile = xs_fopen(filename, "rb")) == NULL)
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
390 return -1;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
391
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
392 /* Read PSID header in */
469
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
393 xs_fread(psidH.magicID, sizeof(psidH.magicID), 1, inFile);
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
394 if (strncmp(psidH.magicID, "PSID", 4) && strncmp(psidH.magicID, "RSID", 4)) {
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
395 xs_fclose(inFile);
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
396 xs_error("Not a PSID or RSID file '%s'\n", filename);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
397 return -2;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
398 }
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
399
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
400 psidH.version = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
401 psidH.dataOffset = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
402 psidH.loadAddress = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
403 psidH.initAddress = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
404 psidH.playAddress = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
405 psidH.nSongs = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
406 psidH.startSong = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
407 psidH.speed = xs_fread_be32(inFile);
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
408
469
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
409 xs_fread(psidH.sidName, sizeof(gchar), sizeof(psidH.sidName), inFile);
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
410 xs_fread(psidH.sidAuthor, sizeof(gchar), sizeof(psidH.sidAuthor), inFile);
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
411 xs_fread(psidH.sidCopyright, sizeof(gchar), sizeof(psidH.sidCopyright), inFile);
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
412
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
413 if (xs_feof(inFile) || xs_ferror(inFile)) {
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
414 xs_fclose(inFile);
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
415 xs_error("Error reading SID file header from '%s'\n", filename);
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
416 return -4;
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
417 }
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
418
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
419 /* Check if we need to load PSIDv2NG header ... */
469
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
420 psidH2.flags = 0; /* Just silence a stupid gcc warning */
d600f45c92d2 Silence a gcc warning; Use xs_*() file handling functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 458
diff changeset
421
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
422 if (psidH.version == 2) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
423 /* Yes, we need to */
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
424 psidH2.flags = xs_fread_be16(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
425 psidH2.startPage = xs_fgetc(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
426 psidH2.pageLength = xs_fgetc(inFile);
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
427 psidH2.reserved = xs_fread_be16(inFile);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
428 }
385
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
429
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
430 /* Allocate buffer */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
431 songData = (guint8 *) g_malloc(XS_SIDBUF_SIZE * sizeof(guint8));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
432 if (!songData) {
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
433 xs_fclose(inFile);
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
434 xs_error("Error allocating temp data buffer for file '%s'\n", filename);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
435 return -3;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
436 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
437
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
438 /* Read data to buffer */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
439 result = xs_fread(songData, sizeof(guint8), XS_SIDBUF_SIZE, inFile);
458
57836945fa71 Use new xs_* file functions for SID-file handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 449
diff changeset
440 xs_fclose(inFile);
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
441
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
442 /* Initialize and start MD5-hash calculation */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
443 xs_md5_init(&inState);
385
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
444
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
445 if (psidH.loadAddress == 0) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
446 /* Strip load address (2 first bytes) */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
447 xs_md5_append(&inState, &songData[2], result - 2);
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
448 } else {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
449 /* Append "as is" */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
450 xs_md5_append(&inState, songData, result);
227
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
451 }
92bad4c7b998 Improved modularization of STIL and song-length database subsystems.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
452
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
453 /* Free buffer */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
454 g_free(songData);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
455
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
456 /* Append header data to hash */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
457 #define XSADDHASH(QDATAB) do { \
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
458 ib8[0] = (QDATAB & 0xff); \
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
459 ib8[1] = (QDATAB >> 8); \
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
460 xs_md5_append(&inState, (guint8 *) &ib8, sizeof(ib8)); \
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
461 } while (0)
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
462
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
463 XSADDHASH(psidH.initAddress);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
464 XSADDHASH(psidH.playAddress);
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
465 XSADDHASH(psidH.nSongs);
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
466 #undef XSADDHASH
385
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
467
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
468 /* Append song speed data to hash */
7dc7e7dbbf90 Indentation fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 369
diff changeset
469 i8 = 0;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
470 for (index = 0; (index < psidH.nSongs) && (index < 32); index++) {
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
471 i8 = (psidH.speed & (1 << index)) ? 60 : 0;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
472 xs_md5_append(&inState, &i8, sizeof(i8));
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
473 }
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
474
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
475 /* Rest of songs (more than 32) */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
476 for (index = 32; index < psidH.nSongs; index++) {
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
477 xs_md5_append(&inState, &i8, sizeof(i8));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
478 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
479
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
480 /* PSIDv2NG specific */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
481 if (psidH.version == 2) {
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
482 /* SEE SIDPLAY HEADERS FOR INFO */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
483 i8 = (psidH2.flags >> 2) & 3;
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
484 if (i8 == 2)
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
485 xs_md5_append(&inState, &i8, sizeof(i8));
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
486 }
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
487
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
488 /* Calculate the hash */
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
489 xs_md5_finish(&inState, hash);
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
490
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
491 return 0;
14
f5d82424b0ed Made song-length database support FINALLY work!
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
492 }
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
495 /* Get node from db index via binary search
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496 */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
497 sldb_node_t *xs_sldb_get(xs_sldb_t *db, const gchar *filename)
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 {
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
499 sldb_node_t keyItem, *key, **item;
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
500
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
501 /* Check the database pointers */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
502 if (!db || !db->nodes || !db->pindex)
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
503 return NULL;
4
4bb09e405eab Added new files for 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
505 /* Get the hash and then look up from db */
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
506 if (xs_get_sid_hash(filename, keyItem.md5Hash) == 0) {
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
507 key = &keyItem;
657
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
508 item = bsearch(&key, db->pindex, db->n,
acaba070cf49 Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
509 sizeof(db->pindex[0]), xs_sldb_cmp);
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
510
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
511 if (item)
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
512 return *item;
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
513 else
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
514 return NULL;
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
515 } else
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
516 return NULL;
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
517 }
359
b1a858b8cb1a Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents: 332
diff changeset
518
509
81756f412b43 Changes based on patch from Heikki 'shd' Orsila: Fix a crash on 64-bit
Matti Hamalainen <ccr@tnsp.org>
parents: 476
diff changeset
519