usr/src/lib/liborchestrator/locale.c
author Alasdair Lumsden <al@everycity.co.uk>
Sat, 10 Sep 2011 02:57:46 +0000
branchoi_151a
changeset 1432 cedb79a30277
parent 1431 be5c727ec6be
permissions -rw-r--r--
1492 oi_151a installer has territories in reverse order
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
1432
cedb79a30277 1492 oi_151a installer has territories in reverse order
Alasdair Lumsden <al@everycity.co.uk>
parents: 1431
diff changeset
   861
	tmp = langp->locale_info;
cedb79a30277 1492 oi_151a installer has territories in reverse order
Alasdair Lumsden <al@everycity.co.uk>
parents: 1431
diff changeset
   862
	while (tmp->next != NULL) {
cedb79a30277 1492 oi_151a installer has territories in reverse order
Alasdair Lumsden <al@everycity.co.uk>
parents: 1431
diff changeset
   863
		tmp = tmp->next;
cedb79a30277 1492 oi_151a installer has territories in reverse order
Alasdair Lumsden <al@everycity.co.uk>
parents: 1431
diff changeset
   864
	}
cedb79a30277 1492 oi_151a installer has territories in reverse order
Alasdair Lumsden <al@everycity.co.uk>
parents: 1431
diff changeset
   865
	tmp->next = locp;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   866
	langp->n_locales++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   867
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   868
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   869
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   870
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
   871
    lang_info_t **return_list, int *ll_total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   872
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   873
	char 		path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   874
	char		trans[MAX_LOCALE + 1];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   875
	char 		linebuf[128];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   876
	FILE		*fp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   877
	char		*c, *c2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   878
	int		i, ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   879
	lang_info_t	*lp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   880
	locale_info_t	*locp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   881
	int		num_entries = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   882
	boolean_t	is_default = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   883
	char		*start = NULL, *t = NULL, *lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   884
	char		*region = NULL, *encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   885
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   886
	*return_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   887
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   888
	if (install_list == NULL || *install_list == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   889
		om_set_error(OM_INVALID_LANG_LIST);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   890
		return;
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
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   893
	(void) memset(trans, 0, sizeof (trans));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   894
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   895
	 * For the installer application supported languages we only
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   896
	 * 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
   897
	 * locale support for UTF-8 in the miniroot.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   898
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   899
	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
   900
		start = install_list[i];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   901
		lang = 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 == COUNTRY_SEP)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   904
			region = 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 (start && *t == CODESET_SEP)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   907
			encoding = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   908
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   909
		if (encoding != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   910
			if (strcmp(encoding, UTF) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   911
				free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   912
				free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   913
				free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   914
				encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   915
				region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   916
				lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   917
				continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   918
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   919
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   920
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   921
		if (strncmp(lang, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   922
			if (region != NULL && strcmp(region, "TW") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   923
				om_errno = handle_chinese_language(region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   924
				    &lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   925
				if (om_errno != OM_SUCCESS) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   926
					goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   927
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   928
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   929
		} 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
   930
		    strcmp(lang, "POSIX") == 0 ||
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
   931
		    strcmp(lang, "C/POSIX") == 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   932
			free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   933
			lang = strdup("en");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   934
			is_default = B_TRUE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   935
			if (lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   936
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   937
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   938
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   939
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   940
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   941
		if ((lp = get_lang_entry(lang, *return_list)) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   942
			continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   943
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   944
			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
   945
			    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
   946
			if (!ret)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   947
				num_entries++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   948
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   949
		free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   950
		free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   951
		free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   952
		lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   953
		region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   954
		encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   955
		is_default = B_FALSE;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   956
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   957
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   958
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   959
	 * For the install application language specifications, which
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   960
	 * 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
   961
	 * 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
   962
	 * translation. The lcttab file in /usr/lib/locale provides
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   963
	 * the correct mapping.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   964
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   965
	lp = *return_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   966
	(void) snprintf(path, sizeof (path), "%s/lcttab", nlspath);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   967
	if ((fp = fopen(path, "r"))) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   968
		for (i = 0; lp != NULL; lp = lp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   969
			locp = lp->locale_info;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   970
			rewind(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   971
			while (fgets(linebuf, 128, fp)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   972
				if (strlen(linebuf) == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   973
				    linebuf[0] == '#') {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   974
					continue;
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
				/* Search for whitespace */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   977
				for (c = linebuf; *c && !isspace(*c); c++)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   978
					;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   979
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   980
				if (*c != '\0') {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   981
					/* End of line - invalid input */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   982
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   983
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   984
				*c = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   985
				if (strcmp(linebuf, locp->locale_name) != 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   986
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   987
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   988
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   989
				/* Found the old name - get the new version */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   990
				for (c++; *c && isspace(*c); c++)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   991
					;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   992
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   993
				if (!*c) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   994
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   995
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   996
				for (c2 = c; *c2 && !isspace(*c2); c2++)
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
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
   999
				*c2 = '\0';
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
				 * We are not interested in UTF-8
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1002
				 * codesets for now.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1003
				 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1004
				if (strstr(c, UTF) != NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1005
					continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1006
				(void) strcpy(trans, c);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1007
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1008
			} /* end while */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1009
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1010
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1011
			 * 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
  1012
			 * If not, copy the original locale data in and
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1013
			 * search for locale_map.
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
			if (trans[0] == '\0')
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1016
				(void) strcpy(trans, locp->locale_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1017
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1018
			locp = (locale_info_t *)malloc(sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1019
			if (locp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1020
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1021
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1022
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1023
			(void) memset(locp, 0, sizeof (locale_info_t));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1024
			locp->locale_name = strdup(trans);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1025
			if (locp->locale_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1026
				om_free_locale_info(locp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1027
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1028
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1029
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1030
			(void) memset(trans, 0, sizeof (trans));
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
			 * free the original lang_info_t->locale_info
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1033
			 * data.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1034
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1035
			om_free_locale_info(lp->locale_info);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1036
			lp->locale_info = locp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1037
			lp->n_locales++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1038
		} /* end for */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1039
	} /* end if */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1040
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
	 * Now, translate language names, in this order, in to native
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1043
	 * locale based on current locale data associated with this language.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1044
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1045
	translate_lang_names(return_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1046
	*ll_total = num_entries;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1047
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1048
	return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1049
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1050
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1051
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1052
	om_free_lang_info(*return_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1053
	*return_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1054
	*ll_total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1055
	free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1056
	free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1057
	free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1058
	free(start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1059
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1060
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1061
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1062
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
  1063
    int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1064
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1065
	int		i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1066
	int		ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1067
	int		num_langs = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1068
	char		*lang = NULL, *encoding = NULL, *region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1069
	char		*locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1070
	lang_info_t	*lp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1071
	char		*orig, *start = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1072
	char		*t = NULL;
1431
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1073
	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
  1074
	boolean_t	locale_in_installer_lang = B_FALSE;
0
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
	*total = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1077
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1078
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1079
	 * 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
  1080
	 * the locale directory. Take this sorted list,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1081
	 * parse appropriately, and insert locale data for each language
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1082
	 * in to the return_list.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1083
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1084
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1085
	for (i = 0; i < lang_total; i++)  {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1086
		orig = start = list[i];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1087
		if (!is_valid_locale(list[i]))
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1088
			continue;
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
		t = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1091
		lang = get_locale_component(&t, &start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1092
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1093
		/*
107
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1094
		 * 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
  1095
		 * The lang value is the language part of
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1096
		 * the lang/locale pair. What was in the original list
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1097
		 * is the locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1098
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1099
		if (start && *t == COUNTRY_SEP) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1100
			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
  1101
		} else {
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1102
			free(lang);
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1103
			lang = NULL;
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1104
			continue;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1105
		}
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
		if (start && *t == CODESET_SEP) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1108
			encoding = get_locale_component(&t, &start);
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
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1111
		if (strncmp(lang, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1112
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1113
			 * If there is a region with the Chinese lang,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1114
			 * 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
  1115
			 * Chinese specifications for language include
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1116
			 * the region, such as zh_HK and zh_TW.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1117
			 * If no region is found, then lang is simply lang
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1118
			 * from above.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1119
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1120
			if (region) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1121
				om_errno = handle_chinese_language(region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1122
				    &lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1123
				if (om_errno != OM_SUCCESS) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1124
					goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1125
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1126
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1127
				/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1128
				 * We need to account for Simplified Chinese,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1129
				 * EUC in the locale list. Its locale name
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1130
				 * does not include a region.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1131
				 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1132
				locale = strdup(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1133
				if (locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1134
					om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1135
					goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1136
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1137
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1138
		} 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
  1139
		    strcmp(lang, "POSIX") == 0 ||
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1140
		    strcmp(lang, "C/POSIX") == 0) {
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1141
			free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1142
			lang = strdup("en");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1143
			if (lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1144
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1145
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1146
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1147
			locale = strdup(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1148
			if (locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1149
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1150
				goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1151
			}
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
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1154
		 * Locale is a combination of  lang, country and codeset.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1155
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1156
		if (encoding != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1157
			locale = strdup(orig);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1158
			if (locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1159
				om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1160
				goto error;
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
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1163
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 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
  1166
		 * anything we are interested in, so skip.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1167
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1168
		if (locale != NULL)  {
1431
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1169
			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
  1170
			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
  1171
			
107
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1172
			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
  1173
			    "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
  1174
			    lang == NULL ? "#" : lang,
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1175
			    region == NULL ? "#" : region);
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1176
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1177
			if ((lp = get_lang_entry(lang, *return_list)) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1178
				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
  1179
				    locale_app_locale);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1180
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1181
				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
  1182
				    return_list, locale_app_locale, locale_in_installer_lang);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1183
				if (!ret) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1184
					num_langs++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1185
					om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1186
					    "num_langs = %d\n", num_langs);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1187
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1188
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1189
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1190
		free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1191
		free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1192
		free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1193
		free(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1194
		region = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1195
		encoding = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1196
		lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1197
		locale = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1198
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1199
	*total = num_langs;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1200
	return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1201
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1202
	om_free_lang_info(*return_list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1203
	*return_list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1204
	free(region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1205
	free(encoding);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1206
	free(lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1207
	free(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1208
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1209
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1210
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1211
 * build_language_list:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1212
 *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1213
 *	The idea is to scan the directories under "path" and
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1214
 *	build the language list, char ** list, associated with
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1215
 *	the "path".
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
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1218
build_language_list(char *path, char **list, int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1219
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1220
	DIR		*locale_dir;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1221
	struct dirent	*locale;		/* entries in locale_dir */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1222
	int		i = 0;
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
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1225
	 * Read in language data from the locale directory.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1226
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1227
	(void) memset(list, 0, sizeof (*list));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1228
	locale_dir = opendir(path);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1229
	if (locale_dir == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1230
		if (errno == EACCES) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1231
			om_set_error(OM_PERMS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1232
		} else if (errno != EMFILE && errno != ENFILE) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1233
			om_set_error(OM_NO_LOCALE_DIR);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1234
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1235
			om_set_error(OM_TOO_MANY_FD);
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
		goto error;
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
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1240
	while (locale = readdir(locale_dir)) {
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
		 * Exclude current and parent directory. Make sure
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1243
		 * we are not over our buffer limit.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1244
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1245
		if (strcmp(locale->d_name, ".") == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1246
		    strcmp(locale->d_name, "..") == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1247
			continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1248
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1249
		list[i] = strdup(locale->d_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1250
		if (list[i] == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1251
			om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1252
			goto error;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1253
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1254
		i++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1255
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1256
	*total = i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1257
	(void) closedir(locale_dir);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1258
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1259
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1260
error:
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1261
	om_free_lang_names(list);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1262
	*list = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1263
	(void) closedir(locale_dir);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1264
	return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1265
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1266
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1267
 * 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
  1268
 * that should be used for localization.
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
 * Input: File *fp  File pointer to locale_map file
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1271
 * Output: Each type of locale category value is returned.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1272
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1273
int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1274
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
  1275
	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
  1276
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1277
	int status = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1278
	char line[BUFSIZ];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1279
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1280
	(void) strcpy(lc_collate, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1281
	(void) strcpy(lc_ctype, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1282
	(void) strcpy(lc_messages, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1283
	(void) strcpy(lc_monetary, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1284
	(void) strcpy(lc_numeric, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1285
	(void) strcpy(lc_time, "C");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1286
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1287
	while (fgets(line, BUFSIZ, fp) != NULL) {
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
		 * Remove the trailing newline, and strip any comments that
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1290
		 * may appear on the read 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
		line[strlen(line) - 1] = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1293
		(void) strip_comment(line);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1294
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1295
		if (strncmp(STR_LANG, line, LEN_LANG) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1296
			(void) strcpy(lang, line + LEN_LANG);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1297
			status = 1;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1298
		} 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
  1299
			(void) strcpy(lc_collate, line + LEN_LC_COLLATE);
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_CTYPE, line, LEN_LC_CTYPE) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1302
			(void) strcpy(lc_ctype, line + LEN_LC_CTYPE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1303
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1304
		} else if (strncmp(STR_LC_MESSAGES, line, LEN_LC_MESSAGES)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1305
		    == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1306
			(void) strcpy(lc_messages, line + LEN_LC_MESSAGES);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1307
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1308
		} else if (strncmp(STR_LC_MONETARY, line, LEN_LC_MONETARY)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1309
		    == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1310
			(void) strcpy(lc_monetary, line + LEN_LC_MONETARY);
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_NUMERIC, line, LEN_LC_NUMERIC) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1313
			(void) strcpy(lc_numeric, line + LEN_LC_NUMERIC);
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
		} 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
  1316
			(void) strcpy(lc_time, line + LEN_LC_TIME);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1317
			status = 2;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1318
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1319
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1320
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1321
	if (status == 1) {
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
		 * 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
  1324
		 * fields with the value put in LANG
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1325
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1326
		(void) strcpy(lc_collate, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1327
		(void) strcpy(lc_ctype, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1328
		(void) strcpy(lc_messages, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1329
		(void) strcpy(lc_monetary, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1330
		(void) strcpy(lc_numeric, lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1331
		(void) strcpy(lc_time, lang);
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
	return (status);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1334
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1335
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1336
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1337
 * Function:	strip_comment
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1338
 * 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
  1339
 *		text, the comment marker, and the whitespace (if any) preceding
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1340
 *		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
  1341
 * Scope:	private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1342
 * Arguments:	buf	- [RO, *RW] (char *)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1343
 *			  The buffer from which the comment is to be stripped.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1344
 * Returns:	char *	- buf, the pointer passed in
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
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1347
strip_comment(char *buf)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1348
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1349
	char *comchr;
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
	if (buf == NULL || (comchr = strchr(buf, '#')) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1352
		return (buf);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1353
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1354
	for (; comchr != buf && isspace(*(comchr - 1)); comchr--)
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
	*comchr = '\0';
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1357
	return (buf);
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 void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1360
set_lang(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1361
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1362
	static char	tmpstr[MAX_LOCALE + 6];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1363
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1364
	(void) setlocale(LC_ALL, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1365
	(void) snprintf(tmpstr, sizeof (tmpstr), "LANG=%s", locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1366
	(void) putenv(tmpstr);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1367
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1368
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1369
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1370
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
  1371
	char *lc_numeric, char *lc_time)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1372
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1373
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1374
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1375
	 * 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
  1376
	 * 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
  1377
	 * a result.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1378
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1379
	static char	tmpstr1[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1380
	static char	tmpstr2[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1381
	static char	tmpstr3[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1382
	static char	tmpstr4[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1383
	static char	tmpstr5[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1384
	static char	tmpstr6[MAX_LOCALE + 15];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1385
	char		*loc = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1386
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1387
	loc = setlocale(LC_COLLATE, lc_collate);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1388
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1389
		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
  1390
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1391
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1392
		    "Could not set lc_collate value\n");
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
	(void) snprintf(tmpstr1, sizeof (tmpstr1), "LC_COLLATE=%s", lc_collate);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1395
	(void) putenv(tmpstr1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1396
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1397
	loc = setlocale(LC_CTYPE, lc_ctype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1398
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1399
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1400
		    "lc_ctype set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1401
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1402
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1403
		    "Could not set lc_ctype value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1404
	(void) snprintf(tmpstr2, sizeof (tmpstr2), "LC_CTYPE=%s", lc_ctype);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1405
	(void) putenv(tmpstr2);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1406
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1407
	loc = setlocale(LC_MESSAGES, lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1408
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1409
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1410
		    "lc_messages set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1411
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1412
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1413
		    "Could not set lc_messages value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1414
	(void) snprintf(tmpstr3, sizeof (tmpstr3),
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1415
	    "LC_MESSAGES=%s", lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1416
	(void) putenv(tmpstr3);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1417
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1418
	loc =  setlocale(LC_MONETARY, lc_monetary);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1419
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1420
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1421
		    "lc_monetary set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1422
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1423
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1424
		    "Could not set lc_monetary value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1425
	(void) snprintf(tmpstr4, sizeof (tmpstr4),
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1426
	    "LC_MONETARY=%s", lc_monetary);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1427
	(void) putenv(tmpstr4);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1428
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1429
	loc = setlocale(LC_NUMERIC, lc_numeric);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1430
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1431
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1432
		    "lc_numeric set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1433
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1434
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1435
		    "Could not set lc_numeric value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1436
	(void) snprintf(tmpstr5, sizeof (tmpstr5), "LC_NUMERIC=%s", lc_numeric);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1437
	(void) putenv(tmpstr5);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1438
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1439
	loc = setlocale(LC_TIME, lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1440
	if (loc)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1441
		om_debug_print(OM_DBGLVL_INFO,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1442
		    "lc_time set to %s\n", loc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1443
	else
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1444
		om_debug_print(OM_DBGLVL_WARN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1445
		    "Could not set lc_time value\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1446
	(void) snprintf(tmpstr6, sizeof (tmpstr6), "LC_TIME=%s", lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1447
	(void) putenv(tmpstr6);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1448
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1449
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1450
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1451
 * Name:	get_locale_description
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1452
 * 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
  1453
 *		a pointer to a buffer containing the contents of that
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1454
 *		file.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1455
 * Scope:	private
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1456
 * Arguments:	locale	- [RO, *RO] (char *)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1457
 *			  The locale whose locale_description is to be read
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1458
 * Returns:	char *	- The first line of the locale_description
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
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1461
get_locale_description(char *lang, char *region)
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
	char	*user_desc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1464
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1465
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1466
	 * Chinese and Korean are handled differently. This is due to
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1467
	 * the locale description for each of these being different than
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1468
	 * the standard.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1469
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1470
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1471
	if (region == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1472
		if (strcmp(lang, dgettext(TEXT_DOMAIN, TRADITIONAL_CHINESE))
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1473
		    == 0 ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1474
		    strcmp(lang, dgettext(TEXT_DOMAIN, SIMPLIFIED_CHINESE))
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1475
		    == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1476
			region = strdup("zh");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1477
		} else if (strcmp(lang, dgettext(TEXT_DOMAIN, "Korean")) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1478
			region = strdup("ko");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1479
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1480
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1481
	user_desc = translate_description(lang, region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1482
	return (user_desc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1483
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1484
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1485
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1486
translate_description(char *lang, char *region)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1487
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1488
	char 		*trans_desc = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1489
	int		len = 0, i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1490
	int		szcountry = sizeof (orchestrator_country_list) /
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1491
	    sizeof (orchestrator_country_list[0]);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1492
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1493
	char		*tmp_ctrystring = 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
	if (lang == NULL || region == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1496
		return (NULL);
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
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1499
	for (i = 0; i < szcountry; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1500
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1501
		 * Translate the country code for this locale.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1502
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1503
		if (strncasecmp(region,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1504
		    orchestrator_country_list[i].country_code, 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1505
			tmp_ctrystring =
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1506
			    dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1507
			    orchestrator_country_list[i].country_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1508
			break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1509
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1510
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1511
	if (tmp_ctrystring) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1512
		len = strlen(lang) + strlen(tmp_ctrystring) + 4;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1513
		trans_desc = (char *)malloc(len);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1514
		if (trans_desc == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1515
			return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1516
		(void) snprintf(trans_desc, len, "%s (%s)",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1517
		    lang, tmp_ctrystring);
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
	return (trans_desc);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1520
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1521
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1522
static char **
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1523
get_actual_languages(char **list, int *total)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1524
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1525
	char	**lp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1526
	char	**lang_listp = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1527
	size_t	sz;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1528
	int	ret = 0;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1529
	int	i, j, k = 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
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1532
	*total = 0;
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
	if (list == NULL || *list == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1535
		return (NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1536
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1537
	sz = sizeof (orchestrator_lang_list)/sizeof (orchestrator_lang_list[0]);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1538
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1539
	lp = list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1540
	for (i = 0; lp[i] != '\0'; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1541
		for (j = 0; j < sz; j++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1542
			if (strncmp(lp[i],
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1543
			    (char *)orchestrator_lang_list[j].lang_code,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1544
			    2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1545
				ret = add_lang_to_list(&lang_listp,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1546
				    lp[i], &k, j);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1547
				if (ret) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1548
					om_free_lang_names(lang_listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1549
					return (NULL);
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
				break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1552
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1553
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1554
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1555
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1556
	 * No lang translation found. Return existing list.
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
	if (j == sz) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1559
		return (lang_listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1560
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1561
	*total = k;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1562
	om_set_error(OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1563
	return (lang_listp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1564
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1565
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1566
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1567
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
  1568
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1569
	int	i;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1570
	char	**lpp = *list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1571
	char	**tmp_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1572
	char	*tmp = NULL;
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1573
	char	*sub = NULL;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1574
	char	*code;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1575
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1576
	tmp_list = *list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1577
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1578
	sub = substitute_language(locale, &code);
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1579
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1580
	if (sub != NULL) {
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1581
		tmp = strdup(sub);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1582
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1583
		tmp = strdup(dgettext(TEXT_DOMAIN,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1584
		    orchestrator_lang_list[j].lang_name));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1585
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1586
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1587
	if (tmp == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1588
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1589
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1590
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1591
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1592
	if (tmp_list != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1593
		/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1594
		 * Search for existence of this language in the list already
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1595
		 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1596
		for (i = 0; tmp_list[i] != NULL && tmp_list[i] != '\0' &&
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1597
		    i < *k; i++) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1598
			if (strcmp(tmp, tmp_list[i]) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1599
				free(tmp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1600
				return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1601
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1602
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1603
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1604
	tmp_list = (char **)realloc(*list, ((*k) + 1) * sizeof (char *));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1605
	if (tmp_list == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1606
		free(tmp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1607
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1608
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1609
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1610
	lpp = *list = tmp_list;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1611
	lpp[*k] = tmp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1612
	(*k)++;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1613
	return (OM_SUCCESS);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1614
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1615
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1616
static boolean_t
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1617
is_valid_locale(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1618
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1619
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1620
	char	path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1621
	struct	stat stat_buf;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1622
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1623
	if (locale == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1624
		return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1625
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1626
	if (strstr(locale, UTF) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1627
		return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1628
1414
5cff819a623b imported patch oi-illumos-locale-support
Alasdair Lumsden <al@everycity.co.uk>
parents: 107
diff changeset
  1629
	(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
  1630
	    NLS_PATH, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1631
	if ((stat(path, &stat_buf) == 0) &&
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1632
	    ((stat_buf.st_mode & S_IFMT) == S_IFREG)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1633
		return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1634
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1635
	return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1636
}
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1637
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1638
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1639
substitute_C_POSIX_language(char **code)
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
	char	*lang = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1642
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1643
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1644
	 * 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
  1645
	 * to 'en'.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1646
	 */
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1647
	lang = dgettext(TEXT_DOMAIN, "English");
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1648
	*code = "en";
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1649
	return (lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1650
}
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
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1653
substitute_chinese_language(char *locale, char **code)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1654
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1655
	int 		i;
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1656
	int		len;
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1657
	char		*sub = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1658
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1659
	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
  1660
		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
  1661
		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
  1662
		    (locale[len] == '\0' || locale[len] == '.')) {
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1663
			sub =
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1664
			    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
  1665
			*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
  1666
			return (sub);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1667
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1668
	}
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1669
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1670
	om_set_error(OM_INVALID_LOCALE);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1671
	return (sub);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1672
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1673
1416
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1674
static char *
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1675
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
  1676
{
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1677
	char *lang = NULL;
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1678
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1679
	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
  1680
		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
  1681
		if (lang == NULL)
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1682
			goto error;
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1683
	} 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
  1684
		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
  1685
	}
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
error:
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1688
	return (lang);
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1689
}
2c9d399a58c0 imported patch oi-issue-1094-liborchestrator-zh-locale
Alasdair Lumsden <al@everycity.co.uk>
parents: 1414
diff changeset
  1690
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1691
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1692
sort_lang_list(char **unsorted_list, int total)
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
	qsort((char **)unsorted_list, total, sizeof (char *), list_cmp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1695
}
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
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1698
handle_chinese_language(char *region, char **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
	int	len;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1701
	char	*chinese_lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1702
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
	len = strlen(*lang) + strlen(region) + 3;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1705
	chinese_lang = (char *)malloc(len);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1706
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1707
	 * If we cannot allocate new language data, return error, but
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1708
	 * don't modify language value. Allow caller to determine what
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1709
	 * to do.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1710
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1711
	if (chinese_lang == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1712
		om_set_error(OM_NO_SPACE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1713
		return (OM_FAILURE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1714
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1715
	(void) snprintf(chinese_lang, len, "%s%s%s", *lang, "_", region);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1716
	free(*lang);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1717
	*lang = chinese_lang;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1718
	return (OM_SUCCESS);
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
static int
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1721
list_cmp(const void *p1, const void *p2)
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
	return (strcmp(*(char **)p1, *(char **)p2));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1724
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1725
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1726
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1727
 * 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
  1728
 * 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
  1729
 * 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
  1730
 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1731
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1732
get_locale_component(char **t, char **start)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1733
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1734
	char	*result = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1735
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1736
	end_of_comp(t, start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1737
	result = copy_up_to(*start, *t);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1738
	*start = (**t != '\0') ? *t + 1: NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1739
	return (result);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1740
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1741
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1742
/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1743
 * 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
  1744
 * 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
  1745
 * component. Or NULL if not found.
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
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1748
end_of_comp(char **t, char **start)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1749
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1750
	(((*t) = strchr((*start), COUNTRY_SEP)) != NULL) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1751
	    (((*t) = strchr((*start), CODESET_SEP)) != NULL) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1752
	/*LINTED*/
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1753
	    (((*t) = strchr((*start), '\0')) != NULL);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1754
}
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
static char *
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1757
copy_up_to(char *start, char *end)
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
	 * XXX look at this.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1761
	 */
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
	ptrdiff_t	diff;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1764
	char		*sub = NULL;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1765
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1766
	if (end == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1767
		diff = strlen(start);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1768
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1769
		/*LINTED*/
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1770
		diff = end - start;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1771
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1772
	sub = (char *)malloc(diff + 1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1773
	(void) memset(sub, 0, diff + 1);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1774
	(void) strlcpy(sub, start, (diff + 1));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1775
	return (sub);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1776
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1777
1431
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1778
/* 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
  1779
 * 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
  1780
 */
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1781
static boolean_t
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1782
is_locale_in_installer_lang(char *locale_name)
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
	if (app_locale == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1785
		app_locale = strdup(setlocale(LC_MESSAGES, NULL));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1786
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1787
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1788
	if (app_locale != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1789
		if (strcmp(locale_name, app_locale) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1790
			/* locale name is same */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1791
			return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1792
		} else if (strncmp(locale_name, app_locale, 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1793
			/* language part is same */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1794
			if ((strncmp(locale_name, "zh_TW", 5) == 0) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1795
			    (strncmp(locale_name, "zh_HK", 5) == 0)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1796
				/* traditional Chinese */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1797
				if ((strncmp(app_locale, "zh_TW", 5) == 0) ||
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1798
				    (strncmp(app_locale, "zh_HK", 5) == 0)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1799
					return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1800
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1801
			} else if (strncmp(locale_name, "zh", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1802
				/* simplified Chinese */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1803
				if ((strncmp(app_locale, "zh_TW", 5) != 0) &&
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1804
				    (strncmp(app_locale, "zh_HK", 5) != 0)) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1805
					return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1806
				}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1807
			} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1808
				/* others */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1809
				return (B_TRUE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1810
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1811
		} else if (strncmp(locale_name, "en", 2) == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1812
			/* English */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1813
			if (strcmp(app_locale, "C") == 0) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1814
				return (B_TRUE);
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
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1817
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1818
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1819
	return (B_FALSE);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1820
}
1431
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1821
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1822
/*
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1823
 * 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
  1824
 * 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
  1825
 * 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
  1826
 */
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1827
static boolean_t
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1828
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
  1829
{
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1830
	if (app_locale == NULL) {
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1831
		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
  1832
	}
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1833
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1834
	if (app_locale != NULL) {
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1835
		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
  1836
			/* locale name is same */
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1837
			return (B_TRUE);
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1838
		} 
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
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1841
	return (B_FALSE);
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1842
}
be5c727ec6be 1491 oi_151a installer picks the wrong default Territory
Alasdair Lumsden <al@everycity.co.uk>
parents: 1416
diff changeset
  1843
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1844
void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1845
om_save_locale(char *locale, boolean_t install_only)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1846
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1847
	FILE 	*fp, *tfp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1848
	char	line[BUFSIZ];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1849
	char	tfile[80];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1850
	char	target[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1851
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1852
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1853
	 * 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
  1854
	 * 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
  1855
	 * will happen later.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1856
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1857
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1858
	if (install_only) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1859
		update_env(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1860
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1861
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1862
	(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
  1863
	(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
  1864
	    INIT_FILE);
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 ((tfp = fopen(tfile, "w")) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1867
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1868
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1869
	if ((fp = fopen(target, "r")) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1870
		while (fgets(line, BUFSIZ, fp) != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1871
			if (strncmp("LANG=", line, 5) == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1872
				continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1873
			if (strncmp("LC_", line, 3) == 0)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1874
				continue;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1875
			if (fputs(line, tfp) == EOF) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1876
				(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1877
				(void) fclose(tfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1878
				return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1879
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1880
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1881
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1882
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1883
	update_init(tfp, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1884
	(void) fclose(tfp);
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 ((fp = fopen(target, "w")) == NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1887
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1888
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1889
	if ((tfp = fopen(tfile, "r")) == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1890
		(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1891
		return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1892
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1893
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1894
	while (fgets(line, BUFSIZ, tfp) != NULL)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1895
		if (fputs(line, fp) == EOF)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1896
			break;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1897
	(void) fclose(fp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1898
	(void) fclose(tfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1899
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1900
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1901
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1902
update_env(char *locale)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1903
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1904
	char path[MAXPATHLEN];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1905
	char lc_collate[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1906
	char lc_ctype[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1907
	char lc_messages[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1908
	char lc_monetary[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1909
	char lc_numeric[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1910
	char lc_time[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1911
	char lang[MAX_LOCALE];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1912
	FILE *mfp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1913
	int rc;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1914
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1915
	(void) snprintf(path, sizeof (path), "%s/%s/locale_map",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1916
	    NLS_PATH, locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1917
	if ((mfp = fopen(path, "r")) == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1918
		set_lang(locale);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1919
	} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1920
		rc = read_locale_file(mfp, lang, lc_collate, lc_ctype,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1921
		    lc_messages, lc_monetary, lc_numeric, lc_time);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1922
		(void) fclose(mfp);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1923
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1924
		if (rc == 1) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1925
			set_lang(lc_messages);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1926
		} else {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1927
			set_lc(lc_collate, lc_ctype, lc_messages, lc_monetary,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1928
			    lc_numeric, lc_time);
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
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1931
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1932
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1933
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1934
update_init(FILE *fp, char *locale)
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
	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
  1937
		(void) fprintf(fp, "LANG=%s\n", locale);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1938
	}
107
73ae3dba821c 1090 Setting of default locale does not really work
Jan Damborsky <Jan.Damborsky@Sun.COM>
parents: 26
diff changeset
  1939
	set_lang(locale);
0
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1940
}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1941
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1942
static void
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1943
translate_lang_names(lang_info_t **list)
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1944
{
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1945
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1946
	char		trans[512];
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1947
	lang_info_t	*langp;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1948
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1949
	/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1950
	 * Set locale to en_US.UTF-8. It doesn't really matter
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1951
	 * what it is set to expect it cannot be C. dgettext does
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1952
	 * not pick up the translated strings if the current locale
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1953
	 * is C.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1954
	 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1955
	set_lang("en_US.UTF-8");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1956
	for (langp = *list; langp != NULL; langp = langp->next) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1957
		if (langp->lang_name != NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1958
			(void) strcpy(trans,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1959
			    dgettext("SUNW_INSTALL_LANG",
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1960
			    langp->lang_name));
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1961
			/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1962
			 * Free original lang name.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1963
			 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1964
			free(langp->lang_name);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1965
			langp->lang_name = strdup(trans);
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1966
			if (langp->lang_name == NULL) {
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1967
				/*
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1968
				 * Log a message. leave the other
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1969
				 * lang names untranslated.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1970
				 * Otherwise, would have to free
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1971
				 * full list and provide
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1972
				 * the user with nothing.
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1973
				 */
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1974
				om_debug_print(OM_DBGLVL_ERR,
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1975
				    "Couldn't allocate memory"
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1976
				    " for translated lang name\n");
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1977
				return;
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1978
			}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1979
		}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1980
	}
87f703f8362e OpenSolaris files for Slim Install
"mw145384 <moriah.waterland@sun.com>"
parents:
diff changeset
  1981
}