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 (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  *
  21  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  22  * Use is subject to license terms.
  23  */
  24 
  25 #ifndef _G11N_H
  26 #define _G11N_H
  27 
  28 #ifdef __cplusplus
  29 extern "C" {
  30 #endif
  31 
  32 
  33 #include "includes.h"
  34 #include <sys/types.h>
  35 
  36 /*
  37  * Functions for language tag negotiation
  38  */
  39 
  40 /* boolean */
  41 uint_t g11n_langtag_is_default(char *langtag);
  42 
  43 /* return 0 if not, 1 if yes, 2 if the country is matched too */
  44 uint_t g11n_langtag_matches_locale(char *langtag, char *locale);
  45 
  46 /* get current locale */
  47 char *g11n_getlocale();
  48 
  49 /* get current locale */
  50 void g11n_setlocale(int category, const char *locale);
  51 
  52 /* get list of locales - returns pointer to array of pointers to char */
  53 char **g11n_getlocales();
  54 
  55 /* get list of langs spoken by the user, from SSH_LANGS env var */
  56 char *g11n_getlangs();
  57 
  58 /* make a comma-separated list of language tags from list of locales */
  59 char *g11n_locales2langs(char **locale_set);
  60 
  61 int g11n_langtag_match(char *langtag1, char *langtag2);
  62 
  63 /* intersect comma-separated lists of IETF language tags */
  64 char *g11n_langtag_set_intersect(char *set1, char *set2);
  65 
  66 char *g11n_clnt_langtag_negotiate(char *clnt_langtags, char *srvr_langtags);
  67 
  68 char **g11n_langtag_set_locale_set_intersect(char *langtag_set,
  69     char **locale_set);
  70 
  71 char *g11n_srvr_locale_negotiate(char *clnt_langtags, char **srvr_locales);
  72 
  73 /* auxiliary functions */
  74 void g11n_freelist(char **list);
  75 
  76 /*
  77  * Functions for converting to ASCII or UTF-8 from the local codeset
  78  * Functions for converting from ASCII or UTF-8 to the local codeset
  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  */
  85 extern char *g11n_convert_from_utf8(const char *str, uint_t *lenp,
  86                                 char **error_str);
  87 
  88 extern char *g11n_convert_to_utf8(const char *str, uint_t *lenp, int native,
  89                                 char **error_str);
  90 
  91 extern char *g11n_filter_string(char *);
  92 extern void g11n_test_langtag(const char *, int);
  93 
  94 #ifdef __cplusplus
  95 }
  96 #endif
  97 
  98 #endif /* _G11N_H */