Subversion Repositories oidplus

Rev

Rev 734 | Rev 737 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 734 Rev 735
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-14                         *)
6
(* Revision: 2022-02-14                         *)
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
 
12
uses
12
uses
13
  Dos, Crt, StrList, VtsFuncs, VtsCui, OidFile, OidUtils;
13
  Dos, Crt, StrList, VtsFuncs, VtsCui, OidFile, OidUtils;
14
 
14
 
15
const
15
const
16
  VERSIONINFO = 'Revision: 2022-02-14';
16
  VERSIONINFO            = 'Revision: 2022-02-14';
17
  DEFAULT_STATUSBAR = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.';
17
  DEFAULT_STATUSBAR      = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.';
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);
28
 
32
 
29
  if DISKIO_SOUND_DEBUGGING then
33
  if DISKIO_SOUND_DEBUGGING then
30
  begin
34
  begin
31
    Sound(70);
35
    Sound(70);
32
    Delay(DISKIO_SOUND_DELAY - 10);
36
    Delay(DISKIO_SOUND_DELAY - 10);
33
    NoSound;
37
    NoSound;
34
    Delay(10);
38
    Delay(10);
35
  end;
39
  end;
36
 
40
 
37
  DrawStatusBar(DEFAULT_STATUSBAR);
41
  DrawStatusBar(DEFAULT_STATUSBAR);
38
end;
42
end;
39
 
43
 
40
procedure _ReadOidFile(filename: string; oid: POid);
44
procedure _ReadOidFile(filename: string; oid: POid);
41
begin
45
begin
42
  DrawStatusBar('Read file ' + filename + '...');
46
  DrawStatusBar('Read file ' + filename + '...');
43
  ReadOidFile(filename, oid);
47
  ReadOidFile(filename, oid);
44
 
48
 
45
  if DISKIO_SOUND_DEBUGGING then
49
  if DISKIO_SOUND_DEBUGGING then
46
  begin
50
  begin
47
    Sound(50);
51
    Sound(50);
48
    Delay(DISKIO_SOUND_DELAY - 10);
52
    Delay(DISKIO_SOUND_DELAY - 10);
49
    NoSound;
53
    NoSound;
50
    Delay(10);
54
    Delay(10);
51
  end;
55
  end;
52
 
56
 
53
  DrawStatusBar(DEFAULT_STATUSBAR);
57
  DrawStatusBar(DEFAULT_STATUSBAR);
54
end;
58
end;
55
 
59
 
56
procedure _Pause;
60
procedure _Pause;
57
var
61
var
58
  bakX, bakY: integer;
62
  bakX, bakY: integer;
59
begin
63
begin
60
  bakX := WhereX;
64
  bakX := WhereX;
61
  bakY := WhereY;
65
  bakY := WhereY;
62
  DrawStatusBar('Press any key to continue');
66
  DrawStatusBar('Press any key to continue');
63
  GoToXY(bakX, bakY);
67
  GoToXY(bakX, bakY);
64
  ReadKey;
68
  ReadKey;
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
93
  sTmp: string;
97
  sTmp: string;
94
  i: integer;
98
  i: integer;
95
begin
99
begin
96
  for i := 0 to ListCount(oid^.AsnIds)-1 do
100
  for i := 0 to ListCount(oid^.AsnIds)-1 do
97
  begin
101
  begin
98
    sTmp := ListGetElement(oid^.AsnIds, i);
102
    sTmp := ListGetElement(oid^.AsnIds, i);
99
    if sTmp = asnid then
103
    if sTmp = asnid then
100
    begin
104
    begin
101
      AsnAlreadyExisting := true;
105
      AsnAlreadyExisting := true;
102
      exit;
106
      exit;
103
    end;
107
    end;
104
  end;
108
  end;
105
  AsnAlreadyExisting := false;
109
  AsnAlreadyExisting := false;
106
end;
110
end;
107
 
111
 
108
function AsnEditor(oid: POID): boolean;
112
function AsnEditor(oid: POID): boolean;
109
var
113
var
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,
154
                    SINGLE_LINE_BOX_PADDING_INNER,
160
                    SINGLE_LINE_BOX_PADDING_INNER,
155
                    ScreenHeight div 2,
161
                    ScreenHeight div 2,
156
                    ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2,
162
                    ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2,
157
                    1,
163
                    1,
158
                    'ADD SINGLE ASN.1 ID',
164
                    'ADD SINGLE ASN.1 ID',
159
                    2) then
165
                    2) then
160
        begin
166
        begin
161
          if sInput = '' then continue;
167
          if sInput = '' then continue;
162
          if not ASN1IDValid(sInput) then
168
          if not ASN1IDValid(sInput) then
163
          begin
169
          begin
164
            ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true);
170
            ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true);
165
            _Pause;
171
            _Pause;
166
          end
172
          end
167
          else if AsnAlreadyExisting(oid, sInput) then
