| 1097 | #ifdef BLIST_DEBUG |
| 1098 | |
| 1099 | int |
| 1100 | main(int ac, char **av) |
| 1101 | { |
| 1102 | daddr_t size = BLIST_RADIX * BLIST_RADIX; |
| 1103 | int i; |
| 1104 | blist_t bl; |
| 1105 | struct sbuf *s; |
| 1106 | |
| 1107 | for (i = 1; i < ac; ++i) { |
| 1108 | const char *ptr = av[i]; |
| 1109 | if (*ptr != '-') { |
| 1110 | size = strtoll(ptr, NULL, 0); |
| 1111 | continue; |
| 1112 | } |
| 1113 | ptr += 2; |
| 1114 | fprintf(stderr, "Bad option: %s\n", ptr - 2); |
| 1115 | exit(1); |
| 1116 | } |
| 1117 | bl = blist_create(size, M_WAITOK); |
| 1118 | if (bl == NULL) { |
| 1119 | fprintf(stderr, "blist_create failed\n"); |
| 1120 | exit(1); |
| 1121 | } |
| 1122 | blist_free(bl, 0, size); |
| 1123 | |
| 1124 | for (;;) { |
| 1125 | char buf[1024]; |
| 1126 | long long da = 0; |
| 1127 | int count = 0, maxcount = 0; |
| 1128 | |
| 1129 | printf("%lld/%lld/%lld> ", (long long)blist_avail(bl), |
| 1130 | (long long)size, (long long)bl->bl_radix * BLIST_RADIX); |
| 1131 | fflush(stdout); |
| 1132 | if (fgets(buf, sizeof(buf), stdin) == NULL) |
| 1133 | break; |
| 1134 | switch(buf[0]) { |
| 1135 | case 'r': |
| 1136 | if (sscanf(buf + 1, "%d", &count) == 1) { |
| 1137 | blist_resize(&bl, count, 1, M_WAITOK); |
| 1138 | } else { |
| 1139 | printf("?\n"); |
| 1140 | } |
| 1141 | case 'p': |
| 1142 | blist_print(bl); |
| 1143 | break; |
| 1144 | case 's': |
| 1145 | s = sbuf_new_auto(); |
| 1146 | blist_stats(bl, s); |
| 1147 | sbuf_finish(s); |
| 1148 | printf("%s", sbuf_data(s)); |
| 1149 | sbuf_delete(s); |
| 1150 | break; |
| 1151 | case 'a': |
| 1152 | if (sscanf(buf + 1, "%d%d", &count, &maxcount) == 2) { |
| 1153 | daddr_t blk = blist_alloc(bl, &count, maxcount); |
| 1154 | printf(" R=%08llx, c=%08d\n", |
| 1155 | (long long)blk, count); |
| 1156 | } else { |
nothing calls this directly
no test coverage detected