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