Browse Source

* better maps

master
Alex 'AdUser' Z 10 years ago
parent
commit
2db02fd2bc
  1. 10
      src/util.c

10
src/util.c

@ -21,6 +21,9 @@
#include <unistd.h> #include <unistd.h>
#include <getopt.h> #include <getopt.h>
#define CHAR_USED '@'
#define CHAR_NONE '-'
void usage(int exitcode) { void usage(int exitcode) {
printf( printf(
"Usage: imdb-util <opts>\n" "Usage: imdb-util <opts>\n"
@ -79,7 +82,7 @@ int db_usage_map(imdb_t *db, unsigned short int cols)
p = blk.data; p = blk.data;
for (i = 0; i < blk.records; i++, p += IMDB_REC_LEN) { for (i = 0; i < blk.records; i++, p += IMDB_REC_LEN) {
t = p + REC_OFF_RU; t = p + REC_OFF_RU;
buf[j] = (*t == 0xFF) ? '1' : '0'; buf[j] = (*t == 0xFF) ? CHAR_USED : CHAR_NONE;
if (j++ < cols) if (j++ < cols)
continue; continue;
puts(buf); puts(buf);
@ -99,6 +102,7 @@ int rec_bitmap(imdb_t *db, imdb_rec_t *sample)
{ {
uint16_t row; uint16_t row;
uint8_t i, j; uint8_t i, j;
char c;
assert(db != NULL); assert(db != NULL);
assert(sample != NULL); assert(sample != NULL);
@ -113,7 +117,9 @@ int rec_bitmap(imdb_t *db, imdb_rec_t *sample)
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
row = *(((uint16_t *) (&sample->data[REC_OFF_BM])) + i); row = *(((uint16_t *) (&sample->data[REC_OFF_BM])) + i);
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
putchar((row & 1) == 1 ? '1' : '0'); c = (row & 1) == 1 ? CHAR_USED : CHAR_NONE;
putchar(c);
putchar(c);
row >>= 1; row >>= 1;
} }
putchar('\n'); putchar('\n');

Loading…
Cancel
Save