<commit_before>/*
 * format/amiga/sextett.c
 * 
 * Sextett compilation by Kingsoft
 *
 * Track 158:
 *  u16 0x92459245
 *  u8 key[3] :: raw bytes
 *  Track gap is zeroes.
 * Track 159:
 *  u16 0x92459245
 * Protection check synchronises on T159, then steps to T161 while
 * simultaneously starting an unsynchronised read DMA. The key from T158 is
 * used as an offset into the read buffer, which must contain a 0x9245 sync
 * word at that offset.
 * We simulate this by filling tracks 160 and 161 with 0x9245.
 */

#include <libdisk/util.h>
#include <private/disk.h>

static void *sextett_protection_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint32_t *block;

    while (stream_next_bit(s) != -1) {
        if (s->word != 0x92459245)
            continue;
        if (tracknr == 158)
            ti->data_bitoff = s->index_offset_bc - 31;
        else /* Tracks 159-161: no data, all same data_bitoff (==0) */
            return memalloc(0);
        if (stream_next_bits(s, 32) == -1)
            break;
        block = memalloc(4);<commit_msg>libdisk: Make sextett analyser more lenient.<commit_after>/*
 * format/amiga/sextett.c
 * 
 * Sextett compilation by Kingsoft
 *
 * Track 158:
 *  u16 0x92459245
 *  u8 key[3] :: raw bytes
 *  Track gap is zeroes.
 * Track 159:
 *  u16 0x92459245
 * Protection check synchronises on T159, then steps to T161 while
 * simultaneously starting an unsynchronised read DMA. The key from T158 is
 * used as an offset into the read buffer, which must contain a 0x9245 sync
 * word at that offset.
 * We simulate this by filling tracks 160 and 161 with 0x9245.
 */

#include <libdisk/util.h>
#include <private/disk.h>

static void *sextett_protection_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint32_t *block;

    /* Tracks 159-161: no data, all same data_bitoff (==0) */
    if ((tracknr >= 159) && (tracknr <= 161)) {
        struct track_info *t158 = &d->di->track[158];
        return (t158->type == TRKTYP_sextett_protection) ? memalloc(0) : NULL;
    }

    /* Track 158: find the key */
    while (stream_next_bit(s) != -1) {
        if (s->word != 0x92459245)
            continue;
        ti->data_bitoff = s->index_offset_bc - 31;
        if (stream_next_bits(s, 32) == -1)
            break;
        block = memalloc(4);
{'fraction_non_alphanumeric': 0.11261261261261261, 'fraction_numerical': 0.07493857493857493, 'mean_word_length': 2.781733746130031, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2244088', 'n_tokens_mistral': 956, 'n_tokens_neox': 818, 'n_words': 267}