//#include "javacall.h"
#include "applet1.h"
//JNIEXPORT jint JNICALL Java_javacall_GetDES (JNIEnv *, jclass, jint p,jint k,jint z)
JNIEXPORT jint JNICALL Java_Applet1_GetDES(JNIEnv *, jclass, jint p,jint k,jint z)
{
int res=GetDES(p,k,z);
return res;
}
jstring convertANSIToUNI(JNIEnv *env,char* cStr)
{
int slen = strlen(cStr);
if(!env||slen==0)
return NULL;
jchar* buffer = new jchar[slen];
int len = MultiByteToWideChar(CP_ACP,0,cStr,strlen(cStr),(LPWSTR)buffer,slen);
if(len>0 && len < slen)
buffer[len]='\0';
jstring js = env->NewString(buffer,len);
delete [] buffer;
return js;
}
void convertUniToANSI(JNIEnv *env,jstring oldStr,char* newStr)
{
int desc_len=256*2;
int len;
if(oldStr==NULL||newStr==NULL)
return ;
wchar_t *w_buffer = new wchar_t[256];
wcscpy(w_buffer,(LPWSTR)env->GetStringChars(oldStr,0));
env->ReleaseStringChars(oldStr,(jchar *)w_buffer);
len = WideCharToMultiByte(CP_ACP,0,w_buffer,1024,newStr,desc_len,NULL,NULL);
if(len>0 && len<desc_len)
{
newStr[len]='\0';
}
delete[] w_buffer;
}
JNIEXPORT jstring JNICALL Java_Applet1_ReadIC(JNIEnv * env,jclass,jint l,jint k,jint m)
{
jstring js;
CString CSjs;
CSjs="12345678";
CSjs=ReadICrCS(l,k,m);
AfxMessageBox(CSjs);
char *cCSjs;
cCSjs=CSjs.GetBuffer();
js=convertANSIToUNI(env,cCSjs);
return js;
}
JNIEXPORT jint JNICALL Java_Applet1_WriteIC(JNIEnv *env,jclass,jint l,jint k,jstring iw,jint m)
{
char chContext[3000];
convertUniToANSI(env,iw,chContext);
CString iwCS;
iwCS.Format(_T("%s"),chContext);
AfxMessageBox(iwCS);
int res=WriteICrCS(l,k,iwCS,m);
return res;
}