home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-src.tgz / tar.out / fsf / tar / intl / textdomain.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  2KB  |  66 lines

  1. /* textdomain.c -- implementation of the textdomain(3) function
  2.    Copyright (C) 1995 Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #ifdef HAVE_CONFIG_H
  19. # include <config.h>
  20. #endif
  21.  
  22. #include <stdlib.h>
  23. #include <string.h>
  24.  
  25. #include "libgettext.h"
  26.  
  27. /* @@ end of prolog @@ */
  28.  
  29. /* Prototypes for functions of libnlsut.  */
  30. extern char *xstrdup __P((const char *__str));
  31.  
  32. /* Name of the default text domain.  */
  33. extern const char _nl_default_default_domain[];
  34.  
  35. /* Default text domain in which entries for gettext(3) are to be found.  */
  36. extern const char *_nl_current_default_domain;
  37.  
  38.  
  39. /* Set the current default message catalog to DOMAINNAME.
  40.    If DOMAINNAME is null, return the current default.
  41.    If DOMAINNAME is "", reset to the default of "messages".  */
  42. char *
  43. textdomain (domainname)
  44.      const char *domainname;
  45. {
  46.   char *old;
  47.  
  48.   /* A NULL pointer requests the current setting.  */ 
  49.   if (domainname == NULL)
  50.     return (char *) _nl_current_default_domain;
  51.  
  52.   old = (char *) _nl_current_default_domain;
  53.  
  54.   /* If domain name is the null string set to default domain "messages".  */
  55.   if (domainname[0] == '\0'
  56.       || strcmp (domainname, _nl_default_default_domain) == 0)
  57.     _nl_current_default_domain = _nl_default_default_domain;
  58.   else
  59.     _nl_current_default_domain = xstrdup (domainname);
  60.  
  61.   if (old != _nl_default_default_domain)
  62.     free (old);
  63.  
  64.   return (char *) _nl_current_default_domain;
  65. }
  66.