Rev 734 | Rev 737 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 734 | Rev 735 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | DISKIO_SOUND_DEBUGGING = false; |
18 | DISKIO_SOUND_DEBUGGING = false; |
19 | DISKIO_SOUND_DELAY = 500; |
19 | DISKIO_SOUND_DELAY = 500; |
20 | ASNEDIT_LINES = 10; |
20 | ASNEDIT_LINES = 10; |
21 | DESCEDIT_LINES = 10; |
21 | DESCEDIT_LINES = 10; |
22 | DESCEDIT_PADDING = 3; |
22 | DESCEDIT_PADDING = 3; |
- | 23 | ACTIONMENU_SIZE = 5; |
|
- | 24 | MAINMENU_WIDTH = 15; |
|
- | 25 | MAINMENU_HEIGHT = 3; |
|
- | 26 | MAINMENU_ALLOW_ESC = false; |
|
23 | 27 | ||
24 | procedure _WriteOidFile(filename: string; oid: POid); |
28 | procedure _WriteOidFile(filename: string; oid: POid); |
25 | begin |
29 | begin |
26 | DrawStatusBar('Write file ' + filename + '...'); |
30 | DrawStatusBar('Write file ' + filename + '...'); |
27 | WriteOidFile(filename, oid); |
31 | WriteOidFile(filename, oid); |
Line 65... | Line 69... | ||
65 | DrawStatusBar(DEFAULT_STATUSBAR); |
69 | DrawStatusBar(DEFAULT_STATUSBAR); |
66 | end; |
70 | end; |
67 | 71 | ||
68 | function _ShowASNIds(subfile: string): string; |
72 | function _ShowASNIds(subfile: string): string; |
69 | var |
73 | var |
70 | coid: TOID; |
74 | childOID: POID; |
71 | j, jmax: integer; |
75 | j, jmax: integer; |
72 | sTmp: string; |
76 | sTmp: string; |
73 | begin |
77 | begin |
74 | sTmp := ''; |
78 | sTmp := ''; |
75 | InitOidDef(@coid); |
79 | CreateOidDef(childOID); |
76 | _ReadOidFile(subfile, @coid); |
80 | _ReadOidFile(subfile, childOID); |
77 | jmax := ListCount(coid.ASNIds)-1; |
81 | jmax := ListCount(childOID^.ASNIds)-1; |
78 | for j := 0 to jmax do |
82 | for j := 0 to jmax do |
79 | begin |
83 | begin |
80 | if j = 0 then sTmp := sTmp + ' ('; |
84 | if j = 0 then sTmp := sTmp + ' ('; |
81 | sTmp := sTmp + ListGetElement(coid.ASNIds, j); |
85 | sTmp := sTmp + ListGetElement(childOID^.ASNIds, j); |
82 | if j = jmax then |
86 | if j = jmax then |
83 | sTmp := sTmp + ')' |
87 | sTmp := sTmp + ')' |
84 | else |
88 | else |
85 | sTmp := sTmp + ', '; |
89 | sTmp := sTmp + ', '; |
86 | end; |
90 | end; |
87 | FreeOidDef(@coid); |
91 | FreeOidDef(childOID); |
88 | _ShowASNIds := sTmp; |
92 | _ShowASNIds := sTmp; |
89 | end; |
93 | end; |
90 | 94 | ||
91 | function AsnAlreadyExisting(oid: POID; asnid: string): boolean; |
95 | function AsnAlreadyExisting(oid: POID; asnid: string): boolean; |
92 | var |
96 | var |
Line 110... | Line 114... | ||
110 | asnList: PStringList; |
114 | asnList: PStringList; |
111 | i: integer; |
115 | i: integer; |
112 | x, y, w, h: integer; |
116 | x, y, w, h: integer; |
113 | res: integer; |
117 | res: integer; |
114 | sInput: string; |
118 | sInput: string; |
- | 119 | menuIdNew, menuIdSave, menuIdExit: integer; |
|
115 | begin |
120 | begin |
116 | AsnEditor := false; |
121 | AsnEditor := false; |
117 | 122 | ||
118 | repeat |
123 | repeat |
119 | InitList(asnList); |
124 | CreateList(asnList); |
120 | 125 | ||
121 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
126 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
122 | begin |
127 | begin |
123 | ListAppend(asnList, ListGetElement(oid^.ASNIDs, i)); |
128 | ListAppend(asnList, ListGetElement(oid^.ASNIDs, i)); |
124 | end; |
129 | end; |
125 | ListAppend(asnList, '<NEW>'); |
130 | menuIdNew := ListAppend(asnList, '<NEW>'); |
126 | ListAppend(asnList, '<SAVE>'); |
131 | menuIdSave := ListAppend(asnList, '<SAVE>'); |
127 | ListAppend(asnList, '<CANCEL>'); |
132 | menuIdExit := ListAppend(asnList, '<CANCEL>'); |
128 | 133 | ||
129 | DrawStatusBar(DEFAULT_STATUSBAR); |
134 | DrawStatusBar(DEFAULT_STATUSBAR); |
130 | x := SINGLE_LINE_BOX_PADDING; |
135 | x := SINGLE_LINE_BOX_PADDING; |
131 | y := ScreenHeight div 2 - ASNEDIT_LINES div 2; |
136 | y := ScreenHeight div 2 - ASNEDIT_LINES div 2; |
132 | w := ScreenWidth - (SINGLE_LINE_BOX_PADDING-1)*2; |
137 | w := ScreenWidth - (SINGLE_LINE_BOX_PADDING-1)*2; |
133 | h := ASNEDIT_LINES; |
138 | h := ASNEDIT_LINES; |
134 | res := DrawSelectionList(x, y, w, h, |
139 | res := DrawSelectionList(x, y, w, h, |
135 | asnList, true, |
140 | asnList, true, |
136 | 'EDIT ASN.1 IDENTIFIERS', |
141 | 'EDIT ASN.1 IDENTIFIERS', |
137 | 2); |
142 | 2); |
- | 143 | FreeList(asnList); |
|
138 | 144 | ||
139 | (* Change double-border to thin-border *) |
145 | (* Change double-border to thin-border *) |
140 | DrawThinBorder(x-1, y-1, w+2, h+2); |
146 | DrawThinBorder(x-1, y-1, w+2, h+2); |
141 | GoToXY(x+1, y-1); |
147 | GoToXY(x+1, y-1); |
142 | Write('EDIT ASN.1 IDENTIFIERS'); |
148 | Write('EDIT ASN.1 IDENTIFIERS'); |
143 | 149 | ||
144 | if res = -1 then |
150 | if res = -1 then |
145 | begin |
151 | begin |
146 | exit; |
152 | exit; |
147 | end |
153 | end |
148 | else if res = ListCount(oid^.ASNIDs) then |
154 | else if res = menuIdNew then |
149 | begin |
155 | begin |
150 | (* "NEW" item was selected *) |
156 | (* "NEW" item was selected *) |
151 | sInput := ''; |
157 | sInput := ''; |
152 | repeat |
158 | repeat |
153 | if QueryVal(sInput, |
159 | if QueryVal(sInput, |
Line 176... | Line 182... | ||
176 | end; |
182 | end; |
177 | end |
183 | end |
178 | else break; |
184 | else break; |
179 | until false; |
185 | until false; |
180 | end |
186 | end |
181 | else if res = ListCount(oid^.ASNIDs)+1 then |
187 | else if res = menuIdSave then |
182 | begin |
188 | begin |
183 | (* "SAVE" item was selected *) |
189 | (* "SAVE" item was selected *) |
184 | AsnEditor := true; |
190 | AsnEditor := true; |
185 | Exit; |
191 | Exit; |
186 | end |
192 | end |
187 | else if res = ListCount(oid^.ASNIDs)+2 then |
193 | else if res = menuIdExit then |
188 | begin |
194 | begin |
189 | (* "CANCEL" item was selected *) |
195 | (* "CANCEL" item was selected *) |
190 | AsnEditor := false; |
196 | AsnEditor := false; |
191 | Exit; |
197 | Exit; |
192 | end |
198 | end |
Line 259... | Line 265... | ||
259 | list: PStringList; |
265 | list: PStringList; |
260 | iId: LongInt; |
266 | iId: LongInt; |
261 | sId: string; |
267 | sId: string; |
262 | begin |
268 | begin |
263 | (* Put all found files into a list *) |
269 | (* Put all found files into a list *) |
264 | InitList(list); |
270 | CreateList(list); |
265 | FindFirst('????????.OID', Archive, DirInfo); |
271 | FindFirst('????????.OID', Archive, DirInfo); |
266 | while DosError = 0 do |
272 | while DosError = 0 do |
267 | begin |
273 | begin |
268 | sId := Copy(DirInfo.Name, 1, 8); |
274 | sId := Copy(DirInfo.Name, 1, 8); |
269 | ListAppend(list, sId); |
275 | ListAppend(list, sId); |
Line 292... | Line 298... | ||
292 | else |
298 | else |
293 | searchDotNotation := parentOID^.DotNotation + '.' + sInput; |
299 | searchDotNotation := parentOID^.DotNotation + '.' + sInput; |
294 | for i := 0 to ListCount(parentOID^.SubIds)-1 do |
300 | for i := 0 to ListCount(parentOID^.SubIds)-1 do |
295 | begin |
301 | begin |
296 | sTmp := ListGetElement(parentOID^.SubIds, i); |
302 | sTmp := ListGetElement(parentOID^.SubIds, i); |
297 | Delete(sTmp, 1, 8); |
- | |
298 | if sTmp = searchDotNotation then |
303 | if DotNotationPart(sTmp) = searchDotNotation then |
299 | begin |
304 | begin |
300 | NumIdAlreadyExisting := true; |
305 | NumIdAlreadyExisting := true; |
301 | exit; |
306 | exit; |
302 | end; |
307 | end; |
303 | end; |
308 | end; |
Line 359... | Line 364... | ||
359 | end; |
364 | end; |
360 | 365 | ||
361 | function NewOidEditor(oid: POID): boolean; |
366 | function NewOidEditor(oid: POID): boolean; |
362 | var |
367 | var |
363 | newfilename: string; |
368 | newfilename: string; |
364 | newoid: TOID; |
369 | newOID: POID; |
365 | begin |
370 | begin |
366 | NewOidEditor := false; |
371 | NewOidEditor := false; |
367 | 372 | ||
368 | InitOidDef(@newoid); |
373 | CreateOidDef(newOID); |
369 | newoid.FileId := NextPossibleFileID; |
374 | newOID^.FileId := NextPossibleFileID; |
370 | newoid.Parent := oid^.FileId + oid^.DotNotation; |
375 | newOID^.Parent := oid^.FileId + oid^.DotNotation; |
371 | if NumIdEditor(@newoid, oid) and |
376 | if NumIdEditor(newOID, oid) and |
372 | AsnEditor(@newoid) and |
377 | AsnEditor(newOID) and |
373 | DescEditor(@newoid) then |
378 | DescEditor(newOID) then |
374 | begin |
379 | begin |
375 | newfilename := newoid.FileId + '.OID'; |
380 | newfilename := newOID^.FileId + '.OID'; |
376 | _WriteOidFile(newfilename, @newoid); |
381 | _WriteOidFile(newfilename, newOID); |
377 | 382 | ||
378 | (* Add link to original file and enable the saving of it *) |
383 | (* Add link to original file and enable the saving of it *) |
379 | ListAppend(oid^.SubIds, newoid.FileId + newoid.DotNotation); |
384 | ListAppend(oid^.SubIds, newOID^.FileId + newOID^.DotNotation); |
380 | NewOidEditor := true; (* request caller to save @oid *) |
385 | NewOidEditor := true; (* request caller to save @oid *) |
381 | end; |
386 | end; |
382 | FreeOidDef(@newoid); |
387 | FreeOidDef(newOID); |
383 | end; |
388 | end; |
384 | 389 | ||
385 | procedure DeleteChildrenRecursive(oid: POID); |
390 | procedure DeleteChildrenRecursive(oid: POID); |
386 | var |
391 | var |
387 | i: integer; |
392 | i: integer; |
388 | childOID: TOID; |
393 | childOID: POID; |
389 | filenameChild: string; |
394 | filenameChild: string; |
390 | begin |
395 | begin |
391 | for i := 0 to ListCount(oid^.SubIds)-1 do |
396 | for i := 0 to ListCount(oid^.SubIds)-1 do |
392 | begin |
397 | begin |
393 | filenameChild := Copy(ListGetElement(oid^.SubIds, i), 1, 8) + '.OID'; |
398 | filenameChild := FileIdPart(ListGetElement(oid^.SubIds, i)) + '.OID'; |
394 | InitOidDef(@childOID); |
399 | CreateOidDef(childOID); |
395 | _ReadOidFile(filenameChild, @childOID); |
400 | _ReadOidFile(filenameChild, childOID); |
396 | DeleteChildrenRecursive(@childOID); |
401 | DeleteChildrenRecursive(childOID); |
397 | FreeOidDef(@childOID); |
402 | FreeOidDef(childOID); |
398 | DeleteFile(filenameChild); |
403 | DeleteFile(filenameChild); |
399 | end; |
404 | end; |
400 | ListClear(oid^.SubIds); |
405 | ListClear(oid^.SubIds); |
401 | end; |
406 | end; |
402 | 407 | ||
403 | procedure DeleteOidRecursive(selfOID: POID); |
408 | procedure DeleteOidRecursive(selfOID: POID); |
404 | var |
409 | var |
405 | i: integer; |
410 | i: integer; |
406 | parentOID: TOID; |
411 | parentOID: POID; |
407 | filenameSelf, filenameParent: string; |
412 | filenameSelf, filenameParent: string; |
408 | fileIdToDelete: string; |
413 | fileIdToDelete: string; |
- | 414 | sTmp: string; |
|
409 | begin |
415 | begin |
410 | (* Remove all children and their files recursively *) |
416 | (* Remove all children and their files recursively *) |
411 | DeleteChildrenRecursive(selfOID); |
417 | DeleteChildrenRecursive(selfOID); |
412 | 418 | ||
413 | (* Remove forward reference in parent OID *) |
419 | (* Remove forward reference in parent OID *) |
414 | filenameParent := Copy(selfOID^.Parent, 1, 8)+'.OID'; |
420 | filenameParent := FileIdPart(selfOID^.Parent) + '.OID'; |
415 | InitOidDef(@parentOID); |
421 | CreateOidDef(parentOID); |
416 | _ReadOidFile(filenameParent, @parentOID); |
422 | _ReadOidFile(filenameParent, parentOID); |
417 | for i := 0 to ListCount(parentOID.SubIds)-1 do |
423 | for i := 0 to ListCount(parentOID^.SubIds)-1 do |
418 | begin |
424 | begin |
419 | if Copy(ListGetElement(parentOID.SubIds, i), 1, 8) = selfOID^.FileId then |
425 | sTmp := ListGetElement(parentOID^.SubIds, i); |
- | 426 | if FileIdPart(sTmp) = selfOID^.FileId then |
|
420 | begin |
427 | begin |
421 | ListDeleteElement(parentOID.SubIds, i); |
428 | ListDeleteElement(parentOID^.SubIds, i); |
422 | _WriteOidFile(filenameParent, @parentOID); |
429 | _WriteOidFile(filenameParent, parentOID); |
423 | break; |
430 | break; |
424 | end; |
431 | end; |
425 | end; |
432 | end; |
426 | FreeOidDef(@parentOID); |
433 | FreeOidDef(parentOID); |
427 | 434 | ||
428 | (* Delete own file *) |
435 | (* Delete own file *) |
429 | fileIdToDelete := selfOID^.FileId; |
436 | fileIdToDelete := selfOID^.FileId; |
430 | filenameSelf := fileIdToDelete+'.OID'; |
437 | filenameSelf := fileIdToDelete+'.OID'; |
431 | DeleteFile(filenameSelf); |
438 | DeleteFile(filenameSelf); |
432 | end; |
439 | end; |
433 | 440 | ||
- | 441 | function _DeleteConfirmation: boolean; |
|
- | 442 | var |
|
- | 443 | sc: Char; |
|
- | 444 | begin |
|
- | 445 | repeat |
|
- | 446 | ShowMessage('Are you sure you want to delete this OID? (Y/N)', 'DELETE OID', true); |
|
- | 447 | DrawStatusBar('Y = Yes; N = No'); |
|
- | 448 | ||
- | 449 | sc := ReadKey; |
|
- | 450 | if sc = #0 then |
|
- | 451 | begin |
|
- | 452 | (* Extended key. Nothing we care about. *) |
|
- | 453 | ReadKey; |
|
- | 454 | continue; |
|
- | 455 | end; |
|
- | 456 | ||
- | 457 | if UpCase(sc) = 'Y' then |
|
- | 458 | begin |
|
- | 459 | _DeleteConfirmation := true; |
|
- | 460 | break; |
|
- | 461 | end; |
|
- | 462 | ||
- | 463 | if UpCase(sc) = 'N' then |
|
- | 464 | begin |
|
- | 465 | _DeleteConfirmation := false; |
|
- | 466 | break; |
|
- | 467 | end; |
|
- | 468 | until false; |
|
- | 469 | end; |
|
- | 470 | ||
434 | procedure DisplayOIDFile(filename: string); |
471 | procedure DisplayOIDFile(filename: string); |
435 | const |
- | |
436 | ID_EXIT = '?EXIT'; |
- | |
437 | ID_ASNEDIT = '?ASN1'; |
- | |
438 | ID_DESCEDIT = '?DESC'; |
- | |
439 | ID_ADDCHILD = '?ADDC'; |
- | |
440 | ID_DELETE = '?DELE'; |
- | |
441 | NAVBAR_SIZE = 5; |
- | |
442 | var |
472 | var |
443 | isRoot: boolean; |
473 | isRoot: boolean; |
444 | f: Text; |
- | |
445 | line, cmd: string; |
- | |
446 | oid: TOID; |
474 | oid: POID; |
447 | i, menuX, menuY: integer; |
475 | i, menuX, menuY: integer; |
448 | linesLeft, linesRequired: integer; |
476 | linesLeft, linesRequired: integer; |
449 | sTmp, subfile: string; |
477 | sTmp, subfile: string; |
450 | sAsn: string; |
- | |
451 | subsel, subfiles: PStringList; |
478 | subsel, subfiles: PStringList; |
452 | subselres: integer; |
479 | subselres: integer; |
453 | sTmp1: string; |
480 | exitRequest: boolean; |
- | 481 | menuIdExit, menuIdAsnEdit, menuIdDescEdit, menuIdAdd, menuIdDelete: integer; |
|
454 | begin |
482 | begin |
- | 483 | exitRequest := false; |
|
455 | repeat |
484 | repeat |
456 | InitOidDef(@oid); |
485 | CreateOidDef(oid); |
457 | _ReadOidFile(filename, @oid); |
486 | _ReadOidFile(filename, oid); |
458 | 487 | ||
459 | (* Print OID information *) |
488 | (* Print OID information *) |
460 | 489 | ||
461 | ClrScr; |
490 | ClrScr; |
462 | 491 | ||
463 | if oid.DotNotation = '' then |
492 | if oid^.DotNotation = '' then |
464 | DrawTitleBar('OID ROOT') |
493 | DrawTitleBar('OID ROOT') |
465 | else |
494 | else |
466 | DrawTitleBar('OID ' + oid.DotNotation); |
495 | DrawTitleBar('OID ' + oid^.DotNotation); |
467 | GotoXY(ScreenWidth-Length(filename)+1,1); |
496 | GotoXY(ScreenWidth-Length(filename)+1,1); |
468 | TextBackground(White); |
497 | TextBackground(White); |
469 | TextColor(Black); |
498 | TextColor(Black); |
470 | WriteLn(filename); |
499 | WriteLn(filename); |
471 | TextBackground(Black); |
500 | TextBackground(Black); |
472 | TextColor(White); |
501 | TextColor(White); |
473 | DrawStatusBar(DEFAULT_STATUSBAR); |
502 | DrawStatusBar(DEFAULT_STATUSBAR); |
474 | GotoXY(1,2); |
503 | GotoXY(1,2); |
475 | 504 | ||
476 | if oid.DotNotation <> '' then |
505 | if oid^.DotNotation <> '' then |
477 | begin |
506 | begin |
478 | WriteLn('Dot-Notation:'); |
507 | WriteLn('Dot-Notation:'); |
479 | WriteLn(oid.DotNotation); |
508 | WriteLn(oid^.DotNotation); |
480 | WriteLn(''); |
509 | WriteLn(''); |
481 | end; |
510 | end; |
482 | 511 | ||
483 | if Trim(oid.Description) <> '' then |
512 | if Trim(oid^.Description) <> '' then |
484 | begin |
513 | begin |
485 | WriteLn('Description:'); |
514 | WriteLn('Description:'); |
486 | WriteLn(oid.Description); |
515 | WriteLn(oid^.Description); |
487 | WriteLn(''); |
516 | WriteLn(''); |
488 | end; |
517 | end; |
489 | 518 | ||
490 | menuX := WhereX + 1; |
519 | menuX := WhereX + 1; |
491 | menuY := ScreenHeight - NAVBAR_SIZE - 1; |
520 | menuY := ScreenHeight - ACTIONMENU_SIZE - 1; |
492 | 521 | ||
493 | if ListCount(oid.ASNIDs) > 0 then |
522 | if ListCount(oid^.ASNIDs) > 0 then |
494 | begin |
523 | begin |
495 | linesLeft := menuY - WhereY - 1; |
524 | linesLeft := menuY - WhereY - 1; |
496 | linesRequired := 1 + ListCount(oid.ASNIds); |
525 | linesRequired := 1 + ListCount(oid^.ASNIds); |
497 | 526 | ||
498 | if LinesLeft < LinesRequired then |
527 | if LinesLeft < LinesRequired then |
499 | begin |
528 | begin |
500 | (* Compact display of ASN.1 identifiers *) |
529 | (* Compact display of ASN.1 identifiers *) |
501 | Write('ASN.1-Identifiers: '); |
530 | Write('ASN.1-Identifiers: '); |
502 | for i := 0 to ListCount(oid.ASNIds)-1 do |
531 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
503 | begin |
532 | begin |
504 | if i > 0 then Write(', '); |
533 | if i > 0 then Write(', '); |
505 | Write(ListGetElement(oid.ASNIds, i)); |
534 | Write(ListGetElement(oid^.ASNIds, i)); |
506 | end; |
535 | end; |
507 | WriteLn(''); |
536 | WriteLn(''); |
508 | end |
537 | end |
509 | else |
538 | else |
510 | begin |
539 | begin |
511 | (* Long display of ASN.1 identifiers *) |
540 | (* Long display of ASN.1 identifiers *) |
512 | WriteLn('ASN.1-Identifiers:'); |
541 | WriteLn('ASN.1-Identifiers:'); |
513 | for i := 0 to ListCount(oid.ASNIds)-1 do |
542 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
514 | begin |
543 | begin |
515 | WriteLn('- '+ListGetElement(oid.ASNIds, i)); |
544 | WriteLn('- '+ListGetElement(oid^.ASNIds, i)); |
516 | end; |
545 | end; |
517 | WriteLn(''); |
546 | WriteLn(''); |
518 | end; |
547 | end; |
519 | end; |
548 | end; |
520 | 549 | ||
521 | (* Now prepare the menu entries *) |
550 | (* Now prepare the menu entries *) |
522 | 551 | ||
523 | InitList(subsel); |
552 | CreateList(subsel); |
524 | InitList(subfiles); |
553 | CreateList(subfiles); |
525 | 554 | ||
526 | sTmp := oid.Parent; |
- | |
527 | if sTmp = '' then |
555 | if oid^.Parent = '' then |
528 | begin |
556 | begin |
529 | isRoot := true; |
557 | isRoot := true; |
530 | end |
558 | end |
531 | else |
559 | else |
532 | begin |
560 | begin |
533 | Delete(sTmp, 1, 8); |
- | |
534 | isRoot := sTmp = oid.DotNotation; |
561 | isRoot := DotNotationPart(oid^.Parent) = oid^.DotNotation; |
535 | end; |
562 | end; |
536 | 563 | ||
537 | if (oid.Parent <> '') and not isRoot then |
564 | if (oid^.Parent <> '') and not isRoot then |
538 | begin |
565 | begin |
539 | sTmp := oid.Parent; |
566 | sTmp := oid^.Parent; |
540 | subfile := Copy(sTmp, 1, 8)+'.OID'; |
567 | subfile := FileIdPart(sTmp) + '.OID'; |
541 | Delete(sTmp, 1, 8); |
- | |
542 | sTmp := sTmp + _ShowASNIds(subfile); |
- | |
543 | ListAppend(subsel, 'Go to parent ' + sTmp); |
568 | ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(subfile)); |
544 | ListAppend(subfiles, subfile); |
569 | ListAppend(subfiles, subfile); |
545 | end; |
570 | end; |
546 | 571 | ||
547 | if isRoot then |
572 | if isRoot then |
548 | begin |
573 | begin |
549 | ListAppend(subsel, 'Back to main menu'); |
574 | menuIdExit := ListAppend(subsel, 'Back to main menu'); |
550 | ListAppend(subfiles, ID_EXIT); |
575 | ListAppend(subfiles, ''); |
551 | end; |
576 | end |
- | 577 | else menuIdExit := -99; |
|
552 | 578 | ||
553 | for i := 0 to ListCount(oid.SubIds)-1 do |
579 | for i := 0 to ListCount(oid^.SubIds)-1 do |
554 | begin |
580 | begin |
555 | sTmp := ListGetElement(oid.SubIds, i); |
581 | sTmp := ListGetElement(oid^.SubIds, i); |
556 | subfile := Copy(sTmp, 1, 8)+'.OID'; |
582 | subfile := FileIdPart(sTmp) + '.OID'; |
557 | Delete(sTmp, 1, 8); |
- | |
558 | sTmp := sTmp + _ShowASNIds(subfile); |
- | |
559 | ListAppend(subsel, 'Go to child ' + sTmp); |
583 | ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(subfile)); |
560 | ListAppend(subfiles, subfile); |
584 | ListAppend(subfiles, subfile); |
561 | end; |
585 | end; |
562 | 586 | ||
563 | if oid.DotNotation <> '' then |
587 | if oid^.DotNotation <> '' then |
564 | begin |
588 | begin |
565 | ListAppend(subsel, 'Edit ASN.1 identifiers'); |
589 | menuIdAsnEdit := ListAppend(subsel, 'Edit ASN.1 identifiers'); |
566 | ListAppend(subfiles, ID_ASNEDIT); |
590 | ListAppend(subfiles, ''); |
567 | end; |
591 | end |
- | 592 | else menuIdAsnEdit := -99; |
|
568 | 593 | ||
569 | ListAppend(subsel, 'Edit description'); |
594 | menuIdDescEdit := ListAppend(subsel, 'Edit description'); |
570 | ListAppend(subfiles, ID_DESCEDIT); |
595 | ListAppend(subfiles, ''); |
571 | 596 | ||
572 | ListAppend(subsel, 'Add child'); |
597 | menuIdAdd := ListAppend(subsel, 'Add child'); |
573 | ListAppend(subfiles, ID_ADDCHILD); |
598 | ListAppend(subfiles, ''); |
574 | 599 | ||
575 | if not isRoot then |
600 | if not isRoot then |
576 | begin |
601 | begin |
577 | ListAppend(subsel, 'Delete OID'); |
602 | menuIdDelete := ListAppend(subsel, 'Delete OID'); |
578 | ListAppend(subfiles, ID_DELETE); |
603 | ListAppend(subfiles, ''); |
579 | end; |
604 | end |
- | 605 | else menuIdDelete := -99; |
|
580 | 606 | ||
581 | (* Show menu *) |
607 | (* Show menu *) |
582 | 608 | ||
583 | subselres := DrawSelectionList(menuX, menuY, |
609 | subselres := DrawSelectionList(menuX, menuY, |
584 | ScreenWidth-2, |
610 | ScreenWidth-2, |
585 | NAVBAR_SIZE, |
611 | ACTIONMENU_SIZE, |
586 | subsel, |
612 | subsel, |
587 | true, |
613 | true, |
588 | 'SELECT ACTION', |
614 | 'SELECT ACTION', |
589 | 1); |
615 | 1); |
590 | 616 | ||
591 | (* Process user selection *) |
617 | (* Process user selection *) |
592 | 618 | ||
593 | if subselres = -1 then |
619 | if subselres = -1 then |
594 | begin |
620 | begin |
595 | exit; |
621 | exitRequest := true; |
596 | end |
622 | end |
597 | else |
- | |
598 | begin |
- | |
599 | sTmp1 := ListGetElement(subfiles, subselres); |
- | |
600 | if sTmp1 = ID_ASNEDIT then |
623 | else if subselres = menuIdAsnEdit then |
601 | begin |
624 | begin |
602 | if AsnEditor(@oid) then |
625 | if AsnEditor(oid) then |
603 | _WriteOidFile(filename, @oid); |
626 | _WriteOidFile(filename, oid); |
604 | end |
627 | end |
605 | else if sTmp1 = ID_DESCEDIT then |
628 | else if subselres = menuIdDescEdit then |
606 | begin |
629 | begin |
607 | if DescEditor(@oid) then |
630 | if DescEditor(oid) then |
608 | _WriteOidFile(filename, @oid); |
631 | _WriteOidFile(filename, oid); |
609 | end |
632 | end |
610 | else if sTmp1 = ID_ADDCHILD then |
633 | else if subselres = menuIdAdd then |
611 | begin |
- | |
612 | if NewOidEditor(@oid) then |
- | |
613 | begin |
634 | begin |
- | 635 | if NewOidEditor(oid) then |
|
614 | _WriteOidFile(filename, @oid); |
636 | _WriteOidFile(filename, oid); |
615 | end; |
- | |
616 | end |
637 | end |
617 | else if sTmp1 = ID_DELETE then |
638 | else if subselres = menuIdDelete then |
618 | begin |
639 | begin |
619 | ShowMessage('Are you sure you want to delete this OID?', 'DELETE OID', true); |
- | |
620 | DrawStatusBar('Y = Yes; any other key = No'); |
- | |
621 | if UpCase(ReadKey) = 'Y' then |
640 | if _DeleteConfirmation then |
622 | begin |
641 | begin |
623 | filename := Copy(oid.Parent,1,8)+'.OID'; |
642 | filename := FileIdPart(oid^.Parent) + '.OID'; |
624 | DeleteOidRecursive(@oid); |
643 | DeleteOidRecursive(oid); |
625 | end; |
644 | end; |
626 | end |
645 | end |
627 | else if sTmp1 = ID_EXIT then |
646 | else if subselres = menuIdExit then |
628 | begin |
647 | begin |
629 | exit; |
648 | exitRequest := true; |
630 | end |
649 | end |
631 | else |
650 | else |
632 | begin |
651 | begin |
633 | filename := sTmp1; |
652 | (* Normal OID *) |
634 | end; |
653 | filename := ListGetElement(subfiles, subselres); |
635 | end; |
654 | end; |
636 | FreeList(subsel); |
655 | FreeList(subsel); |
637 | FreeList(subfiles); |
656 | FreeList(subfiles); |
638 | 657 | ||
639 | FreeOidDef(@oid); |
658 | FreeOidDef(oid); |
640 | until false; |
659 | until exitRequest; |
641 | end; |
660 | end; |
642 | 661 | ||
643 | procedure CreateInitOIDFile(filename: string); |
662 | procedure CreateInitOIDFile(filename: string); |
644 | var |
663 | var |
645 | oid: TOID; |
664 | oid: POID; |
646 | begin |
665 | begin |
647 | InitOidDef(@oid); |
666 | CreateOidDef(oid); |
648 | oid.Description := 'This is the root of the OID tree.' +#13#10 + |
667 | oid^.Description := 'This is the root of the OID tree.' +#13#10 + |
649 | #13#10 + |
668 | #13#10 + |
650 | 'Valid subsequent arcs are per definition:' + #13#10 + |
669 | 'Valid subsequent arcs are per definition:' + #13#10 + |
651 | '- 0 (itu-t)' + #13#10 + |
670 | '- 0 (itu-t)' + #13#10 + |
652 | '- 1 (iso)' + #13#10 + |
671 | '- 1 (iso)' + #13#10 + |
653 | '- 2 (joint-iso-itu-t)'; |
672 | '- 2 (joint-iso-itu-t)'; |
654 | oid.FileId := '00000000'; |
673 | oid^.FileId := '00000000'; |
655 | oid.DotNotation := ''; |
674 | oid^.DotNotation := ''; |
656 | oid.Parent := '00000000'; |
675 | oid^.Parent := '00000000'; |
657 | _WriteOidFile(filename, @oid); |
676 | _WriteOidFile(filename, oid); |
658 | FreeOidDef(@oid); |
677 | FreeOidDef(oid); |
659 | end; |
678 | end; |
660 | 679 | ||
661 | procedure OP_ManageOIDs; |
680 | procedure OP_ManageOIDs; |
- | 681 | var |
|
- | 682 | initFile: string; |
|
662 | begin |
683 | begin |
663 | ClrScr; |
684 | ClrScr; |
664 | DrawTitleBar('Manage Object Identifiers'); |
685 | DrawTitleBar('Manage Object Identifiers'); |
665 | DrawStatusBar(''); |
686 | DrawStatusBar(''); |
666 | 687 | ||
- | 688 | initFile := ZeroPad(0, 8) + '.OID'; |
|
667 | if not FileExists('00000000.OID') then |
689 | if not FileExists(initFile) then |
668 | begin |
690 | begin |
669 | CreateInitOIDFile('00000000.OID'); |
691 | CreateInitOIDFile(initFile); |
670 | end; |
692 | end; |
671 | DisplayOIDFile('00000000.OID'); |
693 | DisplayOIDFile(initFile); |
672 | end; |
694 | end; |
673 | 695 | ||
674 | procedure OP_ManageRAs; |
696 | procedure OP_ManageRAs; |
675 | begin |
697 | begin |
676 | ClrScr; |
698 | ClrScr; |
677 | DrawTitleBar('Manage Registration Authorities'); |
699 | DrawTitleBar('Manage Registration Authorities'); |
678 | DrawStatusBar(''); |
700 | DrawStatusBar(''); |
679 | 701 | ||
680 | (* TODO: Implement "Manage RAs" feature *) |
702 | (* TODO: Implement "Manage RAs" feature *) |
681 | ShowMessage('This feature has not yet been implemented!', 'NOTICE', true); |
- | |
682 | _Pause; |
- | |
683 | end; |
703 | end; |
684 | 704 | ||
685 | procedure OP_ReturnToMSDOS; |
705 | procedure OP_ReturnToMSDOS; |
686 | begin |
706 | begin |
687 | ClrScr; |
707 | ClrScr; |
688 | end; |
708 | end; |
689 | 709 | ||
690 | procedure OP_MainMenu; |
710 | procedure OP_MainMenu; |
691 | const |
- | |
692 | MenuWidth = 15; |
- | |
693 | MenuHeight = 3; |
- | |
694 | var |
711 | var |
695 | menu: PStringList; |
712 | menu: PStringList; |
696 | menuRes, menuLeft, menuTop: integer; |
713 | menuRes, menuLeft, menuTop: integer; |
- | 714 | menuIdOID, menuIdRA, menuIdExit: integer; |
|
697 | begin |
715 | begin |
698 | repeat |
716 | repeat |
699 | ClrScr; |
717 | ClrScr; |
700 | 718 | ||
701 | DrawTitleBar('Welcome to OIDplus for DOS'); |
719 | DrawTitleBar('Welcome to OIDplus for DOS'); |
702 | DrawStatusBar(DEFAULT_STATUSBAR); |
720 | DrawStatusBar(DEFAULT_STATUSBAR); |
703 | GoToXY(ScreenWidth-Length(VERSIONINFO), ScreenHeight-1); |
721 | GoToXY(ScreenWidth-Length(VERSIONINFO), ScreenHeight-1); |
704 | Write(VERSIONINFO); |
722 | Write(VERSIONINFO); |
705 | 723 | ||
706 | InitList(menu); |
724 | CreateList(menu); |
- | 725 | ||
707 | ListAppend(menu, 'Manage OIDs'); |
726 | menuIdOID := ListAppend(menu, 'Manage OIDs'); |
708 | ListAppend(menu, 'Manage RAs'); |
727 | menuIdRA := -99; (*ListAppend(menu, 'Manage RAs');*) |
709 | ListAppend(menu, 'Return to DOS'); |
728 | menuIdExit := ListAppend(menu, 'Return to DOS'); |
- | 729 | ||
710 | menuLeft := round(ScreenWidth/2 -MenuWidth/2); |
730 | menuLeft := round(ScreenWidth/2 -MAINMENU_WIDTH/2); |
711 | menuTop := round(ScreenHeight/2-MenuHeight/2); |
731 | menuTop := round(ScreenHeight/2-MAINMENU_HEIGHT/2); |
712 | menuRes := DrawSelectionList(menuLeft, menuTop, MenuWidth, MenuHeight, menu, true, 'MAIN MENU', 2); |
732 | menuRes := DrawSelectionList(menuLeft, menuTop, |
- | 733 | MAINMENU_WIDTH, MAINMENU_HEIGHT, |
|
- | 734 | menu, true, 'MAIN MENU', 2); |
|
713 | FreeList(menu); |
735 | FreeList(menu); |
714 | 736 | ||
715 | if menuRes = 0 then |
737 | if menuRes = menuIdOID then |
716 | begin |
738 | begin |
717 | OP_ManageOIDs; |
739 | OP_ManageOIDs; |
718 | end; |
740 | end |
719 | - | ||
720 | if menuRes = 1 then |
741 | else if menuRes = menuIdRA then |
721 | begin |
742 | begin |
722 | OP_ManageRAs; |
743 | OP_ManageRAs; |
723 | end; |
744 | end; |
724 | until (menuRes = 2) or (menuRes = -1); |
745 | until (menuRes = menuIdExit) or (MAINMENU_ALLOW_ESC and (menuRes = -1)); |
725 | 746 | ||
726 | OP_ReturnToMSDOS; |
747 | OP_ReturnToMSDOS; |
727 | end; |
748 | end; |
728 | 749 | ||
729 | begin |
750 | begin |