Codec::Result Codec_UTF8::Encoder::FeedChar(char ch, char &chConv) { UChar _ch = static_cast<UChar>(ch); if (GetAddcrFlag() && _ch == '\n') { StoreChar('\n'); chConv = '\r'; return RESULT_Complete; } if (_cntTrails > 0) { if ((_ch & 0xc0) != 0x80) return RESULT_Error; _cntTrails--; } else if ((_ch & 0x80) == 0x00) { // nothing to do } else if ((_ch & 0xe0) == 0xc0) { _cntTrails = 1; } else if ((_ch & 0xf0) == 0xe0) { _cntTrails = 2; } else if ((_ch & 0xf8) == 0xf0) { _cntTrails = 3; } else if ((_ch & 0xfc) == 0xf8) { _cntTrails = 4; } else if ((_ch & 0xfe) == 0xfc) { _cntTrails = 5; } else { return RESULT_Error; } chConv = ch; return RESULT_Complete; }
/* 功能:第二次确认指纹并注册指纹 成功返回SUCCESS,失败返回错误码 */ int Java_xwp_jr_Fingerprint_SecondReg(JNIEnv *env, jclass thiz) { int ret = ACK_NOFINGER; int count = 0; if(OPENED != fd_status) { LOGE("设备未打开"); goto EXIT; } while(ret == ACK_NOFINGER) { if(count > OVERTIME) break; LOGI("获取第二次指纹中。。。。"); ret = GetImage(); count++; usleep(DELAYTIME); } if(ret != SUCCESS) { LOGE("第二次获取指纹失败。。。"); goto EXIT; } ret = GenChar(charbuffer2); if(ret != SUCCESS) { LOGE("生成指纹特征库失败"); goto EXIT; } ret = RegModel(); if(ret != SUCCESS) { LOGE("合并指纹失败"); goto EXIT; } ret = StoreChar(charbuffer2, finger_id); if(ret != SUCCESS) { LOGE("存储指纹失败"); goto EXIT; } finger_id++; LOGI("注册指纹总数:%d", finger_id); EXIT: status = VERIFY; return ret; }
Codec::Result Codec_USASCII::Encoder::FeedChar(char ch, char &chConv) { // acceptable character code is between 0x00 and 0x7f if (ch & 0x80) return RESULT_Error; if (GetAddcrFlag() && ch == '\n') { StoreChar('\n'); chConv = '\r'; } else { chConv = ch; } return RESULT_Complete; }
/************************************************************************ * * CharHandler - WM_CHAR handler * ************************************************************************/ void CharHandler( HWND hWnd, WORD wParam ) { unsigned char ch = (unsigned char)wParam; // // Because DBCS characters are usually generated by IMEs (as two // PostMessages), if a lead byte comes in, the trail byte should // arrive very soon after. We wait here for the trail byte and // store them into the text buffer together. if ( IsDBCSLeadByte( ch ) ) { // // Wait an arbitrary amount of time for the trail byte to // arrive. If it doesn't, then discard the lead byte. // // This could happen if the IME screwed up. Or, more likely, // the user generated the lead byte through ALT-numpad. // MSG msg = {0}; int i = 10; while (!PeekMessage((LPMSG)&msg, hWnd, WM_CHAR, WM_CHAR, PM_REMOVE)) { if ( --i == 0 ) return; Yield(); } StoreDBCSChar( hWnd, (WORD)(((unsigned)(msg.wParam)<<8) | (unsigned)ch )); } else { switch( ch ) { case '\r': case '\t': case '\b': // // Throw away. Already handled at WM_KEYDOWN time. // break; default: StoreChar( hWnd, ch ); break; } } }
/* 功能:两次确认指纹并注册指纹 成功返回SUCCESS,失败返回错误码 */ int Java_xwp_jr_Fingerprint_FingerReg(JNIEnv *env, jclass thiz) { int ret = ACK_NOFINGER; int count = 0; if(OPENED != fd_status) { LOGE("设备未打开"); ret = -1; goto EXIT; } status = REGISTER; LOGI("开始注册指纹"); usleep(DELAYTIME); while(ret == ACK_NOFINGER) { if(count > OVERTIME) break; ret = GetImage(); LOGI("获取第一次指纹中。。。。"); count++; usleep(DELAYTIME); } if(ret != SUCCESS) { LOGE("第一次获取指纹失败"); goto EXIT; } ret = GenChar(charbuffer1); if(ret != SUCCESS) { LOGE("第一次生成指纹库失败"); goto EXIT; } ret = ACK_NOFINGER; count = 0; while(ret == ACK_NOFINGER) { if(count > OVERTIME) break; ret = GetImage(); LOGI("获取第二次指纹中。。。。"); count++; usleep(DELAYTIME); } if(ret != SUCCESS) { LOGE("第二次获取指纹失败"); goto EXIT; } ret = GenChar(charbuffer2); if(ret != SUCCESS) { LOGE("第二次生成指纹库失败"); goto EXIT; } ret = RegModel(); if(ret != SUCCESS) { LOGE("合并指纹库失败"); goto EXIT; } ret = StoreChar(charbuffer2, finger_id); if(ret != SUCCESS) { LOGE("储存指纹库失败"); goto EXIT; } finger_id++; LOGI("注册指纹总数:%d", finger_id); EXIT: LOGI("注册指纹返回值ret : 0x%x", ret); status = VERIFY; return ret; }