73 lines · 1.3 KB · C
RawDownload
#include "tagspriv.h" typedef struct Getter Getter; struct Getter{	int (*f)(Tagctx *ctx);	int format;	int flags;}; enum {	LastResortOnly = 1<<0, // only try if file format is (still) unknown}; static const Getter g[] ={	{tagid3v2, Fmp3, 0},	{tagid3v1, Fmp3, 0},	{tagvorbis, Fvorbis, 0},	{tagflac, Fflac, 0},	{tagm4a, Fm4a, 0},	{tagopus, Fopus, 0},	{tagwav, Fwav, 0},	{tagit, Fit, LastResortOnly},	{tagxm, Fxm, LastResortOnly},	{tags3m, Fs3m, LastResortOnly},	{tagmod, Fmod, LastResortOnly},}; voidtagscallcb(Tagctx *ctx, int type, Tag *tag){	char *s, *e; 	if(type != Timage){		for(s = tag->text.v; (uint8_t)*s <= ' ' && *s; s++);		e = s + strlen(s);		while(e != s && (uint8_t)e[-1] <= ' ')			e--;		if(*e != 0)			*e = 0;		if(*s == 0)			return;		tag->text.v = s;	}	ctx->tag(ctx, type, tag);	if(type != Tunknown)		ctx->found |= 1<<type;} inttagsget(Tagctx *ctx){	int i, res; 	ctx->channels = ctx->samplerate = ctx->bitrate = ctx->duration = 0;	ctx->found = 0;	ctx->format = Funknown;	ctx->restart = 0;	res = -1;	for(i = 0; i < nelem(g); i++){		if((g[i].flags & LastResortOnly) != 0 && ctx->format != Funknown)			continue;		if(g[i].f(ctx) == 0){			ctx->format = g[i].format;			res = 0;		}		ctx->seek(ctx, ctx->restart, 0);	} 	return res;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t