/** Iterate over the partitions on a device. * @param disk Disk to iterate over. * @param cb Callback function. * @return Whether the device contained an MBR partition table. */ static bool mbr_partition_iterate(disk_device_t *disk, partition_iterate_cb_t cb) { mbr_t *mbr __cleanup_free; bool seen_extended; /* Read in the MBR, which is in the first block on the device. */ mbr = malloc(sizeof(*mbr)); if (!read_mbr(disk, mbr, 0) || mbr->signature != MBR_SIGNATURE) return false; /* Check if this is a GPT partition table (technically we should not get * here if this is a GPT disk as the GPT code should be reached first). This * is just a safeguard. */ if (mbr->partitions[0].type == MBR_PARTITION_TYPE_GPT) return false; /* Loop through all partitions in the table. */ seen_extended = false; for (size_t i = 0; i < array_size(mbr->partitions); i++) { mbr_partition_t *partition = &mbr->partitions[i]; if (!is_valid(disk, partition)) continue; if (is_extended(partition)) { if (seen_extended) { dprintf("mbr: warning: ignoring multiple extended partitions\n"); continue; } handle_extended(disk, partition->start_lba, cb); seen_extended = true; } else { cb(disk, i, partition->start_lba, partition->num_sectors); } } return true; }
/* Handle Command, special char or attribute and also check for * channel changes. * Returns 1 if something was written to screen, 0 otherwise */ int disCommand(unsigned char hi, unsigned char lo, ccx_decoder_608_context *context, struct cc_subtitle *sub) { int wrote_to_screen=0; /* Full channel changes are only allowed for "GLOBAL CODES", * "OTHER POSITIONING CODES", "BACKGROUND COLOR CODES", * "MID-ROW CODES". * "PREAMBLE ACCESS CODES", "BACKGROUND COLOR CODES" and * SPECIAL/SPECIAL CHARACTERS allow only switching * between 1&3 or 2&4. */ context->new_channel = check_channel(hi, context); //if (wb->data608->channel!=cc_channel) // continue; if (hi>=0x18 && hi<=0x1f) hi=hi-8; switch (hi) { case 0x10: if (lo>=0x40 && lo<=0x5f) handle_pac(hi, lo, context); break; case 0x11: if (lo>=0x20 && lo<=0x2f) handle_text_attr(hi, lo, context); if (lo>=0x30 && lo<=0x3f) { wrote_to_screen=1; handle_double(hi, lo, context); } if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x12: case 0x13: if (lo>=0x20 && lo<=0x3f) { wrote_to_screen = handle_extended(hi, lo, context); } if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x14: case 0x15: if (lo>=0x20 && lo<=0x2f) handle_command(hi, lo, context, sub); if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x16: if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; case 0x17: if (lo>=0x21 && lo<=0x23) handle_command(hi, lo, context, sub); if (lo>=0x2e && lo<=0x2f) handle_text_attr(hi, lo, context); if (lo>=0x40 && lo<=0x7f) handle_pac(hi, lo, context); break; } return wrote_to_screen; }