** E-Mail: furukawa@tcp-ip.or.jp
** \e$B$^$G8fO"Mm$r$*4j$$$7$^$9!#\e(B
***********************************************************************/
-/* $Id: nkf.c,v 1.58 2005/02/17 16:48:48 rei_furukawa Exp $ */
+/* $Id: nkf.c,v 1.61 2005/02/20 11:57:53 naruse Exp $ */
#define NKF_VERSION "2.0.4"
-#define NKF_RELEASE_DATE "2005-02-02"
+#define NKF_RELEASE_DATE "2005-02-20"
#include "config.h"
static char *CopyRight =
#ifndef MSDOS /* UNIX, OS/2 */
#include <unistd.h>
#include <utime.h>
-#else
+#else /* defined(MSDOS) */
+#ifdef __WIN32__
+#ifdef __BORLANDC__ /* BCC32 */
+#include <utime.h>
+#else /* !defined(__BORLANDC__) */
+#include <sys/utime.h>
+#endif /* (__BORLANDC__) */
+#else /* !defined(__WIN32__) */
#if defined(_MSC_VER) || defined(__MINGW32__) /* VC++, MinGW */
#include <sys/utime.h>
#elif defined(__TURBOC__) /* BCC */
#include <utime.h>
#elif defined(LSI_C) /* LSI C */
+#endif /* (__WIN32__) */
#endif
#endif
#endif
STATIC int kanji_convert PROTO((FILE *f));
STATIC int h_conv PROTO((FILE *f,int c2,int c1));
STATIC int push_hold_buf PROTO((int c2));
-STATIC void set_iconv PROTO((int f, int (*iconv_func)()));
+STATIC void set_iconv PROTO((int f, int (*iconv_func)(int c2,int c1,int c0)));
STATIC int s_iconv PROTO((int c2,int c1,int c0));
STATIC int s2e_conv PROTO((int c2, int c1, int *p2, int *p1));
STATIC int e_iconv PROTO((int c2,int c1,int c0));
STATIC void usage PROTO(());
STATIC void version PROTO(());
STATIC void options PROTO((unsigned char *c));
-#ifdef PERL_XS
+#if defined(PERL_XS) || defined(WIN32DLL)
STATIC void reinit PROTO(());
#endif
static int input_f = FALSE; /* non fixed input code */
static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */
static int mime_f = STRICT_MIME; /* convert MIME B base64 or Q */
+static int mime_decode_f = FALSE; /* mime decode is explicitly on */
static int mimebuf_f = FALSE; /* MIME buffered input */
static int broken_f = FALSE; /* convert ESC-less broken JIS */
static int iso8859_f = FALSE; /* ISO8859 through */
static int end_check;
#endif /*Easy Win */
-#ifndef PERL_XS
+#define STD_GC_BUFSIZE (256)
+int std_gc_buf[STD_GC_BUFSIZE];
+int std_gc_ndx;
+
+#ifdef WIN32DLL
+#include "nkf32dll.c"
+#elif defined(PERL_XS)
+#else /* WIN32DLL */
int
main(argc, argv)
int argc;
#ifdef OVERWRITE
if (overwrite) {
struct stat sb;
-#if defined(MSDOS) && !defined(__MINGW32__)
+#if defined(MSDOS) && !defined(__MINGW32__) && !defined(__WIN32__)
time_t tb[2];
#else
struct utimbuf tb;
}
/* \e$B%?%$%`%9%?%s%W$rI|85\e(B */
-#if defined(MSDOS) && !defined(__MINGW32__)
+#if defined(MSDOS) && !defined(__MINGW32__) && !defined(__WIN32__)
tb[0] = tb[1] = sb.st_mtime;
if (utime(outfname, tb)) {
fprintf(stderr, "Can't set timestamp %s\n", outfname);
#else /* for Other OS */
if (file_out == TRUE)
fclose(stdout);
-#endif
+#endif /*Easy Win */
return (0);
}
-#endif
+#endif /* WIN32DLL */
static
struct {
}
continue;
case 'm': /* MIME support */
+ mime_decode_f = TRUE;
if (*cp=='B'||*cp=='Q') {
mime_decode_mode = *cp++;
mimebuf_f = FIXED_MIME;
}
}
-#define STD_GC_BUFSIZE (256)
-int std_gc_buf[STD_GC_BUFSIZE];
-int std_gc_ndx;
-
+#ifndef WIN32DLL
int
std_getc(f)
FILE *f;
}
return getc(f);
}
+#endif /*WIN32DLL*/
int
std_ungetc(c,f)
return c;
}
+#ifndef WIN32DLL
void
std_putc(c)
int c;
if(c!=EOF)
putchar(c);
}
+#endif /*WIN32DLL*/
int
noconvert(f)
} else if ((c1 == NL || c1 == CR) && broken_f&4) {
input_mode = ASCII; set_iconv(FALSE, 0);
SEND;
- /*
- } else if (c1 == NL && mime_f && !mime_decode_mode ) {
+ } else if (c1 == NL && mime_decode_f && !mime_decode_mode ) {
if ((c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
i_ungetc(SPACE,f);
continue;
}
c1 = NL;
SEND;
- } else if (c1 == CR && mime_f && !mime_decode_mode ) {
+ } else if (c1 == CR && mime_decode_f && !mime_decode_mode ) {
if ((c1=(*i_getc)(f))!=EOF) {
if (c1==SPACE) {
i_ungetc(SPACE,f);
}
c1 = CR;
SEND;
- */
} else
SEND;
}
is_inputcode_set = TRUE;
}
+#ifndef WIN32DLL
void
print_guessed_code (filename)
char *filename;
if (filename != NULL) printf("%s:", filename);
printf("%s\n", codename);
}
+#endif /*WIN32DLL*/
int
hex2bin(x)
(*o_base64conv)(0,NL);
(*o_base64conv)(0,SPACE);
}
- }else if (mime_lastchar2){
+ }/*else if (mime_lastchar2){
if (c1 <=DEL && !nkf_isspace(c1)){
(*o_base64conv)(0,SPACE);
}
- }
- }else{
+ }*/
+ }/*else{
if (c2 && mime_lastchar2 == 0
&& mime_lastchar1 && !nkf_isspace(mime_lastchar1)){
(*o_base64conv)(0,SPACE);
}
- }
+ }*/
mime_lastchar2 = c2;
mime_lastchar1 = c1;
}
mimeout_buf_count = 0;
i = 0;
for (;i<j;i++) {
- if (nkf_isspace(mimeout_buf[i])){
+ /*if (nkf_isspace(mimeout_buf[i])){
break;
- }
+ }*/
mimeout_addchar(mimeout_buf[i]);
}
eof_mime();
}
-#ifdef PERL_XS
+#if defined(PERL_XS) || defined(WIN32DLL)
void
reinit()
{
input_f = FALSE;
alpha_f = FALSE;
mime_f = STRICT_MIME;
+ mime_decode_f = FALSE;
mimebuf_f = FALSE;
broken_f = FALSE;
iso8859_f = FALSE;
#ifdef CHECK_OPTION
iconv_for_check = 0;
#endif
+ input_codename = "";
+#ifdef WIN32DLL
+ reinitdll();
+#endif /*WIN32DLL*/
}
#endif
{
fprintf(stderr,"nkf internal module connection failure.\n");
exit(1);
+ return 0; /* LINT */
}
#ifndef PERL_XS
+#ifdef WIN32DLL
+#define fprintf dllprintf
+#endif
void
usage()
{
,NKF_VERSION,NKF_RELEASE_DATE);
fprintf(stderr,"\n%s\n",CopyRight);
}
-#endif
+#endif /*PERL_XS*/
/**
** \e$B%Q%C%A@):n<T\e(B