Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/include/sudo_gettext.h
1532 views
1
/*
2
* SPDX-License-Identifier: ISC
3
*
4
* Copyright (c) 2011-2014 Todd C. Miller <[email protected]>
5
*
6
* Permission to use, copy, modify, and distribute this software for any
7
* purpose with or without fee is hereby granted, provided that the above
8
* copyright notice and this permission notice appear in all copies.
9
*
10
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
19
#ifndef SUDO_GETTEXT_H
20
#define SUDO_GETTEXT_H
21
22
/*
23
* Solaris locale.h includes libintl.h which causes problems when we
24
* redefine the gettext functions. We include it first to avoid this.
25
*/
26
#include <locale.h>
27
28
#ifdef HAVE_LIBINTL_H
29
30
# include <libintl.h>
31
32
/*
33
* If DEFAULT_TEXT_DOMAIN is defined, use its value as the domain for
34
* gettext() and ngettext() instead of the value set by textdomain().
35
* This is used by the sudoers plugin as well as the convenience libraries.
36
*/
37
# ifdef DEFAULT_TEXT_DOMAIN
38
# undef gettext
39
# define gettext(String) \
40
dgettext(DEFAULT_TEXT_DOMAIN, String)
41
# undef ngettext
42
# define ngettext(String, String_Plural, N) \
43
dngettext(DEFAULT_TEXT_DOMAIN, String, String_Plural, N)
44
# endif
45
46
/*
47
* Older versions of Solaris lack ngettext() so we have to kludge it.
48
*/
49
# ifndef HAVE_NGETTEXT
50
# undef ngettext
51
# define ngettext(String, String_Plural, N) \
52
((N) == 1 ? gettext(String) : gettext(String_Plural))
53
# endif
54
55
/* Gettext convenience macros */
56
# define _(String) gettext(String)
57
# define gettext_noop(String) String
58
# define N_(String) gettext_noop(String)
59
# define U_(String) sudo_warn_gettext(String)
60
61
#else /* !HAVE_LIBINTL_H */
62
63
/*
64
* Internationalization is either unavailable or has been disabled.
65
* Define away the gettext functions used by sudo.
66
*/
67
# define _(String) String
68
# define N_(String) String
69
# define U_(String) String
70
# define textdomain(Domain)
71
# define bindtextdomain(Package, Directory)
72
# define ngettext(String, String_Plural, N) \
73
((N) == 1 ? (String) : (String_Plural))
74
75
#endif /* HAVE_LIBINTL_H */
76
77
#endif /* SUDO_GETTEXT_H */
78
79