Mercurial > hg > xmms-sid
comparison src/xs_length.c @ 424:faf12767a6f1
Preparing for internationalization.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 31 Dec 2006 21:43:04 +0000 |
parents | d2e6682d3ef8 |
children | 230a9d79dd84 |
comparison
equal
deleted
inserted
replaced
423:c0fdf3b3f3e6 | 424:faf12767a6f1 |
---|---|
108 t_xs_sldb_node *tmpNode; | 108 t_xs_sldb_node *tmpNode; |
109 | 109 |
110 /* Allocate new node */ | 110 /* Allocate new node */ |
111 tmpNode = (t_xs_sldb_node *) g_malloc0(sizeof(t_xs_sldb_node)); | 111 tmpNode = (t_xs_sldb_node *) g_malloc0(sizeof(t_xs_sldb_node)); |
112 if (!tmpNode) { | 112 if (!tmpNode) { |
113 xs_error("Error allocating new node. Fatal error.\n"); | 113 xs_error(_("Error allocating new node. Fatal error.\n")); |
114 return NULL; | 114 return NULL; |
115 } | 115 } |
116 | 116 |
117 /* Get hash value */ | 117 /* Get hash value */ |
118 linePos = 0; | 118 linePos = 0; |
123 } | 123 } |
124 | 124 |
125 /* Get playtimes */ | 125 /* Get playtimes */ |
126 if (inLine[linePos] != 0) { | 126 if (inLine[linePos] != 0) { |
127 if (inLine[linePos] != '=') { | 127 if (inLine[linePos] != '=') { |
128 xs_error("'=' expected on column #%d.\n", linePos); | 128 xs_error(_("'=' expected on column #%d.\n"), linePos); |
129 xs_sldb_node_free(tmpNode); | 129 xs_sldb_node_free(tmpNode); |
130 return NULL; | 130 return NULL; |
131 } else { | 131 } else { |
132 /* First playtime is after '=' */ | 132 /* First playtime is after '=' */ |
133 savePos = ++linePos; | 133 savePos = ++linePos; |
145 } | 145 } |
146 | 146 |
147 /* Allocate memory for lengths */ | 147 /* Allocate memory for lengths */ |
148 tmpNode->sLengths = (gint *) g_malloc0(tmpNode->nLengths * sizeof(gint)); | 148 tmpNode->sLengths = (gint *) g_malloc0(tmpNode->nLengths * sizeof(gint)); |
149 if (!tmpNode->sLengths) { | 149 if (!tmpNode->sLengths) { |
150 xs_error("Could not allocate memory for node.\n"); | 150 xs_error(_("Could not allocate memory for node.\n")); |
151 xs_sldb_node_free(tmpNode); | 151 xs_sldb_node_free(tmpNode); |
152 return NULL; | 152 return NULL; |
153 } | 153 } |
154 | 154 |
155 /* Read lengths in */ | 155 /* Read lengths in */ |
190 t_xs_sldb_node *tmpNode; | 190 t_xs_sldb_node *tmpNode; |
191 assert(db); | 191 assert(db); |
192 | 192 |
193 /* Try to open the file */ | 193 /* Try to open the file */ |
194 if ((inFile = fopen(dbFilename, "ra")) == NULL) { | 194 if ((inFile = fopen(dbFilename, "ra")) == NULL) { |
195 xs_error("Could not open SongLengthDB '%s'\n", dbFilename); | 195 xs_error(_("Could not open SongLengthDB '%s'\n"), dbFilename); |
196 return -1; | 196 return -1; |
197 } | 197 } |
198 | 198 |
199 /* Read and parse the data */ | 199 /* Read and parse the data */ |
200 lineNum = 0; | 200 lineNum = 0; |
203 gint linePos; | 203 gint linePos; |
204 fgets(inLine, XS_BUF_SIZE, inFile); | 204 fgets(inLine, XS_BUF_SIZE, inFile); |
205 inLine[XS_BUF_SIZE - 1] = 0; | 205 inLine[XS_BUF_SIZE - 1] = 0; |
206 linePos = 0; | 206 linePos = 0; |
207 lineNum++; | 207 lineNum++; |
208 | |
209 xs_findnext(inLine, &linePos); | |
208 | 210 |
209 /* Check if it is datafield */ | 211 /* Check if it is datafield */ |
210 if (isxdigit(inLine[linePos])) { | 212 if (isxdigit(inLine[linePos])) { |
211 /* Check the length of the hash */ | 213 /* Check the length of the hash */ |
212 gint hashLen; | 214 gint hashLen; |
213 for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++); | 215 for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++); |
214 | 216 |
215 if (hashLen != XS_MD5HASH_LENGTH_CH) { | 217 if (hashLen != XS_MD5HASH_LENGTH_CH) { |
216 xs_error("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n", | 218 xs_error(_("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n"), |
217 dbFilename, lineNum); | 219 dbFilename, lineNum); |
218 } else { | 220 } else { |
219 /* Parse and add node to db */ | 221 /* Parse and add node to db */ |
220 if ((tmpNode = xs_sldb_read_entry(inLine)) != NULL) { | 222 if ((tmpNode = xs_sldb_read_entry(inLine)) != NULL) { |
221 xs_sldb_node_insert(db, tmpNode); | 223 xs_sldb_node_insert(db, tmpNode); |
222 } else { | 224 } else { |
223 xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n", | 225 xs_error(_("Invalid entry in SongLengthDB file '%s' line #%d!\n"), |
224 dbFilename, lineNum); | 226 dbFilename, lineNum); |
225 } | 227 } |
226 } | 228 } |
227 } else if ((inLine[linePos] != ';') && (inLine[linePos] != '[')) { | 229 } else if ((inLine[linePos] != ';') && (inLine[linePos] != '[') && (inLine[linePos] != 0)) { |
228 xs_error("Invalid line in SongLengthDB file '%s' line #%d\n", | 230 xs_error(_("Invalid line in SongLengthDB file '%s' line #%d\n"), |
229 dbFilename, lineNum); | 231 dbFilename, lineNum); |
230 } | 232 } |
231 | 233 |
232 } | 234 } |
233 | 235 |