usr/src/lib/liborchestrator/locale.c
author Jan Damborsky <jan.damborsky@sun.com>
Fri, 07 Mar 2008 10:25:22 +0100
changeset 26 fb9b1fd08e73
parent 0 87f703f8362e
child 107 73ae3dba821c
permissions -rw-r--r--
683 orchestrator should be libspmi* clean
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     1
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     2
 * CDDL HEADER START
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     3
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     7
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    11
 * and limitations under the License.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    12
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    18
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    19
 * CDDL HEADER END
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    20
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    21
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    22
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    23
 * Use is subject to license terms.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    24
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    25
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    26
#pragma ident	"@(#)locale.c	1.3	07/08/27 SMI"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    27
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    28
#include <fcntl.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    29
#include <stdio.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    30
#include <stdlib.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    31
#include <string.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    32
#include <sys/types.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    33
#include <unistd.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    34
#include <stropts.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    35
#include <sys/kbio.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    36
#include <stdio.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    37
#include <libintl.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    38
#include <locale.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    39
#include <malloc.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    40
#include <string.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    41
#include <sys/types.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    42
#include <sys/uio.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    43
#include <unistd.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    44
#include <stdlib.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    45
#include <sys/param.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    46
#include <sys/stat.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    47
#include <errno.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    48
#include <dirent.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    49
#include <ctype.h>
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    50
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    51
#include "orchestrator_private.h"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    52
#include "orchestrator_lang_codes.h"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    53
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    54
#define	COUNTRY_SEP	'_'
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    55
#define	CODESET_SEP	'.'
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    56
#define	UTF		"UTF-8"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    57
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    58
#define	SIMPLIFIED_CHINESE	"Chinese-Simplified"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    59
#define	TRADITIONAL_CHINESE	"Chinese-Traditional"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    60
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    61
#define	INSTALL_NLS_PATH	"/usr/lib/install/data/lib/locale"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    62
#define	NLS_PATH		"/usr/lib/locale"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    63
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    64
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    65
/* Static variables used to store language/locale system information */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    66
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    67
static	lang_info_t 	*install_ll_list = NULL;	/* lang, locale list */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    68
static	lang_info_t	*supported_ll_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    69
static	char		*install_lang_list[MAX_NUM_LANG];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    70
static	char		*supported_lang_list[MAX_NUM_LANG];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    71
static	char		**install_languages = NULL;	/* sorted list */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    72
static	char		**supported_languages = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    73
static	char		*app_locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    74
static	int		lang_initialized = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    75
static	int		install_initialized = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    76
static	int		install_lang_total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    77
static	int		supported_lang_total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    78
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    79
struct	chinese_values {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    80
	char 	*lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    81
	char	*lang_name;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    82
	char	*lang_code;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    83
} chinese_values[] = {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    84
	{"zh", SIMPLIFIED_CHINESE, "sc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    85
	{"zh.GBK", SIMPLIFIED_CHINESE, "sc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    86
	{"zh.UTF-8", SIMPLIFIED_CHINESE, "sc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    87
	{"zh_CN", "SIMPLIFIED_CHINESE", "sc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    88
	{"zh_CN.GB18030", SIMPLIFIED_CHINESE, "sc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    89
	{"zh_HK", TRADITIONAL_CHINESE, "tc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    90
	{"zh_HK.BIG5HK", TRADITIONAL_CHINESE, "tc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    91
	{"zh_HK.UTF-8", TRADITIONAL_CHINESE, "tc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    92
	{"zh_TW", TRADITIONAL_CHINESE, "tc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    93
	{"zh_TW.BIG5", TRADITIONAL_CHINESE, "tc"},
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    94
	{"zh_TW.UTF-8", TRADITIONAL_CHINESE, "tc"}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    95
};
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    96
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    97
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    98
static int 	add_lang_to_list(char ***list, char *locale, int *k, int j);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
    99
static void 	add_locale_entry_to_lang(lang_info_t *lp, char *locale,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   100
    char *region, boolean_t is_default);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   101
static int	build_language_list(char *path, char **, int *);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   102
static void	build_install_ll_list(char *nlspath, char **list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   103
    int lang_total, lang_info_t **return_list, int *ll_total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   104
static void	build_ll_list(char **list, int lang_total,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   105
		    lang_info_t **, int *total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   106
static	char	*copy_up_to(char *start, char *t);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   107
static int	create_lang_entry(char *lang, char *locale, char *region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   108
    lang_info_t **, boolean_t is_default);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   109
static void	end_of_comp(char **t, char **start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   110
static char 	**get_actual_languages(char **list, int *);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   111
static lang_info_t *get_lang_entry(char *, lang_info_t *search_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   112
static char 	*get_locale_component(char **t, char **start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   113
static char 	*get_locale_description(char *lang, char *region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   114
static int 	handle_chinese_language(char *region, char **lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   115
static boolean_t is_locale_in_installer_lang(char *locale_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   116
static boolean_t is_valid_locale(char *locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   117
static int 	list_cmp(const void *p1, const void *p2);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   118
static int 	lang_init(char *path, char **list, int *total, int *init_var);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   119
static int 	save_system_default_locale(char *locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   120
static void 	set_lang(char *locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   121
static void 	set_lc(char *, char *, char *, char *, char *, char *);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   122
static char 	*strip_comment(char *buf);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   123
static char 	*translate_description(char *locale, char *desc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   124
static void 	translate_lang_names(lang_info_t **list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   125
static void 	sort_lang_list(char **unsorted_list, int total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   126
static char 	*substitute_chinese_language(char *locale, char **code);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   127
static char 	*substitute_C_POSIX_language(char **code);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   128
static void 	update_init(FILE *fp, char *locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   129
static void 	update_env(char *locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   130
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   131
#define	STR_LANG	"LANG="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   132
#define	LEN_LANG	(sizeof (STR_LANG) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   133
#define	STR_LC_COLLATE	"LC_COLLATE="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   134
#define	LEN_LC_COLLATE	(sizeof (STR_LC_COLLATE) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   135
#define	STR_LC_CTYPE	"LC_CTYPE="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   136
#define	LEN_LC_CTYPE	(sizeof (STR_LC_CTYPE) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   137
#define	STR_LC_MESSAGES	"LC_MESSAGES="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   138
#define	LEN_LC_MESSAGES	(sizeof (STR_LC_MESSAGES) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   139
#define	STR_LC_MONETARY	"LC_MONETARY="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   140
#define	LEN_LC_MONETARY	(sizeof (STR_LC_MONETARY) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   141
#define	STR_LC_NUMERIC	"LC_NUMERIC="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   142
#define	LEN_LC_NUMERIC	(sizeof (STR_LC_NUMERIC) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   143
#define	STR_LC_TIME	"LC_TIME="
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   144
#define	LEN_LC_TIME	(sizeof (STR_LC_TIME) - 1)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   145
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   146
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   147
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   148
 * om_get_install_lang_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   149
 * This function returns the locales available for use in setting
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   150
 * installer locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   151
 * Input:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   152
 * Output:	int *total, returns the total number of locales found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   153
 * Return:	Pointer to lang_info_t which is a linked list of
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   154
 *		locales available for selection.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   155
 *		NULL if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   156
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   157
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   158
 *		OM_FAILIRE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   159
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   160
lang_info_t *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   161
om_get_install_lang_info(int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   162
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   163
	int		ll_total;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   164
	int		ret;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   165
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   166
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   167
	 * Path to look for locale data.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   168
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   169
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   170
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   171
	 * Build the lang list for the install application support.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   172
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   173
	if (!install_initialized) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   174
		ret = lang_init(INSTALL_NLS_PATH, (char **)&install_lang_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   175
		    &install_lang_total, &install_initialized);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   176
		if (ret)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   177
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   178
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   179
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   180
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   181
	 * For the install languages we build the locale list associated
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   182
	 * with them by reading the lcctab file in the /usr/lib/locale/
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   183
	 * directory.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   184
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   185
	build_install_ll_list(NLS_PATH, (char **)&install_lang_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   186
	    install_lang_total, &install_ll_list, &ll_total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   187
	*total = ll_total;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   188
	return (install_ll_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   189
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   190
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   191
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   192
 * om_get_install_lang_names
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   193
 * This function returns the lang names available for use in setting
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   194
 * installer locale system
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   195
 * Input:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   196
 * Output:	int *total, returns the total number of locales found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   197
 * Return:	char ** list of lang names available for selection.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   198
 *		NULL if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   199
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   200
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   201
 *		OM_FAILIRE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   202
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   203
char **
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   204
om_get_install_lang_names(int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   205
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   206
	int		ret;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   207
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   208
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   209
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   210
	 * Reads directory that contains installation application
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   211
	 * languages. Fills install_lang_list with this data,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   212
	 * if this has not been initialized yet.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   213
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   214
	if (!install_initialized) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   215
		ret = lang_init(INSTALL_NLS_PATH, (char **)&install_lang_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   216
		    &install_lang_total, &install_initialized);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   217
		if (ret)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   218
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   219
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   220
	install_languages = get_actual_languages((char **)install_lang_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   221
	    total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   222
	sort_lang_list(install_languages, *total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   223
	return (install_languages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   224
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   225
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   226
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   227
 * om_get_lang_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   228
 * This function returns the available locales for installation on to
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   229
 * system
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   230
 * Input:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   231
 * Output:	int *total, returns the total number of locales found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   232
 * Return:	Pointer to lang_info_t which is a linked list of
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   233
 *		locales available for selection to install.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   234
 *		NULL if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   235
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   236
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   237
 *		OM_FAILIRE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   238
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   239
lang_info_t *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   240
om_get_lang_info(int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   241
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   242
	int	ret;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   243
	int	locale_total;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   244
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   245
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   246
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   247
	if (!lang_initialized) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   248
		ret = lang_init(NLS_PATH, (char **)&supported_lang_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   249
		    &supported_lang_total, &lang_initialized);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   250
		if (ret)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   251
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   252
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   253
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   254
	 * This function looks in usr/lib/locale on the installation
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   255
	 * media to determine languages that we provide support for.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   256
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   257
	sort_lang_list((char **)&supported_lang_list, supported_lang_total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   258
	build_ll_list((char **)&supported_lang_list, supported_lang_total,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   259
	    &supported_ll_list, &locale_total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   260
	*total = locale_total;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   261
	return (supported_ll_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   262
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   263
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   264
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   265
 * om_get_lang_names
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   266
 * This function returns the language strings that can are supported for
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   267
 * installation on to system.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   268
 * Input:	None
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   269
 * Output:	int *total, returns the total number of lang names found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   270
 * Return:	char ** list of lang names
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   271
 *		NULL if no lang names found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   272
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   273
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   274
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   275
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   276
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   277
char **
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   278
om_get_lang_names(int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   279
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   280
	int	ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   281
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   282
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   283
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   284
	 * We only gather 'supported lang names'. Supported means
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   285
	 * full locale, UTF-8 only. For display to the user for
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   286
	 * default locale selection.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   287
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   288
	if (!lang_initialized) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   289
		ret = lang_init(NLS_PATH, (char **)&supported_lang_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   290
		    &supported_lang_total, &lang_initialized);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   291
		if (ret) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   292
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   293
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   294
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   295
	supported_languages = get_actual_languages(supported_lang_list, total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   296
	sort_lang_list(supported_languages, *total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   297
	return (supported_languages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   298
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   299
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   300
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   301
 * om_get_locale_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   302
 * This function returns a linked list of locale_info_t's that correspond
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   303
 * to the language specified.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   304
 * Input:	char *lang - language for which to return locale data.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   305
 * Output:	int *total, returns the total number of lang names found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   306
 * Return:	locale_info_t * list of locale_names.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   307
 *		NULL if no locale names found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   308
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   309
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   310
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   311
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   312
locale_info_t *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   313
om_get_locale_info(char *lang, int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   314
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   315
	lang_info_t *langp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   316
	locale_info_t *localep = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   317
	lang_info_t	*tmp = supported_ll_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   318
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   319
	if (tmp == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   320
		tmp = install_ll_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   321
	if (tmp == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   322
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   323
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   324
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   325
	 * The lang is passed in as the lang code. Not the translated
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   326
	 * name.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   327
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   328
	for (langp = tmp; langp != NULL; langp = langp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   329
		if (strcmp(langp->lang, lang) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   330
			localep = langp->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   331
			break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   332
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   333
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   334
	*total = langp->n_locales;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   335
	return (localep);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   336
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   337
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   338
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   339
 * om_get_locale_names
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   340
 * This function returns a list of locale names that correspond
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   341
 * to the language specified.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   342
 * Input:	char *lang - language for which to return locale data.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   343
 * Output:	int *total, returns the total number of lang names found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   344
 * Return:	char ** list of locale_names.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   345
 *		NULL if no locale names found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   346
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   347
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   348
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   349
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   350
char **
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   351
om_get_locale_names(char *lang, int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   352
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   353
	lang_info_t 	*langp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   354
	locale_info_t 	*localep = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   355
	char		**locale_names;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   356
	int		i = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   357
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   358
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   359
	 * locale_names is a an array of char *. Allocate each array
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   360
	 * member before strduping the locale_info in to this array.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   361
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   362
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   363
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   364
	 * The lang is passed in as the lang code. Not the translated
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   365
	 * name.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   366
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   367
	for (langp = supported_ll_list; langp != NULL; langp = langp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   368
		if (strcmp(langp->lang, lang) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   369
			localep = langp->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   370
			break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   371
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   372
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   373
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   374
	 * allocate number of char * pointers to correspond to number
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   375
	 * of locale names.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   376
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   377
	locale_names = (char **)malloc(langp->n_locales * sizeof (char *));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   378
	if (locale_names == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   379
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   380
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   381
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   382
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   383
	for (; localep; localep = localep->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   384
		locale_names[i] = strdup(localep->locale_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   385
		if (locale_names[i] == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   386
			om_free_lang_names(locale_names);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   387
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   388
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   389
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   390
		i++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   391
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   392
	*total = i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   393
	return (locale_names);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   394
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   395
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   396
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   397
 * om_set_install_lang_by_value
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   398
 * This function sets the installer application language, using the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   399
 * lang_info_t * data passed in.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   400
 * Input:	lang_info_t	* lang/locale info to set
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   401
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   402
 * Return:	Success or Failure
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   403
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   404
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   405
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   406
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   407
int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   408
om_set_install_lang_by_value(lang_info_t *localep)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   409
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   410
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   411
	 * For install applications, there will only be 1 locale
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   412
	 * associated with that language.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   413
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   414
	locale_info_t *locp = localep->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   415
	if (locp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   416
		om_set_error(OM_INVALID_LOCALE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   417
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   418
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   419
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   420
	om_save_locale(locp->locale_name, B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   421
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   422
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   423
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   424
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   425
 * om_set_install_lang_by_name
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   426
 * This function sets the installer application language, using the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   427
 * lang name passed in.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   428
 * Input:	char *lang name to set.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   429
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   430
 * Return:	int, Success or Failure
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   431
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   432
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   433
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   434
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   435
int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   436
om_set_install_lang_by_name(char *lang)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   437
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   438
	locale_info_t	*locp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   439
	int		total;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   440
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   441
	 * Find the locale entry based on the name passed in. If no
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   442
	 * locales for this language use the default locale of C/POSIX.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   443
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   444
	locp = om_get_locale_info(lang, &total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   445
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   446
	if (locp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   447
		om_set_error(OM_INVALID_LOCALE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   448
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   449
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   450
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   451
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   452
	 * Now, set the environment for the installation application.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   453
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   454
	om_save_locale(locp->locale_name, B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   455
	om_free_locale_info(locp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   456
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   457
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   458
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   459
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   460
 * om_set_default_locale_by_name
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   461
 * This function sets the system default locale by name
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   462
 * Input:	char *lang name to set.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   463
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   464
 * Return:	int, Success or Failure
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   465
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   466
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   467
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   468
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   469
int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   470
om_set_default_locale_by_name(char *localep)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   471
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   472
	int ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   473
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   474
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   475
	 * C/Posix is the default, there is no need to specify it
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   476
	 * in the /etc/default/init file.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   477
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   478
	if (strcasecmp(localep, "C/Posix") == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   479
	    strcasecmp(localep, "Posix") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   480
		return (ret);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   481
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   482
	ret = save_system_default_locale(localep);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   483
	if (!ret)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   484
		om_save_locale(localep, B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   485
	return (ret);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   486
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   487
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   488
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   489
 * om_get_default_locale
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   490
 * This function returns the default locale as set by a call to
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   491
 * set_default_locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   492
 * Input:	locale_info_t *loclistp - list to search
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   493
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   494
 * Return:	locale_info_t * pointer to structure for default locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   495
 * 		or NULL if none found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   496
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   497
 *		OM_SUCCESS if locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   498
 *		OM_FAILURE if no locales found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   499
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   500
locale_info_t *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   501
om_get_def_locale(locale_info_t *loclistp)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   502
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   503
	locale_info_t *lp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   504
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   505
	for (lp = loclistp; lp != NULL; lp = lp->next)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   506
		if (lp->def_locale == B_TRUE)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   507
			return (lp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   508
	return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   509
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   510
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   511
 * om_free_lang_names
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   512
 * This function frees the memory associated with the char **list of lang
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   513
 * names passed in.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   514
 * Input:	char **lang name list.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   515
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   516
 * Return:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   517
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   518
 *		none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   519
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   520
void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   521
om_free_lang_names(char **listp)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   522
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   523
	int	i = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   524
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   525
	for (i = 0; listp[i] != NULL; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   526
		free(listp[i]);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   527
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   528
	free(listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   529
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   530
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   531
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   532
 * om_free_lang_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   533
 * This function frees the memory associated with the lang_info_t *list
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   534
 * Input:	lang_info_t * langp - list to free
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   535
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   536
 * Return:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   537
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   538
 *		none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   539
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   540
void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   541
om_free_lang_info(lang_info_t *langp)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   542
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   543
	lang_info_t *nextp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   544
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   545
	while (langp != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   546
		nextp = langp->next;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   547
		om_free_locale_info((locale_info_t *)langp->locale_info);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   548
		free(langp->lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   549
		free(langp->lang_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   550
		free(langp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   551
		langp = nextp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   552
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   553
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   554
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   555
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   556
 * om_free_locale_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   557
 * This function frees the memory associated with the locale_info_t *list
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   558
 * Input:	locale_info_t * localep - list to free
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   559
 * Output:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   560
 * Return:	none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   561
 * Error Handling:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   562
 *		none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   563
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   564
void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   565
om_free_locale_info(locale_info_t *localep)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   566
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   567
	locale_info_t	*nextp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   568
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   569
	while (localep != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   570
		nextp = localep->next;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   571
		free(localep->locale_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   572
		free(localep->locale_desc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   573
		free(localep);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   574
		localep = nextp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   575
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   576
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   577
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   578
 * Static functions.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   579
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   580
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   581
save_system_default_locale(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   582
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   583
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   584
	FILE 	*fp = (FILE *)NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   585
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   586
	if (locale == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   587
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   588
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   589
	if ((fp = fopen(TMP_INITDEFSYSLOC, "w")) == (FILE *)NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   590
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   591
	if (fprintf(fp, "%s\n", locale) < 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   592
		(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   593
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   594
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   595
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   596
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   597
	if ((fp = fopen(TMP_DEFSYSLOC, "w")) == (FILE *)NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   598
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   599
	if (fprintf(fp, "%s\n", locale) < 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   600
		(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   601
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   602
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   603
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   604
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   605
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   606
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   607
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   608
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   609
lang_init(char *path, char **list, int *total, int *init_var)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   610
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   611
	int	ret;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   612
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   613
	ret = build_language_list(path, list, total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   614
	if (!ret) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   615
		*init_var = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   616
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   617
	return (ret);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   618
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   619
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   620
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   621
 * Function
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   622
 *		create_lang_entry
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   623
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   624
 * Description
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   625
 *		Create a language/locale list node and link
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   626
 *		it into the lang/locale linked list.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   627
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   628
 * Scope
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   629
 *		Private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   630
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   631
 * Parameters
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   632
 *		lang - language to add
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   633
 *		locale - locale which uses lang
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   634
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   635
 * Return
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   636
 *		none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   637
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   638
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   639
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   640
create_lang_entry(char *lang, char *locale, char *region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   641
    lang_info_t **return_list, boolean_t is_default)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   642
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   643
	lang_info_t	*tmp, *last, *new;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   644
	locale_info_t	*lp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   645
	char		**trans_lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   646
	char		*tmp_lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   647
	char		*tmp_locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   648
	char		*code = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   649
	char		*desc = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   650
	int		total;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   651
	lang_info_t	*list = *return_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   652
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   653
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   654
	 * For Chinese we have to handle it specially. There is Traditional
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   655
	 * Chinese or Simplified Chinese. Everything else is a locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   656
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   657
	if (strncmp(lang, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   658
		tmp_lang = strdup(dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   659
		    substitute_chinese_language(lang, &code)));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   660
		if (locale == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   661
			tmp_locale = strdup(dgettext(TEXT_DOMAIN, lang));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   662
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   663
	if (strncmp(lang, "C", 1) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   664
		tmp_lang = strdup(dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   665
		    substitute_C_POSIX_language(&code)));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   666
		if (locale == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   667
			tmp_locale = strdup(dgettext(TEXT_DOMAIN, lang));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   668
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   669
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   670
	new = (lang_info_t *)malloc(sizeof (lang_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   671
	if (new == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   672
		goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   673
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   674
	(void) memset(new, 0, sizeof (lang_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   675
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   676
	new->lang = (code != NULL) ? strdup(code): strdup(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   677
	if (new->lang == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   678
		goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   679
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   680
	if (tmp_lang != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   681
		trans_lang = &tmp_lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   682
	} else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   683
		trans_lang = get_actual_languages(&new->lang, &total);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   684
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   685
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   686
	 * We look for the lang name in our list of iso approved language
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   687
	 * translations. If not found, then it isn't a language so
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   688
	 * we don't create an entry for it.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   689
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   690
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   691
	if (trans_lang != NULL && *trans_lang != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   692
		new->lang_name  = *trans_lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   693
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   694
		om_set_error(OM_NOT_LANG);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   695
		goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   696
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   697
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   698
	new->def_lang = is_default;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   699
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   700
	if (locale != NULL || tmp_locale != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   701
		lp = (locale_info_t *)malloc(sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   702
		if (lp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   703
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   704
			goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   705
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   706
		(void) memset(lp, 0, sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   707
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   708
		if (tmp_locale) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   709
			lp->locale_name = tmp_locale;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   710
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   711
			lp->locale_name = strdup(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   712
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   713
		if (lp->locale_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   714
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   715
			goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   716
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   717
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   718
		desc = get_locale_description(new->lang_name, region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   719
		lp->locale_desc = desc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   720
		new->locale_info = lp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   721
		new->locale_info->def_locale = is_default;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   722
		new->n_locales++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   723
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   724
	if (list != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   725
		for (tmp = list, last = NULL; tmp != NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   726
		    last = tmp, tmp = tmp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   727
			/* Everything is after English */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   728
			if (strcmp(tmp->lang, dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   729
			    "English")) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   730
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   731
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   732
			if (strcmp(tmp->lang, lang) > 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   733
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   734
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   735
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   736
		if (tmp == list) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   737
			new->next = list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   738
			list = new;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   739
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   740
			last->next = new;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   741
			new->next = tmp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   742
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   743
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   744
		list = new;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   745
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   746
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   747
	free(code);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   748
	*(return_list) = list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   749
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   750
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   751
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   752
	free(code);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   753
	om_free_lang_info(new);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   754
	om_free_locale_info(lp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   755
	return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   756
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   757
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   758
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   759
 * Function
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   760
 *		get_lang_entry
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   761
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   762
 * Description
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   763
 *		Get the language/locale list node which uses
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   764
 *		the specified language
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   765
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   766
 * Scope
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   767
 *		Private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   768
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   769
 * Parameters
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   770
 *		lang - language to search for
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   771
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   772
 * Return
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   773
 *		a pointer to the correct lang/locale node or NULL
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   774
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   775
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   776
static lang_info_t *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   777
get_lang_entry(char *lang_name, lang_info_t *search_list)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   778
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   779
	lang_info_t 	*list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   780
	char		*tmp_lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   781
	char		*code = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   782
	boolean_t	found = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   783
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   784
	if (lang_name == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   785
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   786
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   787
	 * Chinese language names are stored differently.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   788
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   789
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   790
	if (strncmp(lang_name, "zh", 2) == 0)  {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   791
		tmp_lang = strdup(dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   792
		    substitute_chinese_language(lang_name, &code)));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   793
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   794
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   795
	for (list = search_list; list != NULL; list = list->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   796
		if (code) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   797
			if (strcmp(list->lang, code) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   798
				found = B_TRUE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   799
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   800
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   801
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   802
			if (strcmp(list->lang, lang_name) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   803
				found = B_TRUE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   804
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   805
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   806
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   807
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   808
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   809
	free(tmp_lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   810
	free(code);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   811
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   812
	if (!found)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   813
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   814
	return (list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   815
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   816
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   817
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   818
 * Function
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   819
 *		add_locale_entry_to_lang
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   820
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   821
 * Description
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   822
 *		Add an additional locale to the list of
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   823
 *		locales that use lang.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   824
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   825
 * Scope
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   826
 *		Private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   827
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   828
 * Parameters
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   829
 *		langp - pointer to the lang/locale node to add locale to
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   830
 *		locale - locale which uses lang
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   831
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   832
 * Return
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   833
 *		none
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   834
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   835
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   836
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   837
add_locale_entry_to_lang(lang_info_t *langp, char *locale_name, char *region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   838
    boolean_t is_default)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   839
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   840
	char		*desc = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   841
	locale_info_t 	*locp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   842
	locale_info_t	*tmp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   843
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   844
	tmp = langp->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   845
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   846
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   847
	 * Check for previous inclusion of this locale entry.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   848
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   849
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   850
	while (tmp != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   851
		if (strcmp(tmp->locale_name, locale_name) == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   852
			return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   853
		tmp = tmp->next;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   854
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   855
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   856
	 * Allocate space for new entry.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   857
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   858
	locp = (locale_info_t *)malloc(sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   859
	if (locp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   860
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   861
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   862
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   863
	(void) memset(locp, 0, sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   864
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   865
	locp->locale_name = strdup(locale_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   866
	if (locp->locale_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   867
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   868
		om_free_locale_info(locp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   869
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   870
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   871
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   872
	desc = get_locale_description(langp->lang_name, region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   873
	locp->locale_desc = desc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   874
	locp->def_locale = is_default;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   875
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   876
	locp->next = langp->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   877
	langp->locale_info = locp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   878
	langp->def_lang = is_default;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   879
	langp->n_locales++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   880
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   881
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   882
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   883
build_install_ll_list(char *nlspath, char **install_list, int lang_total,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   884
    lang_info_t **return_list, int *ll_total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   885
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   886
	char 		path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   887
	char		trans[MAX_LOCALE + 1];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   888
	char 		linebuf[128];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   889
	FILE		*fp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   890
	char		*c, *c2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   891
	int		i, ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   892
	lang_info_t	*lp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   893
	locale_info_t	*locp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   894
	int		num_entries = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   895
	boolean_t	is_default = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   896
	char		*start = NULL, *t = NULL, *lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   897
	char		*region = NULL, *encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   898
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   899
	*return_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   900
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   901
	if (install_list == NULL || *install_list == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   902
		om_set_error(OM_INVALID_LANG_LIST);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   903
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   904
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   905
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   906
	(void) memset(trans, 0, sizeof (trans));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   907
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   908
	 * For the installer application supported languages we only
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   909
	 * want the non-UTF-8 codeset. Why? Because there is not full
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   910
	 * locale support for UTF-8 in the miniroot.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   911
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   912
	for (i = 0; i < lang_total && install_list[i] != NULL; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   913
		start = install_list[i];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   914
		lang = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   915
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   916
		if (start && *t == COUNTRY_SEP)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   917
			region = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   918
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   919
		if (start && *t == CODESET_SEP)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   920
			encoding = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   921
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   922
		if (encoding != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   923
			if (strcmp(encoding, UTF) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   924
				free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   925
				free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   926
				free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   927
				encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   928
				region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   929
				lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   930
				continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   931
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   932
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   933
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   934
		if (strncmp(lang, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   935
			if (region != NULL && strcmp(region, "TW") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   936
				om_errno = handle_chinese_language(region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   937
				    &lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   938
				if (om_errno != OM_SUCCESS) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   939
					goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   940
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   941
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   942
		} else if (strcmp(lang, "C") == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   943
		    strcmp(lang, "POSIX") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   944
			free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   945
			lang = strdup("en");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   946
			is_default = B_TRUE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   947
			if (lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   948
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   949
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   950
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   951
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   952
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   953
		if ((lp = get_lang_entry(lang, *return_list)) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   954
			continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   955
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   956
			ret = create_lang_entry(install_list[i],
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   957
			    install_list[i], region, return_list, is_default);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   958
			if (!ret)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   959
				num_entries++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   960
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   961
		free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   962
		free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   963
		free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   964
		lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   965
		region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   966
		encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   967
		is_default = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   968
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   969
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   970
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   971
	 * For the install application language specifications, which
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   972
	 * are located at /usr/lib/install/data/lib/locale, we need
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   973
	 * to ensure we have an up to date locale/lang name for
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   974
	 * translation. The lcttab file in /usr/lib/locale provides
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   975
	 * the correct mapping.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   976
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   977
	lp = *return_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   978
	(void) snprintf(path, sizeof (path), "%s/lcttab", nlspath);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   979
	if ((fp = fopen(path, "r"))) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   980
		for (i = 0; lp != NULL; lp = lp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   981
			locp = lp->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   982
			rewind(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   983
			while (fgets(linebuf, 128, fp)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   984
				if (strlen(linebuf) == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   985
				    linebuf[0] == '#') {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   986
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   987
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   988
				/* Search for whitespace */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   989
				for (c = linebuf; *c && !isspace(*c); c++)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   990
					;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   991
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   992
				if (*c != '\0') {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   993
					/* End of line - invalid input */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   994
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   995
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   996
				*c = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   997
				if (strcmp(linebuf, locp->locale_name) != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   998
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   999
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1000
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1001
				/* Found the old name - get the new version */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1002
				for (c++; *c && isspace(*c); c++)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1003
					;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1004
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1005
				if (!*c) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1006
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1007
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1008
				for (c2 = c; *c2 && !isspace(*c2); c2++)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1009
					;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1010
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1011
				*c2 = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1012
				/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1013
				 * We are not interested in UTF-8
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1014
				 * codesets for now.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1015
				 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1016
				if (strstr(c, UTF) != NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1017
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1018
				(void) strcpy(trans, c);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1019
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1020
			} /* end while */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1021
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1022
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1023
			 * We may have not found a match in the lcttab file.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1024
			 * If not, copy the original locale data in and
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1025
			 * search for locale_map.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1026
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1027
			if (trans[0] == '\0')
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1028
				(void) strcpy(trans, locp->locale_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1029
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1030
			locp = (locale_info_t *)malloc(sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1031
			if (locp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1032
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1033
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1034
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1035
			(void) memset(locp, 0, sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1036
			locp->locale_name = strdup(trans);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1037
			if (locp->locale_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1038
				om_free_locale_info(locp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1039
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1040
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1041
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1042
			(void) memset(trans, 0, sizeof (trans));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1043
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1044
			 * free the original lang_info_t->locale_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1045
			 * data.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1046
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1047
			om_free_locale_info(lp->locale_info);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1048
			lp->locale_info = locp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1049
			lp->n_locales++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1050
		} /* end for */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1051
	} /* end if */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1052
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1053
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1054
	 * Now, translate language names, in this order, in to native
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1055
	 * locale based on current locale data associated with this language.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1056
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1057
	translate_lang_names(return_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1058
	*ll_total = num_entries;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1059
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1060
	return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1061
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1062
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1063
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1064
	om_free_lang_info(*return_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1065
	*return_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1066
	*ll_total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1067
	free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1068
	free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1069
	free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1070
	free(start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1071
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1072
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1073
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1074
build_ll_list(char **list, int lang_total, lang_info_t **return_list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1075
    int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1076
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1077
	int		i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1078
	int		ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1079
	int		num_langs = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1080
	char		*lang = NULL, *encoding = NULL, *region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1081
	char		*locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1082
	lang_info_t	*lp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1083
	char		*orig, *start = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1084
	char		*t = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1085
	boolean_t	is_default = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1086
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1087
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1088
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1089
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1090
	 * lang_list passed in is a sorted list of the data found in
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1091
	 * the locale directory. Take this sorted list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1092
	 * parse appropriately, and insert locale data for each language
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1093
	 * in to the return_list.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1094
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1095
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1096
	for (i = 0; i < lang_total; i++)  {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1097
		orig = start = list[i];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1098
		if (!is_valid_locale(list[i]))
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1099
			continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1100
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1101
		t = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1102
		lang = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1103
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1104
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1105
		 * If we found a country or codeset sep then we found a
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1106
		 * locale.  The lang value is the language part of
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1107
		 * the lang/locale pair. What was in the original list
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1108
		 * is the locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1109
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1110
		if (start && *t == COUNTRY_SEP) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1111
			region = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1112
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1113
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1114
		if (start && *t == CODESET_SEP) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1115
			encoding = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1116
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1117
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1118
		if (strncmp(lang, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1119
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1120
			 * If there is a region with the Chinese lang,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1121
			 * we need to ensure that it is not its own language.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1122
			 * Chinese specifications for language include
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1123
			 * the region, such as zh_HK and zh_TW.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1124
			 * If no region is found, then lang is simply lang
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1125
			 * from above.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1126
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1127
			if (region) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1128
				om_errno = handle_chinese_language(region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1129
				    &lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1130
				if (om_errno != OM_SUCCESS) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1131
					goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1132
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1133
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1134
				/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1135
				 * We need to account for Simplified Chinese,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1136
				 * EUC in the locale list. Its locale name
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1137
				 * does not include a region.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1138
				 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1139
				locale = strdup(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1140
				if (locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1141
					om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1142
					goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1143
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1144
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1145
		} else if (strcmp(lang, "C") == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1146
		    strcmp(lang, "POSIX") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1147
			free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1148
			lang = strdup("en");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1149
			if (lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1150
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1151
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1152
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1153
			locale = strdup(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1154
			if (locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1155
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1156
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1157
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1158
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1159
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1160
		 * Locale is a combination of  lang, country and codeset.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1161
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1162
		if (encoding != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1163
			locale = strdup(orig);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1164
			if (locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1165
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1166
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1167
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1168
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1169
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1170
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1171
		 * If we don't have the locale value, we haven't found
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1172
		 * anything we are interested in, so skip.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1173
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1174
		if (locale != NULL)  {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1175
			is_default = is_locale_in_installer_lang(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1176
			if ((lp = get_lang_entry(lang, *return_list)) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1177
				add_locale_entry_to_lang(lp, locale, region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1178
				    is_default);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1179
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1180
				ret = create_lang_entry(lang, locale, region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1181
				    return_list, is_default);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1182
				if (!ret) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1183
					num_langs++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1184
					om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1185
					    "num_langs = %d\n", num_langs);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1186
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1187
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1188
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1189
		free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1190
		free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1191
		free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1192
		free(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1193
		region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1194
		encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1195
		lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1196
		locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1197
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1198
	*total = num_langs;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1199
	return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1200
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1201
	om_free_lang_info(*return_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1202
	*return_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1203
	free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1204
	free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1205
	free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1206
	free(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1207
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1208
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1209
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1210
 * build_language_list:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1211
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1212
 *	The idea is to scan the directories under "path" and
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1213
 *	build the language list, char ** list, associated with
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1214
 *	the "path".
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1215
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1216
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1217
build_language_list(char *path, char **list, int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1218
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1219
	DIR		*locale_dir;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1220
	struct dirent	*locale;		/* entries in locale_dir */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1221
	int		i = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1222
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1223
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1224
	 * Read in language data from the locale directory.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1225
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1226
	(void) memset(list, 0, sizeof (*list));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1227
	locale_dir = opendir(path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1228
	if (locale_dir == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1229
		if (errno == EACCES) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1230
			om_set_error(OM_PERMS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1231
		} else if (errno != EMFILE && errno != ENFILE) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1232
			om_set_error(OM_NO_LOCALE_DIR);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1233
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1234
			om_set_error(OM_TOO_MANY_FD);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1235
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1236
		goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1237
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1238
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1239
	while (locale = readdir(locale_dir)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1240
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1241
		 * Exclude current and parent directory. Make sure
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1242
		 * we are not over our buffer limit.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1243
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1244
		if (strcmp(locale->d_name, ".") == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1245
		    strcmp(locale->d_name, "..") == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1246
			continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1247
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1248
		list[i] = strdup(locale->d_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1249
		if (list[i] == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1250
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1251
			goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1252
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1253
		i++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1254
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1255
	*total = i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1256
	(void) closedir(locale_dir);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1257
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1258
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1259
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1260
	om_free_lang_names(list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1261
	*list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1262
	(void) closedir(locale_dir);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1263
	return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1264
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1265
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1266
 * This function reads a locales locale_map file to get the settings
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1267
 * that should be used for localization.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1268
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1269
 * Input: File *fp  File pointer to locale_map file
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1270
 * Output: Each type of locale category value is returned.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1271
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1272
int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1273
read_locale_file(FILE *fp, char *lang, char *lc_collate, char *lc_ctype,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1274
	char *lc_messages, char *lc_monetary, char *lc_numeric, char *lc_time)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1275
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1276
	int status = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1277
	char line[BUFSIZ];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1278
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1279
	(void) strcpy(lc_collate, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1280
	(void) strcpy(lc_ctype, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1281
	(void) strcpy(lc_messages, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1282
	(void) strcpy(lc_monetary, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1283
	(void) strcpy(lc_numeric, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1284
	(void) strcpy(lc_time, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1285
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1286
	while (fgets(line, BUFSIZ, fp) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1287
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1288
		 * Remove the trailing newline, and strip any comments that
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1289
		 * may appear on the read line.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1290
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1291
		line[strlen(line) - 1] = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1292
		(void) strip_comment(line);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1293
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1294
		if (strncmp(STR_LANG, line, LEN_LANG) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1295
			(void) strcpy(lang, line + LEN_LANG);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1296
			status = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1297
		} else if (strncmp(STR_LC_COLLATE, line, LEN_LC_COLLATE) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1298
			(void) strcpy(lc_collate, line + LEN_LC_COLLATE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1299
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1300
		} else if (strncmp(STR_LC_CTYPE, line, LEN_LC_CTYPE) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1301
			(void) strcpy(lc_ctype, line + LEN_LC_CTYPE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1302
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1303
		} else if (strncmp(STR_LC_MESSAGES, line, LEN_LC_MESSAGES)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1304
		    == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1305
			(void) strcpy(lc_messages, line + LEN_LC_MESSAGES);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1306
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1307
		} else if (strncmp(STR_LC_MONETARY, line, LEN_LC_MONETARY)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1308
		    == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1309
			(void) strcpy(lc_monetary, line + LEN_LC_MONETARY);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1310
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1311
		} else if (strncmp(STR_LC_NUMERIC, line, LEN_LC_NUMERIC) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1312
			(void) strcpy(lc_numeric, line + LEN_LC_NUMERIC);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1313
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1314
		} else if (strncmp(STR_LC_TIME, line, LEN_LC_TIME) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1315
			(void) strcpy(lc_time, line + LEN_LC_TIME);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1316
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1317
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1318
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1319
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1320
	if (status == 1) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1321
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1322
		 * There's a LANG, but nothing else, so populate all of the
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1323
		 * fields with the value put in LANG
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1324
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1325
		(void) strcpy(lc_collate, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1326
		(void) strcpy(lc_ctype, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1327
		(void) strcpy(lc_messages, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1328
		(void) strcpy(lc_monetary, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1329
		(void) strcpy(lc_numeric, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1330
		(void) strcpy(lc_time, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1331
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1332
	return (status);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1333
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1334
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1335
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1336
 * Function:	strip_comment
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1337
 * Description:	Given a string of the form 'foo # comment', strip the comment
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1338
 *		text, the comment marker, and the whitespace (if any) preceding
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1339
 *		it.  This modification is done in-place on the passed in string.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1340
 * Scope:	private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1341
 * Arguments:	buf	- [RO, *RW] (char *)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1342
 *			  The buffer from which the comment is to be stripped.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1343
 * Returns:	char *	- buf, the pointer passed in
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1344
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1345
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1346
strip_comment(char *buf)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1347
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1348
	char *comchr;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1349
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1350
	if (buf == NULL || (comchr = strchr(buf, '#')) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1351
		return (buf);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1352
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1353
	for (; comchr != buf && isspace(*(comchr - 1)); comchr--)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1354
		;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1355
	*comchr = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1356
	return (buf);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1357
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1358
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1359
set_lang(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1360
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1361
	static char	tmpstr[MAX_LOCALE + 6];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1362
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1363
	(void) setlocale(LC_ALL, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1364
	(void) snprintf(tmpstr, sizeof (tmpstr), "LANG=%s", locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1365
	(void) putenv(tmpstr);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1366
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1367
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1368
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1369
set_lc(char *lc_collate, char *lc_ctype, char *lc_messages, char *lc_monetary,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1370
	char *lc_numeric, char *lc_time)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1371
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1372
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1373
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1374
	 * The longest addition to a locale value is LC_MESSAGES=. This
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1375
	 * plus the NULL value is 14 chars. Added 15 for padding as
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1376
	 * a result.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1377
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1378
	static char	tmpstr1[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1379
	static char	tmpstr2[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1380
	static char	tmpstr3[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1381
	static char	tmpstr4[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1382
	static char	tmpstr5[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1383
	static char	tmpstr6[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1384
	char		*loc = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1385
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1386
	loc = setlocale(LC_COLLATE, lc_collate);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1387
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1388
		om_debug_print(OM_DBGLVL_INFO, "lc_collate set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1389
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1390
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1391
		    "Could not set lc_collate value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1392
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1393
	(void) snprintf(tmpstr1, sizeof (tmpstr1), "LC_COLLATE=%s", lc_collate);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1394
	(void) putenv(tmpstr1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1395
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1396
	loc = setlocale(LC_CTYPE, lc_ctype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1397
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1398
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1399
		    "lc_ctype set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1400
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1401
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1402
		    "Could not set lc_ctype value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1403
	(void) snprintf(tmpstr2, sizeof (tmpstr2), "LC_CTYPE=%s", lc_ctype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1404
	(void) putenv(tmpstr2);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1405
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1406
	loc = setlocale(LC_MESSAGES, lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1407
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1408
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1409
		    "lc_messages set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1410
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1411
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1412
		    "Could not set lc_messages value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1413
	(void) snprintf(tmpstr3, sizeof (tmpstr3),
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1414
	    "LC_MESSAGES=%s", lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1415
	(void) putenv(tmpstr3);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1416
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1417
	loc =  setlocale(LC_MONETARY, lc_monetary);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1418
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1419
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1420
		    "lc_monetary set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1421
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1422
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1423
		    "Could not set lc_monetary value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1424
	(void) snprintf(tmpstr4, sizeof (tmpstr4),
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1425
	    "LC_MONETARY=%s", lc_monetary);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1426
	(void) putenv(tmpstr4);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1427
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1428
	loc = setlocale(LC_NUMERIC, lc_numeric);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1429
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1430
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1431
		    "lc_numeric set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1432
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1433
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1434
		    "Could not set lc_numeric value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1435
	(void) snprintf(tmpstr5, sizeof (tmpstr5), "LC_NUMERIC=%s", lc_numeric);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1436
	(void) putenv(tmpstr5);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1437
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1438
	loc = setlocale(LC_TIME, lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1439
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1440
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1441
		    "lc_time set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1442
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1443
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1444
		    "Could not set lc_time value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1445
	(void) snprintf(tmpstr6, sizeof (tmpstr6), "LC_TIME=%s", lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1446
	(void) putenv(tmpstr6);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1447
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1448
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1449
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1450
 * Name:	get_locale_description
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1451
 * Description:	Read the locale_description file for a given locale, returning
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1452
 *		a pointer to a buffer containing the contents of that
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1453
 *		file.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1454
 * Scope:	private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1455
 * Arguments:	locale	- [RO, *RO] (char *)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1456
 *			  The locale whose locale_description is to be read
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1457
 * Returns:	char *	- The first line of the locale_description
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1458
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1459
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1460
get_locale_description(char *lang, char *region)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1461
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1462
	char	*user_desc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1463
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1464
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1465
	 * Chinese and Korean are handled differently. This is due to
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1466
	 * the locale description for each of these being different than
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1467
	 * the standard.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1468
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1469
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1470
	if (region == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1471
		if (strcmp(lang, dgettext(TEXT_DOMAIN, TRADITIONAL_CHINESE))
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1472
		    == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1473
		    strcmp(lang, dgettext(TEXT_DOMAIN, SIMPLIFIED_CHINESE))
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1474
		    == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1475
			region = strdup("zh");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1476
		} else if (strcmp(lang, dgettext(TEXT_DOMAIN, "Korean")) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1477
			region = strdup("ko");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1478
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1479
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1480
	user_desc = translate_description(lang, region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1481
	return (user_desc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1482
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1483
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1484
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1485
translate_description(char *lang, char *region)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1486
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1487
	char 		*trans_desc = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1488
	int		len = 0, i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1489
	int		szcountry = sizeof (orchestrator_country_list) /
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1490
	    sizeof (orchestrator_country_list[0]);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1491
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1492
	char		*tmp_ctrystring = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1493
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1494
	if (lang == NULL || region == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1495
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1496
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1497
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1498
	for (i = 0; i < szcountry; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1499
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1500
		 * Translate the country code for this locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1501
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1502
		if (strncasecmp(region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1503
		    orchestrator_country_list[i].country_code, 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1504
			tmp_ctrystring =
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1505
			    dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1506
			    orchestrator_country_list[i].country_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1507
			break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1508
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1509
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1510
	if (tmp_ctrystring) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1511
		len = strlen(lang) + strlen(tmp_ctrystring) + 4;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1512
		trans_desc = (char *)malloc(len);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1513
		if (trans_desc == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1514
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1515
		(void) snprintf(trans_desc, len, "%s (%s)",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1516
		    lang, tmp_ctrystring);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1517
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1518
	return (trans_desc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1519
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1520
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1521
static char **
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1522
get_actual_languages(char **list, int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1523
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1524
	char	**lp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1525
	char	**lang_listp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1526
	size_t	sz;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1527
	int	ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1528
	int	i, j, k = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1529
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1530
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1531
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1532
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1533
	if (list == NULL || *list == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1534
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1535
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1536
	sz = sizeof (orchestrator_lang_list)/sizeof (orchestrator_lang_list[0]);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1537
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1538
	lp = list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1539
	for (i = 0; lp[i] != '\0'; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1540
		for (j = 0; j < sz; j++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1541
			if (strncmp(lp[i],
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1542
			    (char *)orchestrator_lang_list[j].lang_code,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1543
			    2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1544
				ret = add_lang_to_list(&lang_listp,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1545
				    lp[i], &k, j);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1546
				if (ret) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1547
					om_free_lang_names(lang_listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1548
					return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1549
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1550
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1551
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1552
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1553
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1554
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1555
	 * No lang translation found. Return existing list.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1556
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1557
	if (j == sz) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1558
		return (lang_listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1559
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1560
	*total = k;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1561
	om_set_error(OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1562
	return (lang_listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1563
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1564
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1565
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1566
add_lang_to_list(char ***list, char *locale, int *k, int j)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1567
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1568
	int	i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1569
	char	**lpp = *list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1570
	char	**tmp_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1571
	char	*tmp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1572
	char	*code;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1573
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1574
	tmp_list = *list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1575
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1576
	if (strncmp(locale, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1577
		tmp = strdup(dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1578
		    substitute_chinese_language(locale, &code)));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1579
	} else if (strcmp(locale, "C") == 0 || strcmp(locale, "POSIX") == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1580
	    strcmp(locale, "C/POSIX") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1581
		tmp = strdup(dgettext(TEXT_DOMAIN, "English"));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1582
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1583
		tmp = strdup(dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1584
		    orchestrator_lang_list[j].lang_name));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1585
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1586
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1587
	if (tmp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1588
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1589
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1590
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1591
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1592
	if (tmp_list != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1593
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1594
		 * Search for existence of this language in the list already
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1595
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1596
		for (i = 0; tmp_list[i] != NULL && tmp_list[i] != '\0' &&
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1597
		    i < *k; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1598
			if (strcmp(tmp, tmp_list[i]) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1599
				free(tmp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1600
				return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1601
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1602
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1603
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1604
	tmp_list = (char **)realloc(*list, ((*k) + 1) * sizeof (char *));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1605
	if (tmp_list == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1606
		free(tmp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1607
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1608
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1609
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1610
	lpp = *list = tmp_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1611
	lpp[*k] = tmp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1612
	(*k)++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1613
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1614
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1615
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1616
static boolean_t
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1617
is_valid_locale(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1618
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1619
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1620
	char	path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1621
	struct	stat stat_buf;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1622
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1623
	if (locale == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1624
		return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1625
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1626
	if (strstr(locale, UTF) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1627
		return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1628
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1629
	(void) snprintf(path, sizeof (path), "%s/%s/locale_map",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1630
	    NLS_PATH, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1631
	if ((stat(path, &stat_buf) == 0) &&
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1632
	    ((stat_buf.st_mode & S_IFMT) == S_IFREG)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1633
		return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1634
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1635
	return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1636
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1637
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1638
substitute_C_POSIX_language(char **code)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1639
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1640
	char	*lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1641
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1642
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1643
	 * locale is C and or POSIX. Set to English, set code
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1644
	 * to 'en'.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1645
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1646
	lang = strdup(dgettext(TEXT_DOMAIN, "English"));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1647
	if (lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1648
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1649
		*code = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1650
		return (lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1651
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1652
	*code = strdup("en");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1653
	if (*code == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1654
		free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1655
		lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1656
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1657
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1658
	return (lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1659
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1660
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1661
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1662
substitute_chinese_language(char *locale, char **code)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1663
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1664
	int 		i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1665
	char		*sub = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1666
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1667
	*code = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1668
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1669
	for (i = 0; chinese_values[i].lang; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1670
		if (strcmp(locale, chinese_values[i].lang) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1671
			sub = strdup(chinese_values[i].lang_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1672
			*code = strdup(chinese_values[i].lang_code);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1673
			if (sub == NULL || *code == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1674
				free(sub);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1675
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1676
				return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1677
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1678
				return (sub);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1679
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1680
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1681
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1682
	return (sub);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1683
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1684
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1685
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1686
sort_lang_list(char **unsorted_list, int total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1687
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1688
	qsort((char **)unsorted_list, total, sizeof (char *), list_cmp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1689
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1690
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1691
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1692
handle_chinese_language(char *region, char **lang)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1693
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1694
	int	len;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1695
	char	*chinese_lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1696
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1697
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1698
	len = strlen(*lang) + strlen(region) + 3;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1699
	chinese_lang = (char *)malloc(len);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1700
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1701
	 * If we cannot allocate new language data, return error, but
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1702
	 * don't modify language value. Allow caller to determine what
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1703
	 * to do.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1704
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1705
	if (chinese_lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1706
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1707
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1708
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1709
	(void) snprintf(chinese_lang, len, "%s%s%s", *lang, "_", region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1710
	free(*lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1711
	*lang = chinese_lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1712
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1713
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1714
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1715
list_cmp(const void *p1, const void *p2)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1716
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1717
	return (strcmp(*(char **)p1, *(char **)p2));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1718
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1719
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1720
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1721
 * This function gets each of the locale components. It does so
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1722
 * by looking for each component of a locale, as noted above as defines.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1723
 * It returns each segment in t, or NULL if no additional component is found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1724
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1725
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1726
get_locale_component(char **t, char **start)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1727
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1728
	char	*result = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1729
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1730
	end_of_comp(t, start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1731
	result = copy_up_to(*start, *t);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1732
	*start = (**t != '\0') ? *t + 1: NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1733
	return (result);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1734
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1735
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1736
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1737
 * This function looks for each component of the locale string passed in
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1738
 * in the 'start' parameter. If it finds one it returns a pointer to that
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1739
 * component. Or NULL if not found.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1740
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1741
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1742
end_of_comp(char **t, char **start)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1743
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1744
	(((*t) = strchr((*start), COUNTRY_SEP)) != NULL) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1745
	    (((*t) = strchr((*start), CODESET_SEP)) != NULL) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1746
	/*LINTED*/
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1747
	    (((*t) = strchr((*start), '\0')) != NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1748
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1749
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1750
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1751
copy_up_to(char *start, char *end)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1752
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1753
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1754
	 * XXX look at this.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1755
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1756
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1757
	ptrdiff_t	diff;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1758
	char		*sub = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1759
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1760
	if (end == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1761
		diff = strlen(start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1762
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1763
		/*LINTED*/
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1764
		diff = end - start;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1765
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1766
	sub = (char *)malloc(diff + 1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1767
	(void) memset(sub, 0, diff + 1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1768
	(void) strlcpy(sub, start, (diff + 1));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1769
	return (sub);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1770
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1771
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1772
static boolean_t
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1773
is_locale_in_installer_lang(char *locale_name)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1774
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1775
	if (app_locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1776
		app_locale = strdup(setlocale(LC_MESSAGES, NULL));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1777
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1778
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1779
	if (app_locale != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1780
		if (strcmp(locale_name, app_locale) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1781
			/* locale name is same */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1782
			return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1783
		} else if (strncmp(locale_name, app_locale, 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1784
			/* language part is same */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1785
			if ((strncmp(locale_name, "zh_TW", 5) == 0) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1786
			    (strncmp(locale_name, "zh_HK", 5) == 0)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1787
				/* traditional Chinese */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1788
				if ((strncmp(app_locale, "zh_TW", 5) == 0) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1789
				    (strncmp(app_locale, "zh_HK", 5) == 0)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1790
					return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1791
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1792
			} else if (strncmp(locale_name, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1793
				/* simplified Chinese */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1794
				if ((strncmp(app_locale, "zh_TW", 5) != 0) &&
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1795
				    (strncmp(app_locale, "zh_HK", 5) != 0)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1796
					return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1797
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1798
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1799
				/* others */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1800
				return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1801
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1802
		} else if (strncmp(locale_name, "en", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1803
			/* English */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1804
			if (strcmp(app_locale, "C") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1805
				return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1806
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1807
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1808
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1809
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1810
	return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1811
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1812
void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1813
om_save_locale(char *locale, boolean_t install_only)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1814
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1815
	FILE 	*fp, *tfp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1816
	char	line[BUFSIZ];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1817
	char	tfile[80];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1818
	char	target[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1819
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1820
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1821
	 * If this is only setting the installation app locale we don't
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1822
	 * want to modify the users /etc/default/init file just yet. That
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1823
	 * will happen later.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1824
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1825
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1826
	if (install_only) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1827
		update_env(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1828
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1829
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1830
	(void) sprintf(tfile, "/tmp/orchlocale%ld", getpid());
26
fb9b1fd08e73 683 orchestrator should be libspmi* clean
Jan Damborsky <jan.damborsky@sun.com>
parents: 0
diff changeset
  1831
	(void) snprintf(target, sizeof (target), "%s%s", INSTALLED_ROOT_DIR,
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1832
	    INIT_FILE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1833
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1834
	if ((tfp = fopen(tfile, "w")) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1835
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1836
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1837
	if ((fp = fopen(target, "r")) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1838
		while (fgets(line, BUFSIZ, fp) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1839
			if (strncmp("LANG=", line, 5) == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1840
				continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1841
			if (strncmp("LC_", line, 3) == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1842
				continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1843
			if (fputs(line, tfp) == EOF) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1844
				(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1845
				(void) fclose(tfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1846
				return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1847
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1848
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1849
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1850
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1851
	update_init(tfp, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1852
	(void) fclose(tfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1853
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1854
	if ((fp = fopen(target, "w")) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1855
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1856
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1857
	if ((tfp = fopen(tfile, "r")) == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1858
		(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1859
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1860
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1861
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1862
	while (fgets(line, BUFSIZ, tfp) != NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1863
		if (fputs(line, fp) == EOF)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1864
			break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1865
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1866
	(void) fclose(tfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1867
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1868
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1869
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1870
update_env(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1871
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1872
	char path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1873
	char lc_collate[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1874
	char lc_ctype[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1875
	char lc_messages[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1876
	char lc_monetary[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1877
	char lc_numeric[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1878
	char lc_time[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1879
	char lang[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1880
	FILE *mfp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1881
	int rc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1882
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1883
	(void) snprintf(path, sizeof (path), "%s/%s/locale_map",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1884
	    NLS_PATH, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1885
	if ((mfp = fopen(path, "r")) == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1886
		set_lang(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1887
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1888
		rc = read_locale_file(mfp, lang, lc_collate, lc_ctype,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1889
		    lc_messages, lc_monetary, lc_numeric, lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1890
		(void) fclose(mfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1891
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1892
		if (rc == 1) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1893
			set_lang(lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1894
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1895
			set_lc(lc_collate, lc_ctype, lc_messages, lc_monetary,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1896
			    lc_numeric, lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1897
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1898
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1899
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1900
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1901
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1902
update_init(FILE *fp, char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1903
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1904
	char path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1905
	char lc_collate[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1906
	char lc_ctype[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1907
	char lc_messages[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1908
	char lc_monetary[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1909
	char lc_numeric[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1910
	char lc_time[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1911
	char lang[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1912
	FILE *mfp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1913
	int rc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1914
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1915
	(void) snprintf(path, sizeof (path), "%s/%s/locale_map",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1916
	    NLS_PATH, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1917
	if ((mfp = fopen(path, "r")) == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1918
		if (strcmp(locale, "C") != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1919
			(void) fprintf(fp, "LANG=%s\n", locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1920
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1921
		set_lang(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1922
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1923
		rc = read_locale_file(mfp, lang, lc_collate, lc_ctype,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1924
		    lc_messages, lc_monetary, lc_numeric, lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1925
		(void) fclose(mfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1926
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1927
		if (rc == 1) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1928
			(void) fprintf(fp, "LANG=%s\n", lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1929
			set_lang(lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1930
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1931
			(void) fprintf(fp, "LC_COLLATE=%s\n", lc_collate);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1932
			(void) fprintf(fp, "LC_CTYPE=%s\n", lc_ctype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1933
			(void) fprintf(fp, "LC_MESSAGES=%s\n", lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1934
			(void) fprintf(fp, "LC_MONETARY=%s\n", lc_monetary);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1935
			(void) fprintf(fp, "LC_NUMERIC=%s\n", lc_numeric);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1936
			(void) fprintf(fp, "LC_TIME=%s\n", lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1937
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1938
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1939
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1940
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1941
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1942
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1943
translate_lang_names(lang_info_t **list)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1944
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1945
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1946
	char		trans[512];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1947
	lang_info_t	*langp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1948
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1949
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1950
	 * Set locale to en_US.UTF-8. It doesn't really matter
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1951
	 * what it is set to expect it cannot be C. dgettext does
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1952
	 * not pick up the translated strings if the current locale
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1953
	 * is C.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1954
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1955
	set_lang("en_US.UTF-8");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1956
	for (langp = *list; langp != NULL; langp = langp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1957
		if (langp->lang_name != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1958
			(void) strcpy(trans,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1959
			    dgettext("SUNW_INSTALL_LANG",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1960
			    langp->lang_name));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1961
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1962
			 * Free original lang name.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1963
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1964
			free(langp->lang_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1965
			langp->lang_name = strdup(trans);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1966
			if (langp->lang_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1967
				/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1968
				 * Log a message. leave the other
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1969
				 * lang names untranslated.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1970
				 * Otherwise, would have to free
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1971
				 * full list and provide
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1972
				 * the user with nothing.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1973
				 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1974
				om_debug_print(OM_DBGLVL_ERR,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1975
				    "Couldn't allocate memory"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1976
				    " for translated lang name\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1977
				return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1978
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1979
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1980
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1981
}