bool dump::visit(cf_node& n, bool enter) { if (enter) { indent(); dump_flags(n); dump_op(n, n.bc.op_ptr->name); if (n.bc.op_ptr->flags & CF_BRANCH) { sblog << " @" << (n.bc.addr << 1); } dump_common(n); sblog << "\n"; if (!n.empty()) { indent(); sblog << "< "; dump_live_values(n, true); } ++level; } else { --level; if (!n.empty()) { indent(); sblog << "> "; dump_live_values(n, false); } } return true; }
bool dump::visit(region_node& n, bool enter) { if (enter) { indent(); dump_flags(n); sblog << "region #" << n.region_id << " "; dump_common(n); if (!n.vars_defined.empty()) { sblog << "vars_defined: "; dump_set(sh, n.vars_defined); } dump_live_values(n, true); ++level; if (n.loop_phi) run_on(*n.loop_phi); } else { --level; if (n.phi) run_on(*n.phi); indent(); dump_live_values(n, false); } return true; }
bool dump::visit(container_node& n, bool enter) { if (enter) { if (!n.empty()) { indent(); dump_flags(n); sblog << "{ "; if (!n.dst.empty()) { sblog << " preloaded inputs ["; dump_vec(n.dst); sblog << "] "; } dump_live_values(n, true); } ++level; } else { --level; if (!n.empty()) { indent(); sblog << "} "; if (!n.src.empty()) { sblog << " results ["; dump_vec(n.src); sblog << "] "; } dump_live_values(n, false); } } return true; }
void dump_page_badflags(struct page *page, const char *reason, unsigned long badflags) { pr_emerg("page:%p count:%d mapcount:%d mapping:%p index:%#lx\n", page, atomic_read(&page->_count), page_mapcount(page), page->mapping, page->index); BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS); dump_flags(page->flags, pageflag_names, ARRAY_SIZE(pageflag_names)); if (reason) pr_alert("page dumped because: %s\n", reason); if (page->flags & badflags) { pr_alert("bad because of flags:\n"); dump_flags(page->flags & badflags, pageflag_names, ARRAY_SIZE(pageflag_names)); } mem_cgroup_print_bad_page(page); }
int ast_json_dump_str_format(struct ast_json *root, struct ast_str **dst, enum ast_json_encoding_format format) { /* Jansson's json_dump*, even though it's a read operation, isn't * thread safe for concurrent reads. Locking is necessary. * See http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety. */ SCOPED_JSON_LOCK(root); return json_dump_callback((json_t *)root, write_to_ast_str, dst, dump_flags(format)); }
static size_t dump_resp(const void *buf, size_t len, FILE *out) { const dcerpc_resp *r = buf; size_t bytes = dump_flags(&r->flags, out); bytes += fprintf(out, " fraglen=%hu authlen=%hu callid=%lu alloc_hint=%lu context=0x%04hx op=%hu\n", r->fraglen, r->authlen, (unsigned long)r->callid, (unsigned long)r->alloc_hint, r->contextid, r->opnum); bytes += dump_bytes((char *)r->data, len - sizeof *r + 1, out); return bytes; }
int ast_json_dump_new_file_format(struct ast_json *root, const char *path, enum ast_json_encoding_format format) { /* Jansson's json_dump*, even though it's a read operation, isn't * thread safe for concurrent reads. Locking is necessary. * See http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety. */ SCOPED_JSON_LOCK(root); if (!root || !path) { return -1; } return json_dump_file((json_t *)root, path, dump_flags(format)); }
int main(int argc, char *argv[]) { enum { API_MASK, API_REMAINDER, FLAG_VALUE } output; int ch; if ((progname = strrchr(argv[0], '/')) == NULL) progname = argv[0]; else ++progname; output = FLAG_VALUE; while ((ch = getopt(argc, argv, "mrv")) != EOF) switch (ch) { case 'm': output = API_MASK; break; case 'r': output = API_REMAINDER; break; case 'v': verbose = 1; break; case '?': default: return (usage()); } argc -= optind; argv += optind; if (parse() || generate_flags()) return (EXIT_FAILURE); switch (output) { case API_MASK: print_api_mask(); break; case API_REMAINDER: print_api_remainder(); break; case FLAG_VALUE: print_flag_value(); break; } if (verbose) { dump_api(); dump_flags(); } return (EXIT_SUCCESS); }
void dump_vma(const struct vm_area_struct *vma) { pr_emerg("vma %p start %p end %p\n" "next %p prev %p mm %p\n" "prot %lx anon_vma %p vm_ops %p\n" "pgoff %lx file %p private_data %p\n", vma, (void *)vma->vm_start, (void *)vma->vm_end, vma->vm_next, vma->vm_prev, vma->vm_mm, (unsigned long)pgprot_val(vma->vm_page_prot), vma->anon_vma, vma->vm_ops, vma->vm_pgoff, vma->vm_file, vma->vm_private_data); dump_flags(vma->vm_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names)); }
bool dump::visit(fetch_node& n, bool enter) { if (enter) { indent(); dump_flags(n); dump_op(n, n.bc.op_ptr->name); sblog << "\n"; ++level; } else { --level; } return true; }
bool dump::visit(bb_node& n, bool enter) { if (enter) { indent(); dump_flags(n); sblog << "{ BB_" << n.id << " loop_level = " << n.loop_level << " "; dump_live_values(n, true); ++level; } else { --level; indent(); sblog << "} end BB_" << n.id << " "; dump_live_values(n, false); } return true; }
void test_sub(void) { for(;;) { r.A = rand()%256; r.B = rand()%256; printf("%hhu - %hhu = %hhu\n", r.A, r.B, (uint8_t)(r.A - r.B)); bdump8(r.A); bdump8(r.B); sub(REG_B); printf("-----------\n"); bdump8(r.A); dump_flags(r.F); printf("\n=======================================\n"); } }
bool dump::visit(alu_node& n, bool enter) { if (enter) { indent(); dump_flags(n); dump_alu(&n); dump_common(n); sblog << "\n"; ++level; } else { --level; } return true; }
bool dump::visit(alu_group_node& n, bool enter) { if (enter) { indent(); dump_flags(n); sblog << "[ "; dump_live_values(n, true); ++level; } else { --level; indent(); sblog << "] "; dump_live_values(n, false); } return true; }
int main(int argc, char **argv) { struct gdt_desc desc; uint64_t qword; uint32_t base, limit; assert(sizeof(struct gdt_desc) == 8); if (argc != 2) { printf("%s <gdt descriptor>\n", argv[0]); return -1; } // Copy 64-bit value into the descriptor structure. qword = strtoll(argv[1], NULL, 16); memcpy(&desc, &qword, sizeof(struct gdt_desc)); printf("Segment descriptor details\n"); printf("---------------------------\n"); // Detect whether or not the descriptor is 64-bit. if (desc.fl.l) { printf("Mode: Long mode\nType: %s\n", get_descriptor_type(desc.ab.ex)); printf("Base=0, Limit=ffffffffffffffff\n"); if (desc.fl.sz) { printf("Warning: the flag Size should be unset for long mode!\n"); } } else { printf("Mode: %d-bit Protected mode\nType: %s\n", (desc.fl.sz) ? 32 : 16, get_descriptor_type(desc.ab.ex)); base = build_base(desc.base_0_15, desc.base_0_15, desc.base_24_31); limit = build_limit(desc.limit_0_15, desc.limit_16_19); if (desc.fl.gran) { limit = (limit << 12U) + 0xFFF; } printf("Base=%08x, Limit=%08x\n", base, limit); } printf("* Access byte:\n"); dump_access_byte(desc.ab); printf("* Flags:\n"); dump_flags(desc.fl); return 0; }
bool dump::visit(alu_packed_node& n, bool enter) { if (enter) { indent(); dump_flags(n); dump_op(n, n.op_ptr()->name); sblog << " "; dump_live_values(n, true); ++level; } else { --level; if (!n.live_after.empty()) { indent(); dump_live_values(n, false); } } // proccess children only if their src/dst aren't moved to this node yet return n.src.empty(); }
int mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp) { uint8_t *bin = NULL; size_t bin_size = 0; int result; if (fp == NULL) { return MRB_DUMP_INVALID_ARGUMENT; } result = dump_irep(mrb, irep, dump_flags(flags, FLAG_BYTEORDER_NONATIVE), &bin, &bin_size); if (result == MRB_DUMP_OK) { if (fwrite(bin, sizeof(bin[0]), bin_size, fp) != bin_size) { result = MRB_DUMP_WRITE_FAULT; } } mrb_free(mrb, bin); return result; }
bool dump::visit(if_node& n, bool enter) { if (enter) { indent(); dump_flags(n); sblog << "if " << *n.cond << " "; dump_common(n); sblog << " "; dump_live_values(n, true); indent(); sblog <<"{\n"; ++level; } else { --level; indent(); sblog << "} endif "; dump_live_values(n, false); } return true; }
bool dump::visit(depart_node& n, bool enter) { if (enter) { indent(); dump_flags(n); sblog << "depart region #" << n.target->region_id; sblog << (n.empty() ? " " : " after { "); dump_common(n); sblog << " "; dump_live_values(n, true); ++level; } else { --level; if (!n.empty()) { indent(); sblog << "} end_depart "; dump_live_values(n, false); } } return true; }
bool dump::visit(node& n, bool enter) { if (enter) { indent(); dump_flags(n); switch (n.subtype) { case NST_PHI: dump_op(n, "* phi"); break; case NST_PSI: dump_op(n, "* psi"); break; case NST_COPY: dump_op(n, "* copy"); break; default: assert(!"invalid node subtype"); break; } sblog << "\n"; } return false; }
int mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname) { uint8_t *bin = NULL; size_t bin_size = 0, bin_idx = 0; int result; if (fp == NULL || initname == NULL || initname[0] == '\0') { return MRB_DUMP_INVALID_ARGUMENT; } flags = dump_flags(flags, FLAG_BYTEORDER_NATIVE); result = dump_irep(mrb, irep, flags, &bin, &bin_size); if (result == MRB_DUMP_OK) { if (!dump_bigendian_p(flags)) { if (fprintf(fp, "/* dumped in little endian order.\n" " use `mrbc -E` option for big endian CPU. */\n") < 0) { mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } } else { if (fprintf(fp, "/* dumped in big endian order.\n" " use `mrbc -e` option for better performance on little endian CPU. */\n") < 0) { mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } } if (fprintf(fp, "#include <stdint.h>\n") < 0) { /* for uint8_t under at least Darwin */ mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } if (fprintf(fp, "const uint8_t\n" "#if defined __GNUC__\n" "__attribute__((aligned(%u)))\n" "#elif defined _MSC_VER\n" "__declspec(align(%u))\n" "#endif\n" "%s[] = {", (uint16_t)MRB_DUMP_ALIGNMENT, (uint16_t)MRB_DUMP_ALIGNMENT, initname) < 0) { mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } while (bin_idx < bin_size) { if (bin_idx % 16 == 0) { if (fputs("\n", fp) == EOF) { mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } } if (fprintf(fp, "0x%02x,", bin[bin_idx++]) < 0) { mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } } if (fputs("\n};\n", fp) == EOF) { mrb_free(mrb, bin); return MRB_DUMP_WRITE_FAULT; } } mrb_free(mrb, bin); return result; }
int mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size) { return dump_irep(mrb, irep, dump_flags(flags, FLAG_BYTEORDER_NONATIVE), bin, bin_size); }
/* * Dump the object information a format easily parsed by a spreadsheet. * * Original function by -EB- (probably), revisions by -LM- & JG. */ void write_o_info_txt(void) { int i, j, bc; int dlen; char buf[1024]; int fd; FILE *fff = NULL; cptr desc; object_kind *k_ptr; /* We allow 75 characters on the line (plus 2) */ u16b line_length = 75; /* Build the filename */ path_build(buf, 1024, ANGBAND_DIR_EDIT, "o_output.txt"); /* Check for existing file */ fd = fd_open(buf, O_RDONLY); /* Existing file */ if (fd >= 0) { char out_val[160]; /* Close the file */ fd_close(fd); /* Build query */ sprintf(out_val, "Replace existing file %s? ", buf); /* Ask */ if (get_check(out_val)) fd = -1; } /* Open the non-existing file */ if (fd < 0) fff = my_fopen(buf, "w"); /* No output file - fail */ if (!fff) return; /* Write a note */ fprintf(fff, "# File: o_info.txt (autogenerated)\n\n"); /* Read and print out all the objects */ for (i = 0; i < z_info->k_max; i++) { int counter = 1; cptr color_name; /* Get the object */ k_ptr = &k_info[i]; /* Ignore unused objects */ if (!strlen((k_name + k_ptr->name))) { fprintf(fff, "## empty space (available for object) ##\n\n"); continue; } /* Perform any translations */ /* Write New/Number/Name */ fprintf(fff, "N:%d:%s\n", i, k_name + k_ptr->name); /*get the color name*/ color_name = get_ext_color_name(k_ptr->d_attr); /* Write G: line */ fprintf(fff, "G:%d:%c:%s\n", i, k_ptr->d_char, color_name); /*don't do the rest for the pile symbol*/ if (i == 0) { /* Write G: line */ fprintf(fff, "\n\n\n"); continue; } /* Write I: line */ fprintf(fff, "I:%d:%d:%d:%d\n", i, k_ptr->tval, k_ptr->sval, k_ptr->pval); /* Write W: line */ fprintf(fff, "W:%d:%d:%d:%d\n", i, k_ptr->k_level, k_ptr->weight, k_ptr->cost); /* Write P: line */ fprintf(fff, "P:%d:%d:%d:d:%d:%d:%d:%d\n", i, k_ptr->ac, k_ptr->dd, k_ptr->ds, k_ptr->to_h, k_ptr->to_d, k_ptr->to_a); /* Write this A line */ fprintf(fff, "A:%d:%d:%d:%d:%d:%d:%d\n", i, k_ptr->locale[0], k_ptr->chance[0], k_ptr->locale[1], k_ptr->chance[1], k_ptr->locale[2], k_ptr->chance[2]); /* Get the flags, store flag text in a format easily parsed by a * database, but pretty much illegible to a person. */ dump_flags(fff, k_ptr->k_flags1, 1, i); dump_flags(fff, k_ptr->k_flags2, 2, i); dump_flags(fff, k_ptr->k_flags3, 3, i); dump_flags(fff, k_ptr->k_native, 4, i); /* Acquire the description */ desc = k_text + k_ptr->text; dlen = strlen(desc); if (dlen < 1) { /* Space between entries */ fprintf(fff, "\n\n\n"); continue; } /* Write Description */ for (j = 0; j < dlen;) { char buf[160], *t; /* Initialize */ t = buf; bc = 0; /* Build this line */ while (TRUE) { /* Insert this character, count it */ *t++ = desc[j++]; /* Oops. Line is too long. */ if (bc++ >= line_length) { /* Parse backwards until we find a space */ while (!my_isspace(desc[j-1]) && (bc-- > 40)) { j--; t--; } /* Time to end this line */ *t++ = '\0'; break; } /* All done */ if (j >= dlen) { /* Time to end this line */ *t++ = '\0'; break; } } /* Done with this line; write it */ fprintf(fff, "D-%d:%d:%s\n", counter, i, buf); counter++; } /* * Print out empty lines, so all objects have * an equal number of lines * makes parsing and combining the description easier */ for (; counter <+ 9; counter++) { fprintf(fff, "D-%d:%d\n", counter, i); } /* Space between entries */ fprintf(fff, "\n\n\n"); } /* Done */ fclose(fff); }
/* * Use the monster racial information to a format easily parsed by a spreadsheet. * * Original function by -EB- (probably), revisions by -LM- & JG. * Note: This function needs some updating as it is missing some fields. */ void write_f_info_txt(void) { int i, j, bc, x; int dlen; char buf[1024]; int fd; FILE *fff = NULL; cptr desc; feature_type *f_ptr; /* We allow 75 characters on the line (plus 2) */ u16b line_length = 75; /* Build the filename */ path_build(buf, 1024, ANGBAND_DIR_EDIT, "f_output.txt"); /* Check for existing file */ fd = fd_open(buf, O_RDONLY); /* Existing file */ if (fd >= 0) { char out_val[160]; /* Close the file */ fd_close(fd); /* Build query */ sprintf(out_val, "Replace existing file %s? ", buf); /* Ask */ if (get_check(out_val)) fd = -1; } /* Open the non-existing file */ if (fd < 0) fff = my_fopen(buf, "w"); /* No output file - fail */ if (!fff) return; /* Write a note */ fprintf(fff, "# File: f_info.txt (autogenerated)\n\n"); /* Read and print out all the features */ for (i = 0; i < z_info->f_max; i++) { cptr color_name; int counter = 1; desc = NULL; /* Get the monster */ f_ptr = &f_info[i]; /* Ignore empty monsters */ if (!strlen(f_name + f_ptr->name)) { fprintf(fff, "## empty space (available for terrain) ##\n\n"); continue; } /* Perform any translations */ /* Write New/Number/Name */ fprintf(fff, "N:%d:%d:%s\n", i, i, f_name + f_ptr->name); /* Write Mimic */ if (f_ptr->f_mimic > 0) { /*hack, switch to a new f_ptr- t outpit out the name*/ f_ptr = &f_info[f_info[i].f_mimic]; fprintf(fff, "M:%d:%s\n", i, f_name + f_ptr->name); /* Switch Back*/ f_ptr = &f_info[i]; } /* Write Edge */ if (f_ptr->f_edge > 0) { /*hack, switch to a new f_ptr- t outpit out the name*/ f_ptr = &f_info[f_info[i].f_edge]; fprintf(fff, "E:%d:%s\n", i, f_name + f_ptr->name); /* Switch Back*/ f_ptr = &f_info[i]; } /*get the color name*/ color_name = get_ext_color_name(f_ptr->d_attr); /* Write G: line */ fprintf(fff, "G:%d:%c:%s\n",i, f_ptr->d_char, color_name); if (f_ptr->f_edge > 0) { /*hack, switch to a new f_ptr- t outpit out the name*/ f_ptr = &f_info[f_info[i].f_edge]; desc = (f_name + f_ptr->name); /* Switch Back*/ f_ptr = &f_info[i]; } else desc = NULL; /* Write W: line */ fprintf(fff, "W:%d:%d:%d:%d:%d:\n", i, f_ptr->f_level, f_ptr->f_rarity, f_ptr->priority, f_ptr->f_power); /* Write C: line */ fprintf(fff, "C:%d:%d:%d:%d:%d:%d:%d:\n", i, f_ptr->dam_non_native, f_ptr->native_energy_move, f_ptr->non_native_energy_move, f_ptr->native_to_hit_adj, f_ptr->non_native_to_hit_adj, f_ptr->f_stealth_adj); /* Write X: line */ fprintf(fff, "X:%d:%d:%d:%d:%d:%d:%d:%d:\n", i, f_ptr->f_level, f_ptr->f_rarity, f_ptr->f_power, f_ptr->x_damage, f_ptr->x_gf_type, f_ptr->x_timeout_set, f_ptr->x_timeout_rand); /* Get the flags, store flag text in a format easily parsed by a * database, but pretty much illegible to a person. */ dump_flags(fff, f_ptr->f_flags1, 1, i); dump_flags(fff, f_ptr->f_flags2, 2, i); dump_flags(fff, f_ptr->f_flags3, 3, i); /*Drop the default*/ fprintf(fff, "DEFAULT:%d:%d\n", i, f_ptr->defaults); /* Find the next empty state slot (if any) */ for (x = 0; x < MAX_FEAT_STATES; x++) { if (f_ptr->state[x].fs_action != FS_FLAGS_END) { char action_desc[80]; get_feature_name(action_desc, sizeof(action_desc), f_ptr->state[x].fs_action); if (f_ptr->state[x].fs_result > 0) { /*Get the name of terrain switching to*/ f_ptr = &f_info[f_ptr->state[x].fs_result]; desc = (f_name + f_ptr->name); /* Switch Back*/ f_ptr = &f_info[i]; } else desc = NULL; /*drop the "K" line*/ fprintf(fff, "K%d:%d:%s:%s:%d\n", i, x, action_desc, desc, f_ptr->state[x].fs_power); } } /* Acquire the description */ desc = f_text + f_ptr->f_text; dlen = strlen(desc); /* Write Description */ for (j = 0; j < dlen;) { char buf[160], *t; /* Initialize */ t = buf; bc = 0; /* Build this line */ while (TRUE) { /* Insert this character, count it */ *t++ = desc[j++]; /* Oops. Line is too long. */ if (bc++ >= line_length) { /* Parse backwards until we find a space */ while (!my_isspace(desc[j-1]) && (bc-- > 40)) { j--; t--; } /* Time to end this line */ *t++ = '\0'; break; } /* All done */ if (j >= dlen) { /* Time to end this line */ *t++ = '\0'; break; } } /* Done with this line; write it */ fprintf(fff, "D-%d:%d:%s\n", counter, i, buf); counter++; } /* * Print out empty lines, so all monsters have * an equal number of lines * makes parsing and combining the description easier */ for (; counter <+ 3; counter++) { fprintf(fff, "D-%d:%d\n", counter, i); } /* Space between entries */ fprintf(fff, "\n\n\n"); } /* Done */ fclose(fff); }
/* * Dump the object information a format easily parsed by a spreadsheet. * * Original function by -EB- (probably), revisions by -LM- & JG. */ void write_a_info_txt(void) { int i, j, bc; int dlen; char buf[1024]; int fd; FILE *fff = NULL; cptr desc; artifact_type *a_ptr; /* We allow 75 characters on the line (plus 2) */ u16b line_length = 75; /* Build the filename */ path_build(buf, 1024, ANGBAND_DIR_EDIT, "a_output.txt"); /* Check for existing file */ fd = fd_open(buf, O_RDONLY); /* Existing file */ if (fd >= 0) { char out_val[160]; /* Close the file */ fd_close(fd); /* Build query */ sprintf(out_val, "Replace existing file %s? ", buf); /* Ask */ if (get_check(out_val)) fd = -1; } /* Open the non-existing file */ if (fd < 0) fff = my_fopen(buf, "w"); /* No output file - fail */ if (!fff) return; /* Write a note */ fprintf(fff, "# File: a_info.txt (autogenerated)\n\n"); /* Read and print out all the objects */ for (i = 0; i < z_info->art_norm_max; i++) { int counter = 1; char o_name[80]; object_type *i_ptr; object_type object_type_body; /* Get local object */ i_ptr = &object_type_body; /* Get the object */ a_ptr = &a_info[i]; /* Ignore unused objects */ if (!strlen(a_ptr->name)) { fprintf(fff, "## empty space (available for artifact) ##\n\n"); continue; } /* Perform any translations */ /* Write New/Number/Name */ fprintf(fff, "N:%d:%s\n", i, a_ptr->name); /* Write the complete name of the artifact*/ make_fake_artifact(i_ptr, i); /*identify it*/ /* Identify it */ object_aware(i_ptr); object_known(i_ptr); i_ptr->ident |= (IDENT_MENTAL); /* Get a description to dump */ object_desc(o_name, sizeof(o_name), i_ptr, TRUE, 0); /*dump the long name*/ fprintf(fff, "desc:%d: # %s\n", i, o_name); /* Write I: line */ fprintf(fff, "I:%d:%d:%d:%d\n", i, a_ptr->tval, a_ptr->sval, a_ptr->pval); /* Write W: line */ fprintf(fff, "W:%d:%d:%d:%d:%d\n", i, a_ptr->a_level, a_ptr->a_rarity, a_ptr->weight, a_ptr->cost); /* Write P: line */ fprintf(fff, "P:%d:%d:%d:d:%d:%d:%d:%d\n", i, a_ptr->ac, a_ptr->dd, a_ptr->ds, a_ptr->to_h, a_ptr->to_d, a_ptr->to_a); /* Get the flags, store flag text in a format easily parsed by a * database, but pretty much illegible to a person. */ dump_flags(fff, a_ptr->a_flags1, 1, i); dump_flags(fff, a_ptr->a_flags2, 2, i); dump_flags(fff, a_ptr->a_flags3, 3, i); dump_flags(fff, a_ptr->a_native, 4, i); /* Write the A line */ fprintf(fff, "A:%d:%d:%d:%d\n", i, a_ptr->activation, a_ptr->time, a_ptr->randtime); /* Acquire the description */ desc = a_text + a_ptr->text; dlen = strlen(desc); if (dlen < 1) { /* Space between entries */ fprintf(fff, "\n\n\n"); continue; } /* Write Description */ for (j = 0; j < dlen;) { char buf[160], *t; /* Initialize */ t = buf; bc = 0; /* Build this line */ while (TRUE) { /* Insert this character, count it */ *t++ = desc[j++]; /* Oops. Line is too long. */ if (bc++ >= line_length) { /* Parse backwards until we find a space */ while (!my_isspace(desc[j-1]) && (bc-- > 40)) { j--; t--; } /* Time to end this line */ *t++ = '\0'; break; } /* All done */ if (j >= dlen) { /* Time to end this line */ *t++ = '\0'; break; } } /* Done with this line; write it */ fprintf(fff, "D-%d:%d:%s\n", counter, i, buf); counter++; } /* * Print out empty lines, so all objects have * an equal number of lines * makes parsing and combining the description easier */ for (; counter <+ 12; counter++) { fprintf(fff, "D-%d:%d\n", counter, i); } /* Space between entries */ fprintf(fff, "\n\n\n"); } /* Done */ fclose(fff); }
struct tcp_sig* fingerprint_tcp(u8 to_srv, struct packet_data* pk, struct packet_flow* f) { struct tcp_sig* sig; struct tcp_sig_record* m; sig = ck_alloc(sizeof(struct tcp_sig)); packet_to_sig(pk, sig); /* Detect packets generated by p0f-sendsyn; they require special handling to provide the user with response fingerprints, but not interfere with NAT scores and such. */ if (pk->tcp_type == TCP_SYN && pk->win == SPECIAL_WIN && pk->mss == SPECIAL_MSS) f->sendsyn = 1; if (to_srv) start_observation(f->sendsyn ? "sendsyn probe" : "syn", 4, 1, f); else start_observation(f->sendsyn ? "sendsyn response" : "syn+ack", 4, 0, f); tcp_find_match(to_srv, sig, 0, f->syn_mss); if ((m = sig->matched)) { OBSERVF((m->class_id == -1 || f->sendsyn) ? "app" : "os", "%s%s%s", fp_os_names[m->name_id], m->flavor ? " " : "", m->flavor ? m->flavor : (u8*)""); } else { add_observation_field("os", NULL); } if (m && m->bad_ttl) { OBSERVF("dist", "<= %u", sig->dist); } else { if (to_srv) f->client->distance = sig->dist; else f->server->distance = sig->dist; OBSERVF("dist", "%u", sig->dist); } add_observation_field("params", dump_flags(pk, sig)); add_observation_field("raw_sig", dump_sig(pk, sig, f->syn_mss)); if (pk->tcp_type == TCP_SYN) f->syn_mss = pk->mss; /* That's about as far as we go with non-OS signatures. */ if (m && m->class_id == -1) { verify_tool_class(to_srv, f, m->sys, m->sys_cnt); ck_free(sig); return NULL; } if (f->sendsyn) { ck_free(sig); return NULL; } score_nat(to_srv, sig, f); return sig; }
/* * Use the monster racial information to a format easily parsed by a spreadsheet. * * Original function by -EB- (probably), revisions by -LM- & JG. */ void write_r_info_txt(void) { int i, j, bc; int dlen; char buf[1024]; int fd; FILE *fff = NULL; cptr desc; monster_race *r_ptr; /* We allow 75 characters on the line (plus 2) */ u16b line_length = 75; /* Build the filename */ path_build(buf, 1024, ANGBAND_DIR_EDIT, "r_output.txt"); /* Check for existing file */ fd = fd_open(buf, O_RDONLY); /* Existing file */ if (fd >= 0) { char out_val[160]; /* Close the file */ fd_close(fd); /* Build query */ sprintf(out_val, "Replace existing file %s? ", buf); /* Ask */ if (get_check(out_val)) fd = -1; } /* Open the non-existing file */ if (fd < 0) fff = my_fopen(buf, "w"); /* No output file - fail */ if (!fff) return; /* Write a note */ fprintf(fff, "# File: r_info.txt (autogenerated)\n\n"); /* Write a note */ fprintf(fff, "##### The Player #####\n\n"); /* Read and print out all the monsters */ for (i = 0; i < z_info->r_max; i++) { char what_char; cptr color_name; int counter = 1; /* Get the monster */ r_ptr = &r_info[i]; /* Ignore empty monsters */ if (!strlen(r_name + r_ptr->name)) { fprintf(fff, "## empty space (available for monsters) ##\n\n"); continue; } /* Ignore useless monsters */ if (i && !r_ptr->speed) { fprintf(fff, "## empty space (available for monsters) ##\n\n"); continue; } /* Perform any translations */ /* Write New/Number/Name */ fprintf(fff, "N:%d:%d:%s\n", i, i, r_name + r_ptr->name); /*get the color name*/ color_name = get_ext_color_name(r_ptr->d_attr); /* Write G: line */ if (r_ptr->rarity) fprintf(fff, "G:%d:%c:%s \n", i, r_ptr->d_char, color_name); /*don't do rest for player*/ if (i == 0) { /* Write a note */ fprintf(fff, "\n\n ##### The Monsters #####\n\n"); continue; } /* Write I: line */ fprintf(fff, "I:%d:%d:%dd%d:%d:%d:%d\n", i, r_ptr->speed, r_ptr->hdice, r_ptr->hside, r_ptr->aaf, r_ptr->ac, r_ptr->sleep); /* Write W: line */ fprintf(fff, "W:%d:%d::%d:%d:%ld\n", i, r_ptr->level, r_ptr->rarity, r_ptr->mana, r_ptr->mexp); /* Write blows */ for(j = 0; j < 4; j++) { /* Write this blow */ fprintf(fff, format("B-%d:%d:%d:%d:%dd%d\n", j, i, r_ptr->blow[j].method, r_ptr->blow[j].effect, r_ptr->blow[j].d_dice, r_ptr->blow[j].d_side)); } what_char = 'F'; /* Get the flags, store flag text in a format easily parsed by a * database, but pretty much illegible to a person. */ dump_flags(fff, r_ptr->flags1, 1, i); dump_flags(fff, r_ptr->flags2, 2, i); dump_flags(fff, r_ptr->flags3, 3, i); dump_flags(fff, r_ptr->flags4, 4, i); dump_flags(fff, r_ptr->flags5, 5, i); dump_flags(fff, r_ptr->flags6, 6, i); /* Write the terrain native flag. */ what_char = 'T'; dump_flags(fff, r_ptr->r_native, 8, i); fprintf(fff, "S:%d:%d:%d\n", i, r_ptr->freq_ranged, r_ptr->spell_power); /*now the summon flag*/ what_char = 'S'; dump_flags(fff, r_ptr->flags7, 7, i); /* Acquire the description */ desc = r_text + r_ptr->text; dlen = strlen(desc); /* Write Description */ for (j = 0; j < dlen;) { char buf[160], *t; /* Initialize */ t = buf; bc = 0; /* Build this line */ while (TRUE) { /* Insert this character, count it */ *t++ = desc[j++]; /* Oops. Line is too long. */ if (bc++ >= line_length) { /* Parse backwards until we find a space */ while (!my_isspace(desc[j-1]) && (bc-- > 40)) { j--; t--; } /* Time to end this line */ *t++ = '\0'; break; } /* All done */ if (j >= dlen) { /* Time to end this line */ *t++ = '\0'; break; } } /* Done with this line; write it */ fprintf(fff, "D-%d:%d:%s\n", counter, i, buf); counter++; } /* * Print out empty lines, so all monsters have * an equal number of lines * makes parsing and combining the description easier */ for (; counter <+ 12; counter++) { fprintf(fff, "D-%d:%d\n", counter, i); } /* Space between entries */ fprintf(fff, "\n\n\n"); } /* Done */ fclose(fff); }
void dump_mm(const struct mm_struct *mm) { pr_emerg("mm %p mmap %p seqnum %d task_size %lu\n" #ifdef CONFIG_MMU "get_unmapped_area %p\n" #endif "mmap_base %lu mmap_legacy_base %lu highest_vm_end %lu\n" "pgd %p mm_users %d mm_count %d nr_ptes %lu map_count %d\n" "hiwater_rss %lx hiwater_vm %lx total_vm %lx locked_vm %lx\n" "pinned_vm %lx shared_vm %lx exec_vm %lx stack_vm %lx\n" "start_code %lx end_code %lx start_data %lx end_data %lx\n" "start_brk %lx brk %lx start_stack %lx\n" "arg_start %lx arg_end %lx env_start %lx env_end %lx\n" "binfmt %p flags %lx core_state %p\n" #ifdef CONFIG_AIO "ioctx_table %p\n" #endif #ifdef CONFIG_MEMCG "owner %p " #endif "exe_file %p\n" #ifdef CONFIG_MMU_NOTIFIER "mmu_notifier_mm %p\n" #endif #ifdef CONFIG_NUMA_BALANCING "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n" #endif #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) "tlb_flush_pending %d\n" #endif "%s", /* This is here to hold the comma */ mm, mm->mmap, mm->vmacache_seqnum, mm->task_size, #ifdef CONFIG_MMU mm->get_unmapped_area, #endif mm->mmap_base, mm->mmap_legacy_base, mm->highest_vm_end, mm->pgd, atomic_read(&mm->mm_users), atomic_read(&mm->mm_count), atomic_long_read((atomic_long_t *)&mm->nr_ptes), mm->map_count, mm->hiwater_rss, mm->hiwater_vm, mm->total_vm, mm->locked_vm, mm->pinned_vm, mm->shared_vm, mm->exec_vm, mm->stack_vm, mm->start_code, mm->end_code, mm->start_data, mm->end_data, mm->start_brk, mm->brk, mm->start_stack, mm->arg_start, mm->arg_end, mm->env_start, mm->env_end, mm->binfmt, mm->flags, mm->core_state, #ifdef CONFIG_AIO mm->ioctx_table, #endif #ifdef CONFIG_MEMCG mm->owner, #endif mm->exe_file, #ifdef CONFIG_MMU_NOTIFIER mm->mmu_notifier_mm, #endif #ifdef CONFIG_NUMA_BALANCING mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq, #endif #if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) mm->tlb_flush_pending, #endif "" /* This is here to not have a comma! */ ); dump_flags(mm->def_flags, vmaflags_names, ARRAY_SIZE(vmaflags_names)); }
/* * Dump the ego-item information in a format easily parsed by a spreadsheet. * * Original function by -EB- (probably), revisions by -LM- & JG. */ void write_e_info_txt(void) { int i, j, bc; int dlen; char buf[1024]; int fd; FILE *fff = NULL; cptr desc; ego_item_type *e_ptr; /* We allow 75 characters on the line (plus 2) */ u16b line_length = 75; /* Build the filename */ path_build(buf, 1024, ANGBAND_DIR_EDIT, "e_output.txt"); /* Check for existing file */ fd = fd_open(buf, O_RDONLY); /* Existing file */ if (fd >= 0) { char out_val[160]; /* Close the file */ fd_close(fd); /* Build query */ sprintf(out_val, "Replace existing file %s? ", buf); /* Ask */ if (get_check(out_val)) fd = -1; } /* Open the non-existing file */ if (fd < 0) fff = my_fopen(buf, "w"); /* No output file - fail */ if (!fff) return; /* Write a note */ fprintf(fff, "# File: e_info.txt (autogenerated)\n\n"); /* Read and print out all the objects */ for (i = 0; i < z_info->e_max; i++) { int counter = 1; /* Get the ego-item */ e_ptr = &e_info[i]; /* Ignore empty monsters */ if (!strlen((e_name + e_ptr->name))) { fprintf(fff, "## empty space (available for ego-item) ##\n\n"); continue; } /* Perform any translations */ /* Write New/Number/Name */ fprintf(fff, "N:%d:%s\n", i, e_name + e_ptr->name); /* Write X: line */ fprintf(fff, "X:%d:%d:%d\n", i, e_ptr->rating, e_ptr->xtra); /* Write C: line */ fprintf(fff, "C:%d:%d:%d:%d:%d\n", i, e_ptr->max_to_h, e_ptr->max_to_d, e_ptr->max_to_a, e_ptr->max_pval); /* Write W: line */ fprintf(fff, "W:%d:%d:%d:0:%d\n", i, e_ptr->level, e_ptr->rarity, e_ptr->cost); /* Write the T lines */ fprintf(fff, "T:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d\n", i, e_ptr->tval[0], e_ptr->min_sval[0], e_ptr->max_sval[0], e_ptr->tval[1], e_ptr->min_sval[1], e_ptr->max_sval[1], e_ptr->tval[2], e_ptr->min_sval[2], e_ptr->max_sval[2]); /* Get the flags, store flag text in a format easily parsed by a * database, but pretty much illegible to a person. */ dump_flags(fff, e_ptr->flags1, 1, i); dump_flags(fff, e_ptr->flags2, 2, i); dump_flags(fff, e_ptr->flags3, 3, i); dump_flags(fff, e_ptr->e_native, 4, i); /* Acquire the description */ desc = e_text + e_ptr->text; dlen = strlen(desc); if (dlen < 1) { /* Space between entries */ fprintf(fff, "\n\n\n"); continue; } /* Write Description */ for (j = 0; j < dlen;) { char buf[160], *t; /* Initialize */ t = buf; bc = 0; /* Build this line */ while (TRUE) { /* Insert this character, count it */ *t++ = desc[j++]; /* Oops. Line is too long. */ if (bc++ >= line_length) { /* Parse backwards until we find a space */ while (!my_isspace(desc[j-1]) && (bc-- > 40)) { j--; t--; } /* Time to end this line */ *t++ = '\0'; break; } /* All done */ if (j >= dlen) { /* Time to end this line */ *t++ = '\0'; break; } } /* Done with this line; write it */ fprintf(fff, "D-%d:%d:%s\n", counter, i, buf); counter++; } /* * Print out empty lines, so all objects have * an equal number of lines * makes parsing and combining the description easier */ for (; counter <+ 6; counter++) { fprintf(fff, "D-%d:%d\n", counter, i); } /* Space between entries */ fprintf(fff, "\n\n\n"); } /* Done */ fclose(fff); }
void server_mc_event_cb(struct bufferevent *bev, short events, void *ctx) { struct server *s = (struct server *)ctx; dump_flags(events); if (events & BEV_EVENT_CONNECTED) { struct mc *mc; /* * If we received the notification that the connection is established, * then we move the corresponding struct mc from s->pending_peers to * s->peers. */ mc = v_mc_find_if(s->pending_peers, (void *)find_bev, bev); if (mc != v_mc_end(s->pending_peers)) { struct mc tmp; struct endpoint e; endpoint_init(&e, mc->p.address, mc->p.len); /* Check for certificate */ if (mc->ssl_flags & TLS_ENABLE) { X509 *cert; SSL *ssl; EVP_PKEY *pubkey; char name[512]; ssl = bufferevent_openssl_get_ssl(mc->bev); cert = SSL_get_peer_certificate(ssl); if (cert == NULL) { log_info("[META] [TLS] %s doesn't share it's certificate.", mc_presentation(mc, name, sizeof name)); v_mc_erase(s->pending_peers, mc); mc_close(mc); return ; } pubkey = X509_get_pubkey(cert); //UNUSED ? } log_info("[META] [%s] connexion established with %s", mc->ssl_flags & TLS_ENABLE ? "TLS" : "TCP", endpoint_presentation(&e)); memcpy(&tmp, mc, sizeof(tmp)); v_mc_erase(s->pending_peers, mc); mc = v_mc_insert(s->peers, &tmp); mc_hello(mc, s->udp); mc_establish_tunnel(mc, s->udp); } } else if (events & BEV_EVENT_EOF) { /* Disconnected */ struct mc *mc; struct udp_peer *up; mc = v_mc_find_if(s->peers, (void *)find_bev, bev); if (mc != v_mc_end(s->peers)) { char name[INET6_ADDRSTRLEN]; struct sockaddr *sock = mc->p.address; up = v_udp_find_if(s->udp->udp_peers, find_udppeer, sock); if (up != v_udp_end(s->udp->udp_peers)) { v_udp_erase(s->udp->udp_peers, up); log_debug("[%s] stop peering with %s", (up->ssl_flags & DTLS_ENABLE) ? "DTLS" : "UDP", endpoint_presentation(&up->peer_addr)); } log_debug("[META] stop the meta-connexion with %s", mc_presentation(mc, name, sizeof(name))); mc_close(mc); v_mc_erase(s->peers, mc); } } else if (events & BEV_EVENT_ERROR) { struct mc *mc; int everr; int sslerr; everr = EVUTIL_SOCKET_ERROR(); if (everr != 0) { log_warnx("[META] unexpected shutdown of the meta-connexion: (%d) %s", everr, evutil_socket_error_to_string(everr)); } while ((sslerr = bufferevent_get_openssl_error(bev)) != 0) { log_warnx("[META] SSL error code (%d): %s in %s %s", sslerr, ERR_reason_error_string(sslerr), ERR_lib_error_string(sslerr), ERR_func_error_string(sslerr)); } /* * Find if the exception come from a pending peer or a * regular peer and close it. */ mc = v_mc_find_if(s->pending_peers, (void *)find_bev, bev); if (mc != v_mc_end(s->pending_peers)) { char name[128]; log_debug("[META] %s removed from the pending list", mc_presentation(mc, name, sizeof name)); mc_close(mc); v_mc_erase(s->pending_peers, mc); } else { mc = v_mc_find_if(s->peers, (void *)find_bev, bev); if (mc != v_mc_end(s->peers)) { mc_close(mc); v_mc_erase(s->peers, mc); log_debug("[META] socket removed from the peer list"); } } } }