int main(void){ struct nbspqdb_st *nqdb; int status; status = qdb_open(&nqdb, "db.db", sizeof(struct nbspdb_prec_st)); if(status != 0) errx(1, "nbspdb_open: %d", status); print_all_records(nqdb); qdb_close(nqdb); return(0); }
int main(int argn, char **argv) { uint32_t depend_id = 0; char *tail; static struct option long_options[] = { {"depend_id", 1, 0, 'd'}, {0, 0, 0, 0} }; xed_tables_init(); // The state of the machine -- required for decoding xed_state_t dstate; xed_state_zero(&dstate); xed_state_init(&dstate, XED_MACHINE_MODE_LEGACY_32, XED_ADDRESS_WIDTH_32b, XED_ADDRESS_WIDTH_32b); while (1) { int option_index = 0; int c = getopt_long(argn, argv, "d:", long_options, &option_index); if (c == -1) break; switch (c) { case 0: if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf(" with arg %s", optarg); printf("\n"); break; case 'd': depend_id = strtol(optarg, &tail, 0); break; default: abort(); } } //trace_record_t rec; if(optind >= argn) { printf("usage: %s [-d id] trace_file\n", argv[0]); return -1; } FILE *fp = fopen(argv[optind++],"r"); if(!fp) { printf("cannnot open %s! errno=%d\n", argv[optind-1], errno); return -1; } if(depend_id == 0) print_all_records(fp); else trace_back(fp, depend_id); fclose(fp); return 0; }