xref: /titanic_50/usr/src/cmd/ssh/include/g11n.h (revision 1e1ddd6cc98ab5af8293f7ebd132be62900730fd)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
22  * Use is subject to license terms.
23  */
24 
25 #ifndef	_G11N_H
26 #define	_G11N_H
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 #include "includes.h"
36 #include <sys/types.h>
37 
38 /*
39  * Functions for language tag negotiation
40  */
41 
42 /* boolean */
43 uint_t g11n_langtag_is_default(char *langtag);
44 
45 /* return 0 if not, 1 if yes, 2 if the country is matched too */
46 uint_t g11n_langtag_matches_locale(char *langtag, char *locale);
47 
48 /* get current locale */
49 char *g11n_getlocale();
50 
51 /* get current locale */
52 void g11n_setlocale(int category, const char *locale);
53 
54 /* get list of locales - returns pointer to array of pointers to char */
55 char **g11n_getlocales();
56 
57 /* get list of langs spoken by the user, from SSH_LANGS env var */
58 char *g11n_getlangs();
59 
60 /* make a comma-separated list of language tags from list of locales */
61 char *g11n_locales2langs(char **locale_set);
62 
63 int g11n_langtag_match(char *langtag1, char *langtag2);
64 
65 /* intersect comma-separated lists of IETF language tags */
66 char *g11n_langtag_set_intersect(char *set1, char *set2);
67 
68 char *g11n_clnt_langtag_negotiate(char *clnt_langtags, char *srvr_langtags);
69 
70 char **g11n_langtag_set_locale_set_intersect(char *langtag_set,
71     char **locale_set);
72 
73 char *g11n_srvr_locale_negotiate(char *clnt_langtags, char **srvr_locales);
74 
75 
76 /*
77  * Functions for validating ASCII and UTF-8 strings
78  *
79  * The error_str parameter is an optional pointer to a char variable
80  * where to store a string suitable for use with error() or fatal() or
81  * friends.
82  *
83  * The input string is expected to be a null-terminated string if the
84  * len parameter is given a value of 0.
85  *
86  * The return value is 0 if success, EILSEQ or EINVAL.
87  *
88  */
89 
90 uint_t g11n_validate_ascii(const char *str, uint_t len, uchar_t **error_str);
91 
92 uint_t g11n_validate_utf8(const uchar_t *str, uint_t len, uchar_t **error_str);
93 
94 /*
95  * Functions for converting to ASCII or UTF-8 from the local codeset
96  * Functions for converting from ASCII or UTF-8 to the local codeset
97  *
98  * The error_str parameter is an optional pointer to a char variable
99  * where to store a string suitable for use with error() or fatal() or
100  * friends.
101  *
102  * The err parameter is an optional pointer to an integer where 0
103  * (success) or EILSEQ or EINVAL will be stored (failure).
104  *
105  * These functions return NULL if the conversion fails.
106  *
107  */
108 
109 uchar_t *g11n_convert_from_ascii(const char *str, int *err,
110     uchar_t **error_str);
111 
112 uchar_t *g11n_convert_from_utf8(const uchar_t *str, int *err,
113     uchar_t **error_str);
114 
115 char *g11n_convert_to_ascii(const uchar_t *str, int *err,
116     uchar_t **error_str);
117 
118 uchar_t *g11n_convert_to_utf8(const uchar_t *str, int *err,
119     uchar_t **error_str);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* _G11N_H */
126