comparison sidlib.c @ 352:4978ff445572

Add lowercase versions of the STIL field names array as sidlib_stil_fields_lc[]. Rename the uppercase array as sidlib_stil_fields_uc[].
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 21 Jan 2020 04:41:49 +0200
parents c2ebcb0f0d62
children f73270cabde2
comparison
equal deleted inserted replaced
351:d54112385845 352:4978ff445572
4 * (C) Copyright 2014-2020 Tecnic Software productions (TNSP) 4 * (C) Copyright 2014-2020 Tecnic Software productions (TNSP)
5 */ 5 */
6 #include "sidlib.h" 6 #include "sidlib.h"
7 #include "th_endian.h" 7 #include "th_endian.h"
8 #include "th_string.h" 8 #include "th_string.h"
9
10
11 const char *sidlib_stil_fields_uc[STF_LAST] =
12 {
13 "NAME",
14 "AUTHOR",
15 "TITLE",
16 "INFO",
17 "ARTIST",
18 "COMMENT",
19
20 // STF_LAST
21 };
22
23
24 const char *sidlib_stil_fields_lc[STF_LAST] =
25 {
26 "name",
27 "author",
28 "title",
29 "info",
30 "artist",
31 "comment",
32
33 // STF_LAST
34 };
9 35
10 36
11 static char *sidlib_strdup_convert(SIDLibChConvCtx *chconv, const char *str) 37 static char *sidlib_strdup_convert(SIDLibChConvCtx *chconv, const char *str)
12 { 38 {
13 if (chconv != NULL) 39 if (chconv != NULL)
750 776
751 PM_LAST 777 PM_LAST
752 }; 778 };
753 779
754 780
755 const char *sidlib_stil_fields[STF_LAST] =
756 {
757 "NAME",
758 "AUTHOR",
759 "TITLE",
760 "INFO",
761 "ARTIST",
762 "COMMENT",
763
764 // STF_LAST
765 };
766
767
768 typedef struct 781 typedef struct
769 { 782 {
770 size_t lineNum; 783 size_t lineNum;
771 ssize_t linePos; 784 ssize_t linePos;
772 int ch, prevMode, nextMode, parseMode; 785 int ch, prevMode, nextMode, parseMode;
773 BOOL lineStart; 786 BOOL lineStart;
774 } SIDLibSTILParserCtx; 787 } SIDLibSTILParserCtx;
775 788
776 789
777 static int sidlib_stildb_get_field(const char *name) 790 static int sidlib_stildb_get_field(const char *field)
778 { 791 {
779 for (int n = 0; n < STF_LAST; n++) 792 for (int n = 0; n < STF_LAST; n++)
780 { 793 {
781 if (strcmp(sidlib_stil_fields[n], name) == 0) 794 if (strcmp(field, sidlib_stil_fields_uc[n]) == 0)
782 return n; 795 return n;
783 } 796 }
784 797
785 return -1; 798 return -1;
786 } 799 }