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