17#include "id3dependencies/ByteStream/include/byteTypes.h"
18#include "id3dependencies/ByteStream/include/byteStream.h"
19#include "id3dependencies/ByteStream/include/byteInt.h"
33 unsigned long hash = 5381;
36 while (*str !=
'\0') {
38 hash = ((hash << 5) + hash) + c;
126 diff = (c1->
key < c2->
key) ? 0 : (int) (c1->
key - c2->
key);
132 diff = (c1->
min < c2->
min) ? 0 : (int) (c1->
min - c2->
min);
137 diff = (c1->
max < c2->
max) ? 0 : (int) (c1->
max - c2->
max);
154 size_t memCount = snprintf(NULL, 0,
"Type: %d, Key: %zu, min: %zu, max: %zu\n", c->
type, c->
key, c->
min, c->
max);
157 char *str = malloc(
sizeof(
long) +
sizeof(
long) +
sizeof(
int) +
sizeof(
Id3v2ContextType) + 40);
159 (void) snprintf(str, memCount + 1,
"Type: %d, Key: %zu, min: %zu, max: %zu\n", c->
type, c->
key, c->
min, c->
max);
195 listFree((List *) toBeDeleted);
209 return listToString((List *) toBePrinted);
223 return listDeepCopy((List *) toBeCopied);
249 listInsertBack(l, toAdd);
253 listInsertBack(l, toAdd);
274 listInsertBack(l, toAdd);
278 listInsertBack(l, toAdd);
282 listInsertBack(l, toAdd);
301 listInsertBack(l, toAdd);
324 listInsertBack(l, toAdd);
328 listInsertBack(l, toAdd);
332 listInsertBack(l, toAdd);
358 listInsertBack(l, toAdd);
379 listInsertBack(l, toAdd);
383 listInsertBack(l, toAdd);
387 listInsertBack(l, toAdd);
391 listInsertBack(l, toAdd);
412 listInsertBack(l, toAdd);
435 listInsertBack(l, toAdd);
439 listInsertBack(l, toAdd);
443 listInsertBack(l, toAdd);
447 listInsertBack(l, toAdd);
470 listInsertBack(l, toAdd);
474 listInsertBack(l, toAdd);
478 listInsertBack(l, toAdd);
482 listInsertBack(l, toAdd);
509 listInsertBack(l, toAdd);
513 listInsertBack(l, toAdd);
517 listInsertBack(l, toAdd);
521 listInsertBack(l, toAdd);
525 listInsertBack(l, toAdd);
529 listInsertBack(l, toAdd);
533 listInsertBack(l, toAdd);
537 listInsertBack(l, toAdd);
541 listInsertBack(l, toAdd);
565 listInsertBack(l, toAdd);
569 listInsertBack(l, toAdd);
573 listInsertBack(l, toAdd);
596 listInsertBack(l, toAdd);
600 listInsertBack(l, toAdd);
604 listInsertBack(l, toAdd);
626 listInsertBack(l, toAdd);
648 listInsertBack(l, toAdd);
684 listInsertBack(l, toAdd);
688 listInsertBack(l, toAdd);
692 listInsertBack(l, toAdd);
696 listInsertBack(l, toAdd);
700 listInsertBack(l, toAdd);
708 listInsertBack(l, toAdd);
712 listInsertBack(l, toAdd);
716 listInsertBack(l, toAdd);
720 listInsertBack(l, toAdd);
725 listInsertBack(l, toAdd);
751 listInsertBack(l, toAdd);
755 listInsertBack(l, toAdd);
759 listInsertBack(l, toAdd);
763 listInsertBack(l, toAdd);
789 listInsertBack(l, toAdd);
793 listInsertBack(l, toAdd);
797 listInsertBack(l, toAdd);
801 listInsertBack(l, toAdd);
805 listInsertBack(l, toAdd);
830 listInsertBack(l, toAdd);
834 listInsertBack(l, toAdd);
838 listInsertBack(l, toAdd);
842 listInsertBack(l, toAdd);
866 listInsertBack(l, toAdd);
870 listInsertBack(l, toAdd);
893 listInsertBack(l, toAdd);
917 listInsertBack(l, toAdd);
921 listInsertBack(l, toAdd);
925 listInsertBack(l, toAdd);
929 listInsertBack(l, toAdd);
953 listInsertBack(l, toAdd);
957 listInsertBack(l, toAdd);
961 listInsertBack(l, toAdd);
984 listInsertBack(l, toAdd);
988 listInsertBack(l, toAdd);
1012 listInsertBack(l, toAdd);
1016 listInsertBack(l, toAdd);
1040 listInsertBack(l, toAdd);
1044 listInsertBack(l, toAdd);
1048 listInsertBack(l, toAdd);
1074 listInsertBack(l, toAdd);
1100 listInsertBack(l, toAdd);
1104 listInsertBack(l, toAdd);
1108 listInsertBack(l, toAdd);
1112 listInsertBack(l, toAdd);
1116 listInsertBack(l, toAdd);
1120 listInsertBack(l, toAdd);
1124 listInsertBack(l, toAdd);
1128 listInsertBack(l, toAdd);
1132 listInsertBack(l, toAdd);
1136 listInsertBack(l, toAdd);
1158 listInsertBack(l, toAdd);
1182 listInsertBack(l, toAdd);
1186 listInsertBack(l, toAdd);
1213 listInsertBack(l, toAdd);
1217 listInsertBack(l, toAdd);
1221 listInsertBack(l, toAdd);
1225 listInsertBack(l, toAdd);
1229 listInsertBack(l, toAdd);
1233 listInsertBack(l, toAdd);
1237 listInsertBack(l, toAdd);
1241 listInsertBack(l, toAdd);
1266 listInsertBack(l, toAdd);
1270 listInsertBack(l, toAdd);
1294 listInsertBack(l, toAdd);
1298 listInsertBack(l, toAdd);
1323 listInsertBack(l, toAdd);
1327 listInsertBack(l, toAdd);
1331 listInsertBack(l, toAdd);
1358 listInsertBack(l, toAdd);
1362 listInsertBack(l, toAdd);
1366 listInsertBack(l, toAdd);
1370 listInsertBack(l, toAdd);
1393 listInsertBack(l, toAdd);
1417 size_t minFrameContexts = 66;
1944 if (!identifierContextPairs || !key || !context) {
1948 hashTableInsert(identifierContextPairs, key, context);
1971 ByteStream *stream = NULL;
1973 unsigned char *convi = NULL;
1974 uint8_t *out = NULL;
1981 s += (
sizeof(size_t) * 3) + 1;
1983 stream = byteStreamCreate(NULL, s);
1985 byteStreamWrite(stream, (uint8_t *) &cc->
type, 1);
1987 convi = sttob(cc->
key);
1988 byteStreamWrite(stream, convi,
sizeof(
size_t));
1991 convi = sttob(cc->
max);
1992 byteStreamWrite(stream, convi,
sizeof(
size_t));
1995 convi = sttob(cc->
min);
1996 byteStreamWrite(stream, convi,
sizeof(
size_t));
1999 byteStreamRewind(stream);
2001 out = calloc(stream->bufferSize,
sizeof(uint8_t));
2002 *outl = stream->bufferSize;
2003 byteStreamRead(stream, out, stream->bufferSize);
2004 byteStreamDestroy(stream);
2035 size_t memCount = 3;
2037 json = calloc(memCount,
sizeof(
char));
2038 memcpy(json,
"{}\0", memCount);
2042 memCount += snprintf(NULL, 0,
2043 "{\"type\":%d,\"key\":%zu,\"max\":%zu,\"min\":%zu}",
2049 json = calloc(memCount + 1,
sizeof(
char));
2051 (void) snprintf(json, memCount,
2052 "{\"type\":%d,\"key\":%zu,\"max\":%zu,\"min\":%zu}",
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)
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).
#define ID3V2_TAG_VERSION_2
ID3v2.2 major version number (2)
@ noEncoding_context
Raw character data with no encoding or null terminator.
@ iter_context
Iterator for repeating context sequences.
@ numeric_context
Integer values of 8, 16, 32, or 64 bits.
@ encodedString_context
Text string with encoding determined by prior context with the key 'encoding'.
@ latin1Encoding_context
Latin-1 (ISO-8859-1) null-terminated string.
@ adjustment_context
Dynamic upper bound adjustment based on prior context with key 'adjustment'.
@ binary_context
Binary data block with no terminator.
@ bit_context
Bit-level field (1-8 bits).
@ unknown_context
Error/invalid context state (-1).
enum _Id3v2ContextType Id3v2ContextType
Context types for parsing and writing ID3v2 frame content fields.
#define ID3V2_TAG_VERSION_4
ID3v2.4 major version number (4)
size_t min
Minimum size in bytes (or bits for bit_context, or start index for iter_context).
size_t max
Maximum size in bytes (or bits for bit_context, or iteration count for iter_context).
Id3v2ContextType type
Context type determining parsing behavior (string, binary, numeric, etc.)
size_t key
Hashed identifier string for this field. Used to reference this context from other contexts (e....