OSDN Git Service

4aea67a9b8f6ac0dee3e2f98aec0149aef674c2d
[nkf/nkf.git] / nkf.h
1 /*
2  * 
3  * nkf.h - Header file for nkf
4  * 
5  * $Id: nkf.h,v 1.6 2008/11/07 02:43:43 naruse Exp $
6  */
7
8 #ifndef NKF_H
9 #define NKF_H
10
11 /* Wrapper of configurations */
12
13 #ifndef MIME_DECODE_DEFAULT
14 #define MIME_DECODE_DEFAULT STRICT_MIME
15 #endif
16 #ifndef X0201_DEFAULT
17 #define X0201_DEFAULT TRUE
18 #endif
19
20 #if DEFAULT_NEWLINE == 0x0D0A
21 #elif DEFAULT_NEWLINE == 0x0D
22 #else
23 #define DEFAULT_NEWLINE 0x0A
24 #endif
25 #ifdef HELP_OUTPUT_STDERR
26 #define HELP_OUTPUT stderr
27 #else
28 #define HELP_OUTPUT stdout
29 #endif
30
31
32 /* Compatibility definitions */
33
34 #ifdef nkf_char
35 #elif defined(INT_IS_SHORT)
36 typedef long nkf_char;
37 #define NKF_INT32_C(n)   (n##L)
38 #else
39 typedef int nkf_char;
40 #define NKF_INT32_C(n)   (n)
41 #endif
42
43 #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)
44 #define MSDOS
45 #if (defined(__Win32__) || defined(_WIN32)) && !defined(__WIN32__)
46 #define __WIN32__
47 #endif
48 #endif
49
50 #ifdef PERL_XS
51 #undef OVERWRITE
52 #endif
53
54 #ifndef PERL_XS
55 #include <stdio.h>
56 #endif
57
58 #include <stdlib.h>
59 #include <string.h>
60
61 #if defined(MSDOS) || defined(__OS2__)
62 #include <fcntl.h>
63 #include <io.h>
64 #if defined(_MSC_VER) || defined(__WATCOMC__)
65 #define mktemp _mktemp
66 #endif
67 #endif
68
69 #ifdef MSDOS
70 #ifdef LSI_C
71 #define setbinmode(fp) fsetbin(fp)
72 #elif defined(__DJGPP__)
73 #include <libc/dosio.h>
74 void  setbinmode(FILE *fp)
75 {
76     /* we do not use libc's setmode(), which changes COOKED/RAW mode in device. */
77     int fd, m;
78     fd = fileno(fp);
79     m = (__file_handle_modes[fd] & (~O_TEXT)) | O_BINARY;
80     __file_handle_set(fd, m);
81 }
82 #else /* Microsoft C, Turbo C */
83 #define setbinmode(fp) setmode(fileno(fp), O_BINARY)
84 #endif
85 #else /* UNIX */
86 #define setbinmode(fp)
87 #endif
88
89 #ifdef _IOFBF /* SysV and MSDOS, Windows */
90 #define       setvbuffer(fp, buf, size)       setvbuf(fp, buf, _IOFBF, size)
91 #else /* BSD */
92 #define       setvbuffer(fp, buf, size)       setbuffer(fp, buf, size)
93 #endif
94
95 /*Borland C++ 4.5 EasyWin*/
96 #if defined(__TURBOC__) && defined(_Windows) && !defined(__WIN32__) /*Easy Win */
97 #define         EASYWIN
98 #ifndef __WIN16__
99 #define __WIN16__
100 #endif
101 #include <windows.h>
102 #endif
103
104 #ifdef OVERWRITE
105 /* added by satoru@isoternet.org */
106 #if defined(__EMX__)
107 #include <sys/types.h>
108 #endif
109 #include <sys/stat.h>
110 #if !defined(MSDOS) || defined(__DJGPP__) /* UNIX, djgpp */
111 #include <unistd.h>
112 #if defined(__WATCOMC__)
113 #include <sys/utime.h>
114 #else
115 #include <utime.h>
116 #endif
117 #else /* defined(MSDOS) */
118 #ifdef __WIN32__
119 #ifdef __BORLANDC__ /* BCC32 */
120 #include <utime.h>
121 #else /* !defined(__BORLANDC__) */
122 #include <sys/utime.h>
123 #endif /* (__BORLANDC__) */
124 #else /* !defined(__WIN32__) */
125 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) || defined(__OS2__) || defined(__EMX__) || defined(__IBMC__) || defined(__IBMCPP__)  /* VC++, MinGW, Watcom, emx+gcc, IBM VAC++ */
126 #include <sys/utime.h>
127 #elif defined(__TURBOC__) /* BCC */
128 #include <utime.h>
129 #elif defined(LSI_C) /* LSI C */
130 #endif /* (__WIN32__) */
131 #endif
132 #endif
133 #endif
134
135 #if !defined(DEFAULT_CODE_JIS) && !defined(DEFAULT_CODE_SJIS) && \
136         !defined(DEFAULT_CODE_WINDOWS_31J) && !defined(DEFAULT_CODE_EUC) && \
137         !defined(DEFAULT_CODE_UTF8) && !defined(DEFAULT_CODE_LOCALE)
138 #define DEFAULT_CODE_LOCALE
139 #endif
140
141 #ifdef DEFAULT_CODE_LOCALE
142
143 #if defined(__WIN32__) /* not win32 should be posix */
144 # ifndef HAVE_LOCALE_H
145 #  define HAVE_LOCALE_H
146 # endif
147 #elif defined(__OS2__)
148 # undef HAVE_LANGINFO_H /* We do not use kLIBC's langinfo. */
149 # ifndef HAVE_LOCALE_H
150 #  define HAVE_LOCALE_H
151 # endif
152 #elif defined(MSDOS)
153 # ifndef HAVE_LOCALE_H
154 #  define HAVE_LOCALE_H
155 # endif
156 #else
157 # ifndef HAVE_LANGINFO_H
158 #  define HAVE_LANGINFO_H
159 # endif
160 # ifndef HAVE_LOCALE_H
161 #  define HAVE_LOCALE_H
162 # endif
163 #endif
164
165 #ifdef HAVE_LANGINFO_H
166 #include <langinfo.h>
167 #endif
168 #ifdef HAVE_LOCALE_H
169 #include <locale.h>
170 #endif
171
172 #endif /* DEFAULT_CODE_LOCALE */
173
174 #define         FALSE   0
175 #define         TRUE    1
176
177 #ifdef WIN32DLL
178 #include "nkf32.h"
179 #endif
180
181 #endif /* NKF_H */