Mercurial > repos > dawe > srf2fastq
comparison srf2fastq/io_lib-1.12.2/progs/hash_list.c @ 0:d901c9f41a6a default tip
Migrated tool version 1.0.1 from old tool shed archive to new tool shed repository
author | dawe |
---|---|
date | Tue, 07 Jun 2011 17:48:05 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d901c9f41a6a |
---|---|
1 #ifdef HAVE_CONFIG_H | |
2 #include "io_lib_config.h" | |
3 #endif | |
4 | |
5 #include <stdio.h> | |
6 #include <string.h> | |
7 #include <stdlib.h> | |
8 | |
9 #include <io_lib/hash_table.h> | |
10 #include <io_lib/os.h> | |
11 | |
12 /* | |
13 * Dumps a textual represenation of the hash table to stdout. | |
14 */ | |
15 void HashTableLongDump(HashTable *h, FILE *fp, int long_format) { | |
16 int i; | |
17 for (i = 0; i < h->nbuckets; i++) { | |
18 HashItem *hi; | |
19 for (hi = h->bucket[i]; hi; hi = hi->next) { | |
20 HashFileItem *hfi; | |
21 hfi = (HashFileItem *)hi->data.p; | |
22 if (long_format) | |
23 fprintf(fp, "%10"PRId64" %6"PRId32" %.*s\n", | |
24 hfi->pos, hfi->size, hi->key_len, hi->key); | |
25 /* | |
26 fprintf(fp, "%10ld %6d %.*s\n", | |
27 hfi->pos, hfi->size, hi->key_len, hi->key); | |
28 */ | |
29 else | |
30 fprintf(fp, "%.*s\n", hi->key_len, hi->key); | |
31 } | |
32 } | |
33 } | |
34 | |
35 | |
36 /* | |
37 * Lists the contents of a .hash file | |
38 */ | |
39 int main(int argc, char **argv) { | |
40 FILE *fp; | |
41 HashFile *hf; | |
42 int long_format = 0; | |
43 | |
44 /* process command line arguments of the form -arg */ | |
45 if (argc >= 2 && strcmp(argv[1], "-l") == 0) { | |
46 long_format = 1; | |
47 argc--; | |
48 argv++; | |
49 } | |
50 if (argc >= 2) { | |
51 fp = fopen(argv[1], "rb"); | |
52 if (NULL == fp) { | |
53 perror(argv[1]); | |
54 return 1; | |
55 } | |
56 } else { | |
57 fp = stdin; | |
58 } | |
59 | |
60 hf = HashFileLoad(fp); | |
61 if (hf) { | |
62 HashTableLongDump(hf->h, stdout, long_format); | |
63 HashFileDestroy(hf); | |
64 } | |
65 | |
66 return 0; | |
67 } |