10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2705Sjp161948 * Common Development and Distribution License (the "License"). 6*2705Sjp161948 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate * 21*2705Sjp161948 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 220Sstevel@tonic-gate * Use is subject to license terms. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _G11N_H 260Sstevel@tonic-gate #define _G11N_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include "includes.h" 360Sstevel@tonic-gate #include <sys/types.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 390Sstevel@tonic-gate * Functions for language tag negotiation 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* boolean */ 43*2705Sjp161948 uint_t g11n_langtag_is_default(char *langtag); 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* return 0 if not, 1 if yes, 2 if the country is matched too */ 46*2705Sjp161948 uint_t g11n_langtag_matches_locale(char *langtag, char *locale); 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* get current locale */ 49*2705Sjp161948 char *g11n_getlocale(); 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* get current locale */ 520Sstevel@tonic-gate void g11n_setlocale(int category, const char *locale); 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* get list of locales - returns pointer to array of pointers to char */ 55*2705Sjp161948 char **g11n_getlocales(); 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* get list of langs spoken by the user, from SSH_LANGS env var */ 58*2705Sjp161948 char *g11n_getlangs(); 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* make a comma-separated list of language tags from list of locales */ 61*2705Sjp161948 char *g11n_locales2langs(char **locale_set); 620Sstevel@tonic-gate 630Sstevel@tonic-gate int g11n_langtag_match(char *langtag1, char *langtag2); 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* intersect comma-separated lists of IETF language tags */ 66*2705Sjp161948 char *g11n_langtag_set_intersect(char *set1, char *set2); 670Sstevel@tonic-gate 68*2705Sjp161948 char *g11n_clnt_langtag_negotiate(char *clnt_langtags, char *srvr_langtags); 690Sstevel@tonic-gate 70*2705Sjp161948 char **g11n_langtag_set_locale_set_intersect(char *langtag_set, 71*2705Sjp161948 char **locale_set); 720Sstevel@tonic-gate 73*2705Sjp161948 char *g11n_srvr_locale_negotiate(char *clnt_langtags, char **srvr_locales); 740Sstevel@tonic-gate 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * Functions for validating ASCII and UTF-8 strings 780Sstevel@tonic-gate * 790Sstevel@tonic-gate * The error_str parameter is an optional pointer to a char variable 800Sstevel@tonic-gate * where to store a string suitable for use with error() or fatal() or 810Sstevel@tonic-gate * friends. 820Sstevel@tonic-gate * 830Sstevel@tonic-gate * The input string is expected to be a null-terminated string if the 840Sstevel@tonic-gate * len parameter is given a value of 0. 850Sstevel@tonic-gate * 860Sstevel@tonic-gate * The return value is 0 if success, EILSEQ or EINVAL. 870Sstevel@tonic-gate * 880Sstevel@tonic-gate */ 890Sstevel@tonic-gate 90*2705Sjp161948 uint_t g11n_validate_ascii(const char *str, uint_t len, uchar_t **error_str); 910Sstevel@tonic-gate 92*2705Sjp161948 uint_t g11n_validate_utf8(const uchar_t *str, uint_t len, uchar_t **error_str); 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* 950Sstevel@tonic-gate * Functions for converting to ASCII or UTF-8 from the local codeset 960Sstevel@tonic-gate * Functions for converting from ASCII or UTF-8 to the local codeset 970Sstevel@tonic-gate * 980Sstevel@tonic-gate * The error_str parameter is an optional pointer to a char variable 990Sstevel@tonic-gate * where to store a string suitable for use with error() or fatal() or 1000Sstevel@tonic-gate * friends. 1010Sstevel@tonic-gate * 1020Sstevel@tonic-gate * The err parameter is an optional pointer to an integer where 0 1030Sstevel@tonic-gate * (success) or EILSEQ or EINVAL will be stored (failure). 1040Sstevel@tonic-gate * 1050Sstevel@tonic-gate * These functions return NULL if the conversion fails. 1060Sstevel@tonic-gate * 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate 109*2705Sjp161948 uchar_t *g11n_convert_from_ascii(const char *str, int *err, 110*2705Sjp161948 uchar_t **error_str); 1110Sstevel@tonic-gate 112*2705Sjp161948 uchar_t *g11n_convert_from_utf8(const uchar_t *str, int *err, 113*2705Sjp161948 uchar_t **error_str); 1140Sstevel@tonic-gate 115*2705Sjp161948 char *g11n_convert_to_ascii(const uchar_t *str, int *err, 116*2705Sjp161948 uchar_t **error_str); 1170Sstevel@tonic-gate 118*2705Sjp161948 uchar_t *g11n_convert_to_utf8(const uchar_t *str, int *err, 119*2705Sjp161948 uchar_t **error_str); 120*2705Sjp161948 1210Sstevel@tonic-gate #ifdef __cplusplus 1220Sstevel@tonic-gate } 1230Sstevel@tonic-gate #endif 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate #endif /* _G11N_H */ 126