Back to index

nagios-plugins  1.4.16
wchar.in.h
Go to the documentation of this file.
00001 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
00002 
00003    Copyright (C) 2007-2010 Free Software Foundation, Inc.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software Foundation,
00017    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 /* Written by Eric Blake.  */
00020 
00021 /*
00022  * ISO C 99 <wchar.h> for platforms that have issues.
00023  * <http://www.opengroup.org/susv3xbd/wchar.h.html>
00024  *
00025  * For now, this just ensures proper prerequisite inclusion order and
00026  * the declaration of wcwidth().
00027  */
00028 
00029 #if __GNUC__ >= 3
00030 @PRAGMA_SYSTEM_HEADER@
00031 #endif
00032 
00033 #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
00034 /* Special invocation convention:
00035    - Inside glibc and uClibc header files.
00036    - On HP-UX 11.00 we have a sequence of nested includes
00037      <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
00038      once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
00039      and once directly.  In both situations 'wint_t' is not yet defined,
00040      therefore we cannot provide the function overrides; instead include only
00041      the system's <wchar.h>.
00042    - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
00043      the latter includes <wchar.h>.  But here, we have no way to detect whether
00044      <wctype.h> is completely included or is still being included.  */
00045 
00046 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
00047 
00048 #else
00049 /* Normal invocation convention.  */
00050 
00051 #ifndef _GL_WCHAR_H
00052 
00053 #define _GL_ALREADY_INCLUDING_WCHAR_H
00054 
00055 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
00056    <wchar.h>.
00057    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
00058    included before <wchar.h>.
00059    But avoid namespace pollution on glibc systems.  */
00060 #ifndef __GLIBC__
00061 # include <stddef.h>
00062 # include <stdio.h>
00063 # include <time.h>
00064 #endif
00065 
00066 /* Include the original <wchar.h> if it exists.
00067    Some builds of uClibc lack it.  */
00068 /* The include_next requires a split double-inclusion guard.  */
00069 #if @HAVE_WCHAR_H@
00070 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
00071 #endif
00072 
00073 #undef _GL_ALREADY_INCLUDING_WCHAR_H
00074 
00075 #ifndef _GL_WCHAR_H
00076 #define _GL_WCHAR_H
00077 
00078 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
00079 
00080 /* The definition of _GL_ARG_NONNULL is copied here.  */
00081 
00082 /* The definition of _GL_WARN_ON_USE is copied here.  */
00083 
00084 
00085 /* Define wint_t and WEOF.  (Also done in wctype.in.h.)  */
00086 #if !@HAVE_WINT_T@ && !defined wint_t
00087 # define wint_t int
00088 # ifndef WEOF
00089 #  define WEOF -1
00090 # endif
00091 #else
00092 # ifndef WEOF
00093 #  define WEOF ((wint_t) -1)
00094 # endif
00095 #endif
00096 
00097 
00098 /* Override mbstate_t if it is too small.
00099    On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
00100    implementing mbrtowc for encodings like UTF-8.  */
00101 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
00102 typedef int rpl_mbstate_t;
00103 # undef mbstate_t
00104 # define mbstate_t rpl_mbstate_t
00105 # define GNULIB_defined_mbstate_t 1
00106 #endif
00107 
00108 
00109 /* Convert a single-byte character to a wide character.  */
00110 #if @GNULIB_BTOWC@
00111 # if @REPLACE_BTOWC@
00112 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00113 #   undef btowc
00114 #   define btowc rpl_btowc
00115 #  endif
00116 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
00117 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
00118 # else
00119 #  if !@HAVE_BTOWC@
00120 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
00121 #  endif
00122 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
00123 # endif
00124 _GL_CXXALIASWARN (btowc);
00125 #elif defined GNULIB_POSIXCHECK
00126 # undef btowc
00127 # if HAVE_RAW_DECL_BTOWC
00128 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
00129                  "use gnulib module btowc for portability");
00130 # endif
00131 #endif
00132 
00133 
00134 /* Convert a wide character to a single-byte character.  */
00135 #if @GNULIB_WCTOB@
00136 # if @REPLACE_WCTOB@
00137 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00138 #   undef wctob
00139 #   define wctob rpl_wctob
00140 #  endif
00141 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
00142 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
00143 # else
00144 #  if !defined wctob && !@HAVE_DECL_WCTOB@
00145 /* wctob is provided by gnulib, or wctob exists but is not declared.  */
00146 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
00147 #  endif
00148 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
00149 # endif
00150 _GL_CXXALIASWARN (wctob);
00151 #elif defined GNULIB_POSIXCHECK
00152 # undef wctob
00153 # if HAVE_RAW_DECL_WCTOB
00154 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
00155                  "use gnulib module wctob for portability");
00156 # endif
00157 #endif
00158 
00159 
00160 /* Test whether *PS is in the initial state.  */
00161 #if @GNULIB_MBSINIT@
00162 # if @REPLACE_MBSINIT@
00163 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00164 #   undef mbsinit
00165 #   define mbsinit rpl_mbsinit
00166 #  endif
00167 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
00168 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
00169 # else
00170 #  if !@HAVE_MBSINIT@
00171 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
00172 #  endif
00173 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
00174 # endif
00175 _GL_CXXALIASWARN (mbsinit);
00176 #elif defined GNULIB_POSIXCHECK
00177 # undef mbsinit
00178 # if HAVE_RAW_DECL_MBSINIT
00179 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
00180                  "use gnulib module mbsinit for portability");
00181 # endif
00182 #endif
00183 
00184 
00185 /* Convert a multibyte character to a wide character.  */
00186 #if @GNULIB_MBRTOWC@
00187 # if @REPLACE_MBRTOWC@
00188 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00189 #   undef mbrtowc
00190 #   define mbrtowc rpl_mbrtowc
00191 #  endif
00192 _GL_FUNCDECL_RPL (mbrtowc, size_t,
00193                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
00194 _GL_CXXALIAS_RPL (mbrtowc, size_t,
00195                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
00196 # else
00197 #  if !@HAVE_MBRTOWC@
00198 _GL_FUNCDECL_SYS (mbrtowc, size_t,
00199                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
00200 #  endif
00201 _GL_CXXALIAS_SYS (mbrtowc, size_t,
00202                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
00203 # endif
00204 _GL_CXXALIASWARN (mbrtowc);
00205 #elif defined GNULIB_POSIXCHECK
00206 # undef mbrtowc
00207 # if HAVE_RAW_DECL_MBRTOWC
00208 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
00209                  "use gnulib module mbrtowc for portability");
00210 # endif
00211 #endif
00212 
00213 
00214 /* Recognize a multibyte character.  */
00215 #if @GNULIB_MBRLEN@
00216 # if @REPLACE_MBRLEN@
00217 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00218 #   undef mbrlen
00219 #   define mbrlen rpl_mbrlen
00220 #  endif
00221 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
00222 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
00223 # else
00224 #  if !@HAVE_MBRLEN@
00225 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
00226 #  endif
00227 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
00228 # endif
00229 _GL_CXXALIASWARN (mbrlen);
00230 #elif defined GNULIB_POSIXCHECK
00231 # undef mbrlen
00232 # if HAVE_RAW_DECL_MBRLEN
00233 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
00234                  "use gnulib module mbrlen for portability");
00235 # endif
00236 #endif
00237 
00238 
00239 /* Convert a string to a wide string.  */
00240 #if @GNULIB_MBSRTOWCS@
00241 # if @REPLACE_MBSRTOWCS@
00242 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00243 #   undef mbsrtowcs
00244 #   define mbsrtowcs rpl_mbsrtowcs
00245 #  endif
00246 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
00247                   (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
00248                   _GL_ARG_NONNULL ((2)));
00249 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
00250                   (wchar_t *dest, const char **srcp, size_t len,
00251                    mbstate_t *ps));
00252 # else
00253 #  if !@HAVE_MBSRTOWCS@
00254 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
00255                   (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
00256                   _GL_ARG_NONNULL ((2)));
00257 #  endif
00258 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
00259                   (wchar_t *dest, const char **srcp, size_t len,
00260                    mbstate_t *ps));
00261 # endif
00262 _GL_CXXALIASWARN (mbsrtowcs);
00263 #elif defined GNULIB_POSIXCHECK
00264 # undef mbsrtowcs
00265 # if HAVE_RAW_DECL_MBSRTOWCS
00266 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
00267                  "use gnulib module mbsrtowcs for portability");
00268 # endif
00269 #endif
00270 
00271 
00272 /* Convert a string to a wide string.  */
00273 #if @GNULIB_MBSNRTOWCS@
00274 # if @REPLACE_MBSNRTOWCS@
00275 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00276 #   undef mbsnrtowcs
00277 #   define mbsnrtowcs rpl_mbsnrtowcs
00278 #  endif
00279 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
00280                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
00281                    mbstate_t *ps)
00282                   _GL_ARG_NONNULL ((2)));
00283 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
00284                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
00285                    mbstate_t *ps));
00286 # else
00287 #  if !@HAVE_MBSNRTOWCS@
00288 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
00289                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
00290                    mbstate_t *ps)
00291                   _GL_ARG_NONNULL ((2)));
00292 #  endif
00293 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
00294                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
00295                    mbstate_t *ps));
00296 # endif
00297 _GL_CXXALIASWARN (mbsnrtowcs);
00298 #elif defined GNULIB_POSIXCHECK
00299 # undef mbsnrtowcs
00300 # if HAVE_RAW_DECL_MBSNRTOWCS
00301 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
00302                  "use gnulib module mbsnrtowcs for portability");
00303 # endif
00304 #endif
00305 
00306 
00307 /* Convert a wide character to a multibyte character.  */
00308 #if @GNULIB_WCRTOMB@
00309 # if @REPLACE_WCRTOMB@
00310 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00311 #   undef wcrtomb
00312 #   define wcrtomb rpl_wcrtomb
00313 #  endif
00314 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
00315 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
00316 # else
00317 #  if !@HAVE_WCRTOMB@
00318 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
00319 #  endif
00320 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
00321 # endif
00322 _GL_CXXALIASWARN (wcrtomb);
00323 #elif defined GNULIB_POSIXCHECK
00324 # undef wcrtomb
00325 # if HAVE_RAW_DECL_WCRTOMB
00326 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
00327                  "use gnulib module wcrtomb for portability");
00328 # endif
00329 #endif
00330 
00331 
00332 /* Convert a wide string to a string.  */
00333 #if @GNULIB_WCSRTOMBS@
00334 # if @REPLACE_WCSRTOMBS@
00335 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00336 #   undef wcsrtombs
00337 #   define wcsrtombs rpl_wcsrtombs
00338 #  endif
00339 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
00340                   (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
00341                   _GL_ARG_NONNULL ((2)));
00342 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
00343                   (char *dest, const wchar_t **srcp, size_t len,
00344                    mbstate_t *ps));
00345 # else
00346 #  if !@HAVE_WCSRTOMBS@
00347 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
00348                   (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
00349                   _GL_ARG_NONNULL ((2)));
00350 #  endif
00351 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
00352                   (char *dest, const wchar_t **srcp, size_t len,
00353                    mbstate_t *ps));
00354 # endif
00355 _GL_CXXALIASWARN (wcsrtombs);
00356 #elif defined GNULIB_POSIXCHECK
00357 # undef wcsrtombs
00358 # if HAVE_RAW_DECL_WCSRTOMBS
00359 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
00360                  "use gnulib module wcsrtombs for portability");
00361 # endif
00362 #endif
00363 
00364 
00365 /* Convert a wide string to a string.  */
00366 #if @GNULIB_WCSNRTOMBS@
00367 # if @REPLACE_WCSNRTOMBS@
00368 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00369 #   undef wcsnrtombs
00370 #   define wcsnrtombs rpl_wcsnrtombs
00371 #  endif
00372 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
00373                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
00374                    mbstate_t *ps)
00375                   _GL_ARG_NONNULL ((2)));
00376 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
00377                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
00378                    mbstate_t *ps));
00379 # else
00380 #  if !@HAVE_WCSNRTOMBS@
00381 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
00382                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
00383                    mbstate_t *ps)
00384                   _GL_ARG_NONNULL ((2)));
00385 #  endif
00386 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
00387                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
00388                    mbstate_t *ps));
00389 # endif
00390 _GL_CXXALIASWARN (wcsnrtombs);
00391 #elif defined GNULIB_POSIXCHECK
00392 # undef wcsnrtombs
00393 # if HAVE_RAW_DECL_WCSNRTOMBS
00394 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
00395                  "use gnulib module wcsnrtombs for portability");
00396 # endif
00397 #endif
00398 
00399 
00400 /* Return the number of screen columns needed for WC.  */
00401 #if @GNULIB_WCWIDTH@
00402 # if @REPLACE_WCWIDTH@
00403 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00404 #   undef wcwidth
00405 #   define wcwidth rpl_wcwidth
00406 #  endif
00407 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
00408 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
00409 # else
00410 #  if !@HAVE_DECL_WCWIDTH@
00411 /* wcwidth exists but is not declared.  */
00412 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
00413 #  endif
00414 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
00415 # endif
00416 _GL_CXXALIASWARN (wcwidth);
00417 #elif defined GNULIB_POSIXCHECK
00418 # undef wcwidth
00419 # if HAVE_RAW_DECL_WCWIDTH
00420 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
00421                  "use gnulib module wcwidth for portability");
00422 # endif
00423 #endif
00424 
00425 
00426 #endif /* _GL_WCHAR_H */
00427 #endif /* _GL_WCHAR_H */
00428 #endif