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 52705Sjp161948 * Common Development and Distribution License (the "License"). 62705Sjp161948 * 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*5562Sjp161948 * Copyright 2007 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 */ 432705Sjp161948 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 */ 462705Sjp161948 uint_t g11n_langtag_matches_locale(char *langtag, char *locale); 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* get current locale */ 492705Sjp161948 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 */ 552705Sjp161948 char **g11n_getlocales(); 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* get list of langs spoken by the user, from SSH_LANGS env var */ 582705Sjp161948 char *g11n_getlangs(); 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* make a comma-separated list of language tags from list of locales */ 612705Sjp161948 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 */ 662705Sjp161948 char *g11n_langtag_set_intersect(char *set1, char *set2); 670Sstevel@tonic-gate 682705Sjp161948 char *g11n_clnt_langtag_negotiate(char *clnt_langtags, char *srvr_langtags); 690Sstevel@tonic-gate 702705Sjp161948 char **g11n_langtag_set_locale_set_intersect(char *langtag_set, 712705Sjp161948 char **locale_set); 720Sstevel@tonic-gate 732705Sjp161948 char *g11n_srvr_locale_negotiate(char *clnt_langtags, char **srvr_locales); 740Sstevel@tonic-gate 75*5562Sjp161948 /* auxiliary functions */ 76*5562Sjp161948 void g11n_freelist(char **list); 770Sstevel@tonic-gate 780Sstevel@tonic-gate /* 790Sstevel@tonic-gate * Functions for validating ASCII and UTF-8 strings 800Sstevel@tonic-gate * 810Sstevel@tonic-gate * The error_str parameter is an optional pointer to a char variable 820Sstevel@tonic-gate * where to store a string suitable for use with error() or fatal() or 830Sstevel@tonic-gate * friends. 840Sstevel@tonic-gate * 850Sstevel@tonic-gate * The input string is expected to be a null-terminated string if the 860Sstevel@tonic-gate * len parameter is given a value of 0. 870Sstevel@tonic-gate * 880Sstevel@tonic-gate * The return value is 0 if success, EILSEQ or EINVAL. 890Sstevel@tonic-gate * 900Sstevel@tonic-gate */ 910Sstevel@tonic-gate 922705Sjp161948 uint_t g11n_validate_ascii(const char *str, uint_t len, uchar_t **error_str); 930Sstevel@tonic-gate 942705Sjp161948 uint_t g11n_validate_utf8(const uchar_t *str, uint_t len, uchar_t **error_str); 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * Functions for converting to ASCII or UTF-8 from the local codeset 980Sstevel@tonic-gate * Functions for converting from ASCII or UTF-8 to the local codeset 990Sstevel@tonic-gate * 1000Sstevel@tonic-gate * The error_str parameter is an optional pointer to a char variable 1010Sstevel@tonic-gate * where to store a string suitable for use with error() or fatal() or 1020Sstevel@tonic-gate * friends. 1030Sstevel@tonic-gate * 1040Sstevel@tonic-gate * The err parameter is an optional pointer to an integer where 0 1050Sstevel@tonic-gate * (success) or EILSEQ or EINVAL will be stored (failure). 1060Sstevel@tonic-gate * 1070Sstevel@tonic-gate * These functions return NULL if the conversion fails. 1080Sstevel@tonic-gate * 1090Sstevel@tonic-gate */ 1100Sstevel@tonic-gate 1112705Sjp161948 uchar_t *g11n_convert_from_ascii(const char *str, int *err, 1122705Sjp161948 uchar_t **error_str); 1130Sstevel@tonic-gate 1142705Sjp161948 uchar_t *g11n_convert_from_utf8(const uchar_t *str, int *err, 1152705Sjp161948 uchar_t **error_str); 1160Sstevel@tonic-gate 1172705Sjp161948 char *g11n_convert_to_ascii(const uchar_t *str, int *err, 1182705Sjp161948 uchar_t **error_str); 1190Sstevel@tonic-gate 1202705Sjp161948 uchar_t *g11n_convert_to_utf8(const uchar_t *str, int *err, 1212705Sjp161948 uchar_t **error_str); 1222705Sjp161948 1230Sstevel@tonic-gate #ifdef __cplusplus 1240Sstevel@tonic-gate } 1250Sstevel@tonic-gate #endif 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate #endif /* _G11N_H */ 128