2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

Add gettext.h convenience header. This is similar to but distinct from

the one included with the gettext package.
This commit is contained in:
Todd C. Miller 2011-05-20 11:48:17 -04:00
parent a05e963690
commit bf7e7b5752
19 changed files with 108 additions and 98 deletions

View File

@ -93,6 +93,7 @@ include/Makefile.in
include/alloc.h
include/error.h
include/fileops.h
include/gettext.h
include/lbuf.h
include/list.h
include/missing.h

View File

@ -28,9 +28,6 @@
# include <stdlib.h>
# endif
#endif /* STDC_HEADERS */
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include <usersec.h>
#include <uinfo.h>
@ -38,6 +35,9 @@
#include "alloc.h"
#include "error.h"
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
#ifdef HAVE_GETUSERATTR
#ifndef HAVE_SETRLIMIT64

View File

@ -47,14 +47,14 @@
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include "missing.h"
#include "alloc.h"
#include "error.h"
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
/*
* If there is no SIZE_MAX or SIZE_T_MAX we have to assume that size_t
* could be signed (as it is on SunOS 4.x). This just means that

View File

@ -20,12 +20,12 @@
#include <stdio.h>
#include <signal.h>
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include "missing.h"
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
#if defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST == 1
# define my_sys_siglist sys_siglist
#elif defined(HAVE_DECL__SYS_SIGLIST) && HAVE_DECL__SYS_SIGLIST == 1

View File

@ -868,23 +868,7 @@
#undef ISSET
#define ISSET(t, f) ((t) & (f))
/*
* Internationalization support.
*/
#ifdef HAVE_LIBINTL_H
# define _(String) gettext(String)
# define gettext_noop(String) String
# define N_(String) gettext_noop(String)
#else
# define _(String) String
# define N_(String) String
# define textdomain(Domain)
# define bindtextdomain(Package, Directory)
# define ngettext(String, String_Plural, N) \
((N) == 1 ? (String) : (String_Plural))
#endif /* HAVE_LIBINTL_H */
/* New ANSI-style OS defs for HP-UX and ConvexOS. */
/* ANSI-style OS defs for HP-UX and ConvexOS. */
#if defined(hpux) && !defined(__hpux)
# define __hpux 1
#endif /* hpux */

View File

@ -3180,23 +3180,7 @@ AH_BOTTOM([/*
#undef ISSET
#define ISSET(t, f) ((t) & (f))
/*
* Internationalization support.
*/
#ifdef HAVE_LIBINTL_H
# define _(String) gettext(String)
# define gettext_noop(String) String
# define N_(String) gettext_noop(String)
#else
# define _(String) String
# define N_(String) String
# define textdomain(Domain)
# define bindtextdomain(Package, Directory)
# define ngettext(String, String_Plural, N) \
((N) == 1 ? (String) : (String_Plural))
#endif /* HAVE_LIBINTL_H */
/* New ANSI-style OS defs for HP-UX and ConvexOS. */
/* ANSI-style OS defs for HP-UX and ConvexOS. */
#if defined(hpux) && !defined(__hpux)
# define __hpux 1
#endif /* hpux */

View File

@ -25,7 +25,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
# Tools to use
NROFF = @NROFFPROG@ -Tascii
NROFF = @NROFFPROG@
# Our install program supports extra flags...
INSTALL = $(SHELL) $(top_srcdir)/install-sh -c

66
include/gettext.h Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2011 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _SUDO_GETTEXT_H
#define _SUDO_GETTEXT_H
/*
* Solaris locale.h includes libintl.h which causes problems when we
* redefine the gettext functions. We include it first to avoid this.
*/
#if defined(HAVE_LOCALE_H) && defined(__sun__) && defined(__svr4__)
# include <locale.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
/*
* If DEFAULT_TEXT_DOMAIN is defined, use its value as the domain for
* gettext() and ngettext() instead of the value set by textdomain().
* This is used by the sudoers plugin as well as the convenience libraries.
*/
# ifdef DEFAULT_TEXT_DOMAIN
# undef gettext
# define gettext(String) \
dgettext(DEFAULT_TEXT_DOMAIN, String)
# undef ngettext
# define ngettext(String, String_Plural, N) \
dngettext(DEFAULT_TEXT_DOMAIN, String, String_Plural, N)
# endif
/* Gettext convenience macros */
# define _(String) gettext(String)
# define gettext_noop(String) String
# define N_(String) gettext_noop(String)
#else /* !HAVE_LIBINTL_H */
/*
* Internationalization is either unavailable or has been disabled.
* Define away the gettext functions used by sudo.
*/
# define _(String) String
# define N_(String) String
# define textdomain(Domain)
# define bindtextdomain(Package, Directory)
# define ngettext(String, String_Plural, N) \
((N) == 1 ? (String) : (String_Plural))
#endif /* HAVE_LIBINTL_H */
#endif /* _SUDO_GETTEXT_H */

View File

@ -433,9 +433,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
goto done;
}
#ifdef HAVE_LIBINTL_H
bindtextdomain("sudoers", LOCALEDIR);
#endif
sudo_setpwent();
sudo_setgrent();

View File

@ -23,17 +23,15 @@
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# undef _
# define _(String) dgettext("sudoers", String)
#endif
#include "missing.h"
#include "alloc.h"
#include "error.h"
#include "sudo_plugin.h"
#define DEFAULT_TEXT_DOMAIN "sudoers"
#include "gettext.h"
static void _warning(int, const char *, va_list);
void plugin_cleanup(int);

View File

@ -163,9 +163,7 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
return -1;
}
#ifdef HAVE_LIBINTL_H
bindtextdomain("sudoers", LOCALEDIR);
#endif
/*
* Signal setup:

View File

@ -35,16 +35,13 @@
#include "sudo_nss.h"
#include "sudo_plugin.h"
#define DEFAULT_TEXT_DOMAIN "sudoers"
#include "gettext.h"
#ifdef HAVE_MBR_CHECK_MEMBERSHIP
# include <membership.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# undef _
# define _(String) dgettext("sudoers", String)
#endif
/*
* Info pertaining to the invoking user.
*/

