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