grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / locale / getcatalogstr.c
blob5ada000518c0710fbbbfd2ce390f8822dabf2ed6
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <proto/exec.h>
11 #include "locale_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <proto/locale.h>
18 AROS_LH3(CONST_STRPTR, GetCatalogStr,
20 /* SYNOPSIS */
21 AROS_LHA(const struct Catalog *, catalog, A0),
22 AROS_LHA(ULONG, stringNum, D0), /* Not a typo! Needs to be unsigned for ICF_INORDER */
23 AROS_LHA(CONST_STRPTR, defaultString, A1),
25 /* LOCATION */
26 struct LocaleBase *, LocaleBase, 12, Locale)
28 /* FUNCTION
29 This function will return the string specified by the
30 stringNum from the given message catalog, or the defaultString
31 if the string could not be found.
33 If the catalog == NULL, then the defaultString will also be
34 returned.
36 INPUTS
37 catalog - Message catalog to search. May be NULL.
38 stringNum - ID of the string to find.
39 defaultString - String to return in case catalog is NULL or
40 string could not be found.
42 RESULT
43 A pointer to a READ ONLY NULL terminated string. This string
44 pointer is valid as long as the catalog remains open.
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 OpenCatalogA(), CloseCatalog()
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 CONST_STRPTR str = defaultString;
63 if (catalog != NULL)
65 struct CatStr *cs = IntCat(catalog)->ic_CatStrings;
66 ULONG numstrings = IntCat(catalog)->ic_NumStrings;
67 ULONG i = 0;
69 for (i = 0; i < numstrings; i++, cs++)
71 if (cs->cs_Id == stringNum)
73 str = cs->cs_String;
75 break;
77 else
79 if ((IntCat(catalog)->ic_Flags & ICF_INORDER) &&
80 (cs->cs_Id > stringNum))
82 break;
88 return str;
90 AROS_LIBFUNC_EXIT