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