static void dump_data(void *pointer, tag_t *tag) { union_t u; u.v = pointer; switch (tag->type) { case type_char: printf("%d", *u.c); break; case type_uchar: printf("%x", *u.uc); break; case type_short: printf("%d", *u.s); break; case type_ushort: printf("%x", *u.us); break; case type_int: printf("%d", *u.i); break; case type_uint: printf("%x", *u.ui); break; case type_long: printf("%ld", *u.l); break; case type_ulong: printf("%lx", *u.ul); break; case type_float: printf("%f", *u.f); break; case type_double: printf("%f", *u.d); break; default: if (tag->type & type_pointer) printf("%p", u.p); else if (tag->type & type_vector) dump_vector(pointer, tag); else dump_record(pointer, tag); break; } }
static void cmd_dump_log(int argc ATTR_UNUSED, char *argv[]) { uint64_t modseq; int fd, ret; fd = open(argv[1], O_RDONLY); if (fd < 0) i_fatal("open(%s) failed: %m", argv[1]); dump_hdr(fd, &modseq); do { T_BEGIN { ret = dump_record(fd, &modseq); } T_END; } while (ret > 0); }
static void cmd_dump_fts_expunge_log(int argc ATTR_UNUSED, char *argv[]) { buffer_t *buf; int fd, ret; fd = open(argv[1], O_RDONLY); if (fd < 0) i_fatal("open(%s) failed: %m", argv[1]); buf = buffer_create_dynamic(default_pool, 1024); do { T_BEGIN { ret = dump_record(fd, buf); } T_END; } while (ret > 0); buffer_free(&buf); i_close_fd(&fd); }
void cb_record_found (const char *rcdName, void *user_data) { errorCode_t ec; neardal_record *record; printf("\t---- Record found \n"); ec = neardal_get_record_properties(rcdName, &record); if (ec == NEARDAL_SUCCESS) { dump_record(record); open_uri(record); neardal_free_record(record); printf("---- Reading done\n"); printf("---- Waiting for tag removal\n"); } else { printf("Read record error (error:%d='%s').\n",ec,neardal_error_get_text(ec)); } }
int main(int n, char **argv) { const char *fname = NULL; DBM *pdb; datum k,d; int ch; int i; progname = argv[0]; while ((ch = getopt(n, argv, "i:l:wf:v")) != -1) switch (ch) { case 'i': if (!isdigit((int) *optarg)) usage(); lotstup = atoi(optarg); break; case 'l': if (!isdigit((int) *optarg)) usage(); wraplen = atoi(optarg); break; case 'w': needwrap = 1; break; case 'f': fname = optarg; break; case 'v': printf("%s: $Id: rlm_dbm_cat.c,v 1.8 2004/02/26 19:04:28 aland Exp $\n",progname); exit(0); break; default : usage(); exit(1); break; } n -= (optind - 1); argv += (optind -1); if ( fname == NULL) fname = "sandy_db"; if ( ( pdb = dbm_open(fname, O_RDONLY, 0777) ) == NULL ) { perror("Couldn't open database"); exit(1); } if ( n > 1 ) { for ( i = 1 ; i < n ; i++ ) { printf(" Check: %s\n",argv[i]); k.dptr = argv[i]; k.dsize = strlen(argv[i]) + 1; if ( (d = dbm_fetch(pdb,k)).dptr == NULL ) { printf("Not found\n"); } else dump_record(k, d); } } else { for ( k = dbm_firstkey(pdb) ; k.dptr != NULL ; k = dbm_nextkey(pdb) ) if ( (d = dbm_fetch(pdb,k)).dptr == NULL ) { perror("Couldn't fetch user record"); exit(1); } else dump_record(k, d); } dbm_close(pdb); fflush(stdout); return 0; }
int util_dump(WT_SESSION *session, int argc, char *argv[]) { WT_CURSOR *cursor; WT_DECL_RET; size_t len; int ch, i; bool hex, json, reverse; char *checkpoint, *config, *name; hex = json = reverse = false; checkpoint = config = name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "c:f:jrx")) != EOF) switch (ch) { case 'c': checkpoint = __wt_optarg; break; case 'f': /* output file */ if (freopen(__wt_optarg, "w", stdout) == NULL) return (util_err( session, errno, "%s: reopen", __wt_optarg)); break; case 'j': json = true; break; case 'r': reverse = true; break; case 'x': hex = true; break; case '?': default: return (usage()); } argc -= __wt_optind; argv += __wt_optind; /* -j and -x are incompatible. */ if (hex && json) { fprintf(stderr, "%s: the -j and -x dump options are incompatible\n", progname); goto err; } /* The remaining argument is the uri. */ if (argc < 1 || (argc != 1 && !json)) return (usage()); if (json && ((ret = dump_json_begin(session)) != 0 || (ret = dump_prefix(session, hex, json)) != 0)) goto err; for (i = 0; i < argc; i++) { if (json && i > 0) if ((ret = dump_json_separator(session)) != 0) goto err; free(name); name = NULL; if ((name = util_name(session, argv[i], "table")) == NULL) goto err; if (dump_config(session, name, hex, json) != 0) goto err; len = checkpoint == NULL ? 0 : strlen("checkpoint=") + strlen(checkpoint) + 1; len += strlen(json ? "dump=json" : (hex ? "dump=hex" : "dump=print")); if ((config = malloc(len + 10)) == NULL) goto err; if (checkpoint == NULL) config[0] = '\0'; else { (void)strcpy(config, "checkpoint="); (void)strcat(config, checkpoint); (void)strcat(config, ","); } (void)strcat(config, json ? "dump=json" : (hex ? "dump=hex" : "dump=print")); if ((ret = session->open_cursor( session, name, NULL, config, &cursor)) != 0) { fprintf(stderr, "%s: cursor open(%s) failed: %s\n", progname, name, session->strerror(session, ret)); goto err; } if ((ret = dump_record(cursor, reverse, json)) != 0) goto err; if (json && (ret = dump_json_table_end(session)) != 0) goto err; } if (json && ((ret = dump_json_end(session)) != 0)) goto err; if (0) { err: ret = 1; } free(config); free(name); return (ret); }
boolean_t dse_r_dmp(void) { block_id blk; sm_uc_ptr_t bp, b_top, rp; int4 count; int4 dummy_int; cache_rec_ptr_t dummy_cr; short record, size; boolean_t was_crit; int4 nocrit_present; error_def(ERR_DSEBLKRDFAIL); error_def(ERR_CTRLC); if (cli_present("BLOCK") == CLI_PRESENT) { uint4 tmp_blk; if(!cli_get_hex("BLOCK", &tmp_blk)) return FALSE; blk = (block_id)tmp_blk; if (blk < 0 || blk >= cs_addrs->ti->total_blks || !(blk % cs_addrs->hdr->bplmap)) { util_out_print("Error: invalid block number.", TRUE); return FALSE; } patch_curr_blk = blk; } if (cli_present("COUNT") == CLI_PRESENT) { if (!cli_get_hex("COUNT", (uint4 *)&count)) return FALSE; } else count = 1; was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); if (!(bp = t_qread(patch_curr_blk, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (((blk_hdr_ptr_t) bp)->bsiz > cs_addrs->hdr->blk_size) b_top = bp + cs_addrs->hdr->blk_size; else if (((blk_hdr_ptr_t) bp)->bsiz < SIZEOF(blk_hdr)) b_top = bp + SIZEOF(blk_hdr); else b_top = bp + ((blk_hdr_ptr_t) bp)->bsiz; if (((blk_hdr_ptr_t) bp)->levl && patch_is_fdmp) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); util_out_print("Error: cannot perform GLO/ZWR dump on index block.", TRUE); return FALSE; } if (cli_present("RECORD") == CLI_PRESENT) { if (!(rp = skan_rnum (bp, FALSE))) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return FALSE; } } else if (!(rp = skan_offset (bp, FALSE))) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return FALSE; } util_out_print(0, TRUE); for ( ; 0 < count; count--) { if (util_interrupt || !(rp = dump_record(rp, patch_curr_blk, bp, b_top))) break; patch_rec_counter += 1; } DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); if (util_interrupt) rts_error(VARLSTCNT(1) ERR_CTRLC); else if (cli_present("HEADER") == CLI_NEGATED) util_out_print(0, TRUE); return TRUE; }
boolean_t dse_b_dmp(void) { int4 util_len, head, lmap_num, iter1, iter2, mapsize, bplmap, nocrit_present, dummy_int, count; unsigned char util_buff[MAX_UTIL_LEN], mask; boolean_t free, was_crit, invalid_bitmap = FALSE; block_id blk; sm_uc_ptr_t bp, b_top, rp, mb, dump_record(sm_uc_ptr_t rp, block_id blk, sm_uc_ptr_t bp, sm_uc_ptr_t b_top); cache_rec_ptr_t dummy_cr; error_def(ERR_DSEBLKRDFAIL); error_def(ERR_CTRLC); error_def(ERR_BITMAPSBAD); head = cli_present("HEADER"); if (CLI_PRESENT == cli_present("BLOCK")) { if (!cli_get_hex("BLOCK", &blk)) return FALSE; if (blk < 0 || blk >= cs_addrs->ti->total_blks) { util_out_print("Error: invalid block number.", TRUE); return FALSE; } patch_curr_blk = blk; } else blk = patch_curr_blk; if (CLI_PRESENT == cli_present("COUNT")) { if (!cli_get_hex("COUNT", &count)) return FALSE; if (count < 1) return FALSE; } else count = 1; util_out_print(0, TRUE); bplmap = cs_addrs->hdr->bplmap; mapsize = BM_SIZE(bplmap); patch_rec_counter = 1; was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = TRUE; else grab_crit(gv_cur_region); } for ( ; ; ) { if (blk / bplmap * bplmap != blk) { if(!(bp = t_qread(blk, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (((blk_hdr_ptr_t) bp)->levl && patch_is_fdmp) { util_out_print("Error: cannot perform GLO/ZWR dump on index block.", TRUE); if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = FALSE; else rel_crit(gv_cur_region); } return FALSE; } if (((blk_hdr_ptr_t) bp)->bsiz > cs_addrs->hdr->blk_size) b_top = bp + cs_addrs->hdr->blk_size; else if (((blk_hdr_ptr_t) bp)->bsiz < sizeof(blk_hdr)) b_top = bp + sizeof(blk_hdr); else b_top = bp + ((blk_hdr_ptr_t) bp)->bsiz; if (CLI_NEGATED != head && !patch_is_fdmp) { memcpy(util_buff, "Block ", 6); util_len = 6; util_len += i2hex_nofill(blk, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Size ", 8); util_len += 8; util_len += i2hex_nofill(((blk_hdr_ptr_t)bp)->bsiz, &util_buff[util_len], 4); memcpy(&util_buff[util_len], " Level !UL TN ", 18); util_len += 18; util_len += i2hex_nofill(((blk_hdr_ptr_t)bp)->tn, &util_buff[util_len], 8); memcpy(&util_buff[util_len], "!/", 2); util_len += 2; util_buff[util_len] = 0; util_out_print(util_buff, TRUE, ((blk_hdr_ptr_t) bp)->levl ); } rp = bp + sizeof(blk_hdr); if (CLI_PRESENT != head && (!patch_is_fdmp || ((blk_hdr_ptr_t) bp)->levl == 0)) { while (!util_interrupt && (rp = dump_record(rp, blk, bp, b_top))) patch_rec_counter += 1; } if (util_interrupt) { if (!was_crit) rel_crit(gv_cur_region); rts_error(VARLSTCNT(1) ERR_CTRLC); break; } if (CLI_NEGATED == head) util_out_print(0, TRUE); } else if (!patch_is_fdmp) { if(!(bp = t_qread(blk, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (CLI_NEGATED != head) { if (bplmap == 0) { memcpy(util_buff, "Block ", 6); util_len = 6; util_len += i2hex_nofill(blk, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Size ", 8); util_len += 8; util_len += i2hex_nofill(mapsize, &util_buff[util_len], 4); memcpy(&util_buff[util_len], " Master Status: Cannot Determine (bplmap == 0)!/", 50); util_len += 50; util_buff[util_len] = 0; util_out_print(util_buff, TRUE ); } else { mb = cs_addrs->bmm + blk / (8 * bplmap); lmap_num = blk / bplmap; mask = 1 << ( lmap_num - lmap_num / 8 * 8); free = mask & *mb; memcpy(util_buff, "Block ", 6); util_len = 6; util_len += i2hex_nofill(blk, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Size ", 7); util_len += 7; util_len += i2hex_nofill(((blk_hdr_ptr_t)bp)->bsiz, &util_buff[util_len], 4); memcpy(&util_buff[util_len], " Level !SB TN ", 16); util_len += 16; util_len += i2hex_nofill(((blk_hdr_ptr_t)bp)->tn, &util_buff[util_len], 8); util_buff[util_len] = 0; util_out_print(util_buff, FALSE, ((blk_hdr_ptr_t) bp)->levl ); util_len = 0; memcpy(&util_buff[util_len], " Master Status: !AD!/",23); util_len = 23; util_buff[util_len] = 0; util_out_print(util_buff, TRUE, free ? 10 : 4, free ? "Free Space" : "Full"); } } if (CLI_PRESENT != head) { util_out_print (" !_Low order High order", TRUE); lmap_num = 0; while (lmap_num < bplmap) { memcpy(util_buff, "Block ", 6); util_len = 6; i2hex_blkfill(blk + lmap_num, &util_buff[util_len], 8); util_len += 8; memcpy(&util_buff[util_len], ":!_| ", 6); util_len += 6; util_buff[util_len] = 0; util_out_print (util_buff, FALSE); for (iter1 = 0; iter1 < 4; iter1++) { for (iter2 = 0; iter2 < 8; iter2++) { mask = dse_lm_blk_free(lmap_num * BML_BITS_PER_BLK, bp + sizeof(blk_hdr)); if (!mask) util_out_print ("!AD", FALSE, 1, BUSY_CHAR); else if (BLK_FREE == mask) util_out_print ("!AD", FALSE, 1, FREE_CHAR); else if (BLK_RECYCLED == mask) util_out_print ("!AD", FALSE, 1, REUSABLE_CHAR); else { invalid_bitmap = TRUE; util_out_print ("!AD", FALSE, 1, CORRUPT_CHAR); } if (++lmap_num >= bplmap) break; } util_out_print (" ", FALSE); if (lmap_num >= bplmap) break; } util_out_print ("|", TRUE); if (util_interrupt) { if (!was_crit) rel_crit(gv_cur_region); rts_error(VARLSTCNT(1) ERR_CTRLC); } } util_out_print("!/'!AD' == BUSY '!AD' == FREE '!AD' == REUSABLE '!AD' == CORRUPT!/", TRUE,1, BUSY_CHAR, 1, FREE_CHAR, 1, REUSABLE_CHAR, 1, CORRUPT_CHAR); if (invalid_bitmap) rts_error(VARLSTCNT(1) ERR_BITMAPSBAD); } } count--; if (count <= 0 || util_interrupt) break; blk++; if (blk >= cs_addrs->ti->total_blks) blk = 0; } patch_curr_blk = blk; if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = FALSE; else rel_crit(gv_cur_region); } return TRUE; }