int main(int argc, char* const argv[]) { parseopt(argc, argv); if(!ookinit()) { fprintf(stderr, "Initialization failed.\n"); exit(EXIT_FAILURE); } const uint64_t bricksize[3] = { 64, 64, 64 }; struct io* chained = chain2(DebugIO, StdCIO); struct ookfile* fin = ookread(StdCIO, input, vol, bricksize, itype, 1); if(!fin) { perror("open"); exit(EXIT_FAILURE); } free(chained); size_t bsize[3]; ookmaxbricksize(fin, bsize); const size_t components = 1; /* our program assumes this.. */ const size_t bytes_brick = bytewidth(itype) * components * bsize[0]*bsize[1]*bsize[2]; void* data = malloc(bytes_brick); typedef void (t_func_apply)(const void*, double[2], const size_t); t_func_apply* fqn; switch(itype) { case OOK_I8: fqn = mmi8; break; case OOK_U8: fqn = mmu8; break; case OOK_I16: fqn = mmi16; break; case OOK_U16: fqn = mmu16; break; default: assert(false); fqn = NULL; break; /* FIXME! */ } printf("\n"); minmax[0] = FLT_MAX; minmax[1] = -FLT_MAX; for(size_t brick=0; brick < ookbricks(fin); ++brick) { size_t bs[3]; ookbricksize(fin, brick, bs); assert(bs[0] > 0 && bs[1] > 0 && bs[2] > 0); ookbrick(fin, brick, data); fqn(data, minmax, bs[0]*bs[1]*bs[2]); printf("\rProcessed brick %5zu / %5zu... [%lf--%lf]", brick, ookbricks(fin), minmax[0], minmax[1]); } printf("\n"); printf("Data range: %lf--%lf\n", minmax[0], minmax[1]); free(data); free(input); if(ookclose(fin) != 0) { fprintf(stderr, "Error closing files..\n"); } }
void java_bytecode_parsert::rclass_attribute(classt &parsed_class) { u2 attribute_name_index=read_u2(); u4 attribute_length=read_u4(); irep_idt attribute_name=pool_entry(attribute_name_index).s; if(attribute_name=="SourceFile") { u2 sourcefile_index=read_u2(); irep_idt sourcefile_name; std::string fqn(id2string(parsed_class.name)); size_t last_index=fqn.find_last_of("."); if(last_index==std::string::npos) sourcefile_name=pool_entry(sourcefile_index).s; else { std::string package_name=fqn.substr(0, last_index+1); std::replace(package_name.begin(), package_name.end(), '.', '/'); const std::string &full_file_name= package_name+id2string(pool_entry(sourcefile_index).s); sourcefile_name=full_file_name; } for(methodst::iterator m_it=parsed_class.methods.begin(); m_it!=parsed_class.methods.end(); m_it++) { m_it->source_location.set_file(sourcefile_name); for(instructionst::iterator i_it=m_it->instructions.begin(); i_it!=m_it->instructions.end(); i_it++) { if(!i_it->source_location.get_line().empty()) i_it->source_location.set_file(sourcefile_name); } } } else if(attribute_name=="RuntimeInvisibleAnnotations" || attribute_name=="RuntimeVisibleAnnotations") { rRuntimeAnnotation_attribute(parsed_class.annotations); } else skip_bytes(attribute_length); }
int main(int argc, char* const argv[]) { parseopt(argc, argv); if(!ookinit()) { fprintf(stderr, "Initialization failed.\n"); exit(EXIT_FAILURE); } const uint64_t bricksize[3] = { vol[0], 16, 16 }; struct ookfile* fin = ookread(StdCIO, input, vol, bricksize, itype, 1); if(!fin) { perror("ookread"); exit(EXIT_FAILURE); } free(input); input = NULL; struct ookfile* fout = ookcreate(StdCIO, output, vol, bricksize, OOK_U8, 1); if(!fout) { perror("ookcreate"); ookclose(fin); exit(EXIT_FAILURE); } free(output); output = NULL; size_t bsize[3]; ookmaxbricksize(fin, bsize); const size_t components = 1; /* our program assumes this.. */ const size_t bytes_brick = bytewidth(itype) * components * bsize[0]*bsize[1]*bsize[2]; void* data = malloc(bytes_brick); void* odata = malloc(sizeof(uint8_t)*components * bsize[0]*bsize[1]*bsize[2]); typedef void (t_func_apply)(const void*, void*, const size_t); t_func_apply* fqn; switch(itype) { case OOK_I8: fqn = fromi8; break; case OOK_U8: fprintf(stderr, "u8 to u8 makes no sense.\n"); exit(EXIT_FAILURE); break; case OOK_I16: fqn = fromi16; break; case OOK_U16: fqn = fromu16; break; default: assert(false); fqn = NULL; break; /* FIXME! */ } printf("\n"); for(size_t brick=0; brick < ookbricks(fin); ++brick) { size_t bs[3]; ookbricksize(fin, brick, bs); assert(bs[0] > 0 && bs[1] > 0 && bs[2] > 0); ookbrick(fin, brick, data); fqn(data, odata, bs[0]*bs[1]*bs[2]); ookwrite(fout, brick, odata); printf("\rProcessed brick %5zu / %5zu...", brick, ookbricks(fin)); } printf("\n"); free(data); free(odata); if(ookclose(fin) != 0) { fprintf(stderr, "Error closing input\n"); } if(ookclose(fout) != 0) { fprintf(stderr, "Error closing output!\n"); } }