/*****************************************************************************/
/***     Include files.                                                    ***/
/*****************************************************************************/

#include <stdio.h>                      /* Standard IO functions.            */

#include <wchar.h>                      /* XPG/4 library.                    */

/*****************************************************************************/
/***     Main program.                                                     ***/
/*****************************************************************************/

void main(void)
{
  char *ret_string;                     /* String returned from setlocale.   */

                                        /* Set all locale variables to value */
                                        /*  defined in LC_ALL or LANG        */
                                        /*  environment variables.           */
  setlocale(-1, "");
  ret_string = setlocale(-1, NULL);
  printf("\nLocale settings are: %s\n", ret_string);

                                        /* Change the monetary locale to the */
                                        /*  value set in the LC_MONETARY     */
                                        /*  environment variable.  This is   */
                                        /*  redundant, since it was already  */
                                        /*  done in the first setlocale call.*/
                                        /* Query and print the value to show */
                                        /*  that it is no different.         */
  setlocale(2, "");
  ret_string = setlocale(-1, NULL);
  printf("Locale settings are: %s\n", ret_string);

                                        /* Override the numeric locale to be */
                                        /*  hardcoded to "italian in italy"  */
                                        /*  locale.  NOTE: This is hardcoded */
                                        /*  into the program.  There is no   */
                                        /*  way for the application user to  */
                                        /*  set the numeric locale to any    */
                                        /*  other value at run-time.         */
  setlocale(3, "it_it.850");

                                        /* Return the value of the locale    */
                                        /*  settings.                        */
                                        /* Print out the locale settings.    */
  ret_string = setlocale(-1, NULL);
  printf("Locale settings are: %s\n", ret_string);

                                        /* This returns the state of the     */
                                        /*  groups back to the values set    */
                                        /*  in the environment variables.    */
                                        /* Query and print out the string.   */
  setlocale(-1, "");
  ret_string = setlocale(-1, NULL);
  printf("Changed the settings back: %s\n", ret_string);
}
