Mercurial > hg > xmms-sid
comparison src/xs_config.c @ 600:7fcaf6b59b20
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 24 Mar 2007 15:11:03 +0000 |
parents | 91ca76e6c23f |
children | 2729318c311b |
comparison
equal
deleted
inserted
replaced
599:1f7a4ce04cb9 | 600:7fcaf6b59b20 |
---|---|
395 | 395 |
396 | 396 |
397 /* Filter exporting and importing. These functions export/import | 397 /* Filter exporting and importing. These functions export/import |
398 * filter settings to/from SIDPlay2 INI-type files. | 398 * filter settings to/from SIDPlay2 INI-type files. |
399 */ | 399 */ |
400 static gboolean xs_fgetitem(gchar *inLine, size_t *linePos, gchar sep, gchar *tmpStr, size_t tmpMax) | |
401 { | |
402 size_t i; | |
403 for (i = 0; i < tmpMax && inLine[*linePos] && | |
404 !isspace(inLine[*linePos]) && | |
405 inLine[*linePos] != sep; i++, (*linePos)++) | |
406 tmpStr[i] = inLine[*linePos]; | |
407 tmpStr[i] = 0; | |
408 xs_findnext(inLine, linePos); | |
409 return (inLine[*linePos] == sep); | |
410 } | |
411 | |
400 static gboolean xs_filters_import(gchar *pcFilename, t_xs_sid2_filter **pFilters, gint *nFilters) | 412 static gboolean xs_filters_import(gchar *pcFilename, t_xs_sid2_filter **pFilters, gint *nFilters) |
401 { | 413 { |
402 FILE *inFile; | 414 FILE *inFile; |
403 gchar inLine[XS_BUF_SIZE], tmpStr[256], *sectName; | 415 gchar inLine[XS_BUF_SIZE], tmpStr[XS_BUF_SIZE]; |
416 gchar *sectName = NULL; | |
404 gboolean sectBegin; | 417 gboolean sectBegin; |
405 size_t lineNum, i; | 418 size_t lineNum, i; |
406 t_xs_sid2_filter *f; | 419 t_xs_sid2_filter *f; |
407 | 420 |
408 fprintf(stderr, "xs_filters_import(%s)\n", pcFilename); | 421 fprintf(stderr, "xs_filters_import(%s)\n", pcFilename); |
419 lineNum++; | 432 lineNum++; |
420 | 433 |
421 xs_findnext(inLine, &linePos); | 434 xs_findnext(inLine, &linePos); |
422 if (isalpha(inLine[linePos]) && sectBegin) { | 435 if (isalpha(inLine[linePos]) && sectBegin) { |
423 /* A new key/value pair */ | 436 /* A new key/value pair */ |
424 i = 0; | 437 if (!xs_fgetitem(inLine, &linePos, '=', tmpStr, XS_BUF_SIZE)) { |
425 while (i < 256 && inLine[linePos] && !isspace(inLine[linePos]) && inLine[linePos] != '=') { | |
426 tmpStr[i++] = inLine[linePos++]; | |
427 } | |
428 tmpStr[i] = 0; | |
429 xs_findnext(inLine, &linePos); | |
430 if (inLine[linePos] != '=') { | |
431 fprintf(stderr, "invalid line: %s [expect =']'", inLine); | 438 fprintf(stderr, "invalid line: %s [expect =']'", inLine); |
432 } else { | 439 } else { |
433 linePos++; | 440 linePos++; |
434 xs_findnext(inLine, &linePos); | 441 xs_findnext(inLine, &linePos); |
435 if (!isdigit(inLine[linePos])) { | 442 if (!strncmp(tmpStr, "points", 6)) { |
436 fprintf(stderr, "expected numeric: %s\n", inLine); | 443 fprintf(stderr, "points=%s\n", &inLine[linePos]); |
444 } else if (!strncmp(tmpStr, "point", 5)) { | |
445 } else if (!strncmp(tmpStr, "type", 4)) { | |
437 } else { | 446 } else { |
438 | 447 fprintf(stderr, "warning: ukn def: %s @ %s\n", |
448 tmpStr, sectName); | |
439 } | 449 } |
440 } | 450 } |
441 } else if (inLine[linePos] == '[') { | 451 } else if (inLine[linePos] == '[') { |
452 /* Check for existing section */ | |
453 if (sectBegin) { | |
454 fprintf(stderr, "filter ends: %s\n", sectName); | |
455 g_free(sectName); | |
456 } | |
457 | |
442 /* New filter(?) section starts */ | 458 /* New filter(?) section starts */ |
443 linePos++; | 459 linePos++; |
444 i = 0; | 460 for (i = 0; i < XS_BUF_SIZE && inLine[linePos] && inLine[linePos] != ']'; i++, linePos++) |
445 while (i < 256 && inLine[linePos] && inLine[linePos] != ']') { | 461 tmpStr[i] = inLine[linePos]; |
446 tmpStr[i++] = inLine[linePos++]; | |
447 } | |
448 tmpStr[i] = 0; | 462 tmpStr[i] = 0; |
449 | 463 |
450 if (inLine[linePos] != ']') { | 464 if (inLine[linePos] != ']') { |
451 fprintf(stderr, "invalid! expected ']': %s\n", inLine); | 465 fprintf(stderr, "invalid! expected ']': %s\n", inLine); |
452 } else { | 466 } else { |
715 break; | 729 break; |
716 } | 730 } |
717 } | 731 } |
718 | 732 |
719 /* Get filter settings */ | 733 /* Get filter settings */ |
720 if (!xs_curve_get_points(XS_CURVE(LUW(""), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { | 734 /* |
721 // FIXME | 735 if (!xs_curve_get_points(XS_CURVE(LUW("")), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { |
722 xs_error(_("Warning: Could not get filter curve widget points!\n")); | 736 xs_error(_("Warning: Could not get filter curve widget points!\n")); |
723 } | 737 } |
738 */ | |
724 | 739 |
725 /* Release lock */ | 740 /* Release lock */ |
726 XS_MUTEX_UNLOCK(xs_cfg); | 741 XS_MUTEX_UNLOCK(xs_cfg); |
727 | 742 |
728 /* Close window */ | 743 /* Close window */ |