summaryrefslogtreecommitdiff
path: root/support/dktools/Dk4FcsFrame.cpp
blob: 5e2512ecd156dbe87dc6ea4b4660f3a0f4ec392f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
/*
Copyright (C) 2015-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: Dk4FcsFrame.wxc
*/

/**	@file Dk4FcsFrame.cpp The Dk4FcsFrame module.
*/


#line 250 "Dk4FcsFrame.wxc"

#include "dk4conf.h"

#include "wxdkfcs.h"

#include "dk4mem.h"

#include "dk4verswx.h"


#if DK4_HAVE_OPENSSL_MD5_H
#ifndef OPENSSL_MD5_H_INCLUDED
#include <openssl/md5.h>
#define	OPENSSL_MD5_H_INCLUDED 1
#endif
#endif
#if DK4_HAVE_OPENSSL_RIPEMD_H
#ifndef OPENSSL_RIPEMD_H_INCLUDED
#include <openssl/ripemd.h>
#define	OPENSSL_RIPEMD_H_INCLUDED 1
#endif
#endif
#if DK4_HAVE_OPENSSL_SHA_H
#ifndef OPENSSL_SHA_H_INCLUDED
#include <openssl/sha.h>
#define	OPENSSL_SHA_H_INCLUDED 1
#endif
#endif

#if !defined(__WXMSW__)
#include "gui-img/icons/dkicon.xpm"
#endif





#line 286 "Dk4FcsFrame.wxc"



#if	wxCHECK_VERSION(3,0,0)
wxBEGIN_EVENT_TABLE(Dk4FcsFrame,wxFrame)
#else
BEGIN_EVENT_TABLE(Dk4FcsFrame,wxFrame)
#endif
	EVT_MENU(Dk4FcsFrame_Quit, Dk4FcsFrame::OnQuit)
	EVT_MENU(Dk4FcsFrame_Open, Dk4FcsFrame::OnOpen)
	EVT_MENU(Dk4FcsFrame_Help_About, Dk4FcsFrame::OnAbout)
	EVT_MENU(Dk4FcsFrame_Help_Contents, Dk4FcsFrame::OnHelpContents)
	EVT_IDLE(Dk4FcsFrame::OnIdle)
#if	wxCHECK_VERSION(3,0,0)
wxEND_EVENT_TABLE()
#else
END_EVENT_TABLE()
#endif



typedef struct {
/*
	Message digests contexts.
*/
#if DK4_HAVE_OPENSSL_MD5_H
  MD5_CTX	md5;		/**< MD5 context. */
#endif
#if DK4_HAVE_OPENSSL_RIPEMD_H
  RIPEMD160_CTX	ripemd160;	/**< RIPEMD-160 context. */
#endif
#if DK4_HAVE_OPENSSL_SHA_H
  SHA_CTX	sha;		/**< SHA-1 context. */
#if DK4_HAVE_SHA224
  SHA256_CTX	sha224;		/**< SHA-224 context. */
#endif
#if DK4_HAVE_SHA256
  SHA256_CTX	sha256;		/**< SHA-256 context. */
#endif
#if DK4_HAVE_SHA384
  SHA512_CTX	sha384;		/**< SHA-384 context. */
#endif
#if DK4_HAVE_SHA512
  SHA512_CTX	sha512;		/**< SHA-512 context. */
#endif
#endif
  int		iMd5;		/**< Flag: Can use Md5. */
  int		iRipemd160;	/**< Flag: Can use RIPEMD-160. */
  int		iSha1;		/**< Flag: Can use SHA-1. */
  int		iSha224;	/**< Flag: Can use SHA-224. */
  int		iSha256;	/**< Flag: Can use SHA-256. */
  int		iSha384;	/**< Flag: Can use SHA-384. */
  int		iSha512;	/**< Flag: Can use SHA-512. */
} MULTI_CTX;



static const wxChar	dk4fcs_frame_version[] = { DKT_VERSION_WX };



