~ubuntu-branches/ubuntu/vivid/unrar-nonfree/vivid

« back to all changes in this revision

Viewing changes to consio.cpp

  • Committer: Package Import Robot
  • Author(s): Martin Meredith
  • Date: 2015-02-03 12:58:01 UTC
  • mfrom: (1.1.18) (5.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20150203125801-od6ev8cqy1er51vz
Tags: 1:5.2.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include "log.cpp"
3
3
 
4
4
static MESSAGE_TYPE MsgStream=MSG_STDOUT;
5
 
static bool Sound=false;
6
5
const int MaxMsgSize=2*NM+2048;
7
6
 
8
7
#ifdef _WIN_ALL
47
46
}
48
47
 
49
48
 
50
 
void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound)
 
49
void InitConsoleOptions(MESSAGE_TYPE MsgStream)
51
50
{
52
51
  ::MsgStream=MsgStream;
53
 
  ::Sound=Sound;
54
52
}
55
53
 
56
54
 
125
123
 
126
124
 
127
125
#ifndef SILENT
128
 
void Alarm()
129
 
{
130
 
  if (Sound)
131
 
  {
132
 
    static clock_t LastTime=clock();
133
 
    if ((clock()-LastTime)/CLOCKS_PER_SEC>5)
134
 
    {
135
 
#ifdef _WIN_ALL
136
 
      MessageBeep(-1);
137
 
#else
138
 
      putwchar('\007');
139
 
#endif
140
 
    }
141
 
  }
142
 
}
143
 
#endif
144
 
 
145
 
 
146
 
#ifndef SILENT
147
126
static void GetPasswordText(wchar *Str,uint MaxLength)
148
127
{
149
128
  if (MaxLength==0)
181
160
 
182
161
 
183
162
#ifndef SILENT
184
 
bool GetConsolePassword(PASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
 
163
bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password)
185
164
{
186
 
  Alarm();
 
165
  uiAlarm(UIALARM_QUESTION);
187
166
  
188
167
  while (true)
189
168
  {
190
 
    if (Type==PASSWORD_GLOBAL)
 
169
    if (Type==UIPASSWORD_GLOBAL)
191
170
      eprintf(L"\n%s: ",St(MAskPsw));
192
171
    else
193
172
      eprintf(St(MAskPswFor),FileName);
194
173
 
195
174
    wchar PlainPsw[MAXPASSWORD];
196
175
    GetPasswordText(PlainPsw,ASIZE(PlainPsw));
197
 
    if (*PlainPsw==0 && Type==PASSWORD_GLOBAL)
 
176
    if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL)
198
177
      return false;
199
 
    if (Type==PASSWORD_GLOBAL)
 
178
    if (Type==UIPASSWORD_GLOBAL)
200
179
    {
201
180
      eprintf(St(MReAskPsw));
202
181
      wchar CmpStr[MAXPASSWORD];
264
243
 
265
244
 
266
245
#ifndef SILENT
 
246
// We allow this function to return 0 in case of invalid input,
 
247
// because it might be convenient to press Enter to some not dangerous
 
248
// prompts like "insert disk with next volume". We should call this function
 
249
// again in case of 0 in dangerous prompt such as overwriting file.
267
250
int Ask(const wchar *AskStr)
268
251
{
269
 
  Alarm();
 
252
  uiAlarm(UIALARM_QUESTION);
270
253
 
271
254
  const int MaxItems=10;
272
255
  wchar Item[MaxItems][40];