HelpXlate.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /* $XConsortium: HelpXlate.c /main/1 1996/08/22 09:16:03 rswiston $ */
  24. /****************************************************************************
  25. $FILEBEG$: HelpXlate.c
  26. $PROJECT$: Cde 1.0
  27. $COMPONENT$: DtXlate service
  28. $1LINER$: Implements a translation service
  29. $COPYRIGHT$:
  30. (c) Copyright 1993, 1994 Hewlett-Packard Company
  31. (c) Copyright 1993, 1994 International Business Machines Corp.
  32. (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  33. (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
  34. $END$
  35. ****************************************************************************
  36. ************************************<+>*************************************/
  37. #include <stdlib.h>
  38. #include <string.h>
  39. #include <locale.h>
  40. /*=================================================================
  41. $SHAREDBEG$: This header appears in all appropriate DtXlate topics
  42. =======================================================$SKIP$======*/
  43. /*$INCLUDE$*/
  44. #include "StringFuncsI.h"
  45. /*$END$*/
  46. void _DtHelpCeGetLcCtype(char **locale, char **lang, char **charset) {
  47. char *ptr;
  48. char *mLang = NULL;
  49. char *mCharset = NULL;
  50. char *mLocale = setlocale(LC_CTYPE, NULL);
  51. if (mLocale) mLocale = strdup(mLocale);
  52. if (_DtHelpCeStrchr(mLocale, ".", 1, &ptr) == 0) {
  53. *ptr++ = '\0';
  54. if (mLocale != NULL && *mLocale != '\0') mLang = strdup(mLocale);
  55. if (ptr != NULL && *ptr != '\0') mCharset = strdup(ptr);
  56. }
  57. if (lang) *lang = strdup(mLang ? mLang : "C");
  58. if (charset) *charset = strdup(mCharset ? mCharset : "UTF-8");
  59. if (locale) *locale = strdup(mLocale ? mLocale : "C.UTF-8");
  60. free(mLang);
  61. free(mCharset);
  62. free(mLocale);
  63. }