add casts to zune macros to silence some warnings
[tangerine.git] / workbench / libs / locale / getcatalogstr.c
blobcacca493191ac6cf57f8a40ab1077b8ab9507ec8
1 /*
2 Copyright © 1995-2007, 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 OpenCatalog(), CloseCatalog()
55 INTERNALS
57 HISTORY
58 27-11-96 digulla automatically created from
59 locale_lib.fd and clib/locale_protos.h
61 *****************************************************************************/
63 AROS_LIBFUNC_INIT
65 CONST_STRPTR str = defaultString;
67 if(catalog != NULL)
69 struct CatStr *cs = IntCat(catalog)->ic_CatStrings;
70 ULONG numstrings = IntCat(catalog)->ic_NumStrings;
71 ULONG i = 0;
73 for(i = 0; i < numstrings; i++, cs++)
75 if(cs->cs_Id == stringNum)
77 str = cs->cs_String;
78 break;
80 else
82 if((IntCat(catalog)->ic_Flags & ICF_INORDER) &&
83 (cs->cs_Id > stringNum))
85 break;
91 return str;
93 AROS_LIBFUNC_EXIT
95 } /* GetCatalogStr */