static
void
multi_ctx_init(MULTI_CTX *mptr)
{
  

#line 352 "Dk4FcsFrame.wxc"
  DK4_MEMRES(mptr, sizeof(MULTI_CTX));
#if DK4_HAVE_OPENSSL_MD5_H
  if (1 == MD5_Init(&(mptr->md5))) {
    mptr->iMd5 = 1;			

#line 356 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_OPENSSL_RIPEMD_H
  if (1 == RIPEMD160_Init(&(mptr->ripemd160))) {
    mptr->iRipemd160 = 1;		

#line 361 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_OPENSSL_SHA_H
  if (1 == SHA1_Init(&(mptr->sha))) {
    mptr->iSha1 = 1;			

#line 366 "Dk4FcsFrame.wxc"
  }
#if DK4_HAVE_SHA224
  if (1 == SHA224_Init(&(mptr->sha224))) {
    mptr->iSha224 = 1;			

#line 370 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_SHA256
  if (1 == SHA256_Init(&(mptr->sha256))) {
    mptr->iSha256 = 1;			

#line 375 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_SHA384
  if (1 == SHA384_Init(&(mptr->sha384))) {
    mptr->iSha384 = 1;			

#line 380 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_SHA512
  if (1 == SHA512_Init(&(mptr->sha512))) {
    mptr->iSha512 = 1;			

#line 385 "Dk4FcsFrame.wxc"
  }
#endif
#endif
  

#line 389 "Dk4FcsFrame.wxc"
}



static
void
multi_ctx_add(MULTI_CTX *mptr, void *buffer, size_t sz)
{
  

#line 398 "Dk4FcsFrame.wxc"
#if DK4_HAVE_OPENSSL_MD5_H
  if (1 != MD5_Update(&(mptr->md5), buffer, (unsigned long)sz)) {
    mptr->iMd5 = 0;			

#line 401 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_OPENSSL_RIPEMD_H
  if (1 != RIPEMD160_Update(&(mptr->ripemd160), buffer, (unsigned long)sz)) {
    mptr->iRipemd160 = 0;		

#line 406 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_OPENSSL_SHA_H
  if (1 != SHA1_Update(&(mptr->sha), buffer, (unsigned long)sz)) {
    mptr->iSha1 = 0;			

#line 411 "Dk4FcsFrame.wxc"
  }
#if DK4_HAVE_SHA224
  if (1 != SHA224_Update(&(mptr->sha224), buffer, (unsigned long)sz)) {
    mptr->iSha224 = 0;			

#line 415 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_SHA256
  if (1 != SHA256_Update(&(mptr->sha256), buffer, (unsigned long)sz)) {
    mptr->iSha256 = 0;			

#line 420 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_SHA384
  if (1 != SHA384_Update(&(mptr->sha384), buffer, (unsigned long)sz)) {
    mptr->iSha384 = 0;			

#line 425 "Dk4FcsFrame.wxc"
  }
#endif
#if DK4_HAVE_SHA512
  if (1 != SHA512_Update(&(mptr->sha512), buffer, (unsigned long)sz)) {
    mptr->iSha512 = 0;			

#line 430 "Dk4FcsFrame.wxc"
  }
#endif
#endif
  

#line 434 "Dk4FcsFrame.wxc"
}



/**	Thread runs while progress dialog is shown.
	This is a ``fire and forget'' thread destroying itself after running.
*/
class Dk4FcsThread : public wxThread
{
  protected:

    /**	Buffer for reading input file.
    */
    unsigned char	 buf[4096];

    /**	Progress dialog.
    */
    Dk4WxProgressDialog	*pPd;

    /**	Multiple message digest contexts.
    */
    MULTI_CTX		*pCtx;

    /**	File to read from.
    */
    wxFile		*pWxf;

  public:

    /**	Constructor.
	@param	pd	Pointer to progress dialog.
	@param	ctx	Pointer to multiple digest contexts collection.
	@param	wxf	Pointer to file we read from.
    */
    Dk4FcsThread(
      Dk4WxProgressDialog	*pd,
      MULTI_CTX			*ctx,
      wxFile			*wxf
    );

    /**	Thread function.
	@return	Pointer which is ignored.
    */
    virtual
    void *
    Entry();

    /**	Method executed at end of thread.
    */
    virtual
    void
    OnExit();
};



Dk4FcsThread::Dk4FcsThread(
      Dk4WxProgressDialog	*pd,
      MULTI_CTX			*ctx,
      wxFile			*wxf
)
{
  

#line 497 "Dk4FcsFrame.wxc"
  pPd = pd;
  pCtx = ctx;
  pWxf = wxf;
  

#line 501 "Dk4FcsFrame.wxc"
}



void *
Dk4FcsThread::Entry()
{
  wxFileOffset	fileSize	= (wxFileOffset)0UL;
  wxFileOffset	bytesRead	= (wxFileOffset)0UL;
  size_t	bytes		= 0U;
  int		gauge		= 0;
  int		ogauge		= 0;
  bool		canContinue	= true;
  bool		success		= true;
  

#line 516 "Dk4FcsFrame.wxc"
  fileSize = pWxf->Length();
  while(canContinue) {			

#line 518 "Dk4FcsFrame.wxc"
    if (pPd->CanContinue()) {		

#line 519 "Dk4FcsFrame.wxc"
      bytes = pWxf->Read(buf, sizeof(buf));
      

#line 521 "Dk4FcsFrame.wxc"
      if (0 < bytes) {			

#line 522 "Dk4FcsFrame.wxc"
        if ((size_t)(wxInvalidOffset) != bytes) {	

#line 523 "Dk4FcsFrame.wxc"
          multi_ctx_add(pCtx, buf, bytes);
	  bytesRead += (wxFileOffset)bytes;
	  if (bytesRead >= fileSize) {
	    gauge = 1000;		

#line 527 "Dk4FcsFrame.wxc"
	  } else {
	    gauge = (int)((1000.0 * (double)bytesRead) / ((double)fileSize));
	    if (1000 < gauge) {
	      gauge = 1000;		

#line 531 "Dk4FcsFrame.wxc"
	    }
	  }
	  if (gauge != ogauge) {	

#line 534 "Dk4FcsFrame.wxc"
	    pPd->SetGauge(gauge);
	    ogauge = gauge;
	  }
	} else {			

#line 538 "Dk4FcsFrame.wxc"
	  canContinue = false;
	  success = false;
	}
      } else {				

#line 542 "Dk4FcsFrame.wxc"
        canContinue = false;
      }
    } else {				

#line 545 "Dk4FcsFrame.wxc"
      canContinue = false;
      success = false;
    }					

#line 548 "Dk4FcsFrame.wxc"
  }
  

#line 550 "Dk4FcsFrame.wxc"
  pPd->EndProcessing(success);
  

#line 552 "Dk4FcsFrame.wxc"
  return NULL;
}



void
Dk4FcsThread::OnExit()
{
  

#line 561 "Dk4FcsFrame.wxc"
  

#line 562 "Dk4FcsFrame.wxc"
}




#line 567 "Dk4FcsFrame.wxc"
Dk4FcsFrame::Dk4FcsFrame(
  int			  wxid,
  Dk4WxApplicationHelper *applicationHelper,
  Dk4WxHelpController	 *hc,
  int			  argc,
  wxChar		**argv,
  wxChar const * const	 *localizedTexts,
  wxChar const * const	 *nlWx,
  dkChar const * const	 *nlDk
) : Dk4WxFrame(nlWx[0], applicationHelper, hc, wxid)
{
  

#line 579 "Dk4FcsFrame.wxc"
  /*	Further local variables.
  */

  /*	Initialize further local variables.
  */

  sTexts = localizedTexts;
  sNlWx  = nlWx;
  sNlDk  = nlDk;
#if defined(__WXMSW__)
  wxIcon	wxdkfcs_icon(sNlWx[4]);
#else
  wxIcon	wxdkfcs_icon(xpm_dkicon);
#endif
  /*	Initialize further class members.
  */
  bActive = true;
  sFileName = wxEmptyString;
  sDirectory = wxEmptyString;
  if (1 < argc) {
    sFileName = argv[1];
    oAsc.SetAutoStart(true);
    {
      wxFileName	wxfn(sFileName);
      sDirectory = wxfn.GetPath();
    }
#if 0
    /*	Just to test auto exit.
    */
    oAsc.SetAutoExit(true);
#endif
  }
  dkctGUILayoutOK = false;
  dkctGUIContentsPanel = NULL;
  mainSizer = NULL;
  mbMain = NULL;
  menuFile = NULL;
  menuHelp = NULL;
  miFileOpen = NULL;
  miFileExit = NULL;
  miHelpAbout = NULL;
  miHelpContents = NULL;
  verticalSizer = NULL;
  contentsSizer = NULL;
  lFile = NULL;
  tFile = NULL;
  gResults = NULL;
  dkctGUIContentsPanel = new wxPanel(this);
  if(!(dkctGUIContentsPanel)) {
    goto dkctGUILayoutFinished;
  }
#if wxUSE_MENUS
  mbMain = new wxMenuBar(
  );
  if(!(mbMain)) {
    goto dkctGUILayoutFinished;
  }
  menuFile = new wxMenu(
  );
  if(!(menuFile)) {
    goto dkctGUILayoutFinished;
  }
  miFileOpen = menuFile->Append(
    Dk4FcsFrame_Open,
    sTexts[23],
    sTexts[24]
  );
  if(!(miFileOpen)) {
    goto dkctGUILayoutFinished;
  }
  miFileExit = menuFile->Append(
    Dk4FcsFrame_Quit,
    sTexts[1],
    sTexts[2]
  );
  if(!(miFileExit)) {
    goto dkctGUILayoutFinished;
  }
  mbMain->Append(menuFile, sTexts[0]);
  menuHelp = new wxMenu(
  );
  if(!(menuHelp)) {
    goto dkctGUILayoutFinished;
  }
  miHelpAbout = menuHelp->Append(
    Dk4FcsFrame_Help_About,
    sTexts[4],
    sTexts[5]
  );
  if(!(miHelpAbout)) {
    goto dkctGUILayoutFinished;
  }
  miHelpContents = menuHelp->Append(
    Dk4FcsFrame_Help_Contents,
    sTexts[6],
    sTexts[7]
  );
  if(!(miHelpContents)) {
    goto dkctGUILayoutFinished;
  }
  mbMain->Append(menuHelp, sTexts[3]);
  SetMenuBar(mbMain);
#endif
  mainSizer = new wxBoxSizer(
    wxHORIZONTAL
  );
  if(!(mainSizer)) {
    goto dkctGUILayoutFinished;
  }
  mainSizer->Add(10, 10, 0);
  verticalSizer = new wxBoxSizer(
    wxVERTICAL
  );
  if(!(verticalSizer)) {
    goto dkctGUILayoutFinished;
  }
  verticalSizer->Add(10, 10, 0);
  contentsSizer = new wxGridBagSizer(
    5, 5
  );
  if(!(contentsSizer)) {
    goto dkctGUILayoutFinished;
  }
  lFile = new wxStaticText(
    dkctGUIContentsPanel,
    wxID_ANY,
    sTexts[13]
  );
  if(!(lFile)) {
    goto dkctGUILayoutFinished;
  }
  contentsSizer->Add(
    lFile,
    wxGBPosition(0, 0),
    wxGBSpan(1, 1),
    wxALIGN_RIGHT
  );
  tFile = new wxStaticText(
    dkctGUIContentsPanel,
    wxID_ANY,
    wxT("")
  );
  if(!(tFile)) {
    goto dkctGUILayoutFinished;
  }
  contentsSizer->Add(
    tFile,
    wxGBPosition(0, 1),
    wxGBSpan(1, 1),
    wxALIGN_LEFT
  );
  gResults = new wxGrid(
    dkctGUIContentsPanel,
    wxID_ANY
  );
  if(!(gResults)) {
    goto dkctGUILayoutFinished;
  }
  gResults->CreateGrid(7, 1);
  gResults->SetColLabelValue(0, sTexts[21]);
  gResults->SetRowLabelValue(0, sTexts[14]);
  gResults->SetRowLabelValue(1, sTexts[15]);
  gResults->SetRowLabelValue(2, sTexts[16]);
  gResults->SetRowLabelValue(3, sTexts[17]);
  gResults->SetRowLabelValue(4, sTexts[18]);
  gResults->SetRowLabelValue(5, sTexts[19]);
  gResults->SetRowLabelValue(6, sTexts[20]);
  gResults->SetCellValue(0, 0, sNlWx[17]);
  gResults->SetCellValue(1, 0, sNlWx[17]);
  gResults->SetCellValue(2, 0, sNlWx[17]);
  gResults->SetCellValue(3, 0, sNlWx[17]);
  gResults->SetCellValue(4, 0, sNlWx[17]);
  gResults->SetCellValue(5, 0, sNlWx[17]);
  gResults->SetCellValue(6, 0, sNlWx[17]);
  gResults->SetRowLabelSize(wxGRID_AUTOSIZE);
  gResults->SetColLabelSize(wxGRID_AUTOSIZE);
  gResults->AutoSize();
  gResults->EnableEditing(false);
  gResults->SetMinSize(wxSize(300, 200));
  contentsSizer->Add(
    gResults,
    wxGBPosition(1, 0),
    wxGBSpan(1, 2),
    wxALIGN_LEFT|wxGROW
  );
  contentsSizer->AddGrowableRow(1);
  contentsSizer->AddGrowableCol(1);
  verticalSizer->Add(
    contentsSizer,
    1,
    wxGROW
  );
  verticalSizer->Add(10, 10, 0);
  mainSizer->Add(
    verticalSizer,
    1,
    wxGROW
  );
  mainSizer->Add(10, 10, 0);
  dkctGUIContentsPanel->SetSizer(mainSizer);
  SetIcon(wxdkfcs_icon);
  dkctGUILayoutOK = true;
  dkctGUILayoutFinished:
#if wxUSE_STATUSBAR
  if(dkctGUILayoutOK) {
    CreateStatusBar(1);
    SetStatusText(sTexts[8]);
  }
#endif
  if(dkctGUILayoutOK) {
    mainSizer->Fit(this);
    mainSizer->SetSizeHints(this);
  }

#line 612 "Dk4FcsFrame.wxc"
  if(dkctGUILayoutOK) {
    SetTitle(nlWx[0]);
    if (1 < argc) {
      tFile->SetLabel(sFileName);
    }
    gResults->SetCellValue(0, 0, sNlWx[5]);
    gResults->SetCellValue(1, 0, sNlWx[5]);
    gResults->SetCellValue(2, 0, sNlWx[5]);
    gResults->SetCellValue(3, 0, sNlWx[5]);
    gResults->SetCellValue(4, 0, sNlWx[5]);
    gResults->SetCellValue(5, 0, sNlWx[5]);
    gResults->SetCellValue(6, 0, sNlWx[5]);
  }
  
  /*	Release resources allocated by local variables.
  */
  

#line 629 "Dk4FcsFrame.wxc"
}


#line 632 "Dk4FcsFrame.wxc"



Dk4FcsFrame::~Dk4FcsFrame()
{
  

#line 638 "Dk4FcsFrame.wxc"
  /*	Release resources allocated by further class members.
  */
  

#line 641 "Dk4FcsFrame.wxc"
}



bool
Dk4FcsFrame::CanClose(bool WXUNUSED(isFinal))
{
  bool		back	= true;
  

#line 650 "Dk4FcsFrame.wxc"
  

#line 651 "Dk4FcsFrame.wxc"
  return back;
}



void
Dk4FcsFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
{
  

#line 660 "Dk4FcsFrame.wxc"
  Close();
  

#line 662 "Dk4FcsFrame.wxc"
}



void
Dk4FcsFrame::OnAbout(wxCommandEvent & WXUNUSED(event))
{
  wxString	text(wxT(""));
  wxString	title(wxT(""));
  

#line 672 "Dk4FcsFrame.wxc"
  /* Construct message text. */
  text.Append(sNlWx[0]);
  text.Append(sNlWx[7]);
  text.Append(dk4fcs_frame_version);
#if 0
  text.Append(sNlWx[1]);
#endif
  text.Append(sNlWx[8]);
  text.Append(sTexts[9]);
  text.Append(sNlWx[2]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[8]);
  text.Append(sTexts[11]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[9]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[8]);
  text.Append(sTexts[12]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[10]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[11]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[12]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[13]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[14]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[15]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[16]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[18]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[19]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[20]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[21]);
  text.Append(sNlWx[8]);
  text.Append(sNlWx[22]);
  
  /* Construct dialog box title. */
  title.Append(sTexts[10]);
  title.Append(sNlWx[0]);

  /* Show dialog box. */
  wxMessageBox(text, title);
  

#line 723 "Dk4FcsFrame.wxc"
}



void
Dk4FcsFrame::OnHelpContents(wxCommandEvent & WXUNUSED(event))
{
  

#line 731 "Dk4FcsFrame.wxc"
  DisplayContents();
  

#line 733 "Dk4FcsFrame.wxc"
}



/*	__CHANGE__ 017:	Event handlers for further events.
*/



/**	Hexadecimal digits.
*/
static const wxChar	hexdig[] = { wxT("0123456789abcdef") };



void
Dk4FcsFrame::SetCellValueBinary(
  int		 rowno,
  unsigned char	*buf,
  size_t	 bytes
)
{
  wxChar	 obuf[144];
  wxChar	*obptr;
  unsigned short u;
  

#line 759 "Dk4FcsFrame.wxc"
  if (64 >= bytes) {
    obptr = obuf;
    while(bytes--) {
      u = (unsigned short)(*buf);
      u = u >> 4;
      u &= 15;
      *(obptr++) = hexdig[u];		

#line 766 "Dk4FcsFrame.wxc"
      u = (unsigned short)(*buf);
      u &= 15;
      *(obptr++) = hexdig[u];		

#line 769 "Dk4FcsFrame.wxc"
      buf++;
    }
    *obptr = wxT('\0');
    {
      wxString	testString(obuf);
      gResults->SetCellValue(rowno, 0, testString);
    }
  } else {
    /* ERROR: message digest too long, need larger obuf! */
  }
  

#line 780 "Dk4FcsFrame.wxc"
}



bool
Dk4FcsFrame::RunChecksumming(void)
{
  MULTI_CTX	ctx;				 // Digests contexts collection
  unsigned char		 obuf[128];		 // Binary message digests
  Dk4WxProgressDialog	*pd		= NULL;	 // Progress dialog
  Dk4FcsThread		*pt		= NULL;	 // Thread
  int			 res		= 0;	 // Operation result
  bool			updateTable	= false; // Flag: Update the table
  

#line 794 "Dk4FcsFrame.wxc"
  /*	Reset all values.
  */
  gResults->BeginBatch();
  gResults->SetCellValue(0, 0, sNlWx[5]);
  gResults->SetCellValue(1, 0, sNlWx[5]);
  gResults->SetCellValue(2, 0, sNlWx[5]);
  gResults->SetCellValue(3, 0, sNlWx[5]);
  gResults->SetCellValue(4, 0, sNlWx[5]);
  gResults->SetCellValue(5, 0, sNlWx[5]);
  gResults->SetCellValue(6, 0, sNlWx[5]);
  gResults->EndBatch();
  gResults->ForceRefresh();
  Refresh();
  Update();

  /*	Attempt to build checksum.
  */
  if (wxFile::Exists(sFileName)) {			

#line 812 "Dk4FcsFrame.wxc"
    {
      wxFile		wxf(sFileName);
      if (wxf.IsOpened()) {				

#line 815 "Dk4FcsFrame.wxc"
        pd = new Dk4WxProgressDialog(this, pAppHelp);
	if (NULL != pd) {				

#line 817 "Dk4FcsFrame.wxc"
	  pt = new Dk4FcsThread(pd, &ctx, &wxf);
	  if (NULL != pt) {				

#line 819 "Dk4FcsFrame.wxc"
            multi_ctx_init(&ctx);
	    if(wxTHREAD_NO_ERROR == pt->Create()) {	

#line 821 "Dk4FcsFrame.wxc"
	      pt->SetPriority(WXTHREAD_DEFAULT_PRIORITY);
	      pt->Run();
	      res = pd->ShowModal();
	      if (wxID_OK == res) {			

#line 825 "Dk4FcsFrame.wxc"
	        updateTable = true;
	      } else {					

#line 827 "Dk4FcsFrame.wxc"
	        /* !!!!! ERROR: Aborted by user */
	      }
	    } else {					

#line 830 "Dk4FcsFrame.wxc"
	      delete(pt);
	      pt = NULL;
	      /* !!!!! ERROR: Failed to create thread */
	    }
	  } else {					

#line 835 "Dk4FcsFrame.wxc"
	    /* !!!!! ERROR: No thread */
	  }
	  pd->Destroy();
	} else {					

#line 839 "Dk4FcsFrame.wxc"
	  /* !!!!! ERROR: No progress dialog */
	}
      } else {				

#line 842 "Dk4FcsFrame.wxc"
        /* !!!!! ERROR: Failed to open file */
      }
    }
    if (updateTable) {					

#line 846 "Dk4FcsFrame.wxc"
      gResults->BeginBatch();
#if DK4_HAVE_OPENSSL_MD5_H
      if (0 != ctx.iMd5) {				

#line 849 "Dk4FcsFrame.wxc"
        if (1 == MD5_Final(obuf, &(ctx.md5))) {		

#line 850 "Dk4FcsFrame.wxc"
	  SetCellValueBinary(0, obuf, 16);
	}
      }
#endif
#if DK4_HAVE_OPENSSL_RIPEMD_H
      if (0 != ctx.iRipemd160) {			

#line 856 "Dk4FcsFrame.wxc"
        if (1 == RIPEMD160_Final(obuf, &(ctx.ripemd160))) {
	  SetCellValueBinary(1, obuf, 20);		

#line 858 "Dk4FcsFrame.wxc"
	}
      }
#endif
#if DK4_HAVE_OPENSSL_SHA_H
      if (0 != ctx.iSha1) {				

#line 863 "Dk4FcsFrame.wxc"
        if (1 == SHA1_Final(obuf, &(ctx.sha))) {	

#line 864 "Dk4FcsFrame.wxc"
	  SetCellValueBinary(2, obuf, 20);
	}
      }
#if DK4_HAVE_SHA224
      if (0 != ctx.iSha224) {				

#line 869 "Dk4FcsFrame.wxc"
        if (1 == SHA224_Final(obuf, &(ctx.sha224))) {	

#line 870 "Dk4FcsFrame.wxc"
	  SetCellValueBinary(3, obuf, 28);
	}
      }
#endif
#if DK4_HAVE_SHA256
      if (0 != ctx.iSha256) {				

#line 876 "Dk4FcsFrame.wxc"
        if (1 == SHA256_Final(obuf, &(ctx.sha256))) {	

#line 877 "Dk4FcsFrame.wxc"
	  SetCellValueBinary(4, obuf, 32);
	}
      }
#endif
#if DK4_HAVE_SHA384
      if (0 != ctx.iSha384) {				

#line 883 "Dk4FcsFrame.wxc"
        if (1 == SHA384_Final(obuf, &(ctx.sha384))) {	

#line 884 "Dk4FcsFrame.wxc"
	  SetCellValueBinary(5, obuf, 48);
	}
      }
#endif
#if DK4_HAVE_SHA512
      if (0 != ctx.iSha512) {				

#line 890 "Dk4FcsFrame.wxc"
        if (1 == SHA512_Final(obuf, &(ctx.sha512))) {	

#line 891 "Dk4FcsFrame.wxc"
	  SetCellValueBinary(6, obuf, 64);
	}
      }
#endif
#endif
      gResults->AutoSize();
      gResults->EndBatch();
      gResults->ForceRefresh();
      {
        int x, y, w, h;
	GetPosition(&x, &y);
	GetSize(&w, &h);
        mainSizer->Fit(this);
	SetSize(x, y, w, h);
      }
      Refresh();
      Update();
    } else {					

#line 909 "Dk4FcsFrame.wxc"
    }
  } else {					

#line 911 "Dk4FcsFrame.wxc"
    /* !!!!! ERROR: File does not exist */
  }
  

#line 914 "Dk4FcsFrame.wxc"
  return updateTable;
}



void
Dk4FcsFrame::OnOpen(wxCommandEvent & WXUNUSED(event))
{
  bool	canRun	= true;
  int	res	= 0;
  

#line 925 "Dk4FcsFrame.wxc"
  {
    wxFileDialog dlg(this, sTexts[22], sDirectory);
    res = dlg.ShowModal();
    if (wxID_OK == res) {
      sFileName = dlg.GetPath();
      tFile->SetLabel(sFileName);
      {
        wxFileName	wxfn(sFileName);
	sDirectory = wxfn.GetPath();
      }
      canRun = true;
    } else {
      canRun = false;
    }
  }
  if (canRun) {
    (void)RunChecksumming();
  }
  

#line 944 "Dk4FcsFrame.wxc"
}



void
Dk4FcsFrame::OnIdle(wxIdleEvent & event)
{
  bool		success = false;
  

#line 953 "Dk4FcsFrame.wxc"
  if (bActive) {
    /* event.RequestMore(); */
    switch (oAsc.GetReaction()) {
#if 0
      case Dk4WxAutostartController::REACTION_IGNORE : {
      } break;
#endif
      case Dk4WxAutostartController::REACTION_START : {
        oAsc.StartProcessing();
        success = RunChecksumming();
	oAsc.EndProcessing(success);
      } break;
      case Dk4WxAutostartController::REACTION_MORE : {
        event.RequestMore();
      } break;
      case Dk4WxAutostartController::REACTION_EXIT : {
        bActive = false;
	Close();
      } break;
    }
  }
  event.Skip();
  

#line 976 "Dk4FcsFrame.wxc"
}