MsgCat.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * (c) Copyright 1995 Digital Equipment Corporation.
  25. * (c) Copyright 1995 Hewlett-Packard Company.
  26. * (c) Copyright 1995 International Business Machines Corp.
  27. * (c) Copyright 1995 Sun Microsystems, Inc.
  28. * (c) Copyright 1995 Novell, Inc.
  29. * (c) Copyright 1995 FUJITSU LIMITED.
  30. * (c) Copyright 1995 Hitachi.
  31. *
  32. * MsgCat.c - public interfaces for the Cached Message Catalog Service
  33. *
  34. * $TOG: MsgCat.c /main/4 1999/07/02 14:02:03 mgreess $
  35. *
  36. */
  37. #include <stdio.h>
  38. #include <string.h>
  39. #if defined(NO_XLIB)
  40. #define _DtSvcProcessLock()
  41. #define _DtSvcProcessUnlock()
  42. #else
  43. #include <X11/Intrinsic.h>
  44. #include <DtSvcLock.h>
  45. #endif
  46. #include <Dt/MsgCatP.h>
  47. int _DtCatclose(nl_catd catd)
  48. {
  49. return (catd == (nl_catd) -1) ? 0 : catclose(catd);
  50. }
  51. char *_DtCatgets(nl_catd catd, int set, int num, const char *dflt)
  52. {
  53. char *msg = NULL;
  54. if (catd == (nl_catd) -1 || set < 0 || num < 0) {
  55. /* Some catgets() implementations will fault if catd is invalid. */
  56. msg = (char *) dflt;
  57. } else {
  58. /* Per POSIX, we cannot assume catgets() is thread-safe. */
  59. _DtSvcProcessLock();
  60. msg = catgets(catd, set, num, dflt);
  61. _DtSvcProcessUnlock();
  62. }
  63. return msg;
  64. }