comparison src/cdaudio/cddb.c @ 963:9549fea94794 trunk

[svn] Warning fixes from SuSe.
author chainsaw
date Tue, 17 Apr 2007 14:45:19 -0700
parents 597c89a37d07
children
comparison
equal deleted inserted replaced
962:9f0ac3bb82f4 963:9549fea94794
182 gint sock; 182 gint sock;
183 gchar *offsets, *getstr; 183 gchar *offsets, *getstr;
184 gchar buffer[256]; 184 gchar buffer[256];
185 gchar **response; 185 gchar **response;
186 gint i; 186 gint i;
187 gint ret;
187 188
188 if ((sock = cddb_http_open_connection(server, 80)) == 0) 189 if ((sock = cddb_http_open_connection(server, 80)) == 0)
189 return FALSE; 190 return FALSE;
190 191
191 offsets = cddb_generate_offset_string(info); 192 offsets = cddb_generate_offset_string(info);
201 (info->leadout.minute * 60 + info->leadout.second), 202 (info->leadout.minute * 60 + info->leadout.second),
202 cddb_generate_hello_string(), cdda_cfg.cddb_protocol_level); 203 cddb_generate_hello_string(), cdda_cfg.cddb_protocol_level);
203 cddb_log(getstr); 204 cddb_log(getstr);
204 205
205 g_free(offsets); 206 g_free(offsets);
206 write(sock, getstr, strlen(getstr)); 207 ret = write(sock, getstr, strlen(getstr));
208
209 if(ret != strlen(getstr)){
210 g_free(getstr);
211 http_close_connection(sock);
212 return FALSE;
213 }
214
207 g_free(getstr); 215 g_free(getstr);
208 216
209 if (http_read_first_line(sock, buffer, 256) < 0) { 217 if (http_read_first_line(sock, buffer, 256) < 0) {
210 http_close_connection(sock); 218 http_close_connection(sock);
211 return FALSE; 219 return FALSE;
256 } 264 }
257 265
258 static gint 266 static gint
259 cddb_check_protocol_level(const gchar * server) 267 cddb_check_protocol_level(const gchar * server)
260 { 268 {
261 gint level = 0, sock, n; 269 gint level = 0, sock, n, ret;
262 gchar *str, buffer[256]; 270 gchar *str, buffer[256];
263 271
264 if ((sock = cddb_http_open_connection(server, 80)) == 0) 272 if ((sock = cddb_http_open_connection(server, 80)) == 0)
265 return 0; 273 return 0;
266 274
267 str = 275 str =
268 g_strdup_printf 276 g_strdup_printf
269 ("GET /~cddb/cddb.cgi?cmd=stat%s&proto=1 HTTP/1.0\r\n\r\n", 277 ("GET /~cddb/cddb.cgi?cmd=stat%s&proto=1 HTTP/1.0\r\n\r\n",
270 cddb_generate_hello_string()); 278 cddb_generate_hello_string());
271 279
272 write(sock, str, strlen(str)); 280 ret = write(sock, str, strlen(str));
281 if(ret != strlen(str)){
282 g_free(str);
283 http_close_connection(sock);
284 return 0;
285 }
286
287
273 g_free(str); 288 g_free(str);
274 289
275 if ((n = http_read_first_line(sock, buffer, 256)) < 0 || 290 if ((n = http_read_first_line(sock, buffer, 256)) < 0 ||
276 atoi(buffer) != 210) { 291 atoi(buffer) != 210) {
277 if (n > 0) 292 if (n > 0)
306 gchar *discid = NULL, *dartist = NULL, *dtitle = NULL, 321 gchar *discid = NULL, *dartist = NULL, *dtitle = NULL,
307 *dyear = NULL, *dgenre = NULL, *ttitle = NULL; 322 *dyear = NULL, *dgenre = NULL, *ttitle = NULL;
308 gchar *realstr, *temp; 323 gchar *realstr, *temp;
309 gint len, command; 324 gint len, command;
310 gint num, oldnum; 325 gint num, oldnum;
326 gint ret;
311 327
312 if ((sock = cddb_http_open_connection(server, 80)) == 0) 328 if ((sock = cddb_http_open_connection(server, 80)) == 0)
313 return FALSE; 329 return FALSE;
314 330
315 cddb_log("Sending read-command. Disc ID: %08x. Category: %s", 331 cddb_log("Sending read-command. Disc ID: %08x. Category: %s",
320 ("GET /~cddb/cddb.cgi?cmd=cddb+read+%s+%08x%s&proto=%d HTTP/1.0\r\n\r\n", 336 ("GET /~cddb/cddb.cgi?cmd=cddb+read+%s+%08x%s&proto=%d HTTP/1.0\r\n\r\n",
321 cddb_info->category, cddb_info->discid, 337 cddb_info->category, cddb_info->discid,
322 cddb_generate_hello_string(), cdda_cfg.cddb_protocol_level); 338 cddb_generate_hello_string(), cdda_cfg.cddb_protocol_level);
323 cddb_log(readstr); 339 cddb_log(readstr);
324 340
325 write(sock, readstr, strlen(readstr)); 341 ret = write(sock, readstr, strlen(readstr));
342 if(ret != strlen(readstr)){
343 g_free(readstr);
344 http_close_connection(sock);
345 return FALSE;
346 }
347
326 g_free(readstr); 348 g_free(readstr);
327 349
328 if (http_read_first_line(sock, buffer, 256) < 0) { 350 if (http_read_first_line(sock, buffer, 256) < 0) {
329 http_close_connection(sock); 351 http_close_connection(sock);
330 return FALSE; 352 return FALSE;
441 gint sock; 463 gint sock;
442 gchar *getstr; 464 gchar *getstr;
443 gchar buffer[256]; 465 gchar buffer[256];
444 gchar **message; 466 gchar **message;
445 GList *list = NULL; 467 GList *list = NULL;
468 gint ret;
446 469
447 if ((sock = cddb_http_open_connection(server, 80)) == 0) 470 if ((sock = cddb_http_open_connection(server, 80)) == 0)
448 return NULL; 471 return NULL;
449 472
450 cddb_log("Sending sites-command"); 473 cddb_log("Sending sites-command");
453 g_strdup_printf 476 g_strdup_printf
454 ("GET /~cddb/cddb.cgi?cmd=sites%s&proto=%d HTTP/1.0\r\n\r\n", 477 ("GET /~cddb/cddb.cgi?cmd=sites%s&proto=%d HTTP/1.0\r\n\r\n",
455 cddb_generate_hello_string(), protocol_level); 478 cddb_generate_hello_string(), protocol_level);
456 cddb_log(getstr); 479 cddb_log(getstr);
457 480
458 write(sock, getstr, strlen(getstr)); 481 ret = write(sock, getstr, strlen(getstr));
482 if(ret != strlen(getstr)){
483 g_free(getstr);
484 http_close_connection(sock);
485 return NULL;
486 }
459 g_free(getstr); 487 g_free(getstr);
460 488
461 if (http_read_first_line(sock, buffer, 256) < 0) { 489 if (http_read_first_line(sock, buffer, 256) < 0) {
462 http_close_connection(sock); 490 http_close_connection(sock);
463 return NULL; 491 return NULL;