View File

@ -55,9 +55,6 @@
#ifndef HAVE_TIMESPEC
# include "compat/timespec.h"
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <limits.h>
@ -94,6 +91,7 @@
#include "missing.h"
#include "alloc.h"
#include "error.h"
#include "gettext.h"
#ifndef LINE_MAX
# define LINE_MAX 2048
@ -245,10 +243,8 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
decimal = localeconv()->decimal_point;
#endif
#ifdef HAVE_LIBINTL_H
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have sudoreplay domain */
textdomain("sudoers");
#endif
while ((ch = getopt(argc, argv, "d:f:hlm:s:V")) != -1) {
switch(ch) {

View File

@ -74,14 +74,12 @@
#ifdef HAVE_SETLOCALE
# include <locale.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include "sudoers.h"
#include "interfaces.h"
#include "parse.h"
#include "redblack.h"
#include "gettext.h"
#include "sudoers_version.h"
#include <gram.h>
@ -154,17 +152,16 @@ main(int argc, char *argv[])
malloc_options = "AFGJPR";
#endif
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
#ifdef HAVE_LIBINTL_H
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */
textdomain("sudoers");
#endif
#if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME)
setprogname(argc > 0 ? argv[0] : "visudo");
#endif
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */
textdomain("sudoers");
if (argc < 1)
usage(1);

View File

@ -22,13 +22,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include "missing.h"
#include "error.h"
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
static void _warning(int, const char *, va_list);
void cleanup(int);

View File

@ -59,9 +59,6 @@ struct rtentry;
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include <netdb.h>
#include <errno.h>
#ifdef _ISC
@ -87,6 +84,9 @@ struct rtentry;
#include "alloc.h"
#include "error.h"
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
/* Minix apparently lacks IFF_LOOPBACK */
#ifndef IFF_LOOPBACK
# define IFF_LOOPBACK 0

View File

@ -29,11 +29,9 @@
#ifdef HAVE_SETLOCALE
# include <locale.h>
#endif
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include "missing.h"
#include "gettext.h"
int
main (int argc, char *argv[])
@ -43,10 +41,8 @@ main (int argc, char *argv[])
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
#ifdef HAVE_LIBINTL_H
bindtextdomain("sudo", LOCALEDIR);
textdomain("sudo");
#endif
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
textdomain(PACKAGE_NAME);
if (argc < 2)
errx(EXIT_FAILURE, _("requires at least one argument"));

View File

@ -169,19 +169,16 @@ main(int argc, char *argv[], char *envp[])
malloc_options = "AFGJPR";
#endif
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
#if !defined(HAVE_GETPROGNAME) && !defined(HAVE___PROGNAME)
if (argc > 0)
setprogname(argv[0]);
#endif
#ifdef HAVE_LIBINTL_H
bindtextdomain("sudo", LOCALEDIR);
textdomain("sudo");
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
textdomain(PACKAGE_NAME);
/* Must be done before we do any password lookups */
#if defined(HAVE_GETPRPWNAM) && defined(HAVE_SET_AUTH_PARAMETERS)

View File

@ -24,9 +24,6 @@
#ifndef _SUDO_SUDO_H
#define _SUDO_SUDO_H
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif
#include <limits.h>
#include <pathnames.h>
@ -35,6 +32,7 @@
#include "error.h"
#include "fileops.h"
#include "list.h"
#include "gettext.h"
#ifdef __TANDEM
# define ROOT_UID 65535