1 /* 2 uim-util.h utility function prototypes for uim. 3 4 Copyright (c) 2004-2013 uim Project https://github.com/uim/uim 5 6 All rights reserved. 7 8 Redistribution and use in source and binary forms, with or without 9 modification, are permitted provided that the following conditions 10 are met: 11 12 1. Redistributions of source code must retain the above copyright 13 notice, this list of conditions and the following disclaimer. 14 2. Redistributions in binary form must reproduce the above copyright 15 notice, this list of conditions and the following disclaimer in the 16 documentation and/or other materials provided with the distribution. 17 3. Neither the name of authors nor the names of its contributors 18 may be used to endorse or promote products derived from this software 19 without specific prior written permission. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 SUCH DAMAGE. 32 33 */ 34 35 #ifndef UIM_UTIL_H 36 #define UIM_UTIL_H 37 38 #include <stdio.h> 39 #include <sys/types.h> 40 41 #include "uim.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * Returns human-readable language name from a locale string. 49 * 50 * @param locale locale string. typical format of this string is 51 * ll_CC.charset. e.g. for Japanese locale, ja_JP.EUC-JP ll is language code 52 * defined in ISO 639-1, CC is country code defined in ISO 3166. 53 * 54 * @return untranslated language name string, or else "-" if no language is 55 * matched. apply gettext() in caller side if needed. 56 * 57 * @see uim_create_context 58 */ 59 const char * 60 uim_get_language_name_from_locale(const char *locale); 61 62 /** 63 * Returns ISO 639-1 language code from a human-readable language name. 64 * 65 * @param language_name a human-readable language name in English such as 66 * "Japanese". 67 * 68 * @return ISO 639-1 language code such as "ja", or else "-" if no language 69 * is matched. 70 */ 71 const char * 72 uim_get_language_code_from_language_name(const char *language_name); 73 74 75 /* command execution in pipe-connected subprocess (like popen(3))*/ 76 pid_t uim_ipc_open_command(pid_t old_pid, 77 FILE **read_handler, FILE **write_handler, 78 const char *command); 79 pid_t uim_ipc_open_command_with_option(pid_t old_pid, 80 FILE **read_handler, 81 FILE **write_handler, 82 const char *command, 83 const char *option); 84 char *uim_ipc_send_command(pid_t *pid, 85 FILE **read_handler, FILE **write_handler, 86 const char *command, const char *str); 87 88 /* an uim_code_converter implementation using iconv */ 89 extern struct uim_code_converter *uim_iconv; 90 91 92 #ifdef __cplusplus 93 } 94 #endif 95 #endif 96