void load_epilogue(struct context_data *ctx) { struct player_data *p = &ctx->p; struct module_data *m = &ctx->m; struct xmp_module *mod = &m->mod; int i, j; mod->gvl = m->gvol; /* Sanity check for module parameters */ CLAMP(mod->len, 0, XMP_MAX_MOD_LENGTH); CLAMP(mod->pat, 0, 256); CLAMP(mod->ins, 0, 255); CLAMP(mod->smp, 0, MAX_SAMPLES); CLAMP(mod->chn, 0, XMP_MAX_CHANNELS); /* Fix cases where the restart value is invalid e.g. kc_fall8.xm * from http://aminet.net/mods/mvp/mvp_0002.lha (reported by * Ralf Hoffmann <*****@*****.**>) */ if (mod->rst >= mod->len) { mod->rst = 0; } /* Sanity check for tempo and BPM */ if (mod->spd <= 0 || mod->spd > 255) { mod->spd = 6; } CLAMP(mod->bpm, XMP_MIN_BPM, 255); /* Set appropriate values for instrument volumes and subinstrument * global volumes when QUIRK_INSVOL is not set, to keep volume values * consistent if the user inspects struct xmp_module. We can later * set volumes in the loaders and eliminate the quirk. */ for (i = 0; i < mod->ins; i++) { if (~m->quirk & QUIRK_INSVOL) { mod->xxi[i].vol = m->volbase; } for (j = 0; j < mod->xxi[i].nsm; j++) { if (~m->quirk & QUIRK_INSVOL) { mod->xxi[i].sub[j].gvl = m->volbase; } } } /* Sanity check for envelopes */ for (i = 0; i < mod->ins; i++) { check_envelope(&mod->xxi[i].aei); check_envelope(&mod->xxi[i].fei); check_envelope(&mod->xxi[i].pei); } p->flags = p->player_flags; #ifndef LIBXMP_CORE_PLAYER module_quirks(ctx); #endif }
void load_epilogue(struct context_data *ctx) { struct player_data *p = &ctx->p; struct module_data *m = &ctx->m; struct xmp_module *mod = &m->mod; int i, j; mod->gvl = m->gvolbase; /* Fix cases where the restart value is invalid e.g. kc_fall8.xm * from http://aminet.net/mods/mvp/mvp_0002.lha (reported by * Ralf Hoffmann <*****@*****.**>) */ if (mod->rst >= mod->len) { mod->rst = 0; } /* Sanity check */ if (mod->spd == 0) { mod->spd = 6; } if (mod->bpm == 0) { mod->bpm = 125; } /* Set appropriate values for instrument volumes and subinstrument * global volumes when QUIRK_INSVOL is not set, to keep volume values * consistent if the user inspects struct xmp_module. We can later * set volumes in the loaders and eliminate the quirk. */ for (i = 0; i < mod->ins; i++) { if (~m->quirk & QUIRK_INSVOL) { mod->xxi[i].vol = m->volbase; } for (j = 0; j < mod->xxi[i].nsm; j++) { if (~m->quirk & QUIRK_INSVOL) { mod->xxi[i].sub[j].gvl = m->volbase; } } } /* Sanity check for envelopes */ for (i = 0; i < mod->ins; i++) { check_envelope(&mod->xxi[i].aei); check_envelope(&mod->xxi[i].fei); check_envelope(&mod->xxi[i].pei); } p->flags = p->player_flags; module_quirks(ctx); }
void index_mail_set_seq(struct mail *_mail, uint32_t seq) { struct index_mail *mail = (struct index_mail *)_mail; struct index_mail_data *data = &mail->data; struct mail_cache_field *cache_fields = mail->ibox->cache_fields; struct mail_cache_view *cache_view = mail->trans->cache_view; const struct mail_index_header *hdr; struct istream *input; if (data->seq == seq) return; index_mail_reset(mail); data->seq = seq; mail->mail.mail.seq = seq; mail_index_lookup_uid(_mail->transaction->view, seq, &mail->mail.mail.uid); if (mail_index_view_is_inconsistent(_mail->transaction->view)) { mail_set_expunged(&mail->mail.mail); return; } if ((mail->wanted_fields & (MAIL_FETCH_NUL_STATE | MAIL_FETCH_IMAP_BODY | MAIL_FETCH_IMAP_BODYSTRUCTURE)) != 0) { (void)index_mail_get_fixed_field(mail, MAIL_CACHE_FLAGS, &data->cache_flags, sizeof(data->cache_flags)); mail->mail.mail.has_nuls = (data->cache_flags & MAIL_CACHE_FLAG_HAS_NULS) != 0; mail->mail.mail.has_no_nuls = (data->cache_flags & MAIL_CACHE_FLAG_HAS_NO_NULS) != 0; } /* see if wanted_fields can tell us if we need to read/parse header/body */ if ((mail->wanted_fields & MAIL_FETCH_MESSAGE_PARTS) != 0) { unsigned int cache_field = cache_fields[MAIL_CACHE_MESSAGE_PARTS].idx; if (mail_cache_field_exists(cache_view, seq, cache_field) <= 0) { data->access_part |= PARSE_HDR | PARSE_BODY; data->save_message_parts = TRUE; } } if ((mail->wanted_fields & MAIL_FETCH_IMAP_ENVELOPE) != 0) check_envelope(mail); if ((mail->wanted_fields & MAIL_FETCH_IMAP_BODY) != 0 && (data->cache_flags & MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) == 0) { /* we need either imap.body or imap.bodystructure */ unsigned int cache_field1 = cache_fields[MAIL_CACHE_IMAP_BODY].idx; unsigned int cache_field2 = cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx; if (mail_cache_field_exists(cache_view, seq, cache_field1) <= 0 && mail_cache_field_exists(cache_view, seq, cache_field2) <= 0) { data->access_part |= PARSE_HDR | PARSE_BODY; data->save_bodystructure_header = TRUE; data->save_bodystructure_body = TRUE; } } if ((mail->wanted_fields & MAIL_FETCH_IMAP_BODYSTRUCTURE) != 0 && (data->cache_flags & MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) == 0) { unsigned int cache_field = cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx; if (mail_cache_field_exists(cache_view, seq, cache_field) <= 0) { data->access_part |= PARSE_HDR | PARSE_BODY; data->save_bodystructure_header = TRUE; data->save_bodystructure_body = TRUE; } } if ((mail->wanted_fields & MAIL_FETCH_DATE) != 0) { unsigned int cache_field = cache_fields[MAIL_CACHE_SENT_DATE].idx; if (mail_cache_field_exists(cache_view, seq, cache_field) <= 0) { data->access_part |= PARSE_HDR; data->save_sent_date = TRUE; } } if ((mail->wanted_fields & (MAIL_FETCH_STREAM_HEADER | MAIL_FETCH_STREAM_BODY)) != 0) { /* open stream immediately to set expunged flag if it's already lost */ if ((mail->wanted_fields & MAIL_FETCH_STREAM_HEADER) != 0) data->access_part |= READ_HDR; if ((mail->wanted_fields & MAIL_FETCH_STREAM_BODY) != 0) data->access_part |= READ_BODY; /* open the stream only if we didn't get here from mailbox_save_init() */ hdr = mail_index_get_header(_mail->box->view); if (!_mail->saving && _mail->uid < hdr->next_uid) (void)mail_get_stream(_mail, NULL, NULL, &input); } }
int compare_module(struct xmp_module *mod, FILE *f) { char line[1024]; char *s; int i, j, x; /* Check title and format */ read_line(line, 1024, f); fail_unless(!strcmp(line, mod->name), "module name"); read_line(line, 1024, f); fail_unless(!strcmp(line, mod->type), "module type"); /* Check module attributes */ read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == mod->pat, "number of patterns"); x = strtoul(s, &s, 0); fail_unless(x == mod->trk, "number of tracks"); x = strtoul(s, &s, 0); fail_unless(x == mod->chn, "number of channels"); x = strtoul(s, &s, 0); fail_unless(x == mod->ins, "number of instruments"); x = strtoul(s, &s, 0); fail_unless(x == mod->smp, "number of samples"); x = strtoul(s, &s, 0); fail_unless(x == mod->spd, "initial speed"); x = strtoul(s, &s, 0); fail_unless(x == mod->bpm, "initial tempo"); x = strtoul(s, &s, 0); fail_unless(x == mod->len, "module length"); x = strtoul(s, &s, 0); fail_unless(x == mod->rst, "restart position"); x = strtoul(s, &s, 0); fail_unless(x == mod->gvl, "global volume"); /* Check orders */ if (mod->len > 0) { read_line(line, 1024, f); s = line; for (i = 0; i < mod->len; i++) { x = strtoul(s, &s, 0); fail_unless(x == mod->xxo[i], "orders"); } } /* Check instruments */ for (i = 0; i < mod->ins; i++) { struct xmp_instrument *xxi = &mod->xxi[i]; read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == xxi->vol, "instrument volume"); x = strtoul(s, &s, 0); fail_unless(x == xxi->nsm, "number of subinstruments"); x = strtoul(s, &s, 0); fail_unless(x == xxi->rls, "instrument release"); x = strncmp(++s, xxi->name, 32); fail_unless(x == 0, "instrument name"); /* check envelopes */ check_envelope(&xxi->aei, line, f); check_envelope(&xxi->fei, line, f); check_envelope(&xxi->pei, line, f); /* check mapping */ read_line(line, 1024, f); s = line; for (j = 0; j < XMP_MAX_KEYS; j++) { x = strtoul(s, &s, 0); fail_unless(x == xxi->map[j].ins, "instrument map"); } read_line(line, 1024, f); s = line; for (j = 0; j < XMP_MAX_KEYS; j++) { x = strtoul(s, &s, 0); fail_unless(x == xxi->map[j].xpo, "transpose map"); } /* check subinstruments */ for (j = 0; j < xxi->nsm; j++) { struct xmp_subinstrument *sub = &xxi->sub[j]; read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == sub->vol, "subinst volume"); x = strtoul(s, &s, 0); fail_unless(x == sub->gvl, "subinst gl volume"); x = strtoul(s, &s, 0); fail_unless(x == sub->pan, "subinst pan"); x = strtoul(s, &s, 0); fail_unless(x == sub->xpo, "subinst transpose"); x = strtoul(s, &s, 0); fail_unless(x == sub->fin, "subinst finetune"); x = strtoul(s, &s, 0); fail_unless(x == sub->vwf, "subinst vibr wf"); x = strtoul(s, &s, 0); fail_unless(x == sub->vde, "subinst vibr depth"); x = strtoul(s, &s, 0); fail_unless(x == sub->vra, "subinst vibr rate"); x = strtoul(s, &s, 0); fail_unless(x == sub->vsw, "subinst vibr sweep"); x = strtoul(s, &s, 0); fail_unless(x == sub->rvv, "subinst vol var"); x = strtoul(s, &s, 0); fail_unless(x == sub->sid, "subinst sample nr"); x = strtoul(s, &s, 0); fail_unless(x == sub->nna, "subinst NNA"); x = strtoul(s, &s, 0); fail_unless(x == sub->dct, "subinst DCT"); x = strtoul(s, &s, 0); fail_unless(x == sub->dca, "subinst DCA"); x = strtoul(s, &s, 0); fail_unless(x == sub->ifc, "subinst cutoff"); x = strtoul(s, &s, 0); fail_unless(x == sub->ifr, "subinst resonance"); } } /* Check patterns */ for (i = 0; i < mod->pat; i++) { struct xmp_pattern *xxp = mod->xxp[i]; read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == xxp->rows, "pattern rows"); for (j = 0; j < mod->chn; j++) { x = strtoul(s, &s, 0); fail_unless(x == xxp->index[j], "pattern index"); } } /* Check tracks */ for (i = 0; i < mod->trk; i++) { struct xmp_track *xxt = mod->xxt[i]; unsigned char d[16]; MD5_CTX ctx; read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == xxt->rows, "track rows"); MD5Init(&ctx); MD5Update(&ctx, (const unsigned char *)xxt->event, xxt->rows * sizeof (struct xmp_event)); MD5Final(d, &ctx); fail_unless(compare_md5(d, ++s) == 0, "track data"); } /* Check samples */ for (i = 0; i < mod->smp; i++) { struct xmp_sample *xxs = &mod->xxs[i]; unsigned char d[16]; MD5_CTX ctx; int len = xxs->len; if (xxs->flg & XMP_SAMPLE_16BIT) len *= 2; read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == xxs->len, "sample length"); x = strtoul(s, &s, 0); fail_unless(x == xxs->lps, "sample loop start"); x = strtoul(s, &s, 0); fail_unless(x == xxs->lpe, "sample loop end"); x = strtoul(s, &s, 0); fail_unless(x == xxs->flg, "sample flags"); s++; if (len > 0 && xxs->data != NULL) { MD5Init(&ctx); MD5Update(&ctx, xxs->data, len); MD5Final(d, &ctx); fail_unless(compare_md5(d, s) == 0, "sample data"); } s += 32; fail_unless(strcmp(xxs->name, ++s) == 0, "sample name"); } /* Check channels */ for (i = 0; i < mod->chn; i++) { struct xmp_channel *xxc = &mod->xxc[i]; read_line(line, 1024, f); x = strtoul(line, &s, 0); fail_unless(x == xxc->pan, "channel pan"); x = strtoul(s, &s, 0); fail_unless(x == xxc->vol, "channel volume"); x = strtoul(s, &s, 0); fail_unless(x == xxc->flg, "channel flags"); } return 0; }