Subversion Repositories oidplus

Rev

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

Rev 735 Rev 737
Line 210... Line 210...
210
                    2) then
210
                    2) then
211
        begin
211
        begin
212
          if sInput = '' then
212
          if sInput = '' then
213
          begin
213
          begin
214
            (* Empty input = Delete ASN.1 ID *)
214
            (* Empty input = Delete ASN.1 ID *)
215
            ListDeleteElement(oid^.ASNIDs, res);
215
            ListDeleteElementByIndex(oid^.ASNIDs, res);
216
            break;
216
            break;
217
          end
217
          end
218
          else if not ASN1IDValid(sInput) then
218
          else if not ASN1IDValid(sInput) then
219
          begin
219
          begin
220
            ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true);
220
            ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true);
Line 408... Line 408...
408
procedure DeleteOidRecursive(selfOID: POID);
408
procedure DeleteOidRecursive(selfOID: POID);
409
var
409
var
410
  i: integer;
410
  i: integer;
411
  parentOID: POID;
411
  parentOID: POID;
412
  filenameSelf, filenameParent: string;
412
  filenameSelf, filenameParent: string;
413
  fileIdToDelete: string;
-
 
414
  sTmp: string;
-
 
415
begin
413
begin
416
  (* Remove all children and their files recursively *)
414
  (* Remove all children and their files recursively *)
417
  DeleteChildrenRecursive(selfOID);
415
  DeleteChildrenRecursive(selfOID);
418
 
416
 
419
  (* Remove forward reference in parent OID *)
417
  (* Remove forward reference in parent OID *)
420
  filenameParent := FileIdPart(selfOID^.Parent) + '.OID';
418
  filenameParent := FileIdPart(selfOID^.Parent) + '.OID';
421
  CreateOidDef(parentOID);
419
  CreateOidDef(parentOID);
422
  _ReadOidFile(filenameParent, parentOID);
420
  _ReadOidFile(filenameParent, parentOID);
423
  for i := 0 to ListCount(parentOID^.SubIds)-1 do
421
  if ListDeleteElementByValue(parentOID^.SubIds, selfOID^.FileId + selfOID^.DotNotation) then
424
  begin
422
  begin
425
    sTmp := ListGetElement(parentOID^.SubIds, i);
-
 
426
    if FileIdPart(sTmp) = selfOID^.FileId then
-
 
427
    begin
-
 
428
      ListDeleteElement(parentOID^.SubIds, i);
-
 
429
      _WriteOidFile(filenameParent, parentOID);
423
    _WriteOidFile(filenameParent, parentOID);
430
      break;
-
 
431
    end;
-
 
432
  end;
424
  end;
433
  FreeOidDef(parentOID);
425
  FreeOidDef(parentOID);
434
 
426
 
435
  (* Delete own file *)
427
  (* Delete own file *)
436
  fileIdToDelete := selfOID^.FileId;
-
 
437
  filenameSelf := fileIdToDelete+'.OID';
428
  filenameSelf := selfOID^.FileId + '.OID';
438
  DeleteFile(filenameSelf);
429
  DeleteFile(filenameSelf);
439
end;
430
end;
440
 
431
 
441
function _DeleteConfirmation: boolean;
432
function _DeleteConfirmation: boolean;
442
var
433
var
443
  sc: Char;
434
  sc: Char;
444
begin
435
begin
445
  repeat
436
  repeat
446
    ShowMessage('Are you sure you want to delete this OID? (Y/N)', 'DELETE OID', true);
437
    ShowMessage('Are you sure you want to delete this OID? (Y/N)', 'DELETE OID', true);
447
    DrawStatusBar('Y = Yes; N = No');
438
    DrawStatusBar('Y=Yes, N=No');
448
 
439
 
449
    sc := ReadKey;
440
    sc := ReadKey;
450
    if sc = #0 then
441
    if sc = #0 then
451
    begin
442
    begin
452
      (* Extended key. Nothing we care about. *)
443
      (* Extended key. Nothing we care about. *)
Line 456... Line 447...
456
 
447
 
457
    if UpCase(sc) = 'Y' then
448
    if UpCase(sc) = 'Y' then
458
    begin
449
    begin
459
      _DeleteConfirmation := true;
450
      _DeleteConfirmation := true;
460
      break;
451
      break;
461
    end;
452
    end
462
 
-
 
463
    if UpCase(sc) = 'N' then
