Build catalogs. German CT updated.
[AROS.git] / workbench / libs / identify / tools / Function.c
blob8782a046b2f7ed34cb0ea9fc328424d91be7f132
1 /*
2 * Copyright (c) 2010-2011 Matthias Rustler
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
22 * $Id$
25 #include <libraries/identify.h>
27 #include <proto/identify.h>
28 #include <proto/exec.h>
29 #include <proto/dos.h>
30 #include <proto/locale.h>
32 #include <aros/debug.h>
34 #define ARG_TEMPLATE "LN=LIBNAME/A,O=OFFSET/N/A"
36 enum
38 ARG_LIBNAME,
39 ARG_OFFSET,
40 ARG_COUNT
43 struct RDArgs *rda;
46 #define BUFSIZE (50)
48 static TEXT buf_fnname[BUFSIZE];
51 #define CATCOMP_ARRAY
52 #include "strings.h"
54 #define CATALOG_NAME "System/C/IdentifyTools.catalog"
55 #define CATALOG_VERSION 1
57 static struct Catalog *catalog;
60 const char *ver = "$VER: Function 2.0 (31.5.2011)";
63 static void InitLocale(STRPTR catname, ULONG version)
65 LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library", 39);
66 if (LocaleBase)
68 catalog = OpenCatalog(NULL, catname, OC_Version, version,
69 TAG_DONE);
74 static void CleanupLocale(void)
76 if (catalog) CloseCatalog(catalog);
77 if (LocaleBase) CloseLibrary((struct Library *)LocaleBase);
81 static CONST_STRPTR MSG(ULONG id)
83 ULONG arridx;
85 // we have defined message IDs in the *.cd file, so we must first search
86 // for the ID in the array
87 for
89 arridx = 0;
90 arridx < sizeof (CatCompArray) / sizeof (struct CatCompArrayType) - 1;
91 arridx++
94 if (CatCompArray[arridx].cca_ID == id)
96 break;
99 if (catalog != NULL)
101 return GetCatalogStr(catalog, id, CatCompArray[arridx].cca_Str);
103 return CatCompArray[arridx].cca_Str;
107 int main(void)
109 InitLocale(CATALOG_NAME, CATALOG_VERSION);
111 IPTR args[ARG_COUNT] = {0};
113 ULONG offset;
115 rda = (struct RDArgs *)AllocDosObject(DOS_RDARGS, NULL);
116 if (rda)
118 rda->RDA_ExtHelp = (STRPTR)MSG(MSG_FUNC_HELP);
120 if (ReadArgs(ARG_TEMPLATE, args, rda))
122 offset = *(ULONG *)args[ARG_OFFSET];
124 if (IdFunctionTags((STRPTR)args[ARG_LIBNAME],
125 offset,
126 IDTAG_FuncNameStr, buf_fnname,
127 IDTAG_StrLength, BUFSIZE,
128 TAG_DONE) == IDERR_OKAY)
130 Printf(MSG(MSG_FUNC_RESULT),
131 args[ARG_LIBNAME],
132 offset,
133 buf_fnname);
135 FreeArgs(rda);
137 FreeDosObject(DOS_RDARGS, rda);
139 CleanupLocale();
141 return 0;