Annotation of embedaddon/curl/lib/curl_multibyte.h, revision 1.1.1.1

1.1       misho       1: #ifndef HEADER_CURL_MULTIBYTE_H
                      2: #define HEADER_CURL_MULTIBYTE_H
                      3: /***************************************************************************
                      4:  *                                  _   _ ____  _
                      5:  *  Project                     ___| | | |  _ \| |
                      6:  *                             / __| | | | |_) | |
                      7:  *                            | (__| |_| |  _ <| |___
                      8:  *                             \___|\___/|_| \_\_____|
                      9:  *
                     10:  * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
                     11:  *
                     12:  * This software is licensed as described in the file COPYING, which
                     13:  * you should have received as part of this distribution. The terms
                     14:  * are also available at https://curl.haxx.se/docs/copyright.html.
                     15:  *
                     16:  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
                     17:  * copies of the Software, and permit persons to whom the Software is
                     18:  * furnished to do so, under the terms of the COPYING file.
                     19:  *
                     20:  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
                     21:  * KIND, either express or implied.
                     22:  *
                     23:  ***************************************************************************/
                     24: #include "curl_setup.h"
                     25: 
                     26: #if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \
                     27:                                 defined(USE_WIN32_LDAP)) && defined(UNICODE))
                     28: 
                     29:  /*
                     30:   * MultiByte conversions using Windows kernel32 library.
                     31:   */
                     32: 
                     33: wchar_t *Curl_convert_UTF8_to_wchar(const char *str_utf8);
                     34: char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w);
                     35: 
                     36: #endif /* USE_WIN32_IDN || ((USE_WINDOWS_SSPI || USE_WIN32_LDAP) && UNICODE) */
                     37: 
                     38: 
                     39: #if defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI) || \
                     40:     defined(USE_WIN32_LDAP)
                     41: 
                     42: /*
                     43:  * Macros Curl_convert_UTF8_to_tchar(), Curl_convert_tchar_to_UTF8()
                     44:  * and Curl_unicodefree() main purpose is to minimize the number of
                     45:  * preprocessor conditional directives needed by code using these
                     46:  * to differentiate UNICODE from non-UNICODE builds.
                     47:  *
                     48:  * When building with UNICODE defined, this two macros
                     49:  * Curl_convert_UTF8_to_tchar() and Curl_convert_tchar_to_UTF8()
                     50:  * return a pointer to a newly allocated memory area holding result.
                     51:  * When the result is no longer needed, allocated memory is intended
                     52:  * to be free'ed with Curl_unicodefree().
                     53:  *
                     54:  * When building without UNICODE defined, this macros
                     55:  * Curl_convert_UTF8_to_tchar() and Curl_convert_tchar_to_UTF8()
                     56:  * return the pointer received as argument. Curl_unicodefree() does
                     57:  * no actual free'ing of this pointer it is simply set to NULL.
                     58:  */
                     59: 
                     60: #ifdef UNICODE
                     61: 
                     62: #define Curl_convert_UTF8_to_tchar(ptr) Curl_convert_UTF8_to_wchar((ptr))
                     63: #define Curl_convert_tchar_to_UTF8(ptr) Curl_convert_wchar_to_UTF8((ptr))
                     64: #define Curl_unicodefree(ptr)                           \
                     65:   do {                                                  \
                     66:     if(ptr) {                                           \
                     67:       free(ptr);                                        \
                     68:       (ptr) = NULL;                                     \
                     69:     }                                                   \
                     70:   } while(0)
                     71: 
                     72: typedef union {
                     73:   unsigned short       *tchar_ptr;
                     74:   const unsigned short *const_tchar_ptr;
                     75:   unsigned short       *tbyte_ptr;
                     76:   const unsigned short *const_tbyte_ptr;
                     77: } xcharp_u;
                     78: 
                     79: #else
                     80: 
                     81: #define Curl_convert_UTF8_to_tchar(ptr) (ptr)
                     82: #define Curl_convert_tchar_to_UTF8(ptr) (ptr)
                     83: #define Curl_unicodefree(ptr) \
                     84:   do {(ptr) = NULL;} while(0)
                     85: 
                     86: typedef union {
                     87:   char                *tchar_ptr;
                     88:   const char          *const_tchar_ptr;
                     89:   unsigned char       *tbyte_ptr;
                     90:   const unsigned char *const_tbyte_ptr;
                     91: } xcharp_u;
                     92: 
                     93: #endif /* UNICODE */
                     94: 
                     95: #endif /* USE_WIN32_IDN || USE_WINDOWS_SSPI || USE_WIN32_LDAP */
                     96: 
                     97: #endif /* HEADER_CURL_MULTIBYTE_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>