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
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"
48 static TEXT buf_fnname
[BUFSIZE
];
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);
68 catalog
= OpenCatalog(NULL
, catname
, OC_Version
, version
,
74 static void CleanupLocale(void)
76 if (catalog
) CloseCatalog(catalog
);
77 if (LocaleBase
) CloseLibrary((struct Library
*)LocaleBase
);
81 static CONST_STRPTR
MSG(ULONG id
)
85 // we have defined message IDs in the *.cd file, so we must first search
86 // for the ID in the array
90 arridx
< sizeof (CatCompArray
) / sizeof (struct CatCompArrayType
) - 1;
94 if (CatCompArray
[arridx
].cca_ID
== id
)
101 return GetCatalogStr(catalog
, id
, CatCompArray
[arridx
].cca_Str
);
103 return CatCompArray
[arridx
].cca_Str
;
109 InitLocale(CATALOG_NAME
, CATALOG_VERSION
);
111 IPTR args
[ARG_COUNT
] = {0};
115 rda
= (struct RDArgs
*)AllocDosObject(DOS_RDARGS
, NULL
);
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
],
126 IDTAG_FuncNameStr
, buf_fnname
,
127 IDTAG_StrLength
, BUFSIZE
,
128 TAG_DONE
) == IDERR_OKAY
)
130 Printf(MSG(MSG_FUNC_RESULT
),
137 FreeDosObject(DOS_RDARGS
, rda
);