home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2001 January
/
VPR0101A.BIN
/
OLS
/
TAR32053
/
tar32053.exe
/
SRC
/
NKF.C
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-23
|
2KB
|
73 lines
#ifndef __DEFCONF_H
#include "defconf.h"
#endif
/* nkf.c */
#ifdef USE_NKF_DLL
#include "nkf.h"
#include <windows.h>
static char *NKF_DLL_NAME="NKF32.DLL";
static EXIST_NKF=0; /* NKFが存在するか?*/
static FIRST_NKF=1; /* 関数が呼ばれたのが一番最初か?*/
static char nkf_option[100];
/* WINAPI=FAR PASCAL */
static void (WINAPI *OrigGetNkfVersion)(LPSTR verStr);
static int (WINAPI *OrigSetNkfOption)(LPCSTR optStr);
static void (WINAPI *OrigNkfConvert)(LPSTR outStr,LPCSTR inStr);
void GetNkfVersion(char * verStr)
{
if(FIRST_NKF){init_nkf();}
if(EXIST_NKF==0){
strcpy(verStr,"");
}else{
OrigGetNkfVersion(verStr);
}
}
int SetNkfOption(const char * optStr)
{
if(FIRST_NKF){init_nkf();}
if(EXIST_NKF==0){
return -1;
}else{
strcpy(nkf_option,optStr);
OrigSetNkfOption(optStr);
}
}
void NkfConvert(char * outStr,const char * inStr)
{
if(FIRST_NKF){init_nkf();}
/* オプションがない時は変換しない。*/
if(EXIST_NKF==0 || strcmp(nkf_option,"")==0){
strcpy(outStr,inStr);
}else{
OrigNkfConvert(outStr,inStr);
}
}
int init_nkf(void)
{
HINSTANCE hLib;
if(EXIST_NKF==1){return 0;}
FIRST_NKF=0;
hLib=LoadLibrary(NKF_DLL_NAME);
if(hLib<(HINSTANCE)HINSTANCE_ERROR){
return -1;
}
OrigGetNkfVersion=(void (WINAPI *)(LPSTR verStr))GetProcAddress(hLib,"GetNkfVersion");
OrigSetNkfOption=(int (WINAPI *)(LPCSTR optStr))GetProcAddress(hLib,"SetNkfOption");
OrigNkfConvert=(void (WINAPI *)(LPSTR outStr,LPCSTR inStr))GetProcAddress(hLib,"NkfConvert");
if(OrigGetNkfVersion==NULL || OrigSetNkfOption==NULL || OrigNkfConvert==NULL){
return -1;
}
EXIST_NKF=1;
return 0;
}
#endif /*USE_NKF_DLL*/