Subversion Repositories oidplus

Rev

Rev 746 | Rev 748 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 746 Rev 747
Line 1... Line 1...
1
program OIDPLUS;
1
program OIDPLUS;
2
 
2
 
3
(************************************************)
3
(************************************************)
4
(* OIDPLUS.PAS                                  *)
4
(* OIDPLUS.PAS                                  *)
5
(* Author:   Daniel Marschall                   *)
5
(* Author:   Daniel Marschall                   *)
6
(* Revision: 2022-02-15                         *)
6
(* Revision: 2022-02-16                         *)
7
(* License:  Apache 2.0                         *)
7
(* License:  Apache 2.0                         *)
8
(* This file contains:                          *)
8
(* This file contains:                          *)
9
(* - "OIDplus for DOS" program                  *)
9
(* - "OIDplus for DOS" program                  *)
10
(************************************************)
10
(************************************************)
11
 
11
 
Line 19... Line 19...
19
 
19
 
20
uses
20
uses
21
  Dos, Crt, Drivers, StrList, VtsFuncs, VtsCui, OidFile, OidUtils;
21
  Dos, Crt, Drivers, StrList, VtsFuncs, VtsCui, OidFile, OidUtils;
22
 
22
 
23
const
23
const
24
  VERSIONINFO            = 'Revision: 2022-02-15';
24
  VERSIONINFO            = 'Revision: 2022-02-16';
25
  DEFAULT_STATUSBAR      = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.';
25
  DEFAULT_STATUSBAR      = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.';
26
  TITLEBAR_LEFT_TEXT     = 'OIDplus';
26
  TITLEBAR_LEFT_TEXT     = 'OIDplus';
27
  DISKIO_SOUND_DEBUGGING = false;
27
  DISKIO_SOUND_DEBUGGING = false;
28
  DISKIO_SOUND_DELAY     = 500;
28
  DISKIO_SOUND_DELAY     = 500;
29
  ASNEDIT_LINES          = 10;
29
  ASNEDIT_LINES          = 10;
Line 342... Line 342...
342
                1,
342
                1,
343
                'ENTER NUMERIC ID',
343
                'ENTER NUMERIC ID',
344
                2) then
344
                2) then
345
    begin
345
    begin
346
      if sInput = '' then continue;
346
      if sInput = '' then continue;
347
      if not IsPositiveInteger(sInput) then
347
      if not IsPositiveIntegerOrZero(sInput) then
348
      begin
348
      begin
349
        ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true);
349
        ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true);
350
        _Pause;
350
        _Pause;
351
      end
351
      end
352
      else if (parentOID^.DotNotation='') and (StrToInt(sInput) > 2) then
352
      else if (parentOID^.DotNotation='') and (StrToInt(sInput) > 2) then
Line 800... Line 800...
800
  if rootfile = '' then Exit;
800
  if rootfile = '' then Exit;
801
 
801
 
802
  DisplayOIDFile(rootfile);
802
  DisplayOIDFile(rootfile);
803
end;
803
end;
804
 
804
 
805
procedure OP_ManageRAs;
-
 
806
begin
-
 
807
  ClrScr;
-
 
808
  DrawTitleBar('Manage Registration Authorities', TITLEBAR_LEFT_TEXT, '');
-
 
809
  DrawStatusBar('');
-
 
810
 
-
 
811
  (* TODO: Implement "Manage RAs" feature *)
-
 
812
end;
-
 
813
 
-
 
814
procedure OP_ReturnToMSDOS;
805
procedure OP_ReturnToMSDOS;
815
begin
806
begin
816
  ClrScr;
-
 
817
  TextBackground(Black);
