static int tracer_start(void) { int rc = 0; struct dcpu_vcpu *vcpu = tracer_vcpu; if (!vcpu) die("need to specify dcpu to trace"); dump_header(stdout); dump_oneline(vcpu, &tracing_debugger_state, stdout); dcpu_vcpu_backup_state(vcpu, &tracing_debugger_state); while(!vcpu->st.halted) { rc = vcpu->ops.step(vcpu); if (rc<0) break; } dump_header(stdout); if (vcpu->st.halted) return vcpu->st.hcf_code; return rc; }
int main(int argc, char **argv) { int i, nb; FILE *file; CELTMode **m; if (argc%3 != 1) { fprintf (stderr, "must have a multiple of 4 arguments\n"); return 1; } nb = (argc-1)/3; m = malloc(nb*sizeof(CELTMode*)); for (i=0;i<nb;i++) { int Fs, ch, frame; Fs = atoi(argv[3*i+1]); ch = atoi(argv[3*i+2]); frame = atoi(argv[3*i+3]); m[i] = celt_mode_create(Fs, ch, frame, NULL); } file = fopen("static_modes.c", "w"); dump_modes(file, m, nb); fclose(file); file = fopen("static_modes.h", "w"); dump_header(file, m, nb); fclose(file); for (i=0;i<nb;i++) celt_mode_destroy(m[i]); free(m); return 0; }
void dump_header(std::string header) { if (done.find(header) != done.end()) return; done.insert(header); FILE *f = fopen(header.c_str(), "r"); if (f == NULL) { fprintf(stderr, "Could not open header %s.\n", header.c_str()); exit(1); } char line[1024]; while (fgets(line, 1024, f)) { if (strncmp(line, "#include \"", 10) == 0) { char *sub_header = line + 10; for (int i = 0; i < 1014; i++) { if (sub_header[i] == '"') sub_header[i] = 0; } size_t slash_pos = header.rfind('/'); std::string path; if (slash_pos != std::string::npos) path = header.substr(0, slash_pos + 1); dump_header(path + sub_header); } else { fputs(line, stdout); } } fclose(f); }
void stats_dump_all(void) { dump_header(); for(uint8_t i=0;i<STATS_ID_NUM;i++) { dump_line(i); } }
ucell load_dictionary(const char *data, ucell len) { u32 checksum=0; const char *checksum_walk; ucell *walk, *reloc_table; dictionary_header_t *header=(dictionary_header_t *)data; /* assertions */ if (len <= (sizeof(dictionary_header_t)) || strncmp(DICTID, data, 8)) return 0; #ifdef CONFIG_DEBUG_DICTIONARY dump_header(header); #endif checksum_walk=data; while (checksum_walk<data+len) { checksum+=read_long(checksum_walk); checksum_walk+=sizeof(u32); } if(checksum) { printk("Checksum invalid (%08x)!\n", checksum); return 0; } data += sizeof(dictionary_header_t); dicthead = target_long(header->length); memcpy(dict, data, dicthead); reloc_table=(ucell *)(data+dicthead); #ifdef CONFIG_DEBUG_DICTIONARY printk("\nmoving dictionary (%x bytes) to %x\n", (ucell)dicthead, (ucell)dict); printk("\ndynamic relocation..."); #endif for (walk = (ucell *) dict; walk < (ucell *) (dict + dicthead); walk++) { int pos, bit, l; l=(walk-(ucell *)dict); pos=l/BITS; bit=l&~(-BITS); if (reloc_table[pos] & target_ucell((ucell)1ULL << bit)) { // printk("%lx, pos %x, bit %d\n",*walk, pos, bit); write_ucell(walk, read_ucell(walk)+pointer2cell(dict)); } } #ifdef CONFIG_DEBUG_DICTIONARY printk(" done.\n"); #endif last = (ucell *)(dict + target_ucell(header->last)); return -1; }
// file context dump: virtual boost::filesystem::fstream& dumpHeaderToFile(boost::filesystem::fstream& os) const { std::string timeLabel(makeTimeLabel()); os << "# StartTime = " << timeLabel << " [UTC]" << lineBreak(); posEndTime_ = os.tellg() + std::streamoff(14); os << "# EndTime = " << timeLabel << " [UTC]" << lineBreak(); std::ostringstream oss; dump_header(oss); os << oss.str(); return os; }
static int load_image(int fileidx, int argc, char **argv) { FILE *file; uint16_t i, tgasize, nr; struct rgb *imidx; if (argc - fileidx <= 0) { fprintf(stderr, "No input file specified\n"); usage(); return -1; } input_file = argv[fileidx]; file = fopen(input_file, "rb"); if (file == NULL) { fprintf(stderr, "Cannot open %s file!\n",argv[1]); return -1; } nr = fread(&tga, sizeof(struct tga_header), 1, file); if (nr != 1) { fprintf(stderr, "Unable to read file header.\n"); return -1; } if(verify_header(&tga)) { fprintf(stderr, "Unsupported file format\n"); dump_header(&tga); return -1; } tgasize = tga.width * tga.height; image = malloc(tgasize * sizeof(struct rgb)); // FIXME: these shouldn't be here image_out_4bit = malloc(tgasize * sizeof(struct fbit)); image_out_scr2 = malloc(MAX_SCR2_SIZE * sizeof(struct scr2)); if (image == NULL) { fprintf(stderr, "Unable to allocate memory\n"); return -1; } nr = fread(image, sizeof(struct rgb), tgasize, file); if (nr != tgasize) { fprintf(stderr, "Unable to read file data.\n"); return -1; } fclose(file); return 0; }
int main(int argc, char *argv[]) { const SGML_dtd *the_dtd = &HTML_dtd; int ch; int dtd_version = 0; int c_option = FALSE; int h_option = FALSE; int l_option = FALSE; FILE *input = stdin; FILE *output = stdout; while ((ch = getopt(argc, argv, GETOPT)) != -1) { switch (ch) { case 'c': c_option = TRUE; break; case 'h': h_option = TRUE; break; case 'l': l_option = TRUE; input = fopen(optarg, "r"); if (input == 0) failed(optarg); break; case 'o': output = fopen(optarg, "w"); if (output == 0) failed(optarg); break; case 't': dtd_version = 1; break; case 's': dtd_version = 0; break; default: usage(); } } HTSwitchDTD(dtd_version); if (l_option) the_dtd = load_flatfile(input); if (the_dtd != 0) { if (c_option) dump_source(output, the_dtd, dtd_version); if (h_option) dump_header(output, the_dtd); if (!c_option && !h_option) dump_flatfile(output, the_dtd); } return EXIT_SUCCESS; }
json_t *dump_headers(const nghttp2_nv *nva, size_t nvlen) { json_t *headers; size_t i; headers = json_array(); for (i = 0; i < nvlen; ++i) { json_array_append_new(headers, dump_header(nva[i].name, nva[i].namelen, nva[i].value, nva[i].valuelen)); } return headers; }
void stats_dump(uint8_t pb, uint8_t pio) { dump_header(); if(pb) { dump_line(STATS_ID_PB_RX); dump_line(STATS_ID_PB_TX); } if(pio) { dump_line(STATS_ID_PIO_RX); dump_line(STATS_ID_PIO_TX); } }
int check_mdul_hdr(int fd, mdul_hdr_t *m) { if (gV > 1) puts("check_mdul_hdr"); if (MUST_DUMP) puts("WILL DUMP"); int err = 0, red = 0; mdul_hdr_t bak; char *it = NULL; memcpy(&bak, m, sizeof(bak)); swap_mdul_endianness(&bak); if (bak.hdr_len > 65536) die("invalid module header length"); if (!(it = malloc(bak.hdr_len))) die("malloc failed"); if ((red = read(fd, it, bak.hdr_len)) != bak.hdr_len) die("read error!"); if (MUST_DUMP) dump_header(it, bak.hdr_len); __uint32_t cmp_cksum, hdr_cksum; unsigned char magic[4] = {0}; memcpy(&magic, (void*)(&module_magics[0]) + bak.type -1, 4); hdr_cksum = ((mdul_hdr_t*)it)->hdr_cksum; ((mdul_hdr_t*)it)->hdr_cksum = 0; for (unsigned char inc = 0, cmp_cksum = 0; inc != 128;++inc) cmp_cksum += *(it + inc); ((mdul_hdr_t*)it)->hdr_cksum = hdr_cksum; if (bak.hdr_cksum == cmp_cksum || 1) { if (bak.type >= 9 || magic == 0) { err = mdul_hdr_md5(fd, &bak); puts("good module md5 digest"); } else { // magic != 0 || type <= 9 unsigned short x; for (x = 0; magic[x] && magic[x] == bak.magic[x] && x < 4; ++x); if (x != 4) { puts("module magic is wrong!"); err = 1; } else { puts("good module magic!"); err = mdul_hdr_md5(fd, &bak);} } } free(it); return err; }
void Z3BitVector::dump_problem(string& filename_base){ FILE* file = fopen(filename_base.c_str(), "w"); dump_header(file); dump_variables(file); dump_extra(file); dump_conditions(file); dump_check_sat(file); dump_get(file); dump_tail(file); fclose(file); }
int main (int argc, char *argv[]) { /* emit STL header */ dump_header(); /* emit outer and inner spiral */ emit_spiral(true); emit_spiral(false); /* emit full stl file on stdout */ dump_stl(stdout); return 0; }
int main(int argc, char **headers) { // If we're building on visual studio and Halide_SHARED is defined, we'd better // also define it for clients so that dllimport gets used. #if defined(_MSC_VER) && defined(Halide_SHARED) printf("#define Halide_SHARED\n"); #endif for (int i = 1; i < argc; i++) { dump_header(headers[i]); } return 0; }
void spy_dump (spy_t s) { tabstop t; open_output(); spy_accumulate_children_stats(s); if (mode == SPY_DISPLAY_SAMPLES) { display_samples(s); } else { init_tabstop(&t); set_tabstop(s, &t); dump_header(&t); spy_dump_internal(s, &t); } }
void kssl_write(SSL *ssl, kssl_header *k, kssl_operation *r) { BYTE *req; int req_len, n; flatten_operation(k, r, &req, &req_len); dump_header(k, "send"); dump_request(r); n = SSL_write(ssl, req, req_len); if (n != req_len) { fatal_error("Failed to send KSSL header"); } free(req); }
static void oom_kill_process(struct oom_control *oc, const char *message) { struct task_struct *victim = oc->chosen; struct mem_cgroup *oom_group; static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); /* * If the task is already exiting, don't alarm the sysadmin or kill * its children or threads, just give it access to memory reserves * so it can die quickly */ task_lock(victim); if (task_will_free_mem(victim)) { mark_oom_victim(victim); wake_oom_reaper(victim); task_unlock(victim); put_task_struct(victim); return; } task_unlock(victim); if (__ratelimit(&oom_rs)) dump_header(oc, victim); /* * Do we need to kill the entire memory cgroup? * Or even one of the ancestor memory cgroups? * Check this out before killing the victim task. */ oom_group = mem_cgroup_get_oom_group(victim, oc->memcg); __oom_kill_process(victim, message); /* * If necessary, kill all tasks in the selected memory cgroup. */ if (oom_group) { mem_cgroup_print_oom_group(oom_group); mem_cgroup_scan_tasks(oom_group, oom_kill_memcg_member, (void*)message); mem_cgroup_put(oom_group); } }
/* * Determines whether the kernel must panic because of the panic_on_oom sysctl. */ static void check_panic_on_oom(struct oom_control *oc, enum oom_constraint constraint) { if (likely(!sysctl_panic_on_oom)) return; if (sysctl_panic_on_oom != 2) { /* * panic_on_oom == 1 only affects CONSTRAINT_NONE, the kernel * does not panic for cpuset, mempolicy, or memcg allocation * failures. */ if (constraint != CONSTRAINT_NONE) return; } /* Do not panic for oom kills triggered by sysrq */ if (is_sysrq_oom(oc)) return; dump_header(oc, NULL); panic("Out of memory: %s panic_on_oom is enabled\n", sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide"); }
int entry_header_cb(header_translated_t *proper, int entry_index, void *context_data) { dump_header(proper); if(proper->type == T_NORMAL) { char file_path[256] = ""; strcat(file_path, "/tmp/"); strcat(file_path, proper->filename); if((fp_writer = fopen(file_path, "wb")) == NULL) { printf("Could not open [%s] for write.\n", file_path); return -1; } } else printf("Not writing non-normal file.\n\n"); return 0; }
void spy_dump_all () { int i; unsigned long total = 0; tabstop t; spy_t s; open_output(); init_tabstop(&t); for (i = 0; i < nspys; i++) { s = &spys[i]; spy_accumulate_children_stats(s); if (s->n == 0) continue; if (mode != SPY_DISPLAY_SAMPLES) set_tabstop(s, &t); total += spys[i].cumulative; } if (mode == SPY_DISPLAY_SAMPLES) { for (i = 0; i < nspys; i++) { s = &spys[i]; if (s->n == 0) continue; display_samples(s); } } else { dump_header(&t); for (i = 0; i < nspys; i++) { s = &spys[i]; if (s->n == 0) continue; spy_dump_internal(s, &t); } if (mode & SPY_DISPLAY_TOTAL) { fprintf(out, "total: %s.\n", r_dtoa(cycle_to_usec(total))); } } }
void Memcached::dump(const Packet *packet, Options *op) { if (packet->payload_len_ < HEADER_LEN) return ; PacketHeader header(packet->payload_); if (header.magic_ != MAGIC_REQ && header.magic_ != MAGIC_RESP) { return ; } if (!op->op_set_.empty() && op->op_set_.find(header.opcode_) == op->op_set_.end()) { return ; } packet->dump_header(); dump_header(&header); if (packet->payload_len_ == HEADER_LEN) { packet->dump_payload(); return ; } dump_body(&header, packet->payload_ + HEADER_LEN, packet->payload_len_ + HEADER_LEN); if (op->verbose_) { packet->dump_payload(); } }
void dump_header(std::string header) { if (done.find(header) != done.end()) return; done.insert(header); if (header.find("runtime_internal") != std::string::npos) { fprintf(stdout, "#error \"COMPILING_HALIDE_RUNTIME should never be defined for Halide.h\"\n"); return; } FILE *f = fopen(header.c_str(), "r"); if (f == NULL) { fprintf(stderr, "Could not open header %s.\n", header.c_str()); exit(1); } char line[1024]; while (fgets(line, 1024, f)) { if (strncmp(line, "#include \"", 10) == 0) { char *sub_header = line + 10; for (int i = 0; i < 1014; i++) { if (sub_header[i] == '"') sub_header[i] = 0; } size_t slash_pos = header.rfind('/'); std::string path; if (slash_pos != std::string::npos) path = header.substr(0, slash_pos + 1); dump_header(path + sub_header); } else { fputs(line, stdout); } } fclose(f); }
static int BMP_description( FL_IMAGE * im ) { SPEC *sp = fl_calloc( 1, sizeof *sp ); char buf[ 40 ]; if ( fread( buf, 1, 2, im->fpin ) != 2 ) { im->error_message( im, "error while readin bmp file" ); fl_free( sp ); return -1; } sp->fsize = fli_fget4LSBF( im->fpin ); if ( fread( buf, 1, 4, im->fpin ) != 4 ) { im->error_message( im, "error while reading bmp file" ); fl_free( sp ); return -1; } sp->offset = fli_fget4LSBF( im->fpin ); sp->infosize = fli_fget4LSBF( im->fpin ); if ( sp->infosize != 40 && sp->infosize != 64 ) { im->error_message( im, "unsupported old obsolete bmp file" ); fl_free( sp ); return -1; } im->io_spec = sp; sp->w = fli_fget4LSBF( im->fpin ); sp->h = fli_fget4LSBF( im->fpin ); sp->planes = fli_fget2LSBF( im->fpin ); sp->bpp = fli_fget2LSBF( im->fpin ); sp->encode = fli_fget4LSBF( im->fpin ); sp->isize = fli_fget4LSBF( im->fpin ); sp->xres = fli_fget4LSBF( im->fpin ); sp->yres = fli_fget4LSBF(im->fpin); sp->col_used = fli_fget4LSBF( im->fpin ); sp->col_important = fli_fget4LSBF( im->fpin ); if ( bad_bpp( sp->bpp ) ) { flimage_error( im, "%s: bad bpp (%d)", im->infile, sp->bpp ); fl_free( im->io_spec ); im->io_spec = 0; return -1; } if ( sp->infosize != 40 ) { int skip = sp->infosize - 40; if ( skip < 0 || fread( buf, 1, skip, im->fpin ) != ( size_t ) skip ) { flimage_error( im, "%s: error while reading bmp file", im->infile ); fl_free( im->io_spec ); im->io_spec = 0; return -1; } } im->w = sp->w; im->h = sp->h; /* read colormap */ if ( sp->bpp != 24 ) { int i; if ( ( im->map_len = sp->col_used ) <= 0 ) im->map_len = 1 << sp->bpp; flimage_getcolormap( im ); for ( i = 0; i < im->map_len; i++ ) { im->blue_lut[ i ] = getc( im->fpin ); im->green_lut[ i ] = getc( im->fpin ); im->red_lut[ i ] = getc( im->fpin ); im->alpha_lut[ i ] = getc( im->fpin ); } } sp->bpl = ( sp->w * sp->bpp + 7 ) / 8; sp->pad = ( ( sp->bpl + 3 ) / 4 ) * 4 - sp->bpl; /* pad to 4 bytes */ if ( sp->bpp == 24 ) im->type = FL_IMAGE_RGB; else if ( sp->bpp == 1 ) im->type = FL_IMAGE_MONO; else im->type = FL_IMAGE_CI; #if BMPDEBUG dump_header( "after read", sp ); #endif if ( im->setup->header_info ) generate_header_info( im ); return 1; }
int samtools_test_trans_tbl_init_main(int argc, char**argv) { const int NUM_TESTS = 6; int verbose = 0; int success = 0; int failure = 0; int getopt_char; while ((getopt_char = getopt(argc, argv, "v")) != -1) { switch (getopt_char) { case 'v': ++verbose; break; default: break; } } // Set the seed to a fixed value so that calls to lrand48 within functions return predictable values const long GIMMICK_SEED = 0x1234330e; srand48(GIMMICK_SEED); bam_hdr_t* out; bam_hdr_t* translate; if (verbose) fprintf(pysam_stdout, "BEGIN test 1\n"); // setup trans_tbl_t tbl_1; merged_header_t *merged_hdr = init_merged_header(); translate = setup_test_1(merged_hdr); assert(translate); // test if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); } if (verbose) fprintf(pysam_stdout, "RUN test 1\n"); trans_tbl_init(merged_hdr, translate, &tbl_1, false, false, true, NULL); out = finish_merged_header(merged_hdr); free_merged_header(merged_hdr); if (verbose) fprintf(pysam_stdout, "END RUN test 1\n"); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); fprintf(pysam_stdout, "out\n"); dump_header(out); } if (check_test_1(translate, out, &tbl_1)) { if (verbose) fprintf(pysam_stdout, "Test 1 : PASS\n"); ++success; } else { if (verbose) fprintf(pysam_stdout, "Test 1 : FAIL\n"); fprintf(pysam_stderr, "Test 1 : FAIL\n"); ++failure; } // teardown bam_hdr_destroy(translate); bam_hdr_destroy(out); trans_tbl_destroy(&tbl_1); if (verbose) fprintf(pysam_stdout, "END test 1\n"); // test if (verbose) fprintf(pysam_stdout, "BEGIN test 2\n"); // reinit trans_tbl_t tbl_2; merged_hdr = init_merged_header(); translate = setup_test_2(merged_hdr); assert(translate); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); } if (verbose) fprintf(pysam_stdout, "RUN test 2\n"); trans_tbl_init(merged_hdr, translate, &tbl_2, false, false, true, NULL); out = finish_merged_header(merged_hdr); free_merged_header(merged_hdr); if (verbose) fprintf(pysam_stdout, "END RUN test 2\n"); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); fprintf(pysam_stdout, "out\n"); dump_header(out); } if (check_test_2(translate, out, &tbl_2)) { if (verbose) fprintf(pysam_stdout, "Test 2 : PASS\n"); ++success; } else { if (verbose) fprintf(pysam_stdout, "Test 2 : FAIL\n"); fprintf(pysam_stderr, "Test 2 : FAIL\n"); ++failure; } // teardown bam_hdr_destroy(translate); bam_hdr_destroy(out); trans_tbl_destroy(&tbl_2); if (verbose) fprintf(pysam_stdout, "END test 2\n"); // test if (verbose) fprintf(pysam_stdout, "BEGIN test 3\n"); // reinit trans_tbl_t tbl_3; merged_hdr = init_merged_header(); translate = setup_test_3(merged_hdr); assert(translate); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); } if (verbose) fprintf(pysam_stdout, "RUN test 3\n"); trans_tbl_init(merged_hdr, translate, &tbl_3, false, false, true, NULL); out = finish_merged_header(merged_hdr); free_merged_header(merged_hdr); if (verbose) fprintf(pysam_stdout, "END RUN test 3\n"); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); fprintf(pysam_stdout, "out\n"); dump_header(out); } if (check_test_3(translate, out, &tbl_3)) { if (verbose) fprintf(pysam_stdout, "Test 3 : PASS\n"); ++success; } else { if (verbose) fprintf(pysam_stdout, "Test 3 : FAIL\n"); fprintf(pysam_stderr, "Test 3 : FAIL\n"); ++failure; } // teardown bam_hdr_destroy(translate); bam_hdr_destroy(out); trans_tbl_destroy(&tbl_3); if (verbose) fprintf(pysam_stdout, "END test 3\n"); // test if (verbose) fprintf(pysam_stdout, "BEGIN test 4\n"); // reinit trans_tbl_t tbl_4; merged_hdr = init_merged_header(); translate = setup_test_4(merged_hdr); assert(translate); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); } if (verbose) fprintf(pysam_stdout, "RUN test 4\n"); trans_tbl_init(merged_hdr, translate, &tbl_4, false, false, true, NULL); out = finish_merged_header(merged_hdr); free_merged_header(merged_hdr); if (verbose) fprintf(pysam_stdout, "END RUN test 4\n"); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); fprintf(pysam_stdout, "out\n"); dump_header(out); } if (check_test_4(translate, out, &tbl_4)) { if (verbose) fprintf(pysam_stdout, "Test 4 : PASS\n"); ++success; } else { if (verbose) fprintf(pysam_stdout, "Test 4 : FAIL\n"); fprintf(pysam_stderr, "Test 4 : FAIL\n"); ++failure; } // teardown bam_hdr_destroy(translate); bam_hdr_destroy(out); trans_tbl_destroy(&tbl_4); if (verbose) fprintf(pysam_stdout, "END test 4\n"); // test if (verbose) fprintf(pysam_stdout, "BEGIN test 5\n"); // reinit trans_tbl_t tbl_5; merged_hdr = init_merged_header(); translate = setup_test_5(merged_hdr); assert(translate); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); } if (verbose) fprintf(pysam_stdout, "RUN test 5\n"); trans_tbl_init(merged_hdr, translate, &tbl_5, false, false, true, NULL); out = finish_merged_header(merged_hdr); free_merged_header(merged_hdr); if (verbose) fprintf(pysam_stdout, "END RUN test 5\n"); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); fprintf(pysam_stdout, "out\n"); dump_header(out); } if (check_test_5(translate, out, &tbl_5)) { if (verbose) fprintf(pysam_stdout, "Test 5 : PASS\n"); ++success; } else { if (verbose) fprintf(pysam_stdout, "Test 5 : FAIL\n"); fprintf(pysam_stderr, "Test 5 : FAIL\n"); ++failure; } // teardown bam_hdr_destroy(translate); bam_hdr_destroy(out); trans_tbl_destroy(&tbl_5); if (verbose) fprintf(pysam_stdout, "END test 5\n"); // test if (verbose) fprintf(pysam_stdout, "BEGIN test 6\n"); // reinit trans_tbl_t tbl_6; merged_hdr = init_merged_header(); translate = setup_test_6(merged_hdr); assert(translate); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); } if (verbose) fprintf(pysam_stdout, "RUN test 6\n"); trans_tbl_init(merged_hdr, translate, &tbl_6, false, false, true, "filename"); out = finish_merged_header(merged_hdr); free_merged_header(merged_hdr); if (verbose) fprintf(pysam_stdout, "END RUN test 6\n"); if (verbose > 1) { fprintf(pysam_stdout, "translate\n"); dump_header(translate); fprintf(pysam_stdout, "out\n"); dump_header(out); } if (check_test_6(translate, out, &tbl_6)) { if (verbose) fprintf(pysam_stdout, "Test 6 : PASS\n"); ++success; } else { if (verbose) fprintf(pysam_stdout, "Test 6 : FAIL\n"); fprintf(pysam_stderr, "Test 6 : FAIL\n"); ++failure; } // teardown bam_hdr_destroy(translate); bam_hdr_destroy(out); trans_tbl_destroy(&tbl_6); if (verbose) fprintf(pysam_stdout, "END test 6\n"); if (success == NUM_TESTS) { return 0; } else { fprintf(pysam_stderr, "%d failures %d successes\n", failure, success); return 1; } }
static int open_wavpack(bgav_demuxer_context_t * ctx) { bgav_stream_t * s; uint8_t header[HEADER_SIZE]; wvpk_header_t h; wvpk_priv_t * priv; priv = calloc(1, sizeof(*priv)); ctx->priv = priv; if(bgav_input_get_data(ctx->input, header, HEADER_SIZE) < HEADER_SIZE) return 0; parse_header(&h, header); if(ctx->opt->dump_headers) dump_header(&h); /* Use header data to set up stream */ if(h.flags & WV_FLOAT) { bgav_log(ctx->opt, BGAV_LOG_ERROR, LOG_DOMAIN, "Floating point data is not supported"); return 0; } if(h.flags & WV_HYBRID) { bgav_log(ctx->opt, BGAV_LOG_ERROR, LOG_DOMAIN, "Hybrid coding mode is not supported"); return 0; } if(h.flags & WV_INT32) { bgav_log(ctx->opt, BGAV_LOG_ERROR, LOG_DOMAIN, "Integer point data is not supported"); return 0; } /* Create the track and the stream */ ctx->tt = bgav_track_table_create(1); s = bgav_track_add_audio_stream(ctx->tt->cur, ctx->opt); s->data.audio.format.num_channels = 1 + !(h.flags & WV_MONO); s->data.audio.format.samplerate = wv_rates[(h.flags >> 23) & 0xF]; s->fourcc = BGAV_MK_FOURCC('w','v','p','k'); s->data.audio.bits_per_sample = ((h.flags & 3) + 1) << 3; gavl_metadata_set(&ctx->tt->cur->metadata, GAVL_META_FORMAT, "Wavpack"); ctx->tt->cur->duration = gavl_time_unscale(s->data.audio.format.samplerate, h.total_samples); s->duration = h.total_samples; if(ctx->input->input->seek_byte) ctx->flags |= BGAV_DEMUXER_CAN_SEEK; ctx->index_mode = INDEX_MODE_SIMPLE; bgav_demuxer_init_cue(ctx); return 1; }
int main(int argc, char *argv[]) { int c, force = 0, dry_run = 0, verbose = 0, dump = 0; io_channel channel; errcode_t retval; int mount_flags, csum_error = 0, io_error = 0; size_t i, keys_per_block; char *device_name, *tdb_file; io_manager manager = unix_io_manager; struct undo_context undo_ctx; char *buf; struct undo_key_block *keyb; struct undo_key *dkey; struct undo_key_info *ikey; __u32 key_crc, blk_crc, hdr_crc; blk64_t lblk; ext2_filsys fs; __u64 offset = 0; char opt_offset_string[40] = { 0 }; #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); setlocale(LC_CTYPE, ""); bindtextdomain(NLS_CAT_NAME, LOCALEDIR); textdomain(NLS_CAT_NAME); set_com_err_gettext(gettext); #endif add_error_table(&et_ext2_error_table); prg_name = argv[0]; while ((c = getopt(argc, argv, "fhno:vz:")) != EOF) { switch (c) { case 'f': force = 1; break; case 'h': dump = 1; break; case 'n': dry_run = 1; break; case 'o': offset = strtoull(optarg, &buf, 0); if (*buf) { com_err(prg_name, 0, _("illegal offset - %s"), optarg); exit(1); } /* used to indicate that an offset was specified */ opt_offset_string[0] = 1; break; case 'v': verbose = 1; break; case 'z': undo_file = optarg; break; default: usage(); } } if (argc != optind + 2) usage(); tdb_file = argv[optind]; device_name = argv[optind+1]; if (undo_file && strcmp(tdb_file, undo_file) == 0) { printf(_("Will not write to an undo file while replaying it.\n")); exit(1); } /* Interpret the undo file */ retval = manager->open(tdb_file, IO_FLAG_EXCLUSIVE, &undo_ctx.undo_file); if (retval) { com_err(prg_name, errno, _("while opening undo file `%s'\n"), tdb_file); exit(1); } retval = io_channel_read_blk64(undo_ctx.undo_file, 0, -(int)sizeof(undo_ctx.hdr), &undo_ctx.hdr); if (retval) { com_err(prg_name, retval, _("while reading undo file")); exit(1); } if (memcmp(undo_ctx.hdr.magic, E2UNDO_MAGIC, sizeof(undo_ctx.hdr.magic))) { fprintf(stderr, _("%s: Not an undo file.\n"), tdb_file); exit(1); } if (dump) { dump_header(&undo_ctx.hdr); exit(1); } hdr_crc = ext2fs_crc32c_le(~0, (unsigned char *)&undo_ctx.hdr, sizeof(struct undo_header) - sizeof(__u32)); if (!force && ext2fs_le32_to_cpu(undo_ctx.hdr.header_crc) != hdr_crc) { fprintf(stderr, _("%s: Header checksum doesn't match.\n"), tdb_file); exit(1); } undo_ctx.blocksize = ext2fs_le32_to_cpu(undo_ctx.hdr.block_size); undo_ctx.fs_blocksize = ext2fs_le32_to_cpu(undo_ctx.hdr.fs_block_size); if (undo_ctx.blocksize == 0 || undo_ctx.fs_blocksize == 0) { fprintf(stderr, _("%s: Corrupt undo file header.\n"), tdb_file); exit(1); } if (!force && undo_ctx.blocksize > E2UNDO_MAX_BLOCK_SIZE) { fprintf(stderr, _("%s: Undo block size too large.\n"), tdb_file); exit(1); } if (!force && undo_ctx.blocksize < E2UNDO_MIN_BLOCK_SIZE) { fprintf(stderr, _("%s: Undo block size too small.\n"), tdb_file); exit(1); } undo_ctx.super_block = ext2fs_le64_to_cpu(undo_ctx.hdr.super_offset); undo_ctx.num_keys = ext2fs_le64_to_cpu(undo_ctx.hdr.num_keys); io_channel_set_blksize(undo_ctx.undo_file, undo_ctx.blocksize); /* * Do not compare undo_ctx.hdr.f_compat with the available compatible * features set, because a "missing" compatible feature should * not cause any problems. */ if (!force && (undo_ctx.hdr.f_incompat || undo_ctx.hdr.f_rocompat)) { fprintf(stderr, _("%s: Unknown undo file feature set.\n"), tdb_file); exit(1); } /* open the fs */ retval = ext2fs_check_if_mounted(device_name, &mount_flags); if (retval) { com_err(prg_name, retval, _("Error while determining whether " "%s is mounted."), device_name); exit(1); } if (mount_flags & EXT2_MF_MOUNTED) { com_err(prg_name, retval, "%s", _("e2undo should only be run " "on unmounted filesystems")); exit(1); } if (undo_file) { retval = e2undo_setup_tdb(device_name, &manager); if (retval) exit(1); } retval = manager->open(device_name, IO_FLAG_EXCLUSIVE | (dry_run ? 0 : IO_FLAG_RW), &channel); if (retval) { com_err(prg_name, retval, _("while opening `%s'"), device_name); exit(1); } if (*opt_offset_string || e2undo_has_feature_fs_offset(&undo_ctx.hdr)) { if (!*opt_offset_string) offset = ext2fs_le64_to_cpu(undo_ctx.hdr.fs_offset); retval = snprintf(opt_offset_string, sizeof(opt_offset_string), "offset=%llu", offset); if ((size_t) retval >= sizeof(opt_offset_string)) { /* should not happen... */ com_err(prg_name, 0, _("specified offset is too large")); exit(1); } io_channel_set_options(channel, opt_offset_string); } if (!force && check_filesystem(&undo_ctx, channel)) exit(1); /* prepare to read keys */ retval = ext2fs_get_mem(sizeof(struct undo_key_info) * undo_ctx.num_keys, &undo_ctx.keys); if (retval) { com_err(prg_name, retval, "%s", _("while allocating memory")); exit(1); } ikey = undo_ctx.keys; retval = ext2fs_get_mem(undo_ctx.blocksize, &keyb); if (retval) { com_err(prg_name, retval, "%s", _("while allocating memory")); exit(1); } retval = ext2fs_get_mem(E2UNDO_MAX_EXTENT_BLOCKS * undo_ctx.blocksize, &buf); if (retval) { com_err(prg_name, retval, "%s", _("while allocating memory")); exit(1); } /* load keys */ keys_per_block = KEYS_PER_BLOCK(&undo_ctx); lblk = ext2fs_le64_to_cpu(undo_ctx.hdr.key_offset); dbg_printf("nr_keys=%lu, kpb=%zu, blksz=%u\n", undo_ctx.num_keys, keys_per_block, undo_ctx.blocksize); for (i = 0; i < undo_ctx.num_keys; i += keys_per_block) { size_t j, max_j; __le32 crc; retval = io_channel_read_blk64(undo_ctx.undo_file, lblk, 1, keyb); if (retval) { com_err(prg_name, retval, "%s", _("while reading keys")); if (force) { io_error = 1; undo_ctx.num_keys = i - 1; break; } exit(1); } /* check keys */ if (!force && ext2fs_le32_to_cpu(keyb->magic) != KEYBLOCK_MAGIC) { fprintf(stderr, _("%s: wrong key magic at %llu\n"), tdb_file, lblk); exit(1); } crc = keyb->crc; keyb->crc = 0; key_crc = ext2fs_crc32c_le(~0, (unsigned char *)keyb, undo_ctx.blocksize); if (!force && ext2fs_le32_to_cpu(crc) != key_crc) { fprintf(stderr, _("%s: key block checksum error at %llu.\n"), tdb_file, lblk); exit(1); } /* load keys from key block */ lblk++; max_j = undo_ctx.num_keys - i; if (max_j > keys_per_block) max_j = keys_per_block; for (j = 0, dkey = keyb->keys; j < max_j; j++, ikey++, dkey++) { ikey->fsblk = ext2fs_le64_to_cpu(dkey->fsblk); ikey->fileblk = lblk; ikey->blk_crc = ext2fs_le32_to_cpu(dkey->blk_crc); ikey->size = ext2fs_le32_to_cpu(dkey->size); lblk += (ikey->size + undo_ctx.blocksize - 1) / undo_ctx.blocksize; if (E2UNDO_MAX_EXTENT_BLOCKS * undo_ctx.blocksize < ikey->size) { com_err(prg_name, retval, _("%s: block %llu is too long."), tdb_file, ikey->fsblk); exit(1); } /* check each block's crc */ retval = io_channel_read_blk64(undo_ctx.undo_file, ikey->fileblk, -(int)ikey->size, buf); if (retval) { com_err(prg_name, retval, _("while fetching block %llu."), ikey->fileblk); if (!force) exit(1); io_error = 1; continue; } blk_crc = ext2fs_crc32c_le(~0, (unsigned char *)buf, ikey->size); if (blk_crc != ikey->blk_crc) { fprintf(stderr, _("checksum error in filesystem block " "%llu (undo blk %llu)\n"), ikey->fsblk, ikey->fileblk); if (!force) exit(1); csum_error = 1; } } } ext2fs_free_mem(&keyb); /* sort keys in fs block order */ qsort(undo_ctx.keys, undo_ctx.num_keys, sizeof(struct undo_key_info), key_compare); /* replay */ io_channel_set_blksize(channel, undo_ctx.fs_blocksize); for (i = 0, ikey = undo_ctx.keys; i < undo_ctx.num_keys; i++, ikey++) { retval = io_channel_read_blk64(undo_ctx.undo_file, ikey->fileblk, -(int)ikey->size, buf); if (retval) { com_err(prg_name, retval, _("while fetching block %llu."), ikey->fileblk); io_error = 1; continue; } if (verbose) printf("Replayed block of size %u from %llu to %llu\n", ikey->size, ikey->fileblk, ikey->fsblk); if (dry_run) continue; retval = io_channel_write_blk64(channel, ikey->fsblk, -(int)ikey->size, buf); if (retval) { com_err(prg_name, retval, _("while writing block %llu."), ikey->fsblk); io_error = 1; } } if (csum_error) fprintf(stderr, _("Undo file corruption; run e2fsck NOW!\n")); if (io_error) fprintf(stderr, _("IO error during replay; run e2fsck NOW!\n")); if (!(ext2fs_le32_to_cpu(undo_ctx.hdr.state) & E2UNDO_STATE_FINISHED)) { force = 1; fprintf(stderr, _("Incomplete undo record; run e2fsck.\n")); } ext2fs_free_mem(&buf); ext2fs_free_mem(&undo_ctx.keys); io_channel_close(channel); /* If there were problems, try to force a fsck */ if (!dry_run && (force || csum_error || io_error)) { retval = ext2fs_open2(device_name, NULL, EXT2_FLAG_RW | EXT2_FLAG_64BITS, 0, 0, manager, &fs); if (retval) goto out; fs->super->s_state &= ~EXT2_VALID_FS; if (csum_error || io_error) fs->super->s_state |= EXT2_ERROR_FS; ext2fs_mark_super_dirty(fs); ext2fs_close_free(&fs); } out: io_channel_close(undo_ctx.undo_file); return csum_error; }
//////////////////////////////////////////////////////////////////////////////// /// @brief 動き補償 (小ブロック単位) /// /// TODO: メモリアクセスの出力 /// /// @param SF [in] 画素差分データ /// @param b [in] ブロック番号 /// int mc(int SF[8][8], int b) { int p[8][8]; int mixf = 1 - (fptr[0][mb_y][mb_x] & 1); if(pic_coding_type == 1) mixf = 0; dump_header(dump_mv); dump(dump_mv, "mbx mby intra pat", " %2d %2d %d %d", mb_x, mb_y, mb_intra, (mb_pattern >> (5 - b)) & 1); if(!mb_mo_fw) mv[0][0][0] = mv[0][0][1] = 0; if(mb_intra) { dumpx_mc_fetch("# no fetch (mb_intra=1)\n"); } else { uint32_t fetch_a[9][5]; uint8_t fetch_d[9][10]; int ivx = mv[0][0][0]; int ivy = mv[0][0][1]; dump(dump_mv, "mvx mvy", " %5d %5d", ivx, ivy); if(b & 4) { ivx /= 2; ivy /= 2; } // 絶対値の小さい方へ丸め int halfx = ivx & 1; int halfy = ivy & 1; ivx = (ivx & ~1) / 2; ivy = (ivy & ~1) / 2; int oddx = ivx & 1; dump(dump_mv, "ivx halfx", " %3d %d", ivx, halfx); dump(dump_mv, "ivy halfy", " %3d %d", ivy, halfy); ivx += (b < 4) ? (mb_x * 16 + (b & 1) * 8) : (mb_x * 8); ivy += (b < 4) ? (mb_y * 16 + (b & 2) * 4) : (mb_y * 8); dump(dump_mv, "ox oy", " %3d %3d", ivx, ivy); dumpx_mc_fetch("# ivx=%d,halfx=%d,ivy=%d,halfy=%d\n", ivx, halfx, ivy, halfy); // フェッチアドレス計算 if(b < 4) { for(int y = 0; y < 9; ++y) for(int x = 0; x < 10; x += 2) { int ivx2 = x + ivx; int ivy2 = y + ivy; int f = fptr[0][(ivy2 >> 4) & MBY_MASK][(ivx2 >> 4) & MBX_MASK] & 1; fetch_a[y][x >> 1] = FBAGEN(b, f, (ivx2 >> 4), (ivx2 & 14) >> 1, (ivy2 >> 4), (ivy2 & 15)); } } else { for(int y = 0; y < 9; ++y) for(int x = 0; x < 10; x += 2) { int ivx2 = x + ivx; int ivy2 = y + ivy; int f = fptr[0][(ivy2 >> 3) & MBY_MASK][(ivx2 >> 3) & MBX_MASK] & 1; fetch_a[y][x >> 1] = FBAGEN(b, f, (ivx2 >> 3), (ivx2 & 14), (ivy2 >> 3), (ivy2 & 7) << 1); } } // フェッチ実行 for(int y = 0; y < 9; ++y) for(int x = 0; x < 10; x += 2) { uint32_t a = fetch_a[y][x >> 1]; fetch_d[y][x + 0] = fbuf[a + 0]; fetch_d[y][x + 1] = fbuf[a + 1]; dumpx_mc_fetch("%06x %02x%02x\n", fetch_a[y][x >> 1], fetch_d[y][x + 1], fetch_d[y][x + 0]); } // 整数画素・半画素合成 for(int y = 0; y < 8; ++y) for(int x = 0; x < 8; ++x) { int ym = y + halfy; p[y][x] = (fetch_d[y][x + oddx] + fetch_d[y][x + oddx + halfx] + fetch_d[ym][x + oddx] + fetch_d[ym][x + oddx + halfx] + 2) / 4; dumpx_mc_fetch("%s %2x%s", x == 0 ? "#" : "", p[y][x], x == 7 ? "\n" : ""); } dumpx_mc_fetch("#------------------------\n"); // memset(p, 0, sizeof(p)); }
static void test (void) { dump_header (NULL); }
int main (int argc, char *argv[]) { Arguments args; int i, use_taskstat; int in_initrd, clean_environment = 1; int stat_fd, disk_fd, uptime_fd, meminfo_fd, pid, ret = 1; PidScanner *scanner = NULL; unsigned long reltime = 0; BufferFile *stat_file, *disk_file, *per_pid_file, *meminfo_file; PidEventClosure pid_ev_cl; int *fds[] = { &stat_fd, &disk_fd, &uptime_fd, &meminfo_fd, NULL }; const char *fd_names[] = { "/stat", "/diskstats", "/uptime", "/meminfo", NULL }; StackMap map = STACK_MAP_INIT; /* make me findable */ arguments_set_defaults (&args); arguments_parse (&args, argc, argv); if (args.usleep_time > 0) { usleep (args.usleep_time); return 0; } if (enter_environment (args.console_debug)) return 1; fprintf (stderr, "bootchart-collector started as pid %d with %d args: ", (int) getpid(), argc - 1); for (i = 1; i < argc; i++) fprintf (stderr, "'%s' ", argv[i]); fprintf (stderr, "\n"); if (args.dump_path) { Arguments remote_args; ret = buffers_extract_and_dump (args.dump_path, &remote_args); ret |= dump_header (args.dump_path); if (!remote_args.relative_time) ret |= dump_dmsg (args.dump_path); if (!ret) cleanup_dev (); goto exit; } if (!args.relative_time) { /* manually started */ in_initrd = am_in_initrd (); if (in_initrd && sanity_check_initrd ()) goto exit; } pid = bootchart_find_running_pid (NULL); if (args.probe_running) { clean_environment = pid < 0; ret = pid < 0; goto exit; } else { if (pid >= 0) { clean_environment = 0; fprintf (stderr, "bootchart collector already running as pid %d, exiting...\n", pid); goto exit; } } /* defaults */ if (!args.hz) args.hz = 50; for (i = 0; fds [i]; i++) { char *path = malloc (strlen (PROC_PATH) + strlen (fd_names[i]) + 1); strcpy (path, PROC_PATH); strcat (path, fd_names[i]); *fds[i] = open (path, O_RDONLY); if (*fds[i] < 0) { fprintf (stderr, "error opening '%s': %s'\n", path, strerror (errno)); exit (1); } } stat_file = buffer_file_new (&map, "proc_stat.log"); disk_file = buffer_file_new (&map, "proc_diskstats.log"); if ( (use_taskstat = init_taskstat()) ) per_pid_file = buffer_file_new (&map, "taskstats.log"); else per_pid_file = buffer_file_new (&map, "proc_ps.log"); meminfo_file = buffer_file_new (&map, "proc_meminfo.log"); pid_ev_cl.cmdline_file = buffer_file_new (&map, "cmdline2.log"); pid_ev_cl.paternity_file = buffer_file_new (&map, "paternity.log"); if (!stat_file || !disk_file || !per_pid_file || !meminfo_file || !pid_ev_cl.cmdline_file || !pid_ev_cl.paternity_file) { fprintf (stderr, "Error allocating output buffers\n"); return 1; } scanner = pid_scanner_new_netlink (pid_event_cb, &pid_ev_cl); if (!scanner) scanner = pid_scanner_new_proc (PROC_PATH, pid_event_cb, &pid_ev_cl); if (!scanner) return 1; if (args.relative_time) { reltime = get_uptime (uptime_fd); if (! reltime) exit (1); } while (1) { pid_t pid; char uptime[80]; size_t uptimelen; unsigned long u; if (in_initrd) { if (have_dev_tmpfs ()) { if (chroot_into_dev ()) { fprintf (stderr, "failed to chroot into /dev - exiting so run_init can proceed\n"); return 1; } in_initrd = 0; } } u = get_uptime (uptime_fd); if (!u) return 1; uptimelen = sprintf (uptime, "%lu\n", u - reltime); buffer_file_dump_frame_with_timestamp (stat_file, stat_fd, uptime, uptimelen); buffer_file_dump_frame_with_timestamp (disk_file, disk_fd, uptime, uptimelen); buffer_file_dump_frame_with_timestamp (meminfo_file, meminfo_fd, uptime, uptimelen); /* output data for each pid */ buffer_file_append (per_pid_file, uptime, uptimelen); pid_scanner_restart (scanner); while ((pid = pid_scanner_next (scanner))) { if (use_taskstat) dump_taskstat (per_pid_file, scanner); else dump_proc_stat (per_pid_file, pid); } buffer_file_append (per_pid_file, "\n", 1); usleep (1000000 / args.hz); } /* * In reality - we are always killed before we reach * this point */ if (use_taskstat) { if (close (netlink_socket) < 0) { perror ("failed to close netlink socket"); exit (1); } } for (i = 0; fds [i]; i++) { if (close (*fds[i]) < 0) { fprintf (stderr, "error closing file '%s': %s'\n", fd_names[i], strerror (errno)); return 1; } } ret = 0; exit: arguments_free (&args); if (scanner) ret |= pid_scanner_free (scanner); if (clean_environment) clean_enviroment(); return ret; }
kssl_header* kssl_read(SSL *ssl, kssl_header *k, kssl_operation *r) { kssl_header h, *to_return; BYTE buf[KSSL_HEADER_SIZE]; int n; while (1) { n = SSL_read(ssl, buf, KSSL_HEADER_SIZE); if (n <= 0) { int x = SSL_get_error(ssl, n); if (x == SSL_ERROR_WANT_READ || x == SSL_ERROR_WANT_WRITE) { continue; } else if (x == SSL_ERROR_ZERO_RETURN) { fatal_error("Connection closed while reading header\n"); } else { fatal_error("Error performing SSL_read: %x\n", x); } } else { if (n != KSSL_HEADER_SIZE) { fatal_error("Error receiving KSSL header, size: %d", n); } } break; } parse_header(buf, &h); if (h.version_maj != KSSL_VERSION_MAJ) { fatal_error("Version mismatch %d != %d", h.version_maj, KSSL_VERSION_MAJ); } if (k->id != h.id) { fatal_error("ID mismatch %08x != %08x", k->id, h.id); } dump_header(&h, "recv"); to_return = (kssl_header *)malloc(sizeof(kssl_header)); memcpy(to_return, &h, sizeof(kssl_header)); to_return->data = 0; if (h.length > 0) { BYTE *payload = (BYTE *)malloc(h.length); while (1) { n = SSL_read(ssl, payload, h.length); if (n <= 0) { int x = SSL_get_error(ssl, n); if (x == SSL_ERROR_WANT_READ || x == SSL_ERROR_WANT_WRITE) { continue; } else if (x == SSL_ERROR_ZERO_RETURN) { fatal_error("Connection closed while reading payload\n"); } else { fatal_error("Error performing SSL_read: %x\n", x); } } else { if (n != h.length) { fatal_error("Error receiving KSSL payload, size: %d", n); } } break; } if (n != h.length) { fatal_error("Failed to read payload got length %d wanted %d", n, h.length); } dump_payload(h.length, payload); to_return->data = payload; } return to_return; }