2 ** Copyright 2003, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
12 #include <DefaultCatalog.h>
13 #include <EditableCatalog.h>
16 using BPrivate::CatKey
;
17 using BPrivate::DefaultCatalog
;
18 using BPrivate::EditableCatalog
;
24 fprintf(stderr
, "usage: dumpcatalog <catalogFiles>\n");
30 main(int argc
, char **argv
)
32 const char *inputFile
= NULL
;
34 if (!argv
[1] || !strcmp(argv
[1], "--help")) {
39 if (!inputFile
|| !strlen(inputFile
))
42 EditableCatalog
inputCatalog("Default", "dummy", "dummy");
43 if ((res
= inputCatalog
.InitCheck()) != B_OK
) {
44 fprintf(stderr
, "couldn't construct catalog %s - error: %s\n",
45 inputFile
, strerror(res
));
48 if ((res
= inputCatalog
.ReadFromFile(inputFile
)) != B_OK
) {
49 fprintf(stderr
, "couldn't load input-catalog %s - error: %s\n",
50 inputFile
, strerror(res
));
53 DefaultCatalog
* inputCatImpl
54 = dynamic_cast<DefaultCatalog
*>(inputCatalog
.CatalogData());
56 fprintf(stderr
, "couldn't access impl of input-catalog %s\n",
60 // now walk over all entries in input-catalog and dump them to
62 DefaultCatalog::CatWalker
walker(inputCatImpl
);
63 BString str
, ctx
, cmt
;
64 while (!walker
.AtEnd()) {
65 const CatKey
&key(walker
.GetKey());
66 key
.GetStringParts(&str
, &ctx
, &cmt
);
67 printf("Hash:\t\t%" B_PRIu32
"\nKey:\t\t<%s:%s:%s>\nTranslation:\t%s\n"
68 "-----\n", key
.fHashVal
, str
.String(), ctx
.String(), cmt
.String(),
72 int32 count
= inputCatalog
.CountItems();
74 fprintf(stderr
, "%" B_PRId32
" entr%s dumped\n", count
,
75 (count
==1 ? "y": "ies"));
77 fprintf(stderr
, "no entries found\n");