libtags, zuke: add *.mod support (thanks kemal)

This commit is contained in:
Sigrid 2021-04-24 16:07:24 +02:00
parent 83277da309
commit b0e2ea4e5f
5 changed files with 55 additions and 1 deletions

View file

@ -9,6 +9,7 @@ OFILES=\
id3v2.$O\ id3v2.$O\
it.$O\ it.$O\
m4a.$O\ m4a.$O\
mod.$O\
opus.$O\ opus.$O\
s3m.$O\ s3m.$O\
tags.$O\ tags.$O\

View file

@ -0,0 +1,46 @@
#include "tagspriv.h"
/* insane. */
static char* variants[] =
{
"M.K.",
"M!K!",
"M&K!",
"N.T.",
"NSMS",
"FLT4",
"M\0\0\0",
"8\0\0\0",
"FEST",
"FLT8",
"CD81",
"OCTA",
"OKTA",
"16CN",
"32CN",
nil,
};
int
tagmod(Tagctx *ctx)
{
char d[20+1];
int i;
if (ctx->seek(ctx, 1080, 0) != 1080)
return -1;
if (ctx->read(ctx, d, 4) != 4)
return -1;
for (i = 0; ; i++)
if (variants[i] == nil)
return -1;
else if (memcmp(d, variants[i], 4) == 0)
break;
memset(d, 0, sizeof d);
if (ctx->seek(ctx, 0, 0) != 0)
return -1;
if (ctx->read(ctx, d, 20) != 20)
return -1;
txtcb(ctx, Ttitle, "", d);
return 0;
}

View file

@ -18,6 +18,7 @@ extern int tags3m(Tagctx *ctx);
extern int tagvorbis(Tagctx *ctx); extern int tagvorbis(Tagctx *ctx);
extern int tagwav(Tagctx *ctx); extern int tagwav(Tagctx *ctx);
extern int tagxm(Tagctx *ctx); extern int tagxm(Tagctx *ctx);
extern int tagmod(Tagctx *ctx);
static const Getter g[] = static const Getter g[] =
{ {
@ -31,6 +32,7 @@ static const Getter g[] =
{tagit, Fit}, {tagit, Fit},
{tagxm, Fxm}, {tagxm, Fxm},
{tags3m, Fs3m}, {tags3m, Fs3m},
{tagmod, Fmod},
}; };
void void

View file

@ -33,6 +33,7 @@ enum
Fit, Fit,
Fxm, Fxm,
Fs3m, Fs3m,
Fmod,
Fmax, Fmax,
}; };

View file

@ -31,6 +31,7 @@ static char *fmts[] =
[Fit] = "mod", [Fit] = "mod",
[Fxm] = "mod", [Fxm] = "mod",
[Fs3m] = "mod", [Fs3m] = "mod",
[Fmod] = "mod",
}; };
static Meta * static Meta *
@ -196,7 +197,10 @@ scanfile(char *path)
} }
if(ctx.duration == 0){ if(ctx.duration == 0){
if(ctx.format == Fit || ctx.format == Fxm || ctx.format == Fs3m) if(ctx.format == Fit ||
ctx.format == Fxm ||
ctx.format == Fs3m ||
ctx.format == Fmod)
ctx.duration = modduration(path); ctx.duration = modduration(path);
if(ctx.duration == 0) if(ctx.duration == 0)
fprint(2, "%s: no duration\n", path); fprint(2, "%s: no duration\n", path);