453
    else if UpCase(sc) = 'N' then
464
    begin
454
    begin
465
      _DeleteConfirmation := false;
455
      _DeleteConfirmation := false;
466
      break;
456
      break;
467
    end;
457
    end;
468
  until false;
458
  until false;
469
end;
459
end;
470
 
460
 
-
 
461
procedure _DrawOidTitleBar(filename: string; oid: POID);
-
 
462
begin
-
 
463
  if oid^.DotNotation = '' then
-
 
464
    DrawTitleBar('OID ROOT')
-
 
465
  else
-
 
466
    DrawTitleBar('OID ' + oid^.DotNotation);
-
 
467
 
-
 
468
  (* Put loaded filename into the title bar *)
-
 
469
  GotoXY(ScreenWidth-Length(filename)+1,1);
-
 
470
  TextBackground(White);
-
 
471
  TextColor(Black);
-
 
472
  WriteLn(filename);
-
 
473
  TextBackground(Black);
-
 
474
  TextColor(White);
-
 
475
end;
-
 
476
 
471
procedure DisplayOIDFile(filename: string);
477
procedure DisplayOIDFile(filename: string);
472
var
478
var
473
  isRoot: boolean;
479
  isRoot: boolean;
474
  oid: POID;
480
  oid: POID;
475
  i, menuX, menuY: integer;
481
  i, menuX, menuY: integer;
Line 486... Line 492...
486
    _ReadOidFile(filename, oid);
492
    _ReadOidFile(filename, oid);
487
 
493
 
488
    (* Print OID information *)
494
    (* Print OID information *)
489
 
495
 
490
    ClrScr;
496
    ClrScr;
491
 
-
 
492
    if oid^.DotNotation = '' then
-
 
493
      DrawTitleBar('OID ROOT')
497
    _DrawOidTitleBar(filename, oid);
494
    else
-
 
495
      DrawTitleBar('OID ' + oid^.DotNotation);
-
 
496
    GotoXY(ScreenWidth-Length(filename)+1,1);
-
 
497
    TextBackground(White);
-
 
498
    TextColor(Black);
-
 
499
    WriteLn(filename);
-
 
500
    TextBackground(Black);
-
 
501
    TextColor(White);
-
 
502
    DrawStatusBar(DEFAULT_STATUSBAR);
498
    DrawStatusBar(DEFAULT_STATUSBAR);
503
    GotoXY(1,2);
499
    GotoXY(1,2);
504
 
500
 
505
    if oid^.DotNotation <> '' then
501
    if oid^.DotNotation <> '' then
506
    begin
502
    begin
Line 547... Line 543...
547
      end;
543
      end;
548
    end;
544
    end;
549
 
545
 
550
    (* Now prepare the menu entries *)
546
    (* Now prepare the menu entries *)
551
 
547
 
552
    CreateList(subsel);
548
    CreateList(subsel);   (* Contains the human readable OID name *)
553
    CreateList(subfiles);
549
    CreateList(subfiles); (* Contains the file name               *)
554
 
550
 
555
    if oid^.Parent = '' then
551
    if oid^.Parent = '' then
556
    begin
552
    begin
557
      isRoot := true;
553
      isRoot := true;
558
    end
554
    end
Line 668... Line 664...
668
                      #13#10 +
664
                      #13#10 +
669
                      'Valid subsequent arcs are per definition:' + #13#10 +
665
                      'Valid subsequent arcs are per definition:' + #13#10 +
670
                      '- 0 (itu-t)' + #13#10 +
666
                      '- 0 (itu-t)' + #13#10 +
671
                      '- 1 (iso)' + #13#10 +
667
                      '- 1 (iso)' + #13#10 +
672
                      '- 2 (joint-iso-itu-t)';
668
                      '- 2 (joint-iso-itu-t)';
673
  oid^.FileId      := '00000000';
669
  oid^.FileId      := ZeroPad(0, 8);
674
  oid^.DotNotation := '';
670
  oid^.DotNotation := '';
675
  oid^.Parent      := '00000000';
671
  oid^.Parent      := ZeroPad(0, 8);
676
  _WriteOidFile(filename, oid);
672
  _WriteOidFile(filename, oid);
677
  FreeOidDef(oid);
673
  FreeOidDef(oid);
678
end;
674
end;
679
 
675
 
680
procedure OP_ManageOIDs;
676
procedure OP_ManageOIDs;