1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #pragma once
30 
31 /**
32  * @file nl_types.h
33  * @brief Message catalogs.
34  *
35  * Android offers a no-op implementation of these functions to ease porting of historical software.
36  */
37 
38 #include <sys/cdefs.h>
39 
40 __BEGIN_DECLS
41 
42 /**
43  * catopen() flag to use the current locale.
44  */
45 #define NL_CAT_LOCALE 1
46 
47 /**
48  * catgets() default set number.
49  */
50 #define NL_SETD 1
51 
52 /** Message catalog type. */
53 typedef void* nl_catd;
54 
55 /** The type of the constants in `<langinfo.h>`, used by nl_langinfo(). */
56 typedef int nl_item;
57 
58 /**
59  * [catopen(3)](http://man7.org/linux/man-pages/man3/catopen.3.html) opens a message catalog.
60  *
61  * On Android, this always returns failure: `((nl_catd) -1)`.
62  *
63  * Available since API level 28.
64  */
65 nl_catd _Nonnull catopen(const char* _Nonnull __name, int __flag) __INTRODUCED_IN(26);
66 
67 /**
68  * [catgets(3)](http://man7.org/linux/man-pages/man3/catgets.3.html) translates the given message
69  * using the given message catalog.
70  *
71  * On Android, this always returns `__msg`.
72  *
73  * Available since API level 28.
74  */
75 char* _Nonnull catgets(nl_catd _Nonnull __catalog, int __set_number, int __msg_number, const char* _Nonnull __msg) __INTRODUCED_IN(26);
76 
77 /**
78  * [catclose(3)](http://man7.org/linux/man-pages/man3/catclose.3.html) closes a message catalog.
79  *
80  * On Android, this always returns -1 with `errno` set to `EBADF`.
81  */
82 int catclose(nl_catd _Nonnull __catalog) __INTRODUCED_IN(26);
83 
84 __END_DECLS
85