| 1 |
/** |
| 2 |
* This file is part of the Detox package. |
| 3 |
* |
| 4 |
* Copyright (c) Doug Harple <[email protected]> |
| 5 |
* |
| 6 |
* For the full copyright and license information, please view the LICENSE |
| 7 |
* file that was distributed with this source code. |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Helper utility to dump a translation table. |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <stdio.h> |
| 15 |
|
| 16 |
#include "table_dump.h" |
| 17 |
|
| 18 |
void table_dump(table_t *table, int verbose) |
| 19 |
{ |
| 20 |
int i; |
| 21 |
|
| 22 |
for (i = 0; i < table->length; i++) { |
| 23 |
if (!verbose && table->rows[i].key == 0) { |
| 24 |
continue; |
| 25 |
} |
| 26 |
|
| 27 |
printf("index: %d, ", i); |
| 28 |
|
| 29 |
if (table->rows[i].key == 0) { |
| 30 |
printf("empty\n"); |
| 31 |
} else { |
| 32 |
printf("key: 0x%04x, data: %s\n", table->rows[i].key, table->rows[i].data); |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
void table_stats(table_t *table) |
| 38 |
{ |
| 39 |
printf("used: %d\n", table->used); |
| 40 |
printf("available: %d\n", table->length); |
| 41 |
printf("used percent: %0.2f\n", table->used * 100.0 / table->length); |
| 42 |
|
| 43 |
printf("hits: %d\n", table->hits); |
| 44 |
printf("misses: %d\n", table->misses); |
| 45 |
printf("seeks: %d\n", table->seeks); |
| 46 |
printf("overwrites: %d\n", table->overwrites); |
| 47 |
|
| 48 |
printf("longest entry: %d\n", table->max_data_length); |
| 49 |
printf("default translation: %s\n", table->default_translation); |
| 50 |
printf("maximum key: 0x%04x\n", table->max_key); |
| 51 |
} |