static int mmd3_test(HIO_HANDLE *f, char *t, const int start) { char id[4]; uint32 offset, len; if (hio_read(id, 1, 4, f) < 4) return -1; if (memcmp(id, "MMD2", 4) && memcmp(id, "MMD3", 4)) return -1; hio_seek(f, 28, SEEK_CUR); offset = hio_read32b(f); /* expdata_offset */ if (offset) { hio_seek(f, start + offset + 44, SEEK_SET); offset = hio_read32b(f); len = hio_read32b(f); hio_seek(f, start + offset, SEEK_SET); read_title(f, t, len); } else { read_title(f, t, 0); } return 0; }
static int pt3_test(FILE *f, char *t, const int start) { if (read32b(f) != MAGIC_FORM) return -1; read32b(f); /* skip size */ if (read32b(f) != MAGIC_MODL) return -1; if (read32b(f) != MAGIC_VERS) return -1; read32b(f); /* skip size */ fseek(f, 10, SEEK_CUR); if (read32b(f) == MAGIC_INFO) { read32b(f); /* skip size */ read_title(f, t, 32); } else { read_title(f, t, 0); } return 0; }
static int mod_test(HIO_HANDLE *f, char *t, const int start) { int i; char buf[4]; hio_seek(f, start + 1080, SEEK_SET); if (hio_read(buf, 1, 4, f) < 4) return -1; if (!strncmp(buf + 2, "CH", 2) && isdigit((int)buf[0]) && isdigit((int)buf[1])) { i = (buf[0] - '0') * 10 + buf[1] - '0'; if (i > 0 && i <= 32) { goto found; } } if (!strncmp(buf + 1, "CHN", 3) && isdigit((int)*buf)) { if (*buf >= '0' && *buf <='9') { goto found; } } if (memcmp(buf, "M.K.", 4)) return -1; found: hio_seek(f, start + 0, SEEK_SET); read_title(f, t, 20); return 0; }
static int med3_test(HIO_HANDLE *f, char *t, const int start) { if (hio_read32b(f) != MAGIC_MED3) return -1; read_title(f, t, 0); return 0; }
static int no_test(HIO_HANDLE *f, char *t, const int start) { if (hio_read32b(f) != 0x4e4f0000) /* NO 0x00 0x00 */ return -1; read_title(f, t, hio_read8(f)); return 0; }
static int dtt_test(FILE *f, char *t, const int start) { if (read32b(f) != MAGIC_DskT) return -1; read_title(f, t, 64); return 0; }
static int med4_test(xmp_file f, char *t, const int start) { if (read32b(f) != MAGIC_MED4) return -1; read_title(f, t, 0); return 0; }
static int stim_test(FILE *f, char *t, const int start) { if (read32b(f) != MAGIC_STIM) return -1; read_title(f, t, 0); return 0; }
static int it_test(HIO_HANDLE *f, char *t, const int start) { if (hio_read32b(f) != MAGIC_IMPM) return -1; read_title(f, t, 26); return 0; }
static int far_test(FILE *f, char *t, const int start) { if (read32b(f) != MAGIC_FAR) return -1; read_title(f, t, 40); return 0; }
static int dmf_test(xmp_file f, char *t, const int start) { if (read32b(f) != MAGIC_DDMF) return -1; xmp_fseek(f, 9, SEEK_CUR); read_title(f, t, 30); return 0; }
static int dmf_test(HIO_HANDLE * f, char *t, const int start) { if (hio_read32b(f) != MAGIC_DDMF) return -1; hio_seek(f, 9, SEEK_CUR); read_title(f, t, 30); return 0; }
static int dbm_test(FILE * f, char *t, const int start) { if (read32b(f) != MAGIC_DBM0) return -1; fseek(f, 12, SEEK_CUR); read_title(f, t, 44); return 0; }
static int mdl_test(FILE *f, char *t, const int start) { uint16 id; if (read32b(f) != MAGIC_DMDL) return -1; read8(f); /* version */ id = read16b(f); if (id == 0x494e) { /* IN */ read32b(f); read_title(f, t, 32); } else { read_title(f, t, 0); } return 0; }
static int s3m_test(HIO_HANDLE *f, char *t, const int start) { hio_seek(f, start + 44, SEEK_SET); if (hio_read32b(f) != MAGIC_SCRM) return -1; hio_seek(f, start + 0, SEEK_SET); read_title(f, t, 28); return 0; }
static int emod_test(HIO_HANDLE * f, char *t, const int start) { if (hio_read32b(f) != MAGIC_FORM) return -1; hio_read32b(f); if (hio_read32b(f) != MAGIC_EMOD) return -1; if (hio_read32b(f) == MAGIC_EMIC) { hio_read32b(f); /* skip size */ hio_read16b(f); /* skip version */ read_title(f, t, 20); } else { read_title(f, t, 0); } return 0; }
static int ptm_test(FILE *f, char *t, const int start) { fseek(f, start + 44, SEEK_SET); if (read32b(f) != MAGIC_PTMF) return -1; fseek(f, start + 0, SEEK_SET); read_title(f, t, 28); return 0; }
static int s3m_test(xmp_file f, char *t, const int start) { xmp_fseek(f, start + 44, SEEK_SET); if (read32b(f) != MAGIC_SCRM) return -1; xmp_fseek(f, start + 0, SEEK_SET); read_title(f, t, 28); return 0; }
static int emod_test(xmp_file f, char *t, const int start) { if (read32b(f) != MAGIC_FORM) return -1; read32b(f); if (read32b(f) != MAGIC_EMOD) return -1; if (read32b(f) == MAGIC_EMIC) { read32b(f); /* skip size */ read16b(f); /* skip version */ read_title(f, t, 20); } else { read_title(f, t, 0); } return 0; }
static int stim_test(HIO_HANDLE *f, char *t, const int start) { if (hio_read32b(f) != MAGIC_STIM) return -1; if (hio_read16b(f) > 16) return -1; read_title(f, t, 0); return 0; }
static int mfp_test(HIO_HANDLE *f, char *t, const int start) { uint8 buf[384]; int i, len, lps, lsz; if (HIO_HANDLE_TYPE(f) != HIO_HANDLE_TYPE_FILE) return -1; if (hio_read(buf, 1, 384, f) < 384) return -1; /* check restart byte */ if (buf[249] != 0x7f) return -1; for (i = 0; i < 31; i++) { /* check size */ len = readmem16b(buf + i * 8); if (len > 0x7fff) return -1; /* check finetune */ if (buf[i * 8 + 2] & 0xf0) return -1; /* check volume */ if (buf[i * 8 + 3] > 0x40) return -1; /* check loop start */ lps = readmem16b(buf + i * 8 + 4); if (lps > len) return -1; /* check loop size */ lsz = readmem16b(buf + i * 8 + 6); if (lps + lsz - 1 > len) return -1; if (len > 0 && lsz == 0) return -1; } if (buf[248] != readmem16b(buf + 378)) return -1; if (readmem16b(buf + 378) != readmem16b(buf + 380)) return -1; read_title(f, t, 0); return 0; }
static int okt_test(HIO_HANDLE *f, char *t, const int start) { char magic[8]; if (hio_read(magic, 1, 8, f) < 8) return -1; if (strncmp(magic, "OKTASONG", 8)) return -1; read_title(f, t, 0); return 0; }
static int gtk_test(FILE * f, char *t, const int start) { char buf[4]; if (fread(buf, 1, 4, f) < 4) return -1; if (memcmp(buf, "GTK", 3) || buf[3] > 4) return -1; read_title(f, t, 32); return 0; }
static int gdm_test(xmp_file f, char *t, const int start) { if (read32b(f) != MAGIC_GDM) return -1; xmp_fseek(f, start + 0x47, SEEK_SET); if (read32b(f) != MAGIC_GMFS) return -1; xmp_fseek(f, start + 4, SEEK_SET); read_title(f, t, 32); return 0; }
static int mtp_test(HIO_HANDLE *f, char *t, const int start) { char buf[6]; if (hio_read(buf, 1, 6, f) < 6) return -1; if (memcmp(buf, "SONGOK", 6) && memcmp(buf, "IAN92a", 6)) return -1; read_title(f, t, 0); return 0; }
static int asylum_test(HIO_HANDLE *f, char *t, const int start) { char buf[32]; if (hio_read(buf, 1, 32, f) < 32) return -1; if (memcmp(buf, "ASYLUM Music Format V1.0\0\0\0\0\0\0\0\0", 32)) return -1; read_title(f, t, 0); return 0; }
static int emod_test(FILE *f, char *t, const int start) { if (read32b(f) != MAGIC_FORM) return -1; read32b(f); if (read32b(f) != MAGIC_EMOD) return -1; read_title(f, t, 0); return 0; }
static int rad_test(HIO_HANDLE *f, char *t, const int start) { char buf[16]; if (hio_read(buf, 1, 16, f) < 16) return -1; if (memcmp(buf, "RAD by REALiTY!!", 16)) return -1; read_title(f, t, 0); return 0; }
static int xm_test(HIO_HANDLE *f, char *t, const int start) { char buf[20]; if (hio_read(buf, 1, 17, f) < 17) /* ID text */ return -1; if (memcmp(buf, "Extended Module: ", 17)) return -1; read_title(f, t, 20); return 0; }
static int gdm_test(HIO_HANDLE *f, char *t, const int start) { if (hio_read32b(f) != MAGIC_GDM) return -1; hio_seek(f, start + 0x47, SEEK_SET); if (hio_read32b(f) != MAGIC_GMFS) return -1; hio_seek(f, start + 4, SEEK_SET); read_title(f, t, 32); return 0; }