ref: f68e997ecefd77b3d1cd33c21264d5ced6e5d021
dir: /tagspriv.h/
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "tags.h"
#define nil NULL
#define UTFmax 4
#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
enum {
Numgenre = 192,
};
extern const char *id3genres[Numgenre];
static inline uint32_t
beuint(const void *d_)
{
const uint8_t *d = d_;
return d[0]<<24 | d[1]<<16 | d[2]<<8 | d[3];
}
static inline uint32_t
leuint(const void *d_)
{
const uint8_t *d = d_;
return d[3]<<24 | d[2]<<16 | d[1]<<8 | d[0];
}
/*
* Converts (to UTF-8) at most sz bytes of src and writes it to out buffer.
* Returns the number of bytes converted.
* You need sz*2+1 bytes for out buffer to be completely safe.
*/
int iso88591toutf8(uint8_t *out, int osz, const uint8_t *src, int sz);
/*
* Converts (to UTF-8) at most sz bytes of src and writes it to out buffer.
* Returns the number of bytes converted or < 0 in case of error.
* You need sz*4+1 bytes for out buffer to be completely safe.
* UTF-16 defaults to big endian if there is no BOM.
*/
int utf16to8(uint8_t *out, int osz, const uint8_t *src, int sz);
/*
* Same as utf16to8, but CP437 to UTF-8.
*/
int cp437toutf8(uint8_t *o, int osz, const uint8_t *s, int sz);
/*
* This one is common for both vorbis.c and flac.c
* It maps a string k to tag type and executes the callback from ctx.
* Returns 1 if callback was called, 0 otherwise.
*/
void cbvorbiscomment(Tagctx *ctx, char *k, char *v);
/*
* Used to decode base64-encoded picture block.
*/
int debase64(uint8_t *in, int insz, uint8_t *out, int outsz);
/*
* METADATA_BLOCK_PICTURE reader function.
*/
int cbmbp(Tagctx *ctx, char *v, int ssz, int off, int picsz);
void tagscallcb(Tagctx *ctx, int type, Tag *tag);
#define txtcb(ctx, type, k_, v_) \
tagscallcb(ctx, type, &(Tag){.text = {.k = (k_), .v = (char*)(v_)}})
int tagflac(Tagctx *ctx);
int tagid3v1(Tagctx *ctx);
int tagid3v2(Tagctx *ctx);
int tagit(Tagctx *ctx);
int tagm4a(Tagctx *ctx);
int tagopus(Tagctx *ctx);
int tags3m(Tagctx *ctx);
int tagvorbis(Tagctx *ctx);
int tagwav(Tagctx *ctx);
int tagxm(Tagctx *ctx);
int tagmod(Tagctx *ctx);