FX_BOOL CPDF_SecurityHandler::CheckSecurity(int32_t key_len) { CFX_ByteString password = m_pParser->GetPassword(); if (!password.IsEmpty() && CheckPassword(password.raw_str(), password.GetLength(), TRUE, m_EncryptKey, key_len)) { m_bOwnerUnlocked = true; return TRUE; } return CheckPassword(password.raw_str(), password.GetLength(), FALSE, m_EncryptKey, key_len); }
FX_BOOL CPDF_StandardSecurityHandler::CheckSecurity(FX_INT32 key_len) { CFX_ByteString password = m_pParser->GetPassword(); if (CheckPassword(password, password.GetLength(), TRUE, m_EncryptKey, key_len)) { if (password.IsEmpty()) { if (!CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey, key_len)) { return FALSE; } } m_bOwner = TRUE; return TRUE; } return CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey, key_len); }
BOOL TPasswordDlg::EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl) { switch (wID) { case IDOK: { char _buf[MAX_NAMEBUF]; char *buf = outbuf ? outbuf : _buf; GetDlgItemTextU8(PASSWORD_EDIT, buf, MAX_NAMEBUF); if (cfg) { if (CheckPassword(cfg->PasswordStr, buf)) EndDialog(TRUE); else SetDlgItemTextU8(PASSWORD_EDIT, ""), MessageBoxU8(GetLoadStrU8(IDS_CANTAUTH)); } else EndDialog(TRUE); } return TRUE; case IDCANCEL: EndDialog(FALSE); return TRUE; } return FALSE; }
void DecryptDB() { char oldKey[255]; strcpy(oldKey, encryptKey); if(!CheckPassword(dbHeader.checkWord, Translate("current database"))){strcpy(encryptKey, oldKey); encryptKeyLength = strlen(oldKey); return;} WritePlainHeader(); EnterCriticalSection(&csDbAccess); DecodeAll(); LeaveCriticalSection(&csDbAccess); bEncoding = 0; zero_fill(encryptKey, sizeof encryptKey); if (gl_bUnicodeAwareCore) xModifyMenu(hSetPwdMenu, 0, LPGENT("Set Password"), 0); else xModifyMenu(hSetPwdMenu, 0, (TCHAR*) LPGEN("Set Password"), 0); //ugly hack DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0); CryptoEngine->FreeKey(key); CryptoEngine = NULL; }
bool CMac::AddLogin(CString sUsername, CString sPassword, CString sIRCUsername, CString sHost, CString sIdentd) { if(FindLogin(sIRCUsername)) return false; user *pUser=FindUser(sUsername); if(!pUser) return false; if(pUser) if(CheckPassword(sPassword, pUser)) { if(pUser->sHost.Compare("")) if(!strstr(sHost.CStr(), pUser->sHost.CStr())) return false; login *pLogin=new login; pLogin->pUser=pUser; pLogin->sUsername=sUsername; pLogin->sIRCUsername=sIRCUsername; llStart.push_back(pLogin); return true; } return false; }
// CompareCredentials: Checks provided LoginCredential's username and password // against *this. bool LoginCredentials::CompareCredentials(LoginCredentials loginB) { // Check Username & Password of loginB against this. if(!CheckUserName(loginB.GetUserName())) return false; if(!CheckPassword(loginB.GetPassword())) return false; return true; }
bool LoginCredentials::CompareCredentials(std::string user, std::string pass) { // Check provided Username & Password against this. if(!CheckUserName(user)) return false; if(!CheckPassword(pass)) return false; return true; }
bool CUserCryptoManager::CheckUser(const wchar_t *pszUser, const wchar_t *pszPassword) { if(m_UserMode == eNoneMode) return true; if(m_UserMode == ePasswordMode) return CheckPassword(pszPassword); return false; }
void CPasswordDlg::OnOK() { UpdateData(TRUE); // TODO: Add extra validation here if (m_bSetPassword) { char temp[MAX_PATH]; ZeroMemory(temp, MAX_PATH); WideCharToMultiByte(CP_ACP,0,m_OldPassword,m_OldPassword.GetLength(), temp, MAX_PATH, NULL, NULL); if (!CheckPassword("Administrator",temp)) { AfxMessageBox(IDS_INVALID_PASSWORD); return; } if (m_Password != m_PasswordConfirm) { AfxMessageBox(IDS_PASSWORD_MATCH); return; } ZeroMemory(temp, MAX_PATH); WideCharToMultiByte(CP_ACP,0,m_Password,m_Password.GetLength(), temp, MAX_PATH, NULL, NULL); SavePassword("Administrator",temp,TRUE); } else { char temp[MAX_PATH]; ZeroMemory(temp, MAX_PATH); WideCharToMultiByte(CP_ACP,0,m_Password,m_Password.GetLength(), temp, MAX_PATH, NULL, NULL); if (!CheckPassword("Administrator",temp)) { AfxMessageBox(IDS_INVALID_PASSWORD); return; } } CDialog::OnOK(); }
BOOL TSetupSheet::CheckData() { char buf[MAX_PATH_U8]; int val; if (resId == SETUP_SHEET3) { GetDlgItemTextU8(LRUUSER_EDIT, buf, sizeof(buf)); if ((val = atoi(buf)) > MAX_LRUUSER || val < 0) { MessageBox(FmtStr(GetLoadStr(IDS_TOOMANYLRU), MAX_LRUUSER)); return FALSE; } } else if (resId == SETUP_SHEET4) { GetDlgItemTextU8(LOG_EDIT, buf, sizeof(buf)); if (GetDriveType(NULL) == DRIVE_REMOTE && !SendDlgItemMessage(LOG_CHECK, BM_GETCHECK, 0, 0) && strchr(buf, '\\')) { MessageBox(GetLoadStr(IDS_LOGALERT)); return FALSE; } } else if (resId == SETUP_SHEET5) { char buf1[MAX_NAMEBUF], buf2[MAX_NAMEBUF], buf3[MAX_NAMEBUF]; GetDlgItemTextU8(OLDPASSWORD_EDIT, buf1, sizeof(buf1)); GetDlgItemTextU8(NEWPASSWORD_EDIT, buf2, sizeof(buf2)); GetDlgItemTextU8(NEWPASSWORD_EDIT2, buf3, sizeof(buf3)); if (strcmp(buf2, buf3) != 0) { MessageBoxU8(GetLoadStrU8(IDS_NOTSAMEPASS)); return FALSE; } if (!CheckPassword(cfg->PasswordStr, buf1)) { if (*buf1 || *buf2 || *buf3) { SetDlgItemTextU8(PASSWORD_EDIT, ""); MessageBoxU8(GetLoadStrU8(IDS_CANTAUTH)); return FALSE; } } } return TRUE; }
/************************************************************************** * * FUNCTION NAME: ProcessRegisterDialog * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ MRESULT EXPENTRY ProcessRegisterDialog (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { CHAR szID[50]; switch (msg) { case WM_INITDLG : /* Center the dialog box in the frame window of the parent */ CenterDialog (hwnd); return (0); case WM_COMMAND : switch (SHORT1FROMMP (mp1)) { case DID_OK: WinQueryDlgItemText (hwnd, REG_NAME_ID, REGISTER_NAME_LEN, gszRegName); WinQueryDlgItemText (hwnd, REG_ID_ID, sizeof(szID), szID); if (CheckPassword (gszRegName, szID)) { /* The password is cool! Save the settings now */ WinDlgBox (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, CONGRATS_DLG_ID, NULL); gfRegistered = TRUE; WriteIniFile (); /* Disable the register menu item now we're registered */ WinEnableMenuItem (hwndMenu, MENU_REGISTER_ID, !gfRegistered); WinDismissDlg (hwnd, DID_OK); } else { WinDlgBox (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, SORRY_DLG_ID, NULL); } return (0); case DID_CANCEL: /* Dismiss the dialog without saving the values */ WinDismissDlg (hwnd, DID_CANCEL); return (0); case DID_HELP: /* Display the keys help panel */ WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, MPFROM2SHORT(PANEL_REGISTER, NULL), MPFROMSHORT(HM_RESOURCEID)); return (0); default: break; } break; default: break; } return (WinDefDlgProc (hwnd, msg, mp1, mp2)); }
void main(int argc, char **argv) { int going=TRUE,forsok=2,car=1; long tid; char tellstr[100],*tmppscreen, titel[80]; UBYTE tillftkn; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKom © Tomas Kärki 1996-1998", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(ERROR,"Kunde inte öppna IO\n"); if(!getkeyfile()) cleanup(ERROR,"Korrupt nyckelfil\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { /* if(!reggadnamn[0] && ((struct ShortUser *)Servermem->user_list.mlh_TailPred)->nummer >= 4) puttekn("\n\n\rDenna demoversion av NiKom kan hantera maximalt 5 användare.\n\r",-1); else { Versionen är nu obegränsad 970930! */ if((car=nyanv())==2) goto panik; going=FALSE; /* } */ } else if((inloggad=parsenamn(inmat))>=0) { readuser(inloggad,&Servermem->inne[nodnr]); forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inloggad, inmat)) { forsok=FALSE; going=FALSE; } else forsok--; } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); readuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { sprintf(outbuffer,"%s loggar ut från nod %d",getusername(inloggad),nodnr); logevent(outbuffer); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendrexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); SaveProgramCategory(inloggad); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; Servermem->inne[nodnr].textpek=textpek; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); writeuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((tillftkn=gettekn())!='n' && tillftkn!='N'); cleanup(OK,""); }
BOOL TSetupSheet::GetData() { char buf[MAX_PATH_U8]; int i; if (resId == SETUP_SHEET1) { BOOL need_broadcast = FALSE; GetDlgItemTextU8(NICKNAME_EDIT, buf, MAX_NAMEBUF); if (strcmp(cfg->NickNameStr, buf)) { need_broadcast = TRUE; strcpy(cfg->NickNameStr, buf); } GetDlgItemTextU8(GROUP_COMBO, buf, MAX_NAMEBUF); if (strcmp(cfg->GroupNameStr, buf)) { need_broadcast = TRUE; strcpy(cfg->GroupNameStr, buf); } if (need_broadcast) { ::PostMessage(GetMainWnd(), WM_IPMSG_BRNOTIFY, 0, IPMSG_DEFAULT_PORT); } if (SendDlgItemMessage(CLIPMODE_CHECK, BM_GETCHECK, 0, 0)) { cfg->ClipMode |= CLIP_ENABLE; } else { cfg->ClipMode &= ~CLIP_ENABLE; } if (SendDlgItemMessage(CLIPCONFIRM_CHECK, BM_GETCHECK, 0, 0)) { cfg->ClipMode |= CLIP_CONFIRM; } else { cfg->ClipMode &= ~CLIP_CONFIRM; } cfg->brList.Reset(); for (i=0; SendDlgItemMessage(BROADCAST_LIST, LB_GETTEXT, i, (LPARAM)buf) != LB_ERR; i++) cfg->brList.SetHostRaw(buf, ResolveAddr(buf)); cfg->DialUpCheck = (int)SendDlgItemMessage(DIALUP_CHECK, BM_GETCHECK, 0, 0); } else if (resId == SETUP_SHEET2) { cfg->BalloonNotify = (int)SendDlgItemMessage(BALLOONNOTIFY_CHECK, BM_GETCHECK, 0, 0); cfg->OpenCheck = (int)SendDlgItemMessage(OPEN_COMBO, CB_GETCURSEL, 0, 0); // cfg->OpenCheck = (int)SendDlgItemMessage(OPEN_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(QUOTE_EDIT, cfg->QuoteStr, sizeof(cfg->QuoteStr)); cfg->HotKeyCheck = (int)SendDlgItemMessage(HOTKEY_CHECK, BM_GETCHECK, 0, 0); cfg->AbnormalButton = (int)SendDlgItemMessage(ABNORMALBTN_CHECK, BM_GETCHECK, 0, 0); if (::IsWindowEnabled(GetDlgItem(LCID_CHECK))) { cfg->lcid = IsDlgButtonChecked(LCID_CHECK) ? 0x409 : -1; } cfg->ExtendBroadcast = (int)SendDlgItemMessage(EXTBROADCAST_COMBO, CB_GETCURSEL, 0, 0); GetDlgItemTextU8(MAINICON_EDIT, cfg->IconFile, sizeof(cfg->IconFile)); GetDlgItemTextU8(REVICON_EDIT, cfg->RevIconFile, sizeof(cfg->RevIconFile)); ::SendMessage(GetMainWnd(), WM_IPMSG_INITICON, 0, 0); SetDlgIcon(hWnd); SetHotKey(cfg); } else if (resId == SETUP_SHEET3) { cfg->QuoteCheck = (int)SendDlgItemMessage(QUOTE_CHECK, BM_GETCHECK, 0, 0); cfg->SecretCheck = (int)SendDlgItemMessage(SECRET_CHECK, BM_GETCHECK, 0, 0); cfg->OneClickPopup = (int)SendDlgItemMessage(ONECLICK_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(LRUUSER_EDIT, buf, sizeof(buf)); cfg->lruUserMax = atoi(buf); // ControlIME ... 0:off, 1:senddlg on (finddlg:off), 2:always on cfg->ControlIME = (int)SendDlgItemMessage(CONTROLIME_CHECK, BM_GETCHECK, 0, 0); if (cfg->ControlIME && SendDlgItemMessage(FINDDLGIME_CHECK, BM_GETCHECK, 0, 0) == 0) { cfg->ControlIME = 2; } cfg->NoPopupCheck = (int)SendDlgItemMessage(NOPOPUP_CHECK, BM_GETCHECK, 0, 0); cfg->NoBeep = (int)SendDlgItemMessage(NOBEEP_CHECK, BM_GETCHECK, 0, 0); cfg->AbsenceNonPopup = (int)SendDlgItemMessage(ABSENCENONPOPUP_CHECK, BM_GETCHECK, 0, 0); cfg->RecvLogonDisp = (int)SendDlgItemMessage(RECVLOGON_CHECK, BM_GETCHECK, 0, 0); cfg->RecvIPAddr = (int)SendDlgItemMessage(RECVIPADDR_CHECK, BM_GETCHECK, 0, 0); cfg->NoErase = (int)SendDlgItemMessage(NOERASE_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(SOUND_EDIT, cfg->SoundFile, sizeof(cfg->SoundFile)); } else if (resId == SETUP_SHEET4) { cfg->LogCheck = (int)SendDlgItemMessage(LOG_CHECK, BM_GETCHECK, 0, 0); cfg->LogonLog = (int)SendDlgItemMessage(LOGONLOG_CHECK, BM_GETCHECK, 0, 0); cfg->IPAddrCheck = (int)SendDlgItemMessage(IPADDR_CHECK, BM_GETCHECK, 0, 0); if (SendDlgItemMessage(IMAGESAVE_CHECK, BM_GETCHECK, 0, 0)) { cfg->ClipMode |= 2; } else { cfg->ClipMode &= ~2; } cfg->LogUTF8 = (int)SendDlgItemMessage(LOGUTF8_CHECK, BM_GETCHECK, 0, 0); cfg->PasswdLogCheck = (int)SendDlgItemMessage(PASSWDLOG_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(LOG_EDIT, cfg->LogFile, sizeof(cfg->LogFile)); if (cfg->LogCheck) LogMng::StrictLogFile(cfg->LogFile); } else if (resId == SETUP_SHEET5) { char buf[MAX_NAMEBUF]; GetDlgItemTextU8(OLDPASSWORD_EDIT, buf, sizeof(buf)); if (CheckPassword(cfg->PasswordStr, buf)) { GetDlgItemTextU8(NEWPASSWORD_EDIT, buf, sizeof(buf)); MakePassword(buf, cfg->PasswordStr); } } else if (resId == SETUP_SHEET6) { cfg->DefaultUrl = (int)SendDlgItemMessage(DEFAULTURL_CHECK, BM_GETCHECK, 0, 0); for (UrlObj *tmp_obj = (UrlObj *)tmpUrlList.TopObj(); tmp_obj; tmp_obj = (UrlObj *)tmpUrlList.NextObj(tmp_obj)) { UrlObj *obj = SearchUrlObj(&cfg->urlList, tmp_obj->protocol); if (!obj) { obj = new UrlObj; cfg->urlList.AddObj(obj); strcpy(obj->protocol, tmp_obj->protocol); } strcpy(obj->program, tmp_obj->program); } cfg->ShellExec = (int)SendDlgItemMessage(SHELLEXEC_CHECK, BM_GETCHECK, 0, 0); } return TRUE; }
void Webserver::GetJsonResponse(const char* request) { jsonPointer = 0; writing = true; if(StringStartsWith(request, "poll")) { strncpy(jsonResponse, "{\"poll\":[", STRING_LENGTH); if(reprap.GetGCodes()->PrintingAFile()) strncat(jsonResponse, "\"P\",", STRING_LENGTH); // Printing else strncat(jsonResponse, "\"I\",", STRING_LENGTH); // Idle float liveCoordinates[DRIVES+1]; reprap.GetMove()->LiveCoordinates(liveCoordinates); for(int8_t drive = 0; drive < AXES; drive++) { strncat(jsonResponse, "\"", STRING_LENGTH); strncat(jsonResponse, ftoa(0, liveCoordinates[drive], 2), STRING_LENGTH); strncat(jsonResponse, "\",", STRING_LENGTH); } // FIXME: should loop through all Es strncat(jsonResponse, "\"", STRING_LENGTH); strncat(jsonResponse, ftoa(0, liveCoordinates[AXES], 4), STRING_LENGTH); strncat(jsonResponse, "\",", STRING_LENGTH); for(int8_t heater = 0; heater < HEATERS; heater++) { strncat(jsonResponse, "\"", STRING_LENGTH); strncat(jsonResponse, ftoa(0, reprap.GetHeat()->GetTemperature(heater), 1), STRING_LENGTH); if(heater < HEATERS - 1) strncat(jsonResponse, "\",", STRING_LENGTH); else strncat(jsonResponse, "\"", STRING_LENGTH); } strncat(jsonResponse, "]", STRING_LENGTH); // Send the Z probe value char scratch[SHORT_STRING_LENGTH+1]; scratch[SHORT_STRING_LENGTH] = 0; if (platform->GetZProbeType() == 2) { snprintf(scratch, SHORT_STRING_LENGTH, ",\"probe\":\"%d (%d)\"", (int)platform->ZProbe(), platform->ZProbeOnVal()); } else { snprintf(scratch, SHORT_STRING_LENGTH, ",\"probe\":\"%d\"", (int)platform->ZProbe()); } strncat(jsonResponse, scratch, STRING_LENGTH); // Send the amount of buffer space available for gcodes snprintf(scratch, SHORT_STRING_LENGTH, ",\"buff\":%u", GetReportedGcodeBufferSpace()); strncat(jsonResponse, scratch, STRING_LENGTH); // Send the home state. To keep the messages short, we send 1 for homed and 0 for not homed, instead of true and false. strncat(jsonResponse, ",\"hx\":", STRING_LENGTH); strncat(jsonResponse, (reprap.GetGCodes()->GetAxisIsHomed(0)) ? "1" : "0", STRING_LENGTH); strncat(jsonResponse, ",\"hy\":", STRING_LENGTH); strncat(jsonResponse, (reprap.GetGCodes()->GetAxisIsHomed(1)) ? "1" : "0", STRING_LENGTH); strncat(jsonResponse, ",\"hz\":", STRING_LENGTH); strncat(jsonResponse, (reprap.GetGCodes()->GetAxisIsHomed(2)) ? "1" : "0", STRING_LENGTH); // Send the response sequence number strncat(jsonResponse, ",\"seq\":", STRING_LENGTH); snprintf(scratch, SHORT_STRING_LENGTH, "%u", (unsigned int)seq); strncat(jsonResponse, scratch, STRING_LENGTH); // Send the response to the last command. Do this last because it is long and may need to be truncated. strncat(jsonResponse, ",\"resp\":\"", STRING_LENGTH); size_t jp = strnlen(jsonResponse, STRING_LENGTH); const char *p = gcodeReply; while (*p != 0 && jp < STRING_LENGTH - 2) // leave room for the final '"}' { char c = *p++; char esc; switch(c) { case '\r': esc = 'r'; break; case '\n': esc = 'n'; break; case '\t': esc = 't'; break; case '"': esc = '"'; break; case '\\': esc = '\\'; break; default: esc = 0; break; } if (esc) { if (jp == STRING_LENGTH - 3) break; jsonResponse[jp++] = '\\'; jsonResponse[jp++] = esc; } else { jsonResponse[jp++] = c; } } strncat(jsonResponse, "\"}", STRING_LENGTH); jsonResponse[STRING_LENGTH] = 0; JsonReport(true, request); return; } if(StringStartsWith(request, "gcode")) { LoadGcodeBuffer(&clientQualifier[6], true); char scratch[SHORT_STRING_LENGTH+1]; scratch[SHORT_STRING_LENGTH] = 0; snprintf(scratch, SHORT_STRING_LENGTH, "{\"buff\":%u}", GetReportedGcodeBufferSpace()); strncat(jsonResponse, scratch, STRING_LENGTH); JsonReport(true, request); return; } if(StringStartsWith(request, "files")) { char* fileList = platform->GetMassStorage()->FileList(platform->GetGCodeDir(), false); strncpy(jsonResponse, "{\"files\":[", STRING_LENGTH); strncat(jsonResponse, fileList, STRING_LENGTH); strncat(jsonResponse, "]}", STRING_LENGTH); JsonReport(true, request); return; } if(StringStartsWith(request, "name")) { strncpy(jsonResponse, "{\"myName\":\"", STRING_LENGTH); strncat(jsonResponse, myName, STRING_LENGTH); strncat(jsonResponse, "\"}", STRING_LENGTH); JsonReport(true, request); return; } if(StringStartsWith(request, "password")) { CheckPassword(); strncpy(jsonResponse, "{\"password\":\"", STRING_LENGTH); if(gotPassword) strncat(jsonResponse, "right", STRING_LENGTH); else strncat(jsonResponse, "wrong", STRING_LENGTH); strncat(jsonResponse, "\"}", STRING_LENGTH); JsonReport(true, request); return; } if(StringStartsWith(request, "axes")) { strncpy(jsonResponse, "{\"axes\":[", STRING_LENGTH); for(int8_t drive = 0; drive < AXES; drive++) { strncat(jsonResponse, "\"", STRING_LENGTH); strncat(jsonResponse, ftoa(0, platform->AxisLength(drive), 1), STRING_LENGTH); if(drive < AXES-1) strncat(jsonResponse, "\",", STRING_LENGTH); else strncat(jsonResponse, "\"", STRING_LENGTH); } strncat(jsonResponse, "]}", STRING_LENGTH); JsonReport(true, request); return; } JsonReport(false, request); }
int CPDF_StandardSecurityHandler::CheckPassword(FX_LPCBYTE password, FX_DWORD pass_size, FX_BOOL bOwner, FX_LPBYTE key) { return CheckPassword(password, pass_size, bOwner, key, m_KeyLen); }
//----------------------------------------------------------------------------- // Purpose: handles a request //----------------------------------------------------------------------------- void CServerRemoteAccess::WriteDataRequest( CRConServer *pNetworkListener, ra_listener_id listener, const void *buffer, int bufferSize) { m_iBytesReceived += bufferSize; // ConMsg("RemoteAccess: bytes received: %d\n", m_iBytesReceived); if ( bufferSize < 2*sizeof(int) ) // check that the buffer contains at least the id and type { return; } CUtlBuffer cmd(buffer, bufferSize, CUtlBuffer::READ_ONLY); bool invalidRequest = false; while ( invalidRequest == false && (int)cmd.TellGet() < (int)(cmd.Size() - 2 * sizeof(int) ) ) // while there is commands to read { // parse out the buffer int requestID = cmd.GetInt(); pNetworkListener->SetRequestID( listener, requestID ); // tell the rcon server the ID so it can reflect it when the console redirect flushes int requestType = cmd.GetInt(); switch (requestType) { case SERVERDATA_REQUESTVALUE: { if ( IsAuthenticated(listener) ) { char variable[256]; if ( !GetStringHelper( cmd, variable, sizeof(variable) ) ) { invalidRequest = true; break; } RequestValue( listener, requestID, variable); if ( !GetStringHelper( cmd, variable, sizeof(variable) ) ) { invalidRequest = true; break; } } else { char variable[256]; if ( !GetStringHelper( cmd, variable, sizeof(variable) ) ) { invalidRequest = true; break; } if ( !GetStringHelper( cmd, variable, sizeof(variable) ) ) { invalidRequest = true; break; } } } break; case SERVERDATA_SETVALUE: { if ( IsAuthenticated(listener) ) { char variable[256]; char value[256]; if ( !GetStringHelper( cmd, variable, sizeof(variable) ) ) { invalidRequest = true; break; } if ( !GetStringHelper( cmd, value, sizeof(value) ) ) { invalidRequest = true; break; } SetValue(variable, value); } else { char command[512]; if ( !GetStringHelper( cmd, command, sizeof(command) ) ) { invalidRequest = true; break; } if ( !GetStringHelper( cmd, command, sizeof(command) ) ) { invalidRequest = true; break; } } } break; case SERVERDATA_EXECCOMMAND: { if ( IsAuthenticated(listener) ) { char command[512]; if ( !GetStringHelper( cmd, command, sizeof(command) ) ) { invalidRequest = true; break; } ExecCommand(command); if ( listener != m_AdminUIID ) { LogCommand( listener, va( "command \"%s\"", command) ); } if ( !GetStringHelper( cmd, command, sizeof(command) ) ) { invalidRequest = true; break; } } else { char command[512]; if ( !GetStringHelper( cmd, command, sizeof(command) ) ) { invalidRequest = true; break; } if ( !GetStringHelper( cmd, command, sizeof(command) ) ) { invalidRequest = true; break; } LogCommand( listener, "Bad Password" ); } } break; case SERVERDATA_AUTH: { char password[512]; if ( !GetStringHelper( cmd, password, sizeof(password) ) ) { invalidRequest = true; break; } CheckPassword( pNetworkListener, listener, requestID, password ); if ( !GetStringHelper( cmd, password, sizeof(password) ) ) { invalidRequest = true; break; } if ( m_ListenerIDs[ listener ].authenticated ) { // if the second string has a non-zero value, it is a userid. int userID = atoi( password ); const ConCommandBase *var = g_pCVar->GetCommands(); while ( var ) { if ( var->IsCommand() ) { if ( Q_stricmp( var->GetName(), "mp_disable_autokick" ) == 0 ) { Cbuf_AddText( va( "mp_disable_autokick %d\n", userID ) ); Cbuf_Execute(); break; } } var = var->GetNext(); } } } break; case SERVERDATA_TAKE_SCREENSHOT: #ifndef SWDS m_nScreenshotListener = listener; CL_TakeJpeg( ); #endif break; case SERVERDATA_SEND_CONSOLE_LOG: { #ifndef SWDS const char *pLogFile = GetConsoleLogFilename(); CUtlBuffer buf( 1024, 0, CUtlBuffer::TEXT_BUFFER ); if ( g_pFullFileSystem->ReadFile( pLogFile, "GAME", buf ) ) { HZIP hZip = CreateZipZ( 0, 1024 * 1024, ZIP_MEMORY ); void *pMem; unsigned long nLen; ZipAdd( hZip, "console.log", buf.Base(), buf.TellMaxPut(), ZIP_MEMORY ); ZipGetMemory( hZip, &pMem, &nLen ); SendResponseToClient( listener, SERVERDATA_CONSOLE_LOG_RESPONSE, pMem, nLen ); CloseZip( hZip ); } else { LogCommand( listener, "Failed to read console log!\n" ); RespondString( listener, requestID, "Failed to read console log!\n" ); } #endif } break; #ifdef VPROF_ENABLED case SERVERDATA_VPROF: { char password[25]; if ( !GetStringHelper( cmd, password, sizeof(password) ) ) { invalidRequest = true; break; } if ( !GetStringHelper( cmd, password, sizeof(password) ) ) { invalidRequest = true; break; } if ( IsAuthenticated(listener) ) { RegisterVProfDataListener( listener ); LogCommand( listener, "Remote VProf started!\n" ); RespondString( listener, requestID, "Remote VProf started!\n" ); } } break; case SERVERDATA_REMOVE_VPROF: { char password[25]; if ( !GetStringHelper( cmd, password, sizeof(password) ) ) { invalidRequest = true; break; } if ( !GetStringHelper( cmd, password, sizeof(password) ) ) { invalidRequest = true; break; } if ( IsAuthenticated(listener) ) { RemoveVProfDataListener( listener ); LogCommand( listener, "Remote VProf finished!\n" ); RespondString( listener, requestID, "Remote VProf finished!\n" ); } } break; #endif default: Assert(!("Unknown requestType in CServerRemoteAccess::WriteDataRequest()")); cmd.Purge(); invalidRequest = true; break; }; } }
int CPDF_StandardSecurityHandler::CheckPassword(const uint8_t* password, FX_DWORD pass_size, FX_BOOL bOwner, uint8_t* key) { return CheckPassword(password, pass_size, bOwner, key, m_KeyLen); }
void main(int argc,char *argv[]) { int going=TRUE,forsok=2,car=1,x,connectbps, i, tmp; struct NodeType *nt; char *tmppscreen,commandstring[100], configname[50] = "NiKom:DatoCfg/SerNode.cfg"; FILE *fil; if(argc>1) for(x=1; x<argc; x++) { if(argv[x][0]=='-') { if(argv[x][1]=='G') getty=TRUE; else if(argv[x][1]=='B') gettybps=atoi(&argv[x][2]); else if(argv[x][1]=='C') connectbps = atoi(&argv[x][2]); } else strcpy(configname,argv[x]); } if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.library\n"); if(!initnode(NODSER)) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomPreRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); getnodeconfig(configname); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(getty) dtespeed = gettybps; else dtespeed = highbaud; if(!OpenIO(NiKwind)) cleanup(ERROR,"Couldn't setup IO"); strcpy(Servermem->nodid[nodnr],nodid); conreqtkn(); serreqtkn(); Delay(50); for(;;) { inloggad=-1; Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-1; if(getty) Servermem->connectbps[nodnr] = connectbps; else waitconnect(); Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-2; /* Sätt till <Uppringd> för att även hantera -getty-fallet */ reloginspec: updateinactive(); Servermem->inne[nodnr].flaggor = Servermem->cfg.defaultflags; if(!getty) Delay(100); Servermem->inne[nodnr].rader=0; Servermem->inne[nodnr].chrset = CHRS_LATIN1; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); car=TRUE; Servermem->inne[nodnr].chrset = 0; memset(commandhistory,0,1000); going=1; while(going && going<=Servermem->cfg.logintries) { putstring("\r\nNamn: ",-1,0); if(getstring(EKO,40,NULL)) { car=FALSE; break; } if(!stricmp(inmat,Servermem->cfg.ny) && !(Servermem->cfg.cfgflags & NICFG_CLOSEDBBS)) { tmp = RegisterNewUser(); if(tmp == 2) { goto panik; } car = tmp ? 0 : 1; going=FALSE; } else if((inloggad=parsenamn(inmat))>=0) { if(readuser(inloggad,&Servermem->inne[nodnr])) { puttekn("Error reading user data.\r\n", -1); goto panik; } // TODO: Extract password loop. Should be identical to in NiKomCon.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) { if(getstring(STAREKO,15,NULL)) { car=FALSE; break; } } else { if(getstring(EJEKO,15,NULL)) { car=FALSE; break; } } if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else forsok--; } if(going && (Servermem->cfg.logmask & LOG_FAILINLOGG)) { LogEvent(USAGE_LOG, WARN, "Nod %d, %s angivet som namn, fel lösen.", nodnr, getusername(inloggad)); } if(going) going++; } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } if(!car) { if(getty) cleanup(OK,""); disconnect(); continue; } if(going) { putstring("\n\n\rTyvärr. Du har försökt maximalt antal gånger att logga in. Kopplar ned.\n\r",-1,0); goto panik; /* Urrk vad fult. :-) */ } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if((nt = selectNodeType()) == NULL) { goto panik; } abortinactive(); abortserial(); sprintf(commandstring,"%s -N%d -B%d %s",nt->path,nodnr,dtespeed,configname); CloseConsole(); CloseWindow(NiKwind); NiKwind = NULL; RemPort(nikomnodeport); i = 0; if(Servermem->connectbps[nodnr] > 0) { while(Servermem->info.bps[i] != Servermem->connectbps[nodnr] && Servermem->info.bps[i] > 0 && i<49) i++; if(i<49) { if(Servermem->info.bps[i] == Servermem->connectbps[nodnr]) Servermem->info.antbps[i]++; else { Servermem->info.bps[i] = Servermem->connectbps[nodnr]; Servermem->info.antbps[i]++; } } if(!(fil = fopen("NiKom:datocfg/sysinfo.dat","w"))) { /* putstring("Kunde inte spara nya sysinfo.dat..\n",-1,0); */ } if(fwrite((void *)&Servermem->info,sizeof(Servermem->info),1,fil) != 1) { /* putstring("Kunde inte skriva till nya sysinfo.dat....\n",-1,0); */ } fclose(fil); } nodestate = SystemTags(commandstring, SYS_UserShell, TRUE, TAG_DONE); AddPort(nikomnodeport); if(!getty || (nodestate & NIKSTATE_RELOGIN)) { if(!(NiKwind = openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); OpenConsole(NiKwind); } serreqtkn(); if(nodestate & NIKSTATE_RELOGIN) goto reloginspec; panik: Delay(hangupdelay); if(getty) cleanup(OK,""); disconnect(); } }
// Get the Json response for this command. // 'value' is null-terminated, but we also pass its length in case it contains embedded nulls, which matter when uploading files. bool Webserver::GetJsonResponse(const char* request, const char* key, const char* value, size_t valueLength) { bool found = true; // assume success bool keepOpen = false; // assume we don't want to persist the connection if (StringEquals(request, "status")) // new style status request { GetStatusResponse(1); } else if (StringEquals(request, "poll")) // old style status request { GetStatusResponse(0); } else if (StringEquals(request, "gcode") && StringEquals(key, "gcode")) { LoadGcodeBuffer(value); snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"buff\":%u}", GetReportedGcodeBufferSpace()); } else if (StringEquals(request, "upload_begin") && StringEquals(key, "name")) { CancelUpload(); FileStore *f = platform->GetFileStore("0:/", value, true); if (f != NULL) { fileBeingUploaded.Set(f); uploadState = uploadOK; } else { uploadState = uploadError; } GetJsonUploadResponse(); } else if (StringEquals(request, "upload_data") && StringEquals(key, "data")) { if (uploadState == uploadOK) { uploadPointer = value; uploadLength = valueLength; } GetJsonUploadResponse(); keepOpen = true; } else if (StringEquals(request, "upload_end") && StringEquals(key, "size")) { // Write the remaining data if (uploadLength != 0) { if (!fileBeingUploaded.Write(uploadPointer, uploadLength)) { uploadState = uploadError; } } uploadPointer = NULL; uploadLength = 0; if (uploadState == uploadOK && !fileBeingUploaded.Flush()) { uploadState = uploadError; } // Check the file length is as expected if (uploadState == uploadOK && fileBeingUploaded.Length() != strtoul(value, NULL, 10)) { uploadState = uploadError; } // Close the file if (!fileBeingUploaded.Close()) { uploadState = uploadError; } GetJsonUploadResponse(); if (uploadState != uploadOK && strlen(filenameBeingUploaded) != 0) { platform->GetMassStorage()->Delete("0:/", filenameBeingUploaded); } filenameBeingUploaded[0] = 0; } else if (StringEquals(request, "upload_cancel")) { CancelUpload(); snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"err\":%d}", 0); } else if (StringEquals(request, "delete") && StringEquals(key, "name")) { bool ok = platform->GetMassStorage()->Delete("0:/", value); snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"err\":%d}", (ok) ? 0 : 1); } else if (StringEquals(request, "files")) { const char* dir = (StringEquals(key, "dir")) ? value : platform->GetGCodeDir(); const char* fileList = platform->GetMassStorage()->FileList(dir, false); snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"files\":[%s]}", fileList); } else if (StringEquals(request, "fileinfo") && StringEquals(key, "name")) { unsigned long length; float height, filament, layerHeight; char generatedBy[50]; bool found = GetFileInfo(value, length, height, filament, layerHeight, generatedBy, ARRAY_SIZE(generatedBy)); if (found) { snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"err\":0,\"size\":%lu,\"height\":%.2f,\"filament\":%.1f,\"layerHeight\":%.2f,\"generatedBy\":\"%s\"}", length, height, filament, layerHeight, generatedBy); } else { snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"err\":1}"); } } else if (StringEquals(request, "name")) { snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"myName\":\""); size_t j = strlen(jsonResponse); for (size_t i = 0; i < ARRAY_SIZE(myName) - 1; ++i) { char c = myName[i]; if (c < ' ') // if null terminator or bad character break; if (c == '"' || c == '\\') { // Need to escape the quote-mark or backslash for JSON jsonResponse[j++] = '\\'; } jsonResponse[j++] = c; } jsonResponse[j++] = '"'; jsonResponse[j++] = '}'; jsonResponse[j] = 0; } else if (StringEquals(request, "password") && StringEquals(key, "password")) { CheckPassword(value); snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"password\":\"%s\"}", (gotPassword) ? "right" : "wrong"); } else if (StringEquals(request, "axes")) { strncpy(jsonResponse, "{\"axes\":", ARRAY_UPB(jsonResponse)); char ch = '['; for (int8_t drive = 0; drive < AXES; drive++) { sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c%.1f", ch, platform->AxisTotalLength(drive)); ch = ','; } strncat(jsonResponse, "]}", ARRAY_UPB(jsonResponse)); } else if (StringEquals(request, "connect")) { CancelUpload(); GetStatusResponse(1); } else { found = false; } JsonReport(found, request); return keepOpen; }
//---------------------------------------------------------------------------- //! \brief handle OK key press function for any GUI's, //---------------------------------------------------------------------------- void CReturnDlg::OnOK() { Beep1(); CString str; switch(m_iLevel) { case PASSWORD_INPUT: //Password Input if (m_strPassword.GetLength() == 0) { Beep(); return; } if (!CheckPassword()) { m_IncorrectTimes++; if (m_IncorrectTimes >= 5) { CDataFile::Save(L"CLERK PW", L"On"); CDialog::OnCancel(); } else { Beep(); m_strPassword = L""; m_strMsg2.SetCaption(L""); } return; } break; case AMOUNT_INPUT: str = m_strMsg2.m_szCaption; str.Remove('$'); str.Remove(' '); str.Remove('.'); str.Remove(', '); str.TrimLeft('0'); if (str.GetLength() == 0) { Beep(); return; } PutParam(m_TRREC.Amount, str); m_strAmount = m_strMsg2.m_szCaption; break; case CLERK_INPUT: str = m_strMsg2.m_szCaption; PutParam(m_TRREC.ClerkID, str); break; case RECEIP_TINPUT: str = m_strMsg2.m_szCaption; PutParam(m_TRREC.ReceiptNo, str); break; case ENTERCARD_INPUT: if (!m_KeyEntry) { Beep(); return; } KillTimer(1); str = m_strMsg2.m_szCaption; if (str.GetLength() < 10 || str.GetLength() > 19) { Beep(); return; } PutParam(m_TRREC.Account, str); ProcessManualCard(m_TRREC.Account); m_iLevel = MANUALENTRYY-1; break; case DEBITCARDENTRY: KillTimer(1); break; case DEBITCASHBACK: //CASHBACK m_strCashback = m_strMsg2.m_szCaption; break; case DEBITSURCHARGEFEE: //surcharge fee break; case DEBITTIPSELECT: //TipSelect break; case DEBITTOTALCOMFIRM: // TotalComfirm break; // case DEBITSELECTACCOUNT: // SelectAccount // break; case DEBITONLINEPIN: //OnlinePin break; case DEBITMERCHANTCOPY: // for merchant copy of the receipt return; case DEBITCUSTOMERCOPY: // for Customer copy of the receipt KillTimer(1); Print(2); break; case DEBITWAITCOPYEND: // waiting for Customer copy of the receipt ending... // KillTimer(1); return; // == == == == == == == == == == == == == = EMV Chip Card Debit Sale :C chip page 122 == == == == == == == == == == == == == = case CHIPENTRYY: KillTimer(1); break; case SELECT_LANGUAGE: //select language case SELECT_APPLICATIION: //select application case APPLICATION_CONFIRM: //select comfirm Beep(); return; /* case CHIP_DEBITCASHBACK: //CASHBACK m_strCashback = m_strMsg2.m_szCaption; break; case CHIP_DEBITSURCHARGEFEE: //surcharge fee break; case CHIP_DEBITTIPSELECT: //TipSelect break; case CHIP_DEBITTOTALCOMFIRM: // TotalComfirm break; // case CHIP_DEBITSELECTACCOUNT: // SelectAccount // break; */ case CHIP_DEBITENTERPIN: //EnterPin break; case CHIP_PASSTOCLERK: //pass to clerk KillTimer(1); GoToLevel(DOTRANSACTION); return; case CHIP_DEBITMERCHANTCOPY: // for merchant copy of the receipt return; case CHIP_DEBITCUSTOMERCOPY: // for Customer copy of the receipt KillTimer(1); Print(2); break; case CHIP_DEBITWAITCOPYEND: // waiting for Customer copy of the receipt ending... // KillTimer(1); return; // == == == == == == == == == == == == == = Credit Card Sale :C Swiped page 75 == == == == == == == == == == == == == == == == == = case CREDITSWIPEENTRYY: //Fraud Check str = m_strMsg2.m_szCaption; GoToLevel(DOTRANSACTION); return; // PutParam(m_TRREC.FraudNo, str); //Fix me later // break; case CREDITSWIPETOCUSTOMER: KillTimer(1); break; case CREDITSWIPETIPSELECT: //TipSelect break; case CREDITSWIPETOTALCOMFIRM: // TotalComfirm break; case CREDITSWIPETOCLERK: //Pass to clerk KillTimer(1); GoToLevel(DOTRANSACTION); return; case CREDITMERCHANTCOPY: // for merchant copy of the receipt return; case CREDITCUSTOMERCOPY: // for Customer copy of the receipt KillTimer(1); Print(2); break; case CREDITWAITCOPYEND: // waiting for Customer copy of the receipt ending... // KillTimer(1); return; // == == == == == == == == == == == = /Manual Entry == == == == == == == == == == == == == == == == == == == == == == = case MANUALENTRYY: //Fraud Check str = m_strMsg2.m_szCaption; if (str.GetLength() != SZ_EXPIRY_DATE) { Beep(); return; } str = m_strMsg2.m_szCaption.Mid(2,2) + m_strMsg2.m_szCaption.Mid(0,2) ; PutParam(m_TRREC.ExpDate, str); break; case MANUAL_IMPRINT_CARD: break; case MANUAL_SWIPETOCUSTOMER: KillTimer(1); break; case MANUAL_SWIPETIPSELECT: //TipSelect break; case MANUAL_SWIPETOTALCOMFIRM: // TotalComfirm break; case MANUAL_SWIPETOCLERK: //Pass to clerk KillTimer(1); GoToLevel(DOTRANSACTION); return; // == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == = case CANCELENTRY: KillTimer(1); break; case CANCELTOCLERK: KillTimer(1); CDialog::OnCancel(); return; case ERRORENTRY: KillTimer(1); if ( m_TRREC.bEmvTransaction) { GoToLevel(EMV_REMOVE_CARD); } else CDialog::OnCancel(); return; case ERRORENTRY1: KillTimer(1); GoToLevel(m_iNextLevel); return; // == == == == == == == Display Window == == == == == case DISPLAY_WINDOW: if (CDisplay::GetMask() & MASK_OK) CDisplay::SetKeyReturn(KEY_ENTER); return; case EMV_SELECT_LANGUAGE: //EMV Select language case EMV_CONFIRM_AMOUNT: //EMV confirm amount case EMV_SELECT_ACCOUNT: //EMV select account m_strMsg2.m_nFormat = DT_LEFT; ShowText(L"Please Wait...", L"Do not remove", L"Card!"); m_iLevel = EMV_WAIT; SetKeyReturn(KEY_ENTER); return; case EMV_PASS_COUSTOMER: //pass to customer SetKeyReturn(KEY_ENTER); return; case CHIP_DEBITCASHBACK: //CASHBACK m_strCashback = m_strMsg2.m_szCaption; break; case CHIP_DEBITSURCHARGEFEE: //surcharge fee case CHIP_DEBITTIPSELECT: //TipSelect case CHIP_DEBITTOTALCOMFIRM: // TotalComfirm break; case CHIP_DEBITSELECTACCOUNT: // SelectAccount Beep(); return; default: // CDialog::OnOK(); return; } GoNext(); SetFocus(); }
void main(int argc, char **argv) { int going = TRUE, forsok = 2,car = 1, tmp, ch; long tid; char tellstr[100],*tmppscreen, titel[80]; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(EXIT_ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(EXIT_ERROR,"Kunde inte öppna utility.library\n"); if(!(LocaleBase=OpenLibrary("locale.library",38L))) cleanup(EXIT_ERROR,"Kunde inte öppna locale.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(EXIT_ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKomCon", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(EXIT_ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(EXIT_ERROR,"Kunde inte öppna IO\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { Servermem->idletime[nodnr] = time(NULL); memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendautorexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { Servermem->idletime[nodnr] = time(NULL); puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { tmp = RegisterNewUser(); if(tmp == 2) { goto panik; } car = tmp ? 0 : 1; going=FALSE; } else if((inloggad=parsenamn(inmat))>=0) { if(readuser(inloggad,&Servermem->inne[nodnr])) { puttekn("Error reading user data.\r\n", -1); goto panik; } // TODO: Extract password loop. Should be identical to in PreNode/Ser.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else { forsok--; } } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); if(!ReadUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad)) { puttekn("Error reading unread text info.\r\n", -1); LogEvent(SYSTEM_LOG, ERROR, "Can't read unread text info for user %d", inloggad); goto panik; } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { LogEvent(USAGE_LOG, INFO, "%s loggar ut från nod %d", getusername(inloggad), nodnr); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendautorexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); WriteUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: nodestate = 0; puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((ch = GetChar()) != 'n' && ch != 'N'); cleanup(EXIT_OK,""); }