173
          else if AsnAlreadyExisting(oid, sInput) then
168
          begin
174
          begin
169
            ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true);
175
            ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true);
170
            _Pause;
176
            _Pause;
171
          end
177
          end
172
          else
178
          else
173
          begin
179
          begin
174
            ListAppend(oid^.ASNIDs, sInput);
180
            ListAppend(oid^.ASNIDs, sInput);
175
            break;
181
            break;
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
193
    else
199
    else
194
    begin
200
    begin
195
      DrawStatusBar('Note: Remove the text to delete the ASN.1 identifier');
201
      DrawStatusBar('Note: Remove the text to delete the ASN.1 identifier');
196
      sInput := ListGetElement(oid^.ASNIDs, res);
202
      sInput := ListGetElement(oid^.ASNIDs, res);
197
      repeat
203
      repeat
198
        if QueryVal(sInput,
204
        if QueryVal(sInput,
199
                    SINGLE_LINE_BOX_PADDING_INNER,
205
                    SINGLE_LINE_BOX_PADDING_INNER,
200
                    ScreenHeight div 2,
206
                    ScreenHeight div 2,
201
                    ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2,
207
                    ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2,
202
                    1,
208
                    1,
203
                    'EDIT SINGLE ASN.1 ID',
209
                    'EDIT SINGLE ASN.1 ID',
204
                    2) then
210
                    2) then
205
        begin
211
        begin
206
          if sInput = '' then
212
          if sInput = '' then
207
          begin
213
          begin
208
            (* Empty input = Delete ASN.1 ID *)
214
            (* Empty input = Delete ASN.1 ID *)
209
            ListDeleteElement(oid^.ASNIDs, res);
215
            ListDeleteElement(oid^.ASNIDs, res);
210
            break;
216
            break;
211
          end
217
          end
212
          else if not ASN1IDValid(sInput) then
218
          else if not ASN1IDValid(sInput) then
213
          begin
219
          begin
214
            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);
215
            _Pause;
221
            _Pause;
216
          end
222
          end
217
          else if AsnAlreadyExisting(oid, sInput) and
223
          else if AsnAlreadyExisting(oid, sInput) and
218
              not (ListGetElement(oid^.ASNIDs, res) = sInput) then
224
              not (ListGetElement(oid^.ASNIDs, res) = sInput) then
219
          begin
225
          begin
220
            ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true);
226
            ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true);
221
            _Pause;
227
            _Pause;
222
          end
228
          end
223
          else
229
          else
224
          begin
230
          begin
225
            ListSetElement(oid^.ASNIDs, res, sInput);
231
            ListSetElement(oid^.ASNIDs, res, sInput);
226
            break;
232
            break;
227
          end;
233
          end;
228
        end
234
        end
229
        else break;
235
        else break;
230
      until false;
236
      until false;
231
    end;
237
    end;
232
  until false;
238
  until false;
233
end;
239
end;
234
 
240
 
235
function DescEditor(oid: POID): boolean;
241
function DescEditor(oid: POID): boolean;
236
var
242
var
237
  sInput: string;
243
  sInput: string;
238
begin
244
begin
239
  DescEditor := false;
245
  DescEditor := false;
240
 
246
 
241
  DrawStatusBar('Note: Press Ctrl+Return for a line-break.');
247
  DrawStatusBar('Note: Press Ctrl+Return for a line-break.');
242
  sInput := oid^.description;
248
  sInput := oid^.description;
243
  if QueryVal(sInput,
249
  if QueryVal(sInput,
244
              DESCEDIT_PADDING,
250
              DESCEDIT_PADDING,
245
              ScreenHeight div 2 - DESCEDIT_LINES div 2,
251
              ScreenHeight div 2 - DESCEDIT_LINES div 2,
246
              ScreenWidth - (DESCEDIT_PADDING-1)*2,
252
              ScreenWidth - (DESCEDIT_PADDING-1)*2,
247
              DESCEDIT_LINES,
253
              DESCEDIT_LINES,
248
              'EDIT DESCRIPTION',
254
              'EDIT DESCRIPTION',
249
              2) then
255
              2) then
250
  begin
256
  begin
251
    oid^.description := sInput;
257
    oid^.description := sInput;
252
    DescEditor := true; (* request caller to save @oid *)
258
    DescEditor := true; (* request caller to save @oid *)
253
  end;
259
  end;
254
end;
260
end;
255
 
261
 
256
function NextPossibleFileID: string;
262
function NextPossibleFileID: string;
257
var
263
var
258
  DirInfo: SearchRec;
264
  DirInfo: SearchRec;
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);
270
    FindNext(DirInfo);
276
    FindNext(DirInfo);
271
  end;
277
  end;
272
 
278
 
273
  (* Search for the first non existing item in the list *)
279
  (* Search for the first non existing item in the list *)
274
  sId := '';
280
  sId := '';
275
  for iId := 0 to 99999999 do
281
  for iId := 0 to 99999999 do
