📄 main.c
字号:
#include "./Indonesia/General.h"
#include "./tiELib.h"
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#include <stdlib.h>
#define MENU_TEST_CANCEL 0
#define MENU_CHAR_INPUT_S 1
#define MENU_CHAR_INPUT_L 2
#define WORD_INPUT_S 3
#define WORD_FIRSTCAP 4
#define WORD_ALLCAP 5
#define MENU_TEST_ENG_MANUAL 6
U16 count_input_simu;
U16 fnKeyInputSimu(U16 count_input_simu);
static char csKeyInput[30];
int Indonesia_count_result;
U16 pycount_result;
U16 cscount_result;
unsigned short csearchresult[10];
unsigned short wordsearchresult[LEN_INDONESIA_WORD_RESULT];
unsigned short wordsearchresult_bak1[LEN_INDONESIA_WORD_RESULT];
unsigned short wordsearchresult_bak2[LEN_INDONESIA_WORD_RESULT];
int showAlternate_char();
int showAlternate_word();
int main()
{//(1)
//unsigned short csearchresult[10];
//unsigned short wordsearchresult[LEN_Indonesia_WORD_RESULT];
//unsigned short wordsearchresult_bak1[LEN_Indonesia_WORD_RESULT];
//unsigned short wordsearchresult_bak2[LEN_Indonesia_WORD_RESULT];
char input;
char wordinput[LEN_INDONESIA_WORD_INPUT];
int input_count=0;
int ret=0;
int mode_sel=0;
int i=0;
void *dp_energy;
/***** DLL OPEN FOR TEXTINPUT API **************************/
if ( (dp_energy = dlopen("./Indonesia.so",RTLD_LAZY)) == NULL )
{
printf("\nError !!! can't open dp_Indonesia");
}
if ( (Indonesia_char_input_S= dlsym(dp_energy,"Indonesia_char_input_S")) == NULL )
{
printf("\nError !!! can't open Indonesia_char_input_S");
}
if ( (Indonesia_char_input_L = dlsym(dp_energy,"Indonesia_char_input_L")) == NULL )
{
printf("\nError !!! can't open Indonesia_char_input_L");
}
if ( (Indonesia_word_input = dlsym(dp_energy,"Indonesia_word_input")) == NULL )
{
printf("\nError !!! can't open Indonesia_word_input");
}
if ( (sm_cap=dlsym(dp_energy,"sm_cap"))==NULL)
{
printf("\nError !!!can't open sm_cap");
}
/*
if ( (fnEnglishSearch = dlsym(dp_energy,"fnEnglishSearch")) == NULL )
{
printf("\nError !!! can't open fnEnglishSearch");
}
if ( (fnEnCapSel = dlsym(dp_energy,"fnEnCapSel")) == NULL )
{
printf("\nError !!! can't open fnEnCapSel");
}
*/
//-- show menu --//
printf("\n*****************************************************");
printf("\n**** Please select the test mode *******");
printf("\n*****************************************************");
printf("\n*** 1: char_input_S test ... ***");
printf("\n*** 2: char_input_L test ... ***");
printf("\n**** 3: word_input_s test ... ****");
printf("\n**** 4: word_firstcap test ... ****");
printf("\n**** 5: word_allcap test ... ****");
//printf("\n*** 6: eng manual test ... ****");
printf("\n****************************************************\n>");
scanf("%d",&mode_sel);
switch ( mode_sel ) {
case MENU_CHAR_INPUT_S :
while(1){
printf("please input the key!\n");
scanf(" %c",&input);
ret=Indonesia_char_input_S(input,csearchresult);
if (ret==0) {
printf("you input key is :<%c>\n",input);
printf("the Indonesia_count_result is <%d>\n",Indonesia_count_result);
printf("the key corresponding Indonesia char is:\n");
i=0;
while (csearchresult[i]!=0) {
printf("(%d)0x%x ",i+1,csearchresult[i]);
i++;
}
printf("\n"); // show_char();
showAlternate_char();
}
else
printf("you input the wrong key!\n");
}
break;
case MENU_CHAR_INPUT_L:
while(1){
printf("please input the key!\n");
scanf(" %c",&input);
ret=Indonesia_char_input_L(input,csearchresult);
if (ret==0) {
printf("you input key is :<%c>\n",input);
printf("the Indonesia_count_result is <%d>\n",Indonesia_count_result);
printf("the key corresponding Indonesia char is:\n");
i=0;
while (csearchresult[i]!=0) {
printf("(%d)0x%x ",i+1,csearchresult[i]);
i++;
}
printf("\n"); // show_char();
showAlternate_char();
}
else
printf("you input the wrong key!\n");
}
break;
case WORD_INPUT_S://Indonesia词语输入测试;
memset(wordinput,SET_CLEAR,LEN_INDONESIA_WORD_INPUT);//将wordinput前50字符清空;woudinput已经定义为50长度的数组;
memset(wordsearchresult,SET_CLEAR,LEN_INDONESIA_WORD_RESULT<<1);//将wordsearchresult前100字符清空;wordsearchresult已经定义为100长度的数组;
while(1){
printf("please input the key!\n");
scanf(" %c",&wordinput[input_count]);//按照您上句输入的字符存入wordinput数组中;
ret=Indonesia_word_input(wordinput,wordsearchresult);
if (ret==0) {
printf("you input the :");
i=0;
while(wordinput[i]!='\0')
printf("<%c>",wordinput[i++]);
printf("\nIndonesia_count_result is (%d)\n",Indonesia_count_result);
printf("the Indonesia word is:\n");
for(i=0;i<100;i++)
{
printf("(%d)0x%x ",i+1,wordsearchresult[i]);
}
printf("\n");
showAlternate_word();
input_count++; // show_word();
}
else
printf("you input the wrong key!\n");
}
break;
case WORD_FIRSTCAP:
memset(wordinput,SET_CLEAR,LEN_INDONESIA_WORD_INPUT);//将wordinput前50字符清空;woudinput已经定义为50长度的数组;
memset(wordsearchresult,SET_CLEAR,LEN_INDONESIA_WORD_RESULT<<1);//将wordsearchresult前100字符清空;wordsearchresult已经定义为100长度的数组;
memset(wordsearchresult_bak1,SET_CLEAR,LEN_INDONESIA_WORD_RESULT<<1);
while ( 1 ) {
printf("please input the key!\n");
scanf(" %c",&wordinput[input_count]);
ret=Indonesia_word_input(wordinput,wordsearchresult);
sm_cap(WORD_FIRSTCAP,wordsearchresult);
memcpy(wordsearchresult_bak1,wordsearchresult,LEN_INDONESIA_WORD_RESULT<<1);
if ( ret == 0 )
{
printf("you input the :");
i=0;
while(wordinput[i]!='\0')
printf("<%c>",wordinput[i++]);
printf("\nIndonesia_count_result is (%d)\n",Indonesia_count_result);
printf("the Indonesia word is:\n");
for(i=0;i<100;i++)
{
printf("(%d)0x%x ",i+1,wordsearchresult_bak1[i]);
}
printf("\n");
showAlternate_word();
input_count++; // show_word();
}
else
printf("you input the wrong key!\n");
}
break;
case WORD_ALLCAP:
memset(wordinput,SET_CLEAR,LEN_INDONESIA_WORD_INPUT);//将wordinput前50字符清空;woudinput已经定义为50长度的数组;
memset(wordsearchresult,SET_CLEAR,LEN_INDONESIA_WORD_RESULT<<1);//将wordsearchresult前100字符清空;wordsearchresult已经定义为100长度的数组;
memset(wordsearchresult_bak2,SET_CLEAR,LEN_INDONESIA_WORD_RESULT<<1);
while ( 1 ) {
printf("please input the key!\n");
scanf(" %c",&wordinput[input_count]);
ret=Indonesia_word_input(wordinput,wordsearchresult);
sm_cap(WORD_ALLCAP,wordsearchresult);
memcpy(wordsearchresult_bak2,wordsearchresult,LEN_INDONESIA_WORD_RESULT<<1);
if ( ret == 0)
{
printf("you input the :");
i=0;
while(wordinput[i]!='\0')
printf("<%c>",wordinput[i++]);
printf("\nIndonesia_count_result is (%d)\n",Indonesia_count_result);
printf("the Indonesia word is:\n");
for(i=0;i<100;i++)
{
printf("(%d)0x%x ",i+1,wordsearchresult_bak2[i]);
}
printf("\n");
showAlternate_word();
input_count++; // show_word();
}
else
printf("you input the wrong key!\n");}
break;
default:
break;
}
return 0;
}
/********************************************************/
/* get keyinput of the keypad */
/********************************************************/
U16 fnKeyInputSimu(U16 count_input_simu) {
char i;
printf("\nPlease enter key.. ");
scanf("%16d",&csKeyInput[count_input_simu]);
printf("\n your keyinput is:");
for ( i=0;i<strlen(csKeyInput);i++ ) {
printf("(%d) ",csKeyInput[i]);
}
}
//************************************测试程序中分词符************************************//
int showAlternate_word()
{
U16 i;
FILE *ffp;
printf("\n:Fuction showAlternate()\n");
if ( (ffp=fopen("./showalternate","w")) == NULL ) {
printf("\nError!! can't open showalternate");
}
fputc(0xFF,ffp);
fputc(0xFE,ffp);
for ( i=0;i<LEN_INDONESIA_WORD_RESULT;i++ ) {
fwrite(&wordsearchresult[i],2,1,ffp);
}
fclose(ffp);
return 0;
}
int showAlternate_char()
{
U16 i;
FILE *ffp;
printf("\n:Fuction showAlternate()\n");
if ( (ffp=fopen("./showalternate","w")) == NULL )
{
printf("\nError!! can't open showalternate");
}
fputc(0xFF,ffp);
fputc(0xFE,ffp);
for ( i=0;i<10;i++ )
{
fwrite(&csearchresult[i],2,1,ffp);
}
fclose(ffp);
return 0;
}
/**********************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -