id3dev 26.01
An ID3 metadata library
Loading...
Searching...
No Matches
id3v2Context.c
Go to the documentation of this file.
1
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <string.h>
15#include <limits.h>
16#include "id3v2/id3v2Context.h"
17#include "id3dependencies/ByteStream/include/byteTypes.h"
18#include "id3dependencies/ByteStream/include/byteStream.h"
19#include "id3dependencies/ByteStream/include/byteInt.h"
20
32unsigned long id3v2djb2(const char *str) {
33 unsigned long hash = 5381;
34 int c = 0;
35
36 while (*str != '\0') {
37 c = (int) *str++;
38 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
39 }
40
41
42 return hash;
43}
44
60Id3v2ContentContext *id3v2CreateContentContext(Id3v2ContextType type, size_t key, size_t max, size_t min) {
61 Id3v2ContentContext *context = malloc(sizeof(Id3v2ContentContext));
62
63 context->type = type;
64 context->key = key;
65 context->max = max;
66 context->min = min;
67
68 return context;
69}
70
80 if (*toDelete) {
81 free(*toDelete);
82 *toDelete = NULL;
83 toDelete = NULL;
84 }
85}
86
92
100void id3v2DeleteContentContext(void *toBeDeleted) {
102}
103
115int id3v2CompareContentContext(const void *first, const void *second) {
116 const Id3v2ContentContext *c1 = (Id3v2ContentContext *) first;
117 const Id3v2ContentContext *c2 = (Id3v2ContentContext *) second;
118 int diff = 0;
119
120 diff = (c1->type < c2->type) ? 0 : c1->type - c2->type;
121 if (diff != 0) {
122 return diff;
123 }
124
125
126 diff = (c1->key < c2->key) ? 0 : (int) (c1->key - c2->key);
127 if (diff != 0) {
128 return diff;
129 }
130
131
132 diff = (c1->min < c2->min) ? 0 : (int) (c1->min - c2->min);
133 if (diff != 0) {
134 return diff;
135 }
136
137 diff = (c1->max < c2->max) ? 0 : (int) (c1->max - c2->max);
138 return diff;
139}
140
151char *id3v2PrintContentContext(const void *toBePrinted) {
152 const Id3v2ContentContext *c = (Id3v2ContentContext *) toBePrinted;
153
154 size_t memCount = snprintf(NULL, 0, "Type: %d, Key: %zu, min: %zu, max: %zu\n", c->type, c->key, c->min, c->max);
155
156 // 40 chars for the below string
157 char *str = malloc(sizeof(long) + sizeof(long) + sizeof(int) + sizeof(Id3v2ContextType) + 40);
158
159 (void) snprintf(str, memCount + 1, "Type: %d, Key: %zu, min: %zu, max: %zu\n", c->type, c->key, c->min, c->max);
160
161 return str;
162}
163
174void *id3v2CopyContentContext(const void *toBeCopied) {
175 Id3v2ContentContext *copy = (Id3v2ContentContext *) toBeCopied;
176 Id3v2ContentContext *ret = malloc(sizeof(Id3v2ContentContext));
177
178 ret->key = copy->key;
179 ret->max = copy->max;
180 ret->min = copy->min;
181 ret->type = copy->type;
182
183 return (void *) ret;
184}
185
194void id3v2DeleteContentContextList(void *toBeDeleted) {
195 listFree((List *) toBeDeleted);
196}
197
208char *id3v2PrintContentContextList(const void *toBePrinted) {
209 return listToString((List *) toBePrinted);
210}
211
222void *id3v2CopyContentContextList(const void *toBeCopied) {
223 return listDeepCopy((List *) toBeCopied);
224}
225
226
232
246
247 // encoding
248 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
249 listInsertBack(l, toAdd);
250
251 // text
252 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
253 listInsertBack(l, toAdd);
254
255 return l;
256}
257
271
272 // desc
273 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
274 listInsertBack(l, toAdd);
275
276 // desc
277 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
278 listInsertBack(l, toAdd);
279
280 // text
281 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
282 listInsertBack(l, toAdd);
283
284 return l;
285}
286
298
299 // url
300 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("url"), UINT_MAX, 1);
301 listInsertBack(l, toAdd);
302
303 return l;
304}
305
321
322 // encoding
323 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
324 listInsertBack(l, toAdd);
325
326 // desc
327 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
328 listInsertBack(l, toAdd);
329
330 // url
331 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("url"), UINT_MAX, 1);
332 listInsertBack(l, toAdd);
333
334 return l;
335}
336
352List *id3v2CreateAttachedPictureFrameContext(unsigned int version) {
355
356 // encoding
357 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
358 listInsertBack(l, toAdd);
359
360 // image format
361 switch (version) {
363 // format is $xx xx xx
364 toAdd = (void *) id3v2CreateContentContext(noEncoding_context, id3v2djb2("format"), 3, 1);
365 break;
366
369 // format is latin1
370 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("format"), UINT_MAX, 1);
371 break;
372
373 default:
374 // something it wrong
375 toAdd = (void *) id3v2CreateContentContext(unknown_context, id3v2djb2("format"), UINT_MAX, 1);
376 break;
377 }
378
379 listInsertBack(l, toAdd);
380
381 // picture type
382 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("type"), 1, 1);
383 listInsertBack(l, toAdd);
384
385 // desc
386 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
387 listInsertBack(l, toAdd);
388
389 // data
390 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
391 listInsertBack(l, toAdd);
392
393 return l;
394}
395
409
410 // data
411 void *toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
412 listInsertBack(l, toAdd);
413
414 return l;
415}
416
432
433 // identifier
434 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("identifier"), UINT_MAX, 1);
435 listInsertBack(l, toAdd);
436
437 // preview start
438 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("start"), 2, 2);
439 listInsertBack(l, toAdd);
440
441 // length
442 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("length"), 2, 2);
443 listInsertBack(l, toAdd);
444
445 // data
446 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
447 listInsertBack(l, toAdd);
448
449 return l;
450}
451
467
468 // encoding
469 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
470 listInsertBack(l, toAdd);
471
472 // language
473 toAdd = (void *) id3v2CreateContentContext(noEncoding_context, id3v2djb2("language"), 3, 1);
474 listInsertBack(l, toAdd);
475
476 // desc
477 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
478 listInsertBack(l, toAdd);
479
480 // text
481 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
482 listInsertBack(l, toAdd);
483
484 return l;
485}
486
506
507 // encoding
508 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
509 listInsertBack(l, toAdd);
510
511 // price
512 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("price"), UINT_MAX, 1);
513 listInsertBack(l, toAdd);
514
515 // date
516 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("date"), 8, 1);
517 listInsertBack(l, toAdd);
518
519 // url
520 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("url"), UINT_MAX, 1);
521 listInsertBack(l, toAdd);
522
523 // received as (type)
524 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("type"), 1, 1);
525 listInsertBack(l, toAdd);
526
527 // name
528 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("name"), UINT_MAX, 1);
529 listInsertBack(l, toAdd);
530
531 // desc
532 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
533 listInsertBack(l, toAdd);
534
535 // format
536 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("format"), UINT_MAX, 1);
537 listInsertBack(l, toAdd);
538
539 // data
540 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
541 listInsertBack(l, toAdd);
542
543 return l;
544}
545
562
563 // identifier
564 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("identifier"), UINT_MAX, 1);
565 listInsertBack(l, toAdd);
566
567 // content
568 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("content"), UINT_MAX, 1);
569 listInsertBack(l, toAdd);
570
571 // data
572 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
573 listInsertBack(l, toAdd);
574
575 return l;
576}
577
593
594 // identifier
595 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("identifier"), UINT_MAX, 1);
596 listInsertBack(l, toAdd);
597
598 // symbol
599 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("symbol"), 1, 1);
600 listInsertBack(l, toAdd);
601
602 // data
603 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
604 listInsertBack(l, toAdd);
605
606 return l;
607}
608
623
624 // data
625 void *toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), 804, 1);
626 listInsertBack(l, toAdd);
627
628 return l;
629}
630
645
646 // data
647 void *toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, sizeof(uint32_t));
648 listInsertBack(l, toAdd);
649
650
651 return l;
652}
653
672List *id3v2CreateEqualizationFrameContext(unsigned int version) {
675 void *toAdd = NULL;
676
677 switch (version) {
678 // EQU and EQUA
681
682 // adjustment
683 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("adjustment"), 1, 1);
684 listInsertBack(l, toAdd);
685
686 // increment decrement
687 toAdd = (void *) id3v2CreateContentContext(bit_context, id3v2djb2("unary"), 1, 1);
688 listInsertBack(l, toAdd);
689
690 // frequency
691 toAdd = (void *) id3v2CreateContentContext(bit_context, id3v2djb2("frequency"), 15, 15);
692 listInsertBack(l, toAdd);
693
694 // volume (adjustment dependant)
695 toAdd = (void *) id3v2CreateContentContext(adjustment_context, id3v2djb2("volume"), UINT_MAX, 1);
696 listInsertBack(l, toAdd);
697
698 // iter through the last 3 limit is int max but a frames data will 100% run out before this
699 toAdd = (void *) id3v2CreateContentContext(iter_context, id3v2djb2("iter"), UINT_MAX, 1);
700 listInsertBack(l, toAdd);
701 break;
702
703 // EQU2
705
706 // symbol
707 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("symbol"), 1, 1);
708 listInsertBack(l, toAdd);
709
710 // identifier
711 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("identifier"), UINT_MAX, 1);
712 listInsertBack(l, toAdd);
713
714 // volume
715 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("volume"), 2, 2);
716 listInsertBack(l, toAdd);
717
718 // iter through the last 2 limit is int max but a frames data will 100% run out before this
719 toAdd = (void *) id3v2CreateContentContext(iter_context, id3v2djb2("iter"), UINT_MAX, 2);
720 listInsertBack(l, toAdd);
721 break;
722
723 default:
724 toAdd = (void *) id3v2CreateContentContext(unknown_context, id3v2djb2("unknown"), 1, 1);
725 listInsertBack(l, toAdd);
726 break;
727 }
728
729 return l;
730}
731
748
749 // select format
750 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("symbol"), 1, 1);
751 listInsertBack(l, toAdd);
752
753 // type
754 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("type"), 1, 1);
755 listInsertBack(l, toAdd);
756
757 // stamp
758 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("stamp"), 4, 4);
759 listInsertBack(l, toAdd);
760
761 // iter from the type onward
762 toAdd = (void *) id3v2CreateContentContext(iter_context, id3v2djb2("iter"), UINT_MAX, 1);
763 listInsertBack(l, toAdd);
764
765 return l;
766}
767
786
787 // encoding
788 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
789 listInsertBack(l, toAdd);
790
791 // format
792 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("format"), UINT_MAX, 1);
793 listInsertBack(l, toAdd);
794
795 // file name
796 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("name"), UINT_MAX, 1);
797 listInsertBack(l, toAdd);
798
799 // desc
800 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
801 listInsertBack(l, toAdd);
802
803 // data
804 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
805 listInsertBack(l, toAdd);
806
807 return l;
808}
809
827
828 // encoding
829 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
830 listInsertBack(l, toAdd);
831
832 // name
833 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("name"), UINT_MAX, 1);
834 listInsertBack(l, toAdd);
835
836 // text
837 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
838 listInsertBack(l, toAdd);
839
840 // iter from name onward
841 toAdd = (void *) id3v2CreateContentContext(iter_context, id3v2djb2("iter"), UINT_MAX, 1);
842 listInsertBack(l, toAdd);
843
844 return l;
845}
846
863
864 // url
865 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("url"), UINT_MAX, 1);
866 listInsertBack(l, toAdd);
867
868 // data
869 toAdd = (void *) id3v2CreateContentContext(noEncoding_context, id3v2djb2("data"), UINT_MAX, 1);
870 listInsertBack(l, toAdd);
871
872 return l;
873}
874
890
891 // data
892 void *toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
893 listInsertBack(l, toAdd);
894
895 return l;
896}
897
914
915 // data
916 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), UINT_MAX, 1);
917 listInsertBack(l, toAdd);
918
919 // price
920 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("price"), UINT_MAX, 1);
921 listInsertBack(l, toAdd);
922
923 // date
924 toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("date"), 8, 8);
925 listInsertBack(l, toAdd);
926
927 // date
928 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("name"), UINT_MAX, 1);
929 listInsertBack(l, toAdd);
930
931 return l;
932}
933
950
951 // email
952 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("identifier"), UINT_MAX, 1);
953 listInsertBack(l, toAdd);
954
955 // symbol / rating
956 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("symbol"), 1, 1);
957 listInsertBack(l, toAdd);
958
959 // counter
960 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
961 listInsertBack(l, toAdd);
962
963 return l;
964}
965
981
982 // format
983 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("format"), 1, 1);
984 listInsertBack(l, toAdd);
985
986 // stamp
987 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("stamp"), 4, 4);
988 listInsertBack(l, toAdd);
989
990 return l;
991}
992
1009
1010 // email
1011 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("identifier"), UINT_MAX, 1);
1012 listInsertBack(l, toAdd);
1013
1014 // data
1015 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
1016 listInsertBack(l, toAdd);
1017
1018 return l;
1019}
1020
1037
1038 // buffer size
1039 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("buffer"), 3, 3);
1040 listInsertBack(l, toAdd);
1041
1042 // bit
1043 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("flag"), 1, 1);
1044 listInsertBack(l, toAdd);
1045
1046 // offset
1047 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("offset"), 4, 0);
1048 listInsertBack(l, toAdd);
1049
1050 return l;
1051}
1052
1071
1072 // data
1073 void *toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
1074 listInsertBack(l, toAdd);
1075
1076 return l;
1077}
1078
1097
1098 // left
1099 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("left"), 2, 2);
1100 listInsertBack(l, toAdd);
1101
1102 // right
1103 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("right"), 2, 2);
1104 listInsertBack(l, toAdd);
1105
1106 // bounce left
1107 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("bounce left"), 1, 1);
1108 listInsertBack(l, toAdd);
1109
1110 // bounce right
1111 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("bounce right"), 1, 1);
1112 listInsertBack(l, toAdd);
1113
1114 // feedback left 2 left
1115 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("feedback ll"), 1, 1);
1116 listInsertBack(l, toAdd);
1117
1118 // feedback left 2 right
1119 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("feedback lr"), 1, 1);
1120 listInsertBack(l, toAdd);
1121
1122 // feedback right 2 right
1123 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("feedback rr"), 1, 1);
1124 listInsertBack(l, toAdd);
1125
1126 // feedback right 2 left
1127 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("feedback rl"), 1, 1);
1128 listInsertBack(l, toAdd);
1129
1130 // premix l
1131 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("p left"), 1, 1);
1132 listInsertBack(l, toAdd);
1133
1134 // premix r
1135 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("p right"), 1, 1);
1136 listInsertBack(l, toAdd);
1137 return l;
1138}
1139
1155
1156 // offset
1157 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("offset"), 4, 4);
1158 listInsertBack(l, toAdd);
1159
1160 return l;
1161}
1162
1179
1180 // symbol
1181 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("symbol"), 1, 1);
1182 listInsertBack(l, toAdd);
1183
1184 // data
1185 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
1186 listInsertBack(l, toAdd);
1187
1188 return l;
1189}
1190
1210
1211 // encoding
1212 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
1213 listInsertBack(l, toAdd);
1214
1215 // language
1216 toAdd = (void *) id3v2CreateContentContext(noEncoding_context, id3v2djb2("language"), 3, 3);
1217 listInsertBack(l, toAdd);
1218
1219 // format
1220 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("format"), 1, 1);
1221 listInsertBack(l, toAdd);
1222
1223 // symbol
1224 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("symbol"), 1, 1);
1225 listInsertBack(l, toAdd);
1226
1227 // desc
1228 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
1229 listInsertBack(l, toAdd);
1230
1231 // text
1232 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
1233 listInsertBack(l, toAdd);
1234
1235 // stamp
1236 toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("stamp"), 4, 4);
1237 listInsertBack(l, toAdd);
1238
1239 // iter
1240 toAdd = (void *) id3v2CreateContentContext(iter_context, id3v2djb2("iter"), UINT_MAX, 5);
1241 listInsertBack(l, toAdd);
1242
1243 return l;
1244}
1245
1263
1264 // format
1265 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("format"), 1, 1);
1266 listInsertBack(l, toAdd);
1267
1268 // data
1269 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), UINT_MAX, 1);
1270 listInsertBack(l, toAdd);
1271
1272 return l;
1273}
1274
1291
1292 // url
1293 void *toAdd = (void *) id3v2CreateContentContext(latin1Encoding_context, id3v2djb2("url"), UINT_MAX, 1);
1294 listInsertBack(l, toAdd);
1295
1296 // data
1297 toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("data"), 64, 1);
1298 listInsertBack(l, toAdd);
1299
1300 return l;
1301}
1302
1320
1321 // encoding
1322 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
1323 listInsertBack(l, toAdd);
1324
1325 // language
1326 toAdd = (void *) id3v2CreateContentContext(noEncoding_context, id3v2djb2("language"), 3, 1);
1327 listInsertBack(l, toAdd);
1328
1329 // text
1330 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
1331 listInsertBack(l, toAdd);
1332
1333 return l;
1334}
1335
1336
1355
1356 // encoding
1357 void *toAdd = (void *) id3v2CreateContentContext(numeric_context, id3v2djb2("encoding"), 1, 1);
1358 listInsertBack(l, toAdd);
1359
1360 // language
1361 toAdd = (void *) id3v2CreateContentContext(noEncoding_context, id3v2djb2("language"), 3, 3);
1362 listInsertBack(l, toAdd);
1363
1364 // desc
1365 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("desc"), UINT_MAX, 1);
1366 listInsertBack(l, toAdd);
1367
1368 // text
1369 toAdd = (void *) id3v2CreateContentContext(encodedString_context, id3v2djb2("text"), UINT_MAX, 1);
1370 listInsertBack(l, toAdd);
1371
1372 return l;
1373}
1374
1390
1391 // encoding
1392 void *toAdd = (void *) id3v2CreateContentContext(binary_context, id3v2djb2("?"), UINT_MAX, 1);
1393 listInsertBack(l, toAdd);
1394
1395 return l;
1396}
1397
1416HashTable *id3v2CreateDefaultIdentifierContextPairings(unsigned int version) {
1417 size_t minFrameContexts = 66;
1418 HashTable *table = hashTableCreate(minFrameContexts, id3v2DeleteContentContextList, id3v2PrintContentContextList,
1420 List *l = NULL;
1421
1422 switch (version) {
1424
1425 hashTableInsert(table, "BUF", (l = id3v2CreateRecommendedBufferSizeFrameContext()));
1426 listFree(l);
1427
1428 hashTableInsert(table, "CNT", (l = id3v2CreatePlayCounterFrameContext()));
1429 listFree(l);
1430
1431 hashTableInsert(table, "COM", (l = id3v2CreateCommentFrameContext()));
1432 listFree(l);
1433 hashTableInsert(table, "CRA", (l = id3v2CreateAudioEncryptionFrameContext()));
1434 listFree(l);
1435 hashTableInsert(table, "CRM", (l = id3v2CreateEncryptedMetaFrameContext()));
1436 listFree(l);
1437
1438 hashTableInsert(table, "ETC", (l = id3v2CreateEventTimingCodesFrameContext()));
1439 listFree(l);
1440 hashTableInsert(table, "EQU", (l = id3v2CreateEqualizationFrameContext(version)));
1441 listFree(l);
1442
1443 hashTableInsert(table, "GEO", (l = id3v2CreateGeneralEncapsulatedObjectFrameContext()));
1444 listFree(l);
1445
1446 hashTableInsert(table, "IPL", (l = id3v2CreateInvolvedPeopleListFrameContext()));
1447 listFree(l);
1448
1449 hashTableInsert(table, "LNK", (l = id3v2CreateLinkedInformationFrameContext()));
1450 listFree(l);
1451
1452 hashTableInsert(table, "MCI", (l = id3v2CreateMusicCDIdentifierFrameContext()));
1453 listFree(l);
1454 hashTableInsert(table, "MLL", (l = id3v2CreateMPEGLocationLookupTableFrameContext()));
1455 listFree(l);
1456
1457 hashTableInsert(table, "PIC", (l = id3v2CreateAttachedPictureFrameContext(version)));
1458 listFree(l);
1459 hashTableInsert(table, "POP", (l = id3v2CreatePopularimeterFrameContext()));
1460 listFree(l);
1461
1462 hashTableInsert(table, "REV", (l = id3v2CreateReverbFrameContext()));
1463 listFree(l);
1464 hashTableInsert(table, "RVA", (l = id3v2CreateRelativeVolumeAdjustmentFrameContext(version)));
1465 listFree(l);
1466
1467 hashTableInsert(table, "SLT", (l = id3v2CreateSynchronisedLyricFrameContext()));
1468 listFree(l);
1469 hashTableInsert(table, "STC", (l = id3v2CreateSynchronisedTempoCodesFrameContext()));
1470 listFree(l);
1471
1472 hashTableInsert(table, "TAL", (l = id3v2CreateTextFrameContext()));
1473 listFree(l);
1474 hashTableInsert(table, "TBP", (l = id3v2CreateTextFrameContext()));
1475 listFree(l);
1476 hashTableInsert(table, "TCM", (l = id3v2CreateTextFrameContext()));
1477 listFree(l);
1478 hashTableInsert(table, "TCO", (l = id3v2CreateTextFrameContext()));
1479 listFree(l);
1480 hashTableInsert(table, "TCR", (l = id3v2CreateTextFrameContext()));
1481 listFree(l);
1482 hashTableInsert(table, "TDA", (l = id3v2CreateTextFrameContext()));
1483 listFree(l);
1484 hashTableInsert(table, "TDY", (l = id3v2CreateTextFrameContext()));
1485 listFree(l);
1486 hashTableInsert(table, "TEN", (l = id3v2CreateTextFrameContext()));
1487 listFree(l);
1488 hashTableInsert(table, "TFT", (l = id3v2CreateTextFrameContext()));
1489 listFree(l);
1490 hashTableInsert(table, "TIM", (l = id3v2CreateTextFrameContext()));
1491 listFree(l);
1492 hashTableInsert(table, "TKE", (l = id3v2CreateTextFrameContext()));
1493 listFree(l);
1494 hashTableInsert(table, "TLA", (l = id3v2CreateTextFrameContext()));
1495 listFree(l);
1496 hashTableInsert(table, "TLE", (l = id3v2CreateTextFrameContext()));
1497 listFree(l);
1498 hashTableInsert(table, "TMT", (l = id3v2CreateTextFrameContext()));
1499 listFree(l);
1500 hashTableInsert(table, "TOA", (l = id3v2CreateTextFrameContext()));
1501 listFree(l);
1502 hashTableInsert(table, "TOF", (l = id3v2CreateTextFrameContext()));
1503 listFree(l);
1504 hashTableInsert(table, "TOL", (l = id3v2CreateTextFrameContext()));
1505 listFree(l);
1506 hashTableInsert(table, "TOR", (l = id3v2CreateTextFrameContext()));
1507 listFree(l);
1508 hashTableInsert(table, "TOT", (l = id3v2CreateTextFrameContext()));
1509 listFree(l);
1510 hashTableInsert(table, "TP1", (l = id3v2CreateTextFrameContext()));
1511 listFree(l);
1512 hashTableInsert(table, "TP2", (l = id3v2CreateTextFrameContext()));
1513 listFree(l);
1514 hashTableInsert(table, "TP3", (l = id3v2CreateTextFrameContext()));
1515 listFree(l);
1516 hashTableInsert(table, "TP4", (l = id3v2CreateTextFrameContext()));
1517 listFree(l);
1518 hashTableInsert(table, "TPA", (l = id3v2CreateTextFrameContext()));
1519 listFree(l);
1520 hashTableInsert(table, "TPB", (l = id3v2CreateTextFrameContext()));
1521 listFree(l);
1522 hashTableInsert(table, "TRC", (l = id3v2CreateTextFrameContext()));
1523 listFree(l);
1524 hashTableInsert(table, "TRD", (l = id3v2CreateTextFrameContext()));
1525 listFree(l);
1526 hashTableInsert(table, "TRK", (l = id3v2CreateTextFrameContext()));
1527 listFree(l);
1528 hashTableInsert(table, "TSI", (l = id3v2CreateTextFrameContext()));
1529 listFree(l);
1530 hashTableInsert(table, "TSS", (l = id3v2CreateTextFrameContext()));
1531 listFree(l);
1532 hashTableInsert(table, "TT1", (l = id3v2CreateTextFrameContext()));
1533 listFree(l);
1534 hashTableInsert(table, "TT2", (l = id3v2CreateTextFrameContext()));
1535 listFree(l);
1536 hashTableInsert(table, "TT3", (l = id3v2CreateTextFrameContext()));
1537 listFree(l);
1538 hashTableInsert(table, "TXT", (l = id3v2CreateTextFrameContext()));
1539 listFree(l);
1540 hashTableInsert(table, "TXX", (l = id3v2CreateUserDefinedTextFrameContext()));
1541 listFree(l);
1542 hashTableInsert(table, "TYE", (l = id3v2CreateTextFrameContext()));
1543 listFree(l);
1544
1545 hashTableInsert(table, "UFI", (l = id3v2CreateUniqueFileIdentifierFrameContext()));
1546 listFree(l);
1547 hashTableInsert(table, "ULT", (l = id3v2CreateUnsynchronisedLyricFrameContext()));
1548 listFree(l);
1549
1550 hashTableInsert(table, "WAF", (l = id3v2CreateURLFrameContext()));
1551 listFree(l);
1552 hashTableInsert(table, "WAR", (l = id3v2CreateURLFrameContext()));
1553 listFree(l);
1554 hashTableInsert(table, "WAS", (l = id3v2CreateURLFrameContext()));
1555 listFree(l);
1556 hashTableInsert(table, "WCM", (l = id3v2CreateURLFrameContext()));
1557 listFree(l);
1558 hashTableInsert(table, "WCP", (l = id3v2CreateURLFrameContext()));
1559 listFree(l);
1560 hashTableInsert(table, "WPB", (l = id3v2CreateURLFrameContext()));
1561 listFree(l);
1562 hashTableInsert(table, "WXX", (l = id3v2CreateUserDefinedURLFrameContext()));
1563 listFree(l);
1564
1565 break;
1567
1568 hashTableInsert(table, "AENC", (l = id3v2CreateAudioEncryptionFrameContext()));
1569 listFree(l);
1570 hashTableInsert(table, "APIC", (l = id3v2CreateAttachedPictureFrameContext(version)));
1571 listFree(l);
1572
1573 hashTableInsert(table, "COMM", (l = id3v2CreateCommentFrameContext()));
1574 listFree(l);
1575 hashTableInsert(table, "COMR", (l = id3v2CreateCommercialFrameContext()));
1576 listFree(l);
1577
1578 hashTableInsert(table, "ENCR", (l = id3v2CreateRegistrationFrameContext()));
1579 listFree(l);
1580 hashTableInsert(table, "EQUA", (l = id3v2CreateEqualizationFrameContext(version)));
1581 listFree(l);
1582 hashTableInsert(table, "ETCO", (l = id3v2CreateEventTimingCodesFrameContext()));
1583 listFree(l);
1584
1585 hashTableInsert(table, "GEOB", (l = id3v2CreateGeneralEncapsulatedObjectFrameContext()));
1586 listFree(l);
1587 hashTableInsert(table, "GRID", (l = id3v2CreateRegistrationFrameContext()));
1588 listFree(l);
1589
1590 hashTableInsert(table, "IPLS", (l = id3v2CreateInvolvedPeopleListFrameContext()));
1591 listFree(l);
1592
1593 hashTableInsert(table, "LINK", (l = id3v2CreateLinkedInformationFrameContext()));
1594 listFree(l);
1595
1596 hashTableInsert(table, "MCDI", (l = id3v2CreateMusicCDIdentifierFrameContext()));
1597 listFree(l);
1598 hashTableInsert(table, "MLLT", (l = id3v2CreateMPEGLocationLookupTableFrameContext()));
1599 listFree(l);
1600
1601 hashTableInsert(table, "OWNE", (l = id3v2CreateOwnershipFrameContext()));
1602 listFree(l);
1603
1604 hashTableInsert(table, "PRIV", (l = id3v2CreatePrivateFrameContext()));
1605 listFree(l);
1606 hashTableInsert(table, "PCNT", (l = id3v2CreatePlayCounterFrameContext()));
1607 listFree(l);
1608 hashTableInsert(table, "POPM", (l = id3v2CreatePopularimeterFrameContext()));
1609 listFree(l);
1610 hashTableInsert(table, "POSS", (l = id3v2CreatePositionSynchronisationFrameContext()));
1611 listFree(l);
1612
1613 hashTableInsert(table, "RBUF", (l = id3v2CreateRecommendedBufferSizeFrameContext()));
1614 listFree(l);
1615 hashTableInsert(table, "RVAD", (l = id3v2CreateRelativeVolumeAdjustmentFrameContext(version)));
1616 listFree(l);
1617 hashTableInsert(table, "RVRB", (l = id3v2CreateReverbFrameContext()));
1618 listFree(l);
1619
1620 hashTableInsert(table, "SYLT", (l = id3v2CreateSynchronisedLyricFrameContext()));
1621 listFree(l);
1622 hashTableInsert(table, "SYTC", (l = id3v2CreateSynchronisedTempoCodesFrameContext()));
1623 listFree(l);
1624
1625 hashTableInsert(table, "TALB", (l = id3v2CreateTextFrameContext()));
1626 listFree(l);
1627 hashTableInsert(table, "TBPM", (l = id3v2CreateTextFrameContext()));
1628 listFree(l);
1629 hashTableInsert(table, "TCOM", (l = id3v2CreateTextFrameContext()));
1630 listFree(l);
1631 hashTableInsert(table, "TCON", (l = id3v2CreateTextFrameContext()));
1632 listFree(l);
1633 hashTableInsert(table, "TCOP", (l = id3v2CreateTextFrameContext()));
1634 listFree(l);
1635 hashTableInsert(table, "TDAT", (l = id3v2CreateTextFrameContext()));
1636 listFree(l);
1637 hashTableInsert(table, "TDLY", (l = id3v2CreateTextFrameContext()));
1638 listFree(l);
1639 hashTableInsert(table, "TENC", (l = id3v2CreateTextFrameContext()));
1640 listFree(l);
1641 hashTableInsert(table, "TEXT", (l = id3v2CreateTextFrameContext()));
1642 listFree(l);
1643 hashTableInsert(table, "TFLT", (l = id3v2CreateTextFrameContext()));
1644 listFree(l);
1645 hashTableInsert(table, "TIME", (l = id3v2CreateTextFrameContext()));
1646 listFree(l);
1647 hashTableInsert(table, "TIT1", (l = id3v2CreateTextFrameContext()));
1648 listFree(l);
1649 hashTableInsert(table, "TIT2", (l = id3v2CreateTextFrameContext()));
1650 listFree(l);
1651 hashTableInsert(table, "TIT3", (l = id3v2CreateTextFrameContext()));
1652 listFree(l);
1653 hashTableInsert(table, "TKEY", (l = id3v2CreateTextFrameContext()));
1654 listFree(l);
1655 hashTableInsert(table, "TLAN", (l = id3v2CreateTextFrameContext()));
1656 listFree(l);
1657 hashTableInsert(table, "TLEN", (l = id3v2CreateTextFrameContext()));
1658 listFree(l);
1659 hashTableInsert(table, "TMED", (l = id3v2CreateTextFrameContext()));
1660 listFree(l);
1661 hashTableInsert(table, "TOAL", (l = id3v2CreateTextFrameContext()));
1662 listFree(l);
1663 hashTableInsert(table, "TOFN", (l = id3v2CreateTextFrameContext()));
1664 listFree(l);
1665 hashTableInsert(table, "TOLY", (l = id3v2CreateTextFrameContext()));
1666 listFree(l);
1667 hashTableInsert(table, "TOPE", (l = id3v2CreateTextFrameContext()));
1668 listFree(l);
1669 hashTableInsert(table, "TORY", (l = id3v2CreateTextFrameContext()));
1670 listFree(l);
1671 hashTableInsert(table, "TOWN", (l = id3v2CreateTextFrameContext()));
1672 listFree(l);
1673 hashTableInsert(table, "TPE1", (l = id3v2CreateTextFrameContext()));
1674 listFree(l);
1675 hashTableInsert(table, "TPE2", (l = id3v2CreateTextFrameContext()));
1676 listFree(l);
1677 hashTableInsert(table, "TPE3", (l = id3v2CreateTextFrameContext()));
1678 listFree(l);
1679 hashTableInsert(table, "TPE4", (l = id3v2CreateTextFrameContext()));
1680 listFree(l);
1681 hashTableInsert(table, "TPOS", (l = id3v2CreateTextFrameContext()));
1682 listFree(l);
1683 hashTableInsert(table, "TPUB", (l = id3v2CreateTextFrameContext()));
1684 listFree(l);
1685 hashTableInsert(table, "TRCK", (l = id3v2CreateTextFrameContext()));
1686 listFree(l);
1687 hashTableInsert(table, "TRDA", (l = id3v2CreateTextFrameContext()));
1688 listFree(l);
1689 hashTableInsert(table, "TRSN", (l = id3v2CreateTextFrameContext()));
1690 listFree(l);
1691 hashTableInsert(table, "TRSO", (l = id3v2CreateTextFrameContext()));
1692 listFree(l);
1693 hashTableInsert(table, "TSIZ", (l = id3v2CreateTextFrameContext()));
1694 listFree(l);
1695 hashTableInsert(table, "TSRC", (l = id3v2CreateTextFrameContext()));
1696 listFree(l);
1697 hashTableInsert(table, "TSSE", (l = id3v2CreateTextFrameContext()));
1698 listFree(l);
1699 hashTableInsert(table, "TYER", (l = id3v2CreateTextFrameContext()));
1700 listFree(l);
1701 hashTableInsert(table, "TXXX", (l = id3v2CreateUserDefinedTextFrameContext()));
1702 listFree(l);
1703
1704 hashTableInsert(table, "UFID", (l = id3v2CreateUniqueFileIdentifierFrameContext()));
1705 listFree(l);
1706 hashTableInsert(table, "USER", (l = id3v2CreateTermsOfUseFrameContext()));
1707 listFree(l);
1708 hashTableInsert(table, "USLT", (l = id3v2CreateUnsynchronisedLyricFrameContext()));
1709 listFree(l);
1710
1711 hashTableInsert(table, "WCOM", (l = id3v2CreateURLFrameContext()));
1712 listFree(l);
1713 hashTableInsert(table, "WCOP", (l = id3v2CreateURLFrameContext()));
1714 listFree(l);
1715 hashTableInsert(table, "WOAF", (l = id3v2CreateURLFrameContext()));
1716 listFree(l);
1717 hashTableInsert(table, "WOAR", (l = id3v2CreateURLFrameContext()));
1718 listFree(l);
1719 hashTableInsert(table, "WOAS", (l = id3v2CreateURLFrameContext()));
1720 listFree(l);
1721 hashTableInsert(table, "WORS", (l = id3v2CreateURLFrameContext()));
1722 listFree(l);
1723 hashTableInsert(table, "WPAY", (l = id3v2CreateURLFrameContext()));
1724 listFree(l);
1725 hashTableInsert(table, "WPUB", (l = id3v2CreateURLFrameContext()));
1726 listFree(l);
1727 hashTableInsert(table, "WXXX", (l = id3v2CreateUserDefinedURLFrameContext()));
1728 listFree(l);
1729
1730 break;
1732
1733 hashTableInsert(table, "AENC", (l = id3v2CreateAudioEncryptionFrameContext()));
1734 listFree(l);
1735 hashTableInsert(table, "APIC", (l = id3v2CreateAttachedPictureFrameContext(version)));
1736 listFree(l);
1737 hashTableInsert(table, "ASPI", (l = id3v2CreateAudioSeekPointIndexFrameContext()));
1738 listFree(l);
1739
1740 hashTableInsert(table, "COMM", (l = id3v2CreateCommentFrameContext()));
1741 listFree(l);
1742 hashTableInsert(table, "COMR", (l = id3v2CreateCommercialFrameContext()));
1743 listFree(l);
1744
1745 hashTableInsert(table, "ENCR", (l = id3v2CreateRegistrationFrameContext()));
1746 listFree(l);
1747 hashTableInsert(table, "EQU2", (l = id3v2CreateEqualizationFrameContext(version)));
1748 listFree(l);
1749 hashTableInsert(table, "ETCO", (l = id3v2CreateEventTimingCodesFrameContext()));
1750 listFree(l);
1751
1752 hashTableInsert(table, "GEOB", (l = id3v2CreateGeneralEncapsulatedObjectFrameContext()));
1753 listFree(l);
1754 hashTableInsert(table, "GRID", (l = id3v2CreateRegistrationFrameContext()));
1755 listFree(l);
1756
1757 hashTableInsert(table, "LINK", (l = id3v2CreateLinkedInformationFrameContext()));
1758 listFree(l);
1759
1760 hashTableInsert(table, "MCDI", (l = id3v2CreateMusicCDIdentifierFrameContext()));
1761 listFree(l);
1762 hashTableInsert(table, "MLLT", (l = id3v2CreateMPEGLocationLookupTableFrameContext()));
1763 listFree(l);
1764
1765 hashTableInsert(table, "OWNE", (l = id3v2CreateOwnershipFrameContext()));
1766 listFree(l);
1767
1768 hashTableInsert(table, "PRIV", (l = id3v2CreatePrivateFrameContext()));
1769 listFree(l);
1770 hashTableInsert(table, "PCNT", (l = id3v2CreatePlayCounterFrameContext()));
1771 listFree(l);
1772 hashTableInsert(table, "POPM", (l = id3v2CreatePopularimeterFrameContext()));
1773 listFree(l);
1774 hashTableInsert(table, "POSS", (l = id3v2CreatePositionSynchronisationFrameContext()));
1775 listFree(l);
1776
1777 hashTableInsert(table, "RBUF", (l = id3v2CreateRecommendedBufferSizeFrameContext()));
1778 listFree(l);
1779 hashTableInsert(table, "RVA2", (l = id3v2CreateRelativeVolumeAdjustmentFrameContext(version)));
1780 listFree(l);
1781 hashTableInsert(table, "RVRB", (l = id3v2CreateReverbFrameContext()));
1782 listFree(l);
1783
1784 hashTableInsert(table, "SEEK", (l = id3v2CreateSeekFrameContext()));
1785 listFree(l);
1786 hashTableInsert(table, "SIGN", (l = id3v2CreateSignatureFrameContext()));
1787 listFree(l);
1788 hashTableInsert(table, "SYLT", (l = id3v2CreateSynchronisedLyricFrameContext()));
1789 listFree(l);
1790 hashTableInsert(table, "SYTC", (l = id3v2CreateSynchronisedTempoCodesFrameContext()));
1791 listFree(l);
1792
1793 hashTableInsert(table, "TALB", (l = id3v2CreateTextFrameContext()));
1794 listFree(l);
1795 hashTableInsert(table, "TBPM", (l = id3v2CreateTextFrameContext()));
1796 listFree(l);
1797 hashTableInsert(table, "TCOM", (l = id3v2CreateTextFrameContext()));
1798 listFree(l);
1799 hashTableInsert(table, "TCON", (l = id3v2CreateTextFrameContext()));
1800 listFree(l);
1801 hashTableInsert(table, "TCOP", (l = id3v2CreateTextFrameContext()));
1802 listFree(l);
1803 hashTableInsert(table, "TDEN", (l = id3v2CreateTextFrameContext()));
1804 listFree(l);
1805 hashTableInsert(table, "TDLY", (l = id3v2CreateTextFrameContext()));
1806 listFree(l);
1807 hashTableInsert(table, "TDOR", (l = id3v2CreateTextFrameContext()));
1808 listFree(l);
1809 hashTableInsert(table, "TDRC", (l = id3v2CreateTextFrameContext()));
1810 listFree(l);
1811 hashTableInsert(table, "TDRL", (l = id3v2CreateTextFrameContext()));
1812 listFree(l);
1813 hashTableInsert(table, "TDTG", (l = id3v2CreateTextFrameContext()));
1814 listFree(l);
1815 hashTableInsert(table, "TENC", (l = id3v2CreateTextFrameContext()));
1816 listFree(l);
1817 hashTableInsert(table, "TEXT", (l = id3v2CreateTextFrameContext()));
1818 listFree(l);
1819 hashTableInsert(table, "TFLT", (l = id3v2CreateTextFrameContext()));
1820 listFree(l);
1821 hashTableInsert(table, "TIPL", (l = id3v2CreateTextFrameContext()));
1822 listFree(l);
1823 hashTableInsert(table, "TIT1", (l = id3v2CreateTextFrameContext()));
1824 listFree(l);
1825 hashTableInsert(table, "TIT2", (l = id3v2CreateTextFrameContext()));
1826 listFree(l);
1827 hashTableInsert(table, "TIT3", (l = id3v2CreateTextFrameContext()));
1828 listFree(l);
1829 hashTableInsert(table, "TKEY", (l = id3v2CreateTextFrameContext()));
1830 listFree(l);
1831 hashTableInsert(table, "TLAN", (l = id3v2CreateTextFrameContext()));
1832 listFree(l);
1833 hashTableInsert(table, "TLEN", (l = id3v2CreateTextFrameContext()));
1834 listFree(l);
1835 hashTableInsert(table, "TMCL", (l = id3v2CreateTextFrameContext()));
1836 listFree(l);
1837 hashTableInsert(table, "TMED", (l = id3v2CreateTextFrameContext()));
1838 listFree(l);
1839 hashTableInsert(table, "TMOO", (l = id3v2CreateTextFrameContext()));
1840 listFree(l);
1841 hashTableInsert(table, "TOAL", (l = id3v2CreateTextFrameContext()));
1842 listFree(l);
1843 hashTableInsert(table, "TOFN", (l = id3v2CreateTextFrameContext()));
1844 listFree(l);
1845 hashTableInsert(table, "TOLY", (l = id3v2CreateTextFrameContext()));
1846 listFree(l);
1847 hashTableInsert(table, "TOPE", (l = id3v2CreateTextFrameContext()));
1848 listFree(l);
1849 hashTableInsert(table, "TOWN", (l = id3v2CreateTextFrameContext()));
1850 listFree(l);
1851 hashTableInsert(table, "TPE1", (l = id3v2CreateTextFrameContext()));
1852 listFree(l);
1853 hashTableInsert(table, "TPE2", (l = id3v2CreateTextFrameContext()));
1854 listFree(l);
1855 hashTableInsert(table, "TPE3", (l = id3v2CreateTextFrameContext()));
1856 listFree(l);
1857 hashTableInsert(table, "TPE4", (l = id3v2CreateTextFrameContext()));
1858 listFree(l);
1859 hashTableInsert(table, "TPOS", (l = id3v2CreateTextFrameContext()));
1860 listFree(l);
1861 hashTableInsert(table, "TPRO", (l = id3v2CreateTextFrameContext()));
1862 listFree(l);
1863 hashTableInsert(table, "TPUB", (l = id3v2CreateTextFrameContext()));
1864 listFree(l);
1865 hashTableInsert(table, "TRCK", (l = id3v2CreateTextFrameContext()));
1866 listFree(l);
1867 hashTableInsert(table, "TRSN", (l = id3v2CreateTextFrameContext()));
1868 listFree(l);
1869 hashTableInsert(table, "TRSO", (l = id3v2CreateTextFrameContext()));
1870 listFree(l);
1871 hashTableInsert(table, "TSOA", (l = id3v2CreateTextFrameContext()));
1872 listFree(l);
1873 hashTableInsert(table, "TSOP", (l = id3v2CreateTextFrameContext()));
1874 listFree(l);
1875 hashTableInsert(table, "TSOT", (l = id3v2CreateTextFrameContext()));
1876 listFree(l);
1877 hashTableInsert(table, "TSRC", (l = id3v2CreateTextFrameContext()));
1878 listFree(l);
1879 hashTableInsert(table, "TSSE", (l = id3v2CreateTextFrameContext()));
1880 listFree(l);
1881 hashTableInsert(table, "TSST", (l = id3v2CreateTextFrameContext()));
1882 listFree(l);
1883 hashTableInsert(table, "TXXX", (l = id3v2CreateUserDefinedTextFrameContext()));
1884 listFree(l);
1885
1886 hashTableInsert(table, "UFID", (l = id3v2CreateUniqueFileIdentifierFrameContext()));
1887 listFree(l);
1888 hashTableInsert(table, "USER", (l = id3v2CreateTermsOfUseFrameContext()));
1889 listFree(l);
1890 hashTableInsert(table, "USLT", (l = id3v2CreateUnsynchronisedLyricFrameContext()));
1891 listFree(l);
1892
1893 hashTableInsert(table, "WCOM", (l = id3v2CreateURLFrameContext()));
1894 listFree(l);
1895 hashTableInsert(table, "WCOP", (l = id3v2CreateURLFrameContext()));
1896 listFree(l);
1897 hashTableInsert(table, "WOAF", (l = id3v2CreateURLFrameContext()));
1898 listFree(l);
1899 hashTableInsert(table, "WOAR", (l = id3v2CreateURLFrameContext()));
1900 listFree(l);
1901 hashTableInsert(table, "WOAS", (l = id3v2CreateURLFrameContext()));
1902 listFree(l);
1903 hashTableInsert(table, "WORS", (l = id3v2CreateURLFrameContext()));
1904 listFree(l);
1905 hashTableInsert(table, "WPAY", (l = id3v2CreateURLFrameContext()));
1906 listFree(l);
1907 hashTableInsert(table, "WPUB", (l = id3v2CreateURLFrameContext()));
1908 listFree(l);
1909 hashTableInsert(table, "WXXX", (l = id3v2CreateUserDefinedURLFrameContext()));
1910 listFree(l);
1911
1912 break;
1913 default:
1914 break;
1915 }
1916
1917 hashTableInsert(table, "?", (l = id3v2CreateGenericFrameContext()));
1918 listFree(l);
1919 hashTableInsert(table, "T", (l = id3v2CreateTextFrameContext()));
1920 listFree(l);
1921 hashTableInsert(table, "W", (l = id3v2CreateURLFrameContext()));
1922 listFree(l);
1923
1924 return table;
1925}
1926
1942bool id3v2InsertIdentifierContextPair(HashTable *identifierContextPairs, char key[ID3V2_FRAME_ID_MAX_SIZE],
1943 List *context) {
1944 if (!identifierContextPairs || !key || !context) {
1945 return false;
1946 }
1947
1948 hashTableInsert(identifierContextPairs, key, context);
1949
1950 return true;
1951}
1952
1970uint8_t *id3v2ContextSerialize(Id3v2ContentContext *cc, size_t *outl) {
1971 ByteStream *stream = NULL;
1972 size_t s = 0;
1973 unsigned char *convi = NULL;
1974 uint8_t *out = NULL;
1975
1976 if (cc == NULL) {
1977 *outl = 0;
1978 return out;
1979 }
1980
1981 s += (sizeof(size_t) * 3) + 1;
1982
1983 stream = byteStreamCreate(NULL, s);
1984
1985 byteStreamWrite(stream, (uint8_t *) &cc->type, 1);
1986
1987 convi = sttob(cc->key);
1988 byteStreamWrite(stream, convi, sizeof(size_t));
1989 free(convi);
1990
1991 convi = sttob(cc->max);
1992 byteStreamWrite(stream, convi, sizeof(size_t));
1993 free(convi);
1994
1995 convi = sttob(cc->min);
1996 byteStreamWrite(stream, convi, sizeof(size_t));
1997 free(convi);
1998
1999 byteStreamRewind(stream);
2000
2001 out = calloc(stream->bufferSize, sizeof(uint8_t));
2002 *outl = stream->bufferSize;
2003 byteStreamRead(stream, out, stream->bufferSize);
2004 byteStreamDestroy(stream);
2005 return out;
2006}
2007
2034 char *json = NULL;
2035 size_t memCount = 3;
2036 if (cc == NULL) {
2037 json = calloc(memCount, sizeof(char));
2038 memcpy(json, "{}\0", memCount);
2039 return json;
2040 }
2041
2042 memCount += snprintf(NULL, 0,
2043 "{\"type\":%d,\"key\":%zu,\"max\":%zu,\"min\":%zu}",
2044 cc->type,
2045 cc->key,
2046 cc->max,
2047 cc->min);
2048
2049 json = calloc(memCount + 1, sizeof(char));
2050
2051 (void) snprintf(json, memCount,
2052 "{\"type\":%d,\"key\":%zu,\"max\":%zu,\"min\":%zu}",
2053 cc->type,
2054 cc->key,
2055 cc->max,
2056 cc->min);
2057
2058 return json;
2059}
List * id3v2CreateGeneralEncapsulatedObjectFrameContext(void)
Creates a context definition list for general encapsulated object frames (GEOB).
List * id3v2CreateURLFrameContext(void)
Creates a context definition list for standard ID3v2 URL frames.
List * id3v2CreateAudioSeekPointIndexFrameContext(void)
Creates a context definition list for Audio Seek Point Index frames (ASPI).
List * id3v2CreateRecommendedBufferSizeFrameContext(void)
Creates a context definition list for recommended buffer size frames (RBUF).
bool id3v2InsertIdentifierContextPair(HashTable *identifierContextPairs, char key[ID3V2_FRAME_ID_MAX_SIZE], List *context)
Inserts a new frame identifier and context pairing into an existing frame mapping table.
List * id3v2CreateCommentFrameContext(void)
Creates a context definition list for comment frames (COMM).
void id3v2DeleteContentContext(void *toBeDeleted)
List/Hash API required functions.
List * id3v2CreateUniqueFileIdentifierFrameContext(void)
Creates a context definition list for unique file identifier frames (UFID).
List * id3v2CreateEncryptedMetaFrameContext(void)
Creates a context definition list for encrypted metadata frames (ENCR).
List * id3v2CreateSynchronisedLyricFrameContext(void)
Creates a context definition list for synchronised lyrics/text frames (SYLT).
unsigned long id3v2djb2(const char *str)
Computes a DJB2 hash value for a null-terminated string.
List * id3v2CreateOwnershipFrameContext(void)
Creates a context definition list for ownership frames (OWNE).
HashTable * id3v2CreateDefaultIdentifierContextPairings(unsigned int version)
Creates a default mapping of frame identifiers to their corresponding parse contexts for all ID3v2 ve...
List * id3v2CreateSignatureFrameContext(void)
Creates a context definition list for signature frames (SIGN).
void * id3v2CopyContentContextList(const void *toBeCopied)
Creates a deep copy of a content context list.
List * id3v2CreateMPEGLocationLookupTableFrameContext(void)
Creates a context definition list for MPEG location lookup table frames (MLLT).
List * id3v2CreateEqualizationFrameContext(unsigned int version)
Creates a context definition list for equalization frames (EQU/EQUA/EQU2).
List * id3v2CreateUserDefinedTextFrameContext(void)
Creates a context definition list for user-defined text frames (TXXX).
List * id3v2CreateGenericFrameContext(void)
Creates a context definition list for generic frames with unknown or unrecognized structure.
List * id3v2CreatePrivateFrameContext(void)
Creates a context definition list for private frames (PRIV).
void id3v2DestroyContentContext(Id3v2ContentContext **toDelete)
Frees all memory allocated for a content context and nullifies the pointer.
uint8_t * id3v2ContextSerialize(Id3v2ContentContext *cc, size_t *outl)
Creates a binary representation of a content context structure for serialization.
List * id3v2CreateRegistrationFrameContext(void)
Creates a context definition list for encryption method registration (ENCR) or group identification (...
List * id3v2CreateMusicCDIdentifierFrameContext(void)
Creates a context definition list for music CD identifier frames (MCDI).
List * id3v2CreateTextFrameContext(void)
Context list generation.
List * id3v2CreateSeekFrameContext(void)
Creates a context definition list for seek frames (SEEK).
List * id3v2CreateAttachedPictureFrameContext(unsigned int version)
Creates a context definition list for attached picture frames (APIC/PIC).
List * id3v2CreateLinkedInformationFrameContext(void)
Creates a context definition list for linked information frames (LINK).
List * id3v2CreateUserDefinedURLFrameContext(void)
Creates a context definition list for user-defined URL frames (WXXX).
char * id3v2PrintContentContext(const void *toBePrinted)
Generates a string representation of a content context for debugging.
List * id3v2CreateEventTimingCodesFrameContext(void)
Creates a context definition list for event timing codes frames (ETCO).
List * id3v2CreateReverbFrameContext(void)
Creates a context definition list for reverb frames (RVRB).
char * id3v2PrintContentContextList(const void *toBePrinted)
Generates a string representation of a content context list for debugging.
List * id3v2CreatePositionSynchronisationFrameContext(void)
Creates a context definition list for position synchronisation frames (POSS).
List * id3v2CreateAudioEncryptionFrameContext(void)
Creates a context definition list for Audio Encryption frames (AENC).
List * id3v2CreatePopularimeterFrameContext(void)
Creates a context definition list for popularimeter frames (POPM).
List * id3v2CreateInvolvedPeopleListFrameContext(void)
Creates a context definition list for involved people list frames (IPLS) in ID3v2....
void id3v2DeleteContentContextList(void *toBeDeleted)
Frees all memory allocated for a list of content contexts.
List * id3v2CreateSynchronisedTempoCodesFrameContext(void)
Creates a context definition list for synchronised tempo codes frames (SYTC).
List * id3v2CreateTermsOfUseFrameContext(void)
Creates a context definition list for terms of use frames (USER).
char * id3v2ContextToJSON(const Id3v2ContentContext *cc)
Converts a content context structure to its JSON representation.
List * id3v2CreateUnsynchronisedLyricFrameContext(void)
Creates a context definition list for unsynchronised lyrics/text frames (USLT).
List * id3v2CreatePlayCounterFrameContext(void)
Creates a context definition list for play counter frames (PCNT).
List * id3v2CreateRelativeVolumeAdjustmentFrameContext(unsigned int version)
Creates a context definition list for relative volume adjustment frames (RVA/RVAD/RVA2).
List * id3v2CreateCommercialFrameContext(void)
Creates a context definition list for commercial frames (COMR).
Id3v2ContentContext * id3v2CreateContentContext(Id3v2ContextType type, size_t key, size_t max, size_t min)
Creates a content context structure defining entry constraints and metadata.
int id3v2CompareContentContext(const void *first, const void *second)
Performs comparison of two content context structures.
void * id3v2CopyContentContext(const void *toBeCopied)
Creates a deep copy of a content context structure.
Function definitions for ID3v2 frame context definitions and parsing configuration.
void id3v2DeleteContentContext(void *toBeDeleted)
List/Hash API required functions.
void * id3v2CopyContentContextList(const void *toBeCopied)
Creates a deep copy of a content context list.
char * id3v2PrintContentContext(const void *toBePrinted)
Generates a string representation of a content context for debugging.
char * id3v2PrintContentContextList(const void *toBePrinted)
Generates a string representation of a content context list for debugging.
void id3v2DeleteContentContextList(void *toBeDeleted)
Frees all memory allocated for a list of content contexts.
int id3v2CompareContentContext(const void *first, const void *second)
Performs comparison of two content context structures.
void * id3v2CopyContentContext(const void *toBeCopied)
Creates a deep copy of a content context structure.
#define ID3V2_TAG_VERSION_3
ID3v2.3 major version number (3)
Definition id3v2Types.h:43
struct _Id3v2ContentContext Id3v2ContentContext
Parsing instructions for a single field within an ID3v2 frame.
#define ID3V2_FRAME_ID_MAX_SIZE
Maximum size in bytes for a frame ID field (4 bytes).
Definition id3v2Types.h:70
#define ID3V2_TAG_VERSION_2
ID3v2.2 major version number (2)
Definition id3v2Types.h:40
@ noEncoding_context
Raw character data with no encoding or null terminator.
Definition id3v2Types.h:173
@ iter_context
Iterator for repeating context sequences.
Definition id3v2Types.h:221
@ numeric_context
Integer values of 8, 16, 32, or 64 bits.
Definition id3v2Types.h:197
@ encodedString_context
Text string with encoding determined by prior context with the key 'encoding'.
Definition id3v2Types.h:185
@ latin1Encoding_context
Latin-1 (ISO-8859-1) null-terminated string.
Definition id3v2Types.h:191
@ adjustment_context
Dynamic upper bound adjustment based on prior context with key 'adjustment'.
Definition id3v2Types.h:227
@ binary_context
Binary data block with no terminator.
Definition id3v2Types.h:179
@ bit_context
Bit-level field (1-8 bits).
Definition id3v2Types.h:215
@ unknown_context
Error/invalid context state (-1).
Definition id3v2Types.h:167
enum _Id3v2ContextType Id3v2ContextType
Context types for parsing and writing ID3v2 frame content fields.
#define ID3V2_TAG_VERSION_4
ID3v2.4 major version number (4)
Definition id3v2Types.h:46
size_t min
Minimum size in bytes (or bits for bit_context, or start index for iter_context).
Definition id3v2Types.h:248
size_t max
Maximum size in bytes (or bits for bit_context, or iteration count for iter_context).
Definition id3v2Types.h:254
Id3v2ContextType type
Context type determining parsing behavior (string, binary, numeric, etc.)
Definition id3v2Types.h:239
size_t key
Hashed identifier string for this field. Used to reference this context from other contexts (e....
Definition id3v2Types.h:242