17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 532f863ecSjp161948 * Common Development and Distribution License (the "License"). 632f863ecSjp161948 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate * 21*9a8058b5Sjp161948 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 227c478bd9Sstevel@tonic-gate * Use is subject to license terms. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _G11N_H 267c478bd9Sstevel@tonic-gate #define _G11N_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include "includes.h" 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * Functions for language tag negotiation 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* boolean */ 4332f863ecSjp161948 uint_t g11n_langtag_is_default(char *langtag); 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* return 0 if not, 1 if yes, 2 if the country is matched too */ 4632f863ecSjp161948 uint_t g11n_langtag_matches_locale(char *langtag, char *locale); 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* get current locale */ 497c478bd9Sstevel@tonic-gate char *g11n_getlocale(); 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* get current locale */ 527c478bd9Sstevel@tonic-gate void g11n_setlocale(int category, const char *locale); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* get list of locales - returns pointer to array of pointers to char */ 557c478bd9Sstevel@tonic-gate char **g11n_getlocales(); 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* get list of langs spoken by the user, from SSH_LANGS env var */ 587c478bd9Sstevel@tonic-gate char *g11n_getlangs(); 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* make a comma-separated list of language tags from list of locales */ 617c478bd9Sstevel@tonic-gate char *g11n_locales2langs(char **locale_set); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate int g11n_langtag_match(char *langtag1, char *langtag2); 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* intersect comma-separated lists of IETF language tags */ 667c478bd9Sstevel@tonic-gate char *g11n_langtag_set_intersect(char *set1, char *set2); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate char *g11n_clnt_langtag_negotiate(char *clnt_langtags, char *srvr_langtags); 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate char **g11n_langtag_set_locale_set_intersect(char *langtag_set, 717c478bd9Sstevel@tonic-gate char **locale_set); 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate char *g11n_srvr_locale_negotiate(char *clnt_langtags, char **srvr_locales); 747c478bd9Sstevel@tonic-gate 75*9a8058b5Sjp161948 /* auxiliary functions */ 76*9a8058b5Sjp161948 void g11n_freelist(char **list); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * Functions for validating ASCII and UTF-8 strings 807c478bd9Sstevel@tonic-gate * 817c478bd9Sstevel@tonic-gate * The error_str parameter is an optional pointer to a char variable 827c478bd9Sstevel@tonic-gate * where to store a string suitable for use with error() or fatal() or 837c478bd9Sstevel@tonic-gate * friends. 847c478bd9Sstevel@tonic-gate * 857c478bd9Sstevel@tonic-gate * The input string is expected to be a null-terminated string if the 867c478bd9Sstevel@tonic-gate * len parameter is given a value of 0. 877c478bd9Sstevel@tonic-gate * 887c478bd9Sstevel@tonic-gate * The return value is 0 if success, EILSEQ or EINVAL. 897c478bd9Sstevel@tonic-gate * 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate 9232f863ecSjp161948 uint_t g11n_validate_ascii(const char *str, uint_t len, uchar_t **error_str); 937c478bd9Sstevel@tonic-gate 9432f863ecSjp161948 uint_t g11n_validate_utf8(const uchar_t *str, uint_t len, uchar_t **error_str); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Functions for converting to ASCII or UTF-8 from the local codeset 987c478bd9Sstevel@tonic-gate * Functions for converting from ASCII or UTF-8 to the local codeset 997c478bd9Sstevel@tonic-gate * 1007c478bd9Sstevel@tonic-gate * The error_str parameter is an optional pointer to a char variable 1017c478bd9Sstevel@tonic-gate * where to store a string suitable for use with error() or fatal() or 1027c478bd9Sstevel@tonic-gate * friends. 1037c478bd9Sstevel@tonic-gate * 1047c478bd9Sstevel@tonic-gate * The err parameter is an optional pointer to an integer where 0 1057c478bd9Sstevel@tonic-gate * (success) or EILSEQ or EINVAL will be stored (failure). 1067c478bd9Sstevel@tonic-gate * 1077c478bd9Sstevel@tonic-gate * These functions return NULL if the conversion fails. 1087c478bd9Sstevel@tonic-gate * 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate 11132f863ecSjp161948 uchar_t *g11n_convert_from_ascii(const char *str, int *err, 11232f863ecSjp161948 uchar_t **error_str); 1137c478bd9Sstevel@tonic-gate 11432f863ecSjp161948 uchar_t *g11n_convert_from_utf8(const uchar_t *str, int *err, 11532f863ecSjp161948 uchar_t **error_str); 1167c478bd9Sstevel@tonic-gate 11732f863ecSjp161948 char *g11n_convert_to_ascii(const uchar_t *str, int *err, 11832f863ecSjp161948 uchar_t **error_str); 1197c478bd9Sstevel@tonic-gate 12032f863ecSjp161948 uchar_t *g11n_convert_to_utf8(const uchar_t *str, int *err, 12132f863ecSjp161948 uchar_t **error_str); 12232f863ecSjp161948 1237c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate #endif 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate #endif /* _G11N_H */ 128