Ruby  2.0.0p247(2013-06-27revision41674)
ext/nkf/nkf-utf8/nkf.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * nkf.h - Header file for nkf
00004  * 
00005  * $Id: nkf.h 38204 2012-12-05 04:08:17Z nobu $
00006  */
00007 
00008 #ifndef NKF_H
00009 #define NKF_H
00010 
00011 /* Wrapper of configurations */
00012 
00013 #ifndef MIME_DECODE_DEFAULT
00014 #define MIME_DECODE_DEFAULT STRICT_MIME
00015 #endif
00016 #ifndef X0201_DEFAULT
00017 #define X0201_DEFAULT TRUE
00018 #endif
00019 
00020 #if DEFAULT_NEWLINE == 0x0D0A
00021 #elif DEFAULT_NEWLINE == 0x0D
00022 #else
00023 #define DEFAULT_NEWLINE 0x0A
00024 #endif
00025 #ifdef HELP_OUTPUT_STDERR
00026 #define HELP_OUTPUT stderr
00027 #else
00028 #define HELP_OUTPUT stdout
00029 #endif
00030 
00031 
00032 /* Compatibility definitions */
00033 
00034 #ifdef nkf_char
00035 #elif defined(INT_IS_SHORT)
00036 typedef long nkf_char;
00037 #define NKF_INT32_C(n)   (n##L)
00038 #else
00039 typedef int nkf_char;
00040 #define NKF_INT32_C(n)   (n)
00041 #endif
00042 
00043 #if (defined(__TURBOC__) || defined(_MSC_VER) || defined(LSI_C) || (defined(__WATCOMC__) && defined(__386__) && !defined(__LINUX__)) || defined(__MINGW32__) || defined(__EMX__) || defined(__MSDOS__) || defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)) && !defined(MSDOS)
00044 #define MSDOS
00045 #if (defined(__Win32__) || defined(_WIN32)) && !defined(__WIN32__)
00046 #define __WIN32__
00047 #endif
00048 #endif
00049 
00050 #ifdef PERL_XS
00051 #undef OVERWRITE
00052 #endif
00053 
00054 #ifndef PERL_XS
00055 #include <stdio.h>
00056 #endif
00057 
00058 #include <stdlib.h>
00059 #include <string.h>
00060 
00061 #if defined(MSDOS) || defined(__OS2__)
00062 #include <fcntl.h>
00063 #include <io.h>
00064 #if defined(_MSC_VER) || defined(__WATCOMC__)
00065 #define mktemp _mktemp
00066 #endif
00067 #endif
00068 
00069 #ifdef MSDOS
00070 #ifdef LSI_C
00071 #define setbinmode(fp) fsetbin(fp)
00072 #elif defined(__DJGPP__)
00073 #include <libc/dosio.h>
00074 void  setbinmode(FILE *fp)
00075 {
00076     /* we do not use libc's setmode(), which changes COOKED/RAW mode in device. */
00077     int fd, m;
00078     fd = fileno(fp);
00079     m = (__file_handle_modes[fd] & (~O_TEXT)) | O_BINARY;
00080     __file_handle_set(fd, m);
00081 }
00082 #else /* Microsoft C, Turbo C */
00083 #define setbinmode(fp) setmode(fileno(fp), O_BINARY)
00084 #endif
00085 #else /* UNIX */
00086 #define setbinmode(fp) (void)(fp)
00087 #endif
00088 
00089 #ifdef _IOFBF /* SysV and MSDOS, Windows */
00090 #define       setvbuffer(fp, buf, size)       setvbuf(fp, buf, _IOFBF, size)
00091 #else /* BSD */
00092 #define       setvbuffer(fp, buf, size)       setbuffer(fp, buf, size)
00093 #endif
00094 
00095 /*Borland C++ 4.5 EasyWin*/
00096 #if defined(__TURBOC__) && defined(_Windows) && !defined(__WIN32__) /*Easy Win */
00097 #define         EASYWIN
00098 #ifndef __WIN16__
00099 #define __WIN16__
00100 #endif
00101 #include <windows.h>
00102 #endif
00103 
00104 #ifdef OVERWRITE
00105 /* added by satoru@isoternet.org */
00106 #if defined(__EMX__)
00107 #include <sys/types.h>
00108 #endif
00109 #include <sys/stat.h>
00110 #if !defined(MSDOS) || defined(__DJGPP__) /* UNIX, djgpp */
00111 #include <unistd.h>
00112 #if defined(__WATCOMC__)
00113 #include <sys/utime.h>
00114 #else
00115 #include <utime.h>
00116 #endif
00117 #else /* defined(MSDOS) */
00118 #ifdef __WIN32__
00119 #ifdef __BORLANDC__ /* BCC32 */
00120 #include <utime.h>
00121 #else /* !defined(__BORLANDC__) */
00122 #include <sys/utime.h>
00123 #endif /* (__BORLANDC__) */
00124 #else /* !defined(__WIN32__) */
00125 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) || defined(__OS2__) || defined(__EMX__) || defined(__IBMC__) || defined(__IBMCPP__)  /* VC++, MinGW, Watcom, emx+gcc, IBM VAC++ */
00126 #include <sys/utime.h>
00127 #elif defined(__TURBOC__) /* BCC */
00128 #include <utime.h>
00129 #elif defined(LSI_C) /* LSI C */
00130 #endif /* (__WIN32__) */
00131 #endif
00132 #endif
00133 #endif
00134 
00135 #if !defined(DEFAULT_CODE_JIS) && !defined(DEFAULT_CODE_SJIS) && \
00136         !defined(DEFAULT_CODE_WINDOWS_31J) && !defined(DEFAULT_CODE_EUC) && \
00137         !defined(DEFAULT_CODE_UTF8) && !defined(DEFAULT_CODE_LOCALE)
00138 #define DEFAULT_CODE_LOCALE
00139 #endif
00140 
00141 #ifdef DEFAULT_CODE_LOCALE
00142 
00143 #if defined(__WIN32__) /* not win32 should be posix */
00144 # ifndef HAVE_LOCALE_H
00145 #  define HAVE_LOCALE_H
00146 # endif
00147 #elif defined(__OS2__)
00148 # undef HAVE_LANGINFO_H /* We do not use kLIBC's langinfo. */
00149 # ifndef HAVE_LOCALE_H
00150 #  define HAVE_LOCALE_H
00151 # endif
00152 #elif defined(MSDOS)
00153 # ifndef HAVE_LOCALE_H
00154 #  define HAVE_LOCALE_H
00155 # endif
00156 #else
00157 # ifndef HAVE_LANGINFO_H
00158 #  define HAVE_LANGINFO_H
00159 # endif
00160 # ifndef HAVE_LOCALE_H
00161 #  define HAVE_LOCALE_H
00162 # endif
00163 #endif
00164 
00165 #ifdef HAVE_LANGINFO_H
00166 #include <langinfo.h>
00167 #endif
00168 #ifdef HAVE_LOCALE_H
00169 #include <locale.h>
00170 #endif
00171 
00172 #endif /* DEFAULT_CODE_LOCALE */
00173 
00174 #define         FALSE   0
00175 #define         TRUE    1
00176 
00177 #ifndef ARG_UNUSED
00178 #if defined(__GNUC__)
00179 #  define ARG_UNUSED  __attribute__ ((unused))
00180 #else
00181 #  define ARG_UNUSED
00182 #endif
00183 #endif
00184 
00185 #ifdef WIN32DLL
00186 #include "nkf32.h"
00187 #endif
00188 
00189 #endif /* NKF_H */
00190