int is_hotword(wchar wc,const char *path)
{
char filename[100]="\0";
sprintf(filename,"%s/%s",path,"hotword.txt");
static FILE *fp=NULL;
static char hotword[256]="\0";
if(!fp)
{
fp=fopen(filename,"rt");
char buffer[256]="\0";
while (fgets(buffer, sizeof(buffer) - 1, fp) > 0)
{
char *pvalue = (char *)memchr(buffer, '\t', sizeof(buffer));
int ikeylen = (pvalue - buffer) > MAX_WORD_LEN ? MAX_WORD_LEN : (pvalue - buffer);
char tmpword[10]="\0";
memcpy(tmpword , buffer ,ikeylen);
sprintf(hotword,"%s%s",hotword,tmpword);
}
}
size_t inlen = 1*sizeof (wchar );
size_t outlen = MAX_WORD_LEN;
char key[10]="\0";
char word[10]="\0";
memcpy (word, &wc , sizeof (wchar));
CODE_CONVERT_T::w2g(word, inlen, key, outlen);
if ( strstr (key,hotword)!=NULL )
{
return 1;
}
else
{
return 0;
}
}