/** 冲正交易处理过程 假定pBankTrans里已经填好了交易数据(在bankguard.cpp里调用) 银行返回结果仍存放在pBankTrans里 */ int Do_DeTrans (T_t_tif_tradeserial *tradeserial,BANK_TRANS_REQUEST *pBankTrans ) { //TODO: 发送冲正记录.注意填空格 writelog(LOG_INFO,"补发冲正", ret); //组织银行包 //memset(pBankTrans, ' ', sizeof(bank_trans)); //写交易代码 strnscpy( pBankTrans->TradeCode,TRADE_BANK_DETRANS, BANK_TRADE_CODE_LEN); //写交易日期和交易时间 strnscpy(pBankTrans->TradeDate,tradeserial.operate_date,sizeof(pBankTrans->TradeDate)); strnscpy(pBankTrans->TradeTime,tradeserial.operate_time,sizeof(pBankTrans->TradeTime)); //改成校园卡卡号 sprintf(pBankTrans->CustAccountNo,"%-10d",tradeserial.card_id); //写银行卡号字段 strnscpy(pBankTrans->BankCardNo,tradeserial.b_act_id, sizeof(pBankTrans->BankCardNo)); //写商户号字段 strnscpy(pBankTrans->MercAccount,SCHOOL_ACCOUNT_NO,sizeof(pBankTrans->MercAccount)); //写转帐金额字段 sprintf(pBankTrans->TransMoney,"%-9d", int(tradeserial.trade_fee)); //写银行卡密码字段!!!oldpwd? or pwd in shm? strnscpy(pBankTrans->BankCardPwd, tradeserial.oldpwd,sizeof(pBankTrans->BankCardPwd)); //写校园端流水号!!!serial_no or ReviseSerial_no? f? sprintf(pBankTrans->CustSn,"%-8d",tradeserial.other_seri_no); //sprintf(bank_trans.BankSn, //写院校代码 sprintf(pBankTrans->CustNo,"%-16s",SCHOOL_CODE); //写校验mac码 generate_mac((char*)pBankTrans,BANK_TRANS_PACKLEN,pBankTrans->MAC); BANK_TRANS_REQUEST BankTransPak; memcpy((void*)&BankTransPak, (void*)pBankTrans, BANK_TRANS_PACKLEN); //做必要的数据预处理 TRACE_BANK_TRANS(&BankTransPak,"send detrans package"); int ret = send_to_and_recv_from_bank((char*)&BankTransPak, BANK_TRANS_PACKLEN, (char*)&BankTransPak, BANK_TRANS_PACKLEN,0); if(ret != 0) return ret; TRACE_BANK_TRANS(&BankTransPak,"recv detrans package"); memcpy((char*)pBankTrans, (char*)&BankTransPak, BANK_TRANS_PACKLEN); // 调用者应该处理银行返回的BankSn return 0; }
int config_update_file() { sprintf(txtbuffer, "%sswiss.ini", deviceHandler_initial->name); FILE *fp = fopen( txtbuffer, "wb" ); if(fp) { // Write out header every time char *str = "# Swiss Configuration File!\r\n# Anything written in here will be lost!\r\n\r\n#!!Swiss Settings Start!!\r\n"; fwrite(str, 1, strlen(str), fp); // Write out Swiss settings sprintf(txtbuffer, "Default Device=%s\r\n",(configSwissSettings.defaultDevice ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "SD/IDE Speed=%s\r\n",(configSwissSettings.exiSpeed ? "32MHz":"16MHz")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Swiss Video Mode=%s\r\n",(uiVModeStr[configSwissSettings.uiVMode])); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Enable Debug=%s\r\n",(configSwissSettings.debugUSB ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Force No DVD Drive Mode=%s\r\n",(configSwissSettings.hasDVDDrive ? "No":"Yes")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Hide Unknown file types=%s\r\n",(configSwissSettings.hideUnknownFileTypes ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Stop DVD Motor on startup=%s\r\n",(configSwissSettings.stopMotor ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Enable WiiRD debug=%s\r\n",(configSwissSettings.wiirdDebug ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Enable File Management=%s\r\n",(configSwissSettings.enableFileManagement ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "SMBUserName=%s\r\n",configSwissSettings.smbUser); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "SMBPassword=%s\r\n",configSwissSettings.smbPassword); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "SMBShareName=%s\r\n",configSwissSettings.smbShare); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "SMBHostIP=%s\r\n",configSwissSettings.smbServerIp); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "#!!Swiss Settings End!!\r\n\r\n"); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); // Write out Game Configs int i; for(i = 0; i < configEntriesCount; i++) { char buffer[256]; strnscpy(buffer, &configEntries[i].game_id[0], 4); sprintf(txtbuffer, "ID=%s\r\n",buffer); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); strnscpy(buffer, &configEntries[i].game_name[0], 32); sprintf(txtbuffer, "Name=%s\r\n",buffer); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); strnscpy(buffer, &configEntries[i].comment[0], 128); sprintf(txtbuffer, "Comment=%s\r\n",buffer); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); strnscpy(buffer, &configEntries[i].status[0], 32); sprintf(txtbuffer, "Status=%s\r\n",buffer); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Force Video Mode=%s\r\n",uiVModeStr[configEntries[i].gameVMode]); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Soft Progressive=%s\r\n",softProgressiveStr[configEntries[i].softProgressive]); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Mute Audio Streaming=%s\r\n",(configEntries[i].muteAudioStreaming ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Force Widescreen=%s\r\n",forceWidescreenStr[configEntries[i].forceWidescreen]); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Force Anisotropy=%s\r\n",(configEntries[i].forceAnisotropy ? "Yes":"No")); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); sprintf(txtbuffer, "Force Encoding=%s\r\n\r\n\r\n",forceEncodingStr[configEntries[i].forceEncoding]); fwrite(txtbuffer, 1, strlen(txtbuffer), fp); } fclose(fp); return 1; } return 0; }