MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / GetConsolePassword

Function GetConsolePassword

Libraries/unrar/consio.cpp:186–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185#ifndef SILENT
186bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
187{
188 if (!StdinRedirected)
189 uiAlarm(UIALARM_QUESTION);
190
191 while (true)
192 {
193 if (!StdinRedirected)
194 if (Type==UIPASSWORD_GLOBAL)
195 eprintf(L"\n%s: ",St(MAskPsw));
196 else
197 eprintf(St(MAskPswFor),FileName);
198
199 wchar PlainPsw[MAXPASSWORD];
200 GetPasswordText(PlainPsw,ASIZE(PlainPsw));
201 if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL)
202 return false;
203 if (!StdinRedirected && Type==UIPASSWORD_GLOBAL)
204 {
205 eprintf(St(MReAskPsw));
206 wchar CmpStr[MAXPASSWORD];
207 GetPasswordText(CmpStr,ASIZE(CmpStr));
208 if (*CmpStr==0 || wcscmp(PlainPsw,CmpStr)!=0)
209 {
210 eprintf(St(MNotMatchPsw));
211 cleandata(PlainPsw,sizeof(PlainPsw));
212 cleandata(CmpStr,sizeof(CmpStr));
213 continue;
214 }
215 cleandata(CmpStr,sizeof(CmpStr));
216 }
217 Password->Set(PlainPsw);
218 cleandata(PlainPsw,sizeof(PlainPsw));
219 break;
220 }
221 return true;
222}
223#endif
224
225

Callers 1

uiGetPasswordFunction · 0.85

Calls 6

StFunction · 0.85
GetPasswordTextFunction · 0.85
cleandataFunction · 0.85
SetMethod · 0.80
uiAlarmFunction · 0.70
eprintfFunction · 0.70

Tested by

no test coverage detected