loadmsgcat.c revision 5bc5a89c2a5c07b0237c13d37d869c986b5435fb
15bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o/* Load needed message catalogs.
25bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
35bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
45bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   This program is free software; you can redistribute it and/or modify
55bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   it under the terms of the GNU General Public License as published by
65bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   the Free Software Foundation; either version 2, or (at your option)
75bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   any later version.
85bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
95bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   This program is distributed in the hope that it will be useful,
105bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   but WITHOUT ANY WARRANTY; without even the implied warranty of
115bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
125bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   GNU General Public License for more details.
135bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
145bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   You should have received a copy of the GNU General Public License
155bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   along with this program; if not, write to the Free Software Foundation,
165bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
175bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
185bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#ifdef HAVE_CONFIG_H
195bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# include <config.h>
205bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
215bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
225bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#include <fcntl.h>
235bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#include <sys/types.h>
245bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#include <sys/stat.h>
255bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
265bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if defined STDC_HEADERS || defined _LIBC
275bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# include <stdlib.h>
285bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
295bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
305bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if defined HAVE_UNISTD_H || defined _LIBC
315bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# include <unistd.h>
325bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
335bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
345bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if (defined HAVE_MMAP && defined HAVE_MUNMAP) || defined _LIBC
355bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# include <sys/mman.h>
365bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
375bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
385bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#include "gettext.h"
395bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#include "gettextP.h"
405bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
415bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o/* @@ end of prolog @@ */
425bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
435bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#ifdef _LIBC
445bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o/* Rename the non ISO C functions.  This is required by the standard
455bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   because some ISO C functions will require linking with this object
465bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   file and the name space must not be polluted.  */
475bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# define open   __open
485bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# define close  __close
495bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# define read   __read
505bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# define mmap   __mmap
515bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o# define munmap __munmap
525bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
535bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
545bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o/* We need a sign, whether a new catalog was loaded, which can be associated
555bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   with all translations.  This is important if the translations are
565bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   cached by one of GCC's features.  */
575bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'oint _nl_msg_cat_cntr = 0;
585bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
595bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
605bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o/* Load the message catalogs specified by FILENAME.  If it is no valid
615bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o   message catalog do nothing.  */
625bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'ovoid
635bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'ointernal_function
645bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o_nl_load_domain (domain_file)
655bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     struct loaded_l10nfile *domain_file;
665bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o{
675bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  int fd;
685bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  size_t size;
695bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  struct stat st;
705bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  struct mo_file_header *data = (struct mo_file_header *) -1;
715bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
725bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    || defined _LIBC
735bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  int use_mmap = 0;
745bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
755bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  struct loaded_domain *domain;
765bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
775bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain_file->decided = 1;
785bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain_file->data = NULL;
795bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
805bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* If the record does not represent a valid locale the FILENAME
815bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     might be NULL.  This can happen when according to the given
825bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     specification the locale file name is different for XPG and CEN
835bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     syntax.  */
845bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (domain_file->filename == NULL)
855bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    return;
865bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
875bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* Try to open the addressed file.  */
885bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  fd = open (domain_file->filename, O_RDONLY);
895bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (fd == -1)
905bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    return;
915bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
925bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* We must know about the size of the file.  */
935bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (fstat (fd, &st) != 0
945bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      || (size = (size_t) st.st_size) != st.st_size
955bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      || size < sizeof (struct mo_file_header))
965bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    {
975bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      /* Something went wrong.  */
985bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      close (fd);
995bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      return;
1005bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    }
1015bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1025bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
1035bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    || defined _LIBC
1045bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* Now we are ready to load the file.  If mmap() is available we try
1055bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     this first.  If not available or it failed we try to load it.  */
1065bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
1075bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o					 MAP_PRIVATE, fd, 0);
1085bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1095bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (data != (struct mo_file_header *) -1)
1105bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    {
1115bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      /* mmap() call was successful.  */
1125bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      close (fd);
1135bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      use_mmap = 1;
1145bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    }
1155bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
1165bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1175bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* If the data is not yet available (i.e. mmap'ed) we try to load
1185bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     it manually.  */
1195bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (data == (struct mo_file_header *) -1)
1205bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    {
1215bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      size_t to_read;
1225bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      char *read_ptr;
1235bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1245bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      data = (struct mo_file_header *) malloc (size);
1255bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      if (data == NULL)
1265bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	return;
1275bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1285bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      to_read = size;
1295bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      read_ptr = (char *) data;
1305bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      do
1315bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	{
1325bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	  long int nb = (long int) read (fd, read_ptr, to_read);
1335bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	  if (nb == -1)
1345bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	    {
1355bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	      close (fd);
1365bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	      return;
1375bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	    }
1385bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1395bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	  read_ptr += nb;
1405bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	  to_read -= nb;
1415bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	}
1425bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      while (to_read > 0);
1435bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1445bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      close (fd);
1455bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    }
1465bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1475bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* Using the magic number we can test whether it really is a message
1485bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     catalog file.  */
1495bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED)
1505bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    {
1515bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      /* The magic number is wrong: not a message catalog file.  */
1525bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
1535bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    || defined _LIBC
1545bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      if (use_mmap)
1555bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	munmap ((caddr_t) data, size);
1565bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      else
1575bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
1585bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	free (data);
1595bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      return;
1605bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    }
1615bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1625bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain_file->data
1635bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    = (struct loaded_domain *) malloc (sizeof (struct loaded_domain));
1645bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (domain_file->data == NULL)
1655bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    return;
1665bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1675bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain = (struct loaded_domain *) domain_file->data;
1685bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain->data = (char *) data;
1695bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
1705bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    || defined _LIBC
1715bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain->use_mmap = use_mmap;
1725bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
1735bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain->mmap_size = size;
1745bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  domain->must_swap = data->magic != _MAGIC;
1755bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
1765bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* Fill in the information about the available tables.  */
1775bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  switch (W (domain->must_swap, data->revision))
1785bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    {
1795bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    case 0:
1805bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      domain->nstrings = W (domain->must_swap, data->nstrings);
1815bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      domain->orig_tab = (struct string_desc *)
1825bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	((char *) data + W (domain->must_swap, data->orig_tab_offset));
1835bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      domain->trans_tab = (struct string_desc *)
1845bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	((char *) data + W (domain->must_swap, data->trans_tab_offset));
1855bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      domain->hash_size = W (domain->must_swap, data->hash_tab_size);
1865bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      domain->hash_tab = (nls_uint32 *)
1875bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	((char *) data + W (domain->must_swap, data->hash_tab_offset));
1885bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      break;
1895bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    default:
1905bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      /* This is an illegal revision.  */
1915bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
1925bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    || defined _LIBC
1935bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      if (use_mmap)
1945bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	munmap ((caddr_t) data, size);
1955bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      else
1965bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
1975bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o	free (data);
1985bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      free (domain);
1995bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      domain_file->data = NULL;
2005bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o      return;
2015bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    }
2025bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
2035bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  /* Show that one domain is changed.  This might make some cached
2045bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     translations invalid.  */
2055bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  ++_nl_msg_cat_cntr;
2065bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o}
2075bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
2085bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
2095bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#ifdef _LIBC
2105bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'ovoid
2115bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'ointernal_function
2125bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o_nl_unload_domain (domain)
2135bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o     struct loaded_domain *domain;
2145bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o{
2155bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  if (domain->use_mmap)
2165bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    munmap ((caddr_t) domain->data, domain->mmap_size);
2175bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  else
2185bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o    free ((void *) domain->data);
2195bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o
2205bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o  free (domain);
2215bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o}
2225bc5a89c2a5c07b0237c13d37d869c986b5435fbTheodore Ts'o#endif
223