276
  begin
282
  begin
277
    sId := ZeroPad(iId, 8);
283
    sId := ZeroPad(iId, 8);
278
    if not ListContains(list, sId) then break;
284
    if not ListContains(list, sId) then break;
279
  end;
285
  end;
280
  NextPossibleFileId := sId;
286
  NextPossibleFileId := sId;
281
  FreeList(list);
287
  FreeList(list);
282
end;
288
end;
283
 
289
 
284
function NumIdAlreadyExisting(parentOID: POID; sInput: string): boolean;
290
function NumIdAlreadyExisting(parentOID: POID; sInput: string): boolean;
285
var
291
var
286
  searchDotNotation: string;
292
  searchDotNotation: string;
287
  sTmp: string;
293
  sTmp: string;
288
  i: integer;
294
  i: integer;
289
begin
295
begin
290
  if parentOID^.DotNotation = '' then
296
  if parentOID^.DotNotation = '' then
291
    searchDotNotation := sInput
297
    searchDotNotation := sInput
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;
304
  NumIdAlreadyExisting := false;
309
  NumIdAlreadyExisting := false;
305
end;
310
end;
306
 
311
 
307
function NumIdEditor(oid: POID; parentOID: POID): boolean;
312
function NumIdEditor(oid: POID; parentOID: POID): boolean;
308
var
313
var
309
  sInput: string;
314
  sInput: string;
310
begin
315
begin
311
  NumIdEditor := false;
316
  NumIdEditor := false;
312
  sInput := '';
317
  sInput := '';
313
 
318
 
314
  repeat
319
  repeat
315
    if QueryVal(sInput,
320
    if QueryVal(sInput,
316
                SINGLE_LINE_BOX_PADDING_INNER,
321
                SINGLE_LINE_BOX_PADDING_INNER,
317
                ScreenHeight div 2,
322
                ScreenHeight div 2,
318
                ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2,
323
                ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2,
319
                1,
324
                1,
320
                'ENTER NUMERIC ID',
325
                'ENTER NUMERIC ID',
321
                2) then
326
                2) then
322
    begin
327
    begin
323
      if sInput = '' then continue;
328
      if sInput = '' then continue;
324
      if not IsNumeric(sInput) then
329
      if not IsNumeric(sInput) then
325
      begin
330
      begin
326
        ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true);
331
        ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true);
327
        _Pause;
332
        _Pause;
328
      end
333
      end
329
      else if (parentOID^.DotNotation='') and (StrToInt(sInput) > 2) then
334
      else if (parentOID^.DotNotation='') and (StrToInt(sInput) > 2) then
330
      begin
335
      begin
331
        ShowMessage('Invalid numeric ID (root arc can only be 0, 1, or 2)', 'ERROR', true);
336
        ShowMessage('Invalid numeric ID (root arc can only be 0, 1, or 2)', 'ERROR', true);
332
        _Pause;
337
        _Pause;
333
      end
338
      end
334
      else if ((parentOID^.DotNotation='0') or (parentOID^.DotNotation='1')) and (StrToInt(sInput) > 39) then
339
      else if ((parentOID^.DotNotation='0') or (parentOID^.DotNotation='1')) and (StrToInt(sInput) > 39) then
335
      begin
340
      begin
336
        ShowMessage('Invalid numeric ID (root 0 and 1 must have sub-arc of 0..39)', 'ERROR', true);
341
        ShowMessage('Invalid numeric ID (root 0 and 1 must have sub-arc of 0..39)', 'ERROR', true);
337
        _Pause;
342
        _Pause;
338
      end
343
      end
339
      else if NumIdAlreadyExisting(parentOID, sInput) then
344
      else if NumIdAlreadyExisting(parentOID, sInput) then
340
      begin
345
      begin
341
        ShowMessage('This numeric ID is already used in this arc', 'ERROR', true);
346
        ShowMessage('This numeric ID is already used in this arc', 'ERROR', true);
342
        _Pause;
347
        _Pause;
343
      end
348
      end
344
      else
349
      else
345
      begin
350
      begin
346
        if parentOID^.DotNotation = '' then
351
        if parentOID^.DotNotation = '' then
347
          oid^.DotNotation := sInput
352
          oid^.DotNotation := sInput
348
        else
353
        else
349
          oid^.DotNotation := parentOID^.DotNotation + '.' + sInput;
354
          oid^.DotNotation := parentOID^.DotNotation + '.' + sInput;
350
        NumIdEditor := true; (* request caller to save @oid *)
355
        NumIdEditor := true; (* request caller to save @oid *)
351
        Exit;
356
        Exit;
352
      end;
357
      end;
353
    end
358
    end
354
    else
359
    else
355
    begin
360
    begin
356
      Exit;
361
      Exit;
357
    end;
362
    end;
358
  until false;
363
  until false;
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
730
  OP_MainMenu;
751
  OP_MainMenu;
731
end.
752
end.
732
 
753