807
  (* Note: These two lines don't seem to be necessary if you use DoneVideo *)
818
  TextColor(LightGray);
808
  ResetDefaultDosColors;
819
  ClrScr; (*Important, so that the DOS command prompt is also LightGray *)
809
  ClrScr; (*Important, so that the DOS command prompt is also LightGray *)
820
 
810
 
821
  WriteLn('Thank you for using OIDplus for DOS.');
811
  WriteLn('Thank you for using OIDplus for DOS.');
822
  WriteLn('');
812
  WriteLn('');
823
end;
813
end;
824
 
814
 
825
function _GetTreeViewLine(oid: POID; indent: integer): string;
815
function _GetTreeViewLine(oid: POID; indent: integer): string;
826
var
816
var
827
  i: integer;
817
  i: integer;
828
  sTmp: string;
818
  sTmp, sTmp2: string;
829
begin
819
begin
830
  (* Build line *)
820
  (* Build line *)
831
  sTmp := RepeatStr(' ', indent*TREEVIEW_INDENT);
821
  sTmp := RepeatStr(' ', indent*TREEVIEW_INDENT);
832
  if oid^.DotNotation = '' then
822
  if oid^.DotNotation = '' then
833
    sTmp := sTmp + 'Object Identifiers'
823
    sTmp := sTmp + 'Object Identifiers'
Line 839... Line 829...
839
    if Trim(oid^.Description) <> '' then
829
    if Trim(oid^.Description) <> '' then
840
    begin
830
    begin
841
      sTmp := sTmp + ': ' + oid^.Description;
831
      sTmp := sTmp + ': ' + oid^.Description;
842
    end;
832
    end;
843
  end;
833
  end;
-
 
834
 
844
  for i := 1 to Length(sTmp) do
835
  sTmp := StringReplace(sTmp, #13#10, ' ');
845
  begin
836
  repeat
-
 
837
    sTmp2 := sTmp;
846
    if (sTmp[i]=#13) or (sTmp[i]=#10) then sTmp[i] := ' ';
838
    sTmp := StringReplace(sTmp, '  ', ' ');
847
  end;
839
  until sTmp = sTmp2;
-
 
840
 
848
  sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
841
  sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
849
  _GetTreeViewLine := sTmp;
842
  _GetTreeViewLine := sTmp;
850
end;
843
end;
851
 
844
 
852
procedure _RecTreeExport(oid: POID; var F: Text; indent: integer);
845
procedure _RecTreeExport(oid: POID; var F: Text; indent: integer);
Line 892... Line 885...
892
      FreeOidDef(suboid);
885
      FreeOidDef(suboid);
893
    end
886
    end
894
  end;
887
  end;
895
end;
888
end;
896
 
889
 
-
 
890
procedure TreeViewPreview;
-
 
891
var
-
 
892
  list: PStringList;
-
 
893
begin
-
 
894
  CreateList(list);
-
 
895
 
-
 
896
  DrawStatusBar('Press ESC to return to the main menu');
-
 
897
  ListLoadFromFile(list, TREEVIEW_FILENAME);
-
 
898
  DrawSelectionList(2, 3, ScreenWidth-2, ScreenHeight-4,
-
 
899
                    list, true, 'PREVIEW OF '+TREEVIEW_FILENAME, 2);
-
 
900
  (* TODO: Jump to selected OID *)
-
 
901
 
-
 
902
  DrawStatusBar(DEFAULT_STATUSBAR);
-
 
903
 
-
 
904
  FreeList(list);
-
 
905
end;
-
 
906
 
897
procedure OP_TreeView;
907
procedure OP_TreeView;
898
var
908
var
899
  F: Text;
909
  F: Text;
900
  rootoid: POID;
910
  rootoid: POID;
901
  rootfile: string;
911
  rootfile: string;
Line 941... Line 951...
941
  if res then
951
  if res then
942
  begin
952
  begin
943
    ShowMessage('TreeView successfully exported as '+TREEVIEW_FILENAME, 'TREEVIEW EXPORT', true);
953
    ShowMessage('TreeView successfully exported as '+TREEVIEW_FILENAME, 'TREEVIEW EXPORT', true);
944
    _Pause;
954
    _Pause;
945
  end;
955
  end;
-
 
956
 
-
 
957
  TreeViewPreview;
946
end;
958
end;
947
 
959
 
948
procedure OP_MainMenu;
960
procedure OP_MainMenu;
949
var
961
var
950
  menu: PStringList;
962
  menu: PStringList;
951
  menuRes, menuLeft, menuTop: integer;
963
  menuRes, menuLeft, menuTop: integer;
952
  menuIdOID, menuIdRA, menuIdTree, menuIdExit: integer;
964
  menuIdOID, menuIdTree, menuIdExit: integer;
953
begin
965
begin
954
  repeat
966
  repeat
955
    ClrScr;
967
    ClrScr;
956
 
968
 
957
    DrawTitleBar('Welcome to OIDplus for DOS', '', '');
969
    DrawTitleBar('Welcome to OIDplus for DOS', '', '');
Line 960... Line 972...
960
    Write(VERSIONINFO);
972
    Write(VERSIONINFO);
961
 
973
 
962
    CreateList(menu);
974
    CreateList(menu);
963
 
975
 
964
    menuIdOID  := ListAppend(menu, 'Manage OIDs');
976
    menuIdOID  := ListAppend(menu, 'Manage OIDs');
965
    menuIdRA   := -99; (*ListAppend(menu, 'Manage RAs');*)
-
 
966
    menuIdTree := ListAppend(menu, 'Export TreeView');
977
    menuIdTree := ListAppend(menu, 'Export TreeView');
967
    menuIdExit := ListAppend(menu, 'Return to DOS');
978
    menuIdExit := ListAppend(menu, 'Return to DOS');
968
 
979
 
969
    menuLeft := round(ScreenWidth/2 -MAINMENU_WIDTH/2);
980
    menuLeft := round(ScreenWidth/2 -MAINMENU_WIDTH/2);
970
    menuTop  := round(ScreenHeight/2-MAINMENU_HEIGHT/2);
981
    menuTop  := round(ScreenHeight/2-MAINMENU_HEIGHT/2);
Line 975... Line 986...
975
 
986
 
976
    if menuRes = menuIdOID then
987
    if menuRes = menuIdOID then
977
    begin
988
    begin
978
      OP_ManageOIDs;
989
      OP_ManageOIDs;
979
    end
990
    end
980
    else if menuRes = menuIdRA then
-
 
981
    begin
-
 
982
      OP_ManageRAs;
-
 
983
    end
-
 
984
    else if menuRes = menuIdTree then
991
    else if menuRes = menuIdTree then
985
    begin
992
    begin
986
      OP_Treeview;
993
      OP_Treeview;
987
    end;
994
    end;
988
  until (menuRes = menuIdExit) or (MAINMENU_ALLOW_ESC and (menuRes = -1));
995
  until (menuRes = menuIdExit) or (MAINMENU_ALLOW_ESC and (menuRes = -1));
Line 992... Line 999...
992
 
999
 
993
begin
1000
begin
994
  InitVideo; (* sets ScreenWidth and ScreenHeight *)
1001
  InitVideo; (* sets ScreenWidth and ScreenHeight *)
995
  CursorOff;
1002
  CursorOff;
996
  OP_MainMenu;
1003
  OP_MainMenu;
-
 
1004
  CursorOn;
997
  DoneVideo;
1005
  DoneVideo;
998
end.
1006
end.