Rev 738 | Rev 740 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 738 | Rev 739 | ||
---|---|---|---|
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; |
23 | ACTIONMENU_SIZE = 5; |
24 | MAINMENU_WIDTH = 15; |
24 | MAINMENU_WIDTH = 15; |
25 | MAINMENU_HEIGHT = 3; |
25 | MAINMENU_HEIGHT = 3; |
26 | MAINMENU_ALLOW_ESC = false; |
26 | MAINMENU_ALLOW_ESC = false; |
27 | TITLEBAR_LEFT_TEXT = 'OIDplus'; |
27 | TITLEBAR_LEFT_TEXT = 'OIDplus'; |
28 | 28 | ||
29 | procedure _WriteOidFile(filename: string; oid: POid); |
29 | procedure _WriteOidFile(filename: string; oid: POid); |
30 | begin |
30 | begin |
31 | DrawStatusBar('Write file ' + filename + '...'); |
31 | DrawStatusBar('Write file ' + filename + '...'); |
32 | WriteOidFile(filename, oid); |
32 | WriteOidFile(filename, oid); |
33 | 33 | ||
34 | if DISKIO_SOUND_DEBUGGING then |
34 | if DISKIO_SOUND_DEBUGGING then |
35 | begin |
35 | begin |
36 | Sound(70); |
36 | Sound(70); |
37 | Delay(DISKIO_SOUND_DELAY - 10); |
37 | Delay(DISKIO_SOUND_DELAY - 10); |
38 | NoSound; |
38 | NoSound; |
39 | Delay(10); |
39 | Delay(10); |
40 | end; |
40 | end; |
41 | 41 | ||
42 | DrawStatusBar(DEFAULT_STATUSBAR); |
42 | DrawStatusBar(DEFAULT_STATUSBAR); |
43 | end; |
43 | end; |
44 | 44 | ||
45 | procedure _ReadOidFile(filename: string; oid: POid); |
45 | procedure _ReadOidFile(filename: string; oid: POid); |
46 | begin |
46 | begin |
47 | DrawStatusBar('Read file ' + filename + '...'); |
47 | DrawStatusBar('Read file ' + filename + '...'); |
48 | ReadOidFile(filename, oid); |
48 | ReadOidFile(filename, oid); |
49 | 49 | ||
50 | if DISKIO_SOUND_DEBUGGING then |
50 | if DISKIO_SOUND_DEBUGGING then |
51 | begin |
51 | begin |
52 | Sound(50); |
52 | Sound(50); |
53 | Delay(DISKIO_SOUND_DELAY - 10); |
53 | Delay(DISKIO_SOUND_DELAY - 10); |
54 | NoSound; |
54 | NoSound; |
55 | Delay(10); |
55 | Delay(10); |
56 | end; |
56 | end; |
57 | 57 | ||
58 | DrawStatusBar(DEFAULT_STATUSBAR); |
58 | DrawStatusBar(DEFAULT_STATUSBAR); |
59 | end; |
59 | end; |
60 | 60 | ||
61 | procedure _Pause; |
61 | procedure _Pause; |
62 | var |
62 | var |
63 | bakX, bakY: integer; |
63 | bakX, bakY: integer; |
64 | begin |
64 | begin |
65 | bakX := WhereX; |
65 | bakX := WhereX; |
66 | bakY := WhereY; |
66 | bakY := WhereY; |
67 | DrawStatusBar('Press any key to continue'); |
67 | DrawStatusBar('Press any key to continue'); |
68 | GoToXY(bakX, bakY); |
68 | GoToXY(bakX, bakY); |
69 | ReadKey; |
69 | ReadKey; |
70 | DrawStatusBar(DEFAULT_STATUSBAR); |
70 | DrawStatusBar(DEFAULT_STATUSBAR); |
71 | end; |
71 | end; |
72 | 72 | ||
73 | function _ShowASNIds(subfile: string): string; |
73 | function _ShowASNIds(subfile: string): string; |
74 | var |
74 | var |
75 | childOID: POID; |
75 | childOID: POID; |
76 | j, jmax: integer; |
76 | j, jmax: integer; |
77 | sTmp: string; |
77 | sTmp: string; |
78 | begin |
78 | begin |
79 | sTmp := ''; |
79 | sTmp := ''; |
80 | CreateOidDef(childOID); |
80 | CreateOidDef(childOID); |
81 | _ReadOidFile(subfile, childOID); |
81 | _ReadOidFile(subfile, childOID); |
82 | jmax := ListCount(childOID^.ASNIds)-1; |
82 | jmax := ListCount(childOID^.ASNIds)-1; |
83 | for j := 0 to jmax do |
83 | for j := 0 to jmax do |
84 | begin |
84 | begin |
85 | if j = 0 then sTmp := sTmp + ' ('; |
85 | if j = 0 then sTmp := sTmp + ' ('; |
86 | sTmp := sTmp + ListGetElement(childOID^.ASNIds, j); |
86 | sTmp := sTmp + ListGetElement(childOID^.ASNIds, j); |
87 | if j = jmax then |
87 | if j = jmax then |
88 | sTmp := sTmp + ')' |
88 | sTmp := sTmp + ')' |
89 | else |
89 | else |
90 | sTmp := sTmp + ', '; |
90 | sTmp := sTmp + ', '; |
91 | end; |
91 | end; |
92 | FreeOidDef(childOID); |
92 | FreeOidDef(childOID); |
93 | _ShowASNIds := sTmp; |
93 | _ShowASNIds := sTmp; |
94 | end; |
94 | end; |
95 | 95 | ||
96 | function AsnAlreadyExisting(oid: POID; asnid: string): boolean; |
96 | function AsnAlreadyExisting(oid: POID; asnid: string): boolean; |
97 | var |
97 | var |
98 | sTmp: string; |
98 | sTmp: string; |
99 | i: integer; |
99 | i: integer; |
100 | begin |
100 | begin |
101 | for i := 0 to ListCount(oid^.AsnIds)-1 do |
101 | for i := 0 to ListCount(oid^.AsnIds)-1 do |
102 | begin |
102 | begin |
103 | sTmp := ListGetElement(oid^.AsnIds, i); |
103 | sTmp := ListGetElement(oid^.AsnIds, i); |
104 | if sTmp = asnid then |
104 | if sTmp = asnid then |
105 | begin |
105 | begin |
106 | AsnAlreadyExisting := true; |
106 | AsnAlreadyExisting := true; |
107 | exit; |
107 | exit; |
108 | end; |
108 | end; |
109 | end; |
109 | end; |
110 | AsnAlreadyExisting := false; |
110 | AsnAlreadyExisting := false; |
111 | end; |
111 | end; |
112 | 112 | ||
113 | function AsnEditor(oid: POID): boolean; |
113 | function AsnEditor(oid: POID): boolean; |
114 | var |
114 | var |
115 | asnList: PStringList; |
115 | asnList: PStringList; |
116 | i: integer; |
116 | i: integer; |
117 | x, y, w, h: integer; |
117 | x, y, w, h: integer; |
118 | res: integer; |
118 | res: integer; |
119 | sInput: string; |
119 | sInput: string; |
120 | menuIdNew, menuIdSave, menuIdExit: integer; |
120 | menuIdNew, menuIdSave, menuIdExit: integer; |
121 | begin |
121 | begin |
122 | AsnEditor := false; |
122 | AsnEditor := false; |
123 | 123 | ||
124 | repeat |
124 | repeat |
125 | CreateList(asnList); |
125 | CreateList(asnList); |
126 | 126 | ||
127 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
127 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
128 | begin |
128 | begin |
129 | ListAppend(asnList, ListGetElement(oid^.ASNIDs, i)); |
129 | ListAppend(asnList, ListGetElement(oid^.ASNIDs, i)); |
130 | end; |
130 | end; |
131 | menuIdNew := ListAppend(asnList, '<NEW>'); |
131 | menuIdNew := ListAppend(asnList, '<NEW>'); |
132 | menuIdSave := ListAppend(asnList, '<SAVE>'); |
132 | menuIdSave := ListAppend(asnList, '<SAVE>'); |
133 | menuIdExit := ListAppend(asnList, '<CANCEL>'); |
133 | menuIdExit := ListAppend(asnList, '<CANCEL>'); |
134 | 134 | ||
135 | DrawStatusBar(DEFAULT_STATUSBAR); |
135 | DrawStatusBar(DEFAULT_STATUSBAR); |
136 | x := SINGLE_LINE_BOX_PADDING; |
136 | x := SINGLE_LINE_BOX_PADDING; |
137 | y := ScreenHeight div 2 - ASNEDIT_LINES div 2; |
137 | y := ScreenHeight div 2 - ASNEDIT_LINES div 2; |
138 | w := ScreenWidth - (SINGLE_LINE_BOX_PADDING-1)*2; |
138 | w := ScreenWidth - (SINGLE_LINE_BOX_PADDING-1)*2; |
139 | h := ASNEDIT_LINES; |
139 | h := ASNEDIT_LINES; |
140 | res := DrawSelectionList(x, y, w, h, |
140 | res := DrawSelectionList(x, y, w, h, |
141 | asnList, true, |
141 | asnList, true, |
142 | 'EDIT ASN.1 IDENTIFIERS', |
142 | 'EDIT ASN.1 IDENTIFIERS', |
143 | 2); |
143 | 2); |
144 | FreeList(asnList); |
144 | FreeList(asnList); |
145 | 145 | ||
146 | (* Change double-border to thin-border *) |
146 | (* Change double-border to thin-border *) |
147 | DrawThinBorder(x-1, y-1, w+2, h+2); |
147 | DrawThinBorder(x-1, y-1, w+2, h+2); |
148 | GoToXY(x+1, y-1); |
148 | GoToXY(x+1, y-1); |
149 | Write('EDIT ASN.1 IDENTIFIERS'); |
149 | Write('EDIT ASN.1 IDENTIFIERS'); |
150 | 150 | ||
151 | if res = -1 then |
151 | if res = -1 then |
152 | begin |
152 | begin |
153 | exit; |
153 | exit; |
154 | end |
154 | end |
155 | else if res = menuIdNew then |
155 | else if res = menuIdNew then |
156 | begin |
156 | begin |
157 | (* "NEW" item was selected *) |
157 | (* "NEW" item was selected *) |
158 | sInput := ''; |
158 | sInput := ''; |
159 | repeat |
159 | repeat |
160 | if QueryVal(sInput, |
160 | if QueryVal(sInput, |
161 | SINGLE_LINE_BOX_PADDING_INNER, |
161 | SINGLE_LINE_BOX_PADDING_INNER, |
162 | ScreenHeight div 2, |
162 | ScreenHeight div 2, |
163 | ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2, |
163 | ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2, |
164 | 1, |
164 | 1, |
165 | 'ADD SINGLE ASN.1 ID', |
165 | 'ADD SINGLE ASN.1 ID', |
166 | 2) then |
166 | 2) then |
167 | begin |
167 | begin |
168 | if sInput = '' then continue; |
168 | if sInput = '' then continue; |
169 | if not ASN1IDValid(sInput) then |
169 | if not ASN1IDValid(sInput) then |
170 | begin |
170 | begin |
171 | ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true); |
171 | ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true); |
172 | _Pause; |
172 | _Pause; |
173 | end |
173 | end |
174 | else if AsnAlreadyExisting(oid, sInput) then |
174 | else if AsnAlreadyExisting(oid, sInput) then |
175 | begin |
175 | begin |
176 | ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true); |
176 | ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true); |
177 | _Pause; |
177 | _Pause; |
178 | end |
178 | end |
179 | else |
179 | else |
180 | begin |
180 | begin |
181 | ListAppend(oid^.ASNIDs, sInput); |
181 | ListAppend(oid^.ASNIDs, sInput); |
182 | break; |
182 | break; |
183 | end; |
183 | end; |
184 | end |
184 | end |
185 | else break; |
185 | else break; |
186 | until false; |
186 | until false; |
187 | end |
187 | end |
188 | else if res = menuIdSave then |
188 | else if res = menuIdSave then |
189 | begin |
189 | begin |
190 | (* "SAVE" item was selected *) |
190 | (* "SAVE" item was selected *) |
191 | AsnEditor := true; |
191 | AsnEditor := true; |
192 | Exit; |
192 | Exit; |
193 | end |
193 | end |
194 | else if res = menuIdExit then |
194 | else if res = menuIdExit then |
195 | begin |
195 | begin |
196 | (* "CANCEL" item was selected *) |
196 | (* "CANCEL" item was selected *) |
197 | AsnEditor := false; |
197 | AsnEditor := false; |
198 | Exit; |
198 | Exit; |
199 | end |
199 | end |
200 | else |
200 | else |
201 | begin |
201 | begin |
202 | DrawStatusBar('Note: Remove the text to delete the ASN.1 identifier'); |
202 | DrawStatusBar('Note: Remove the text to delete the ASN.1 identifier'); |
203 | sInput := ListGetElement(oid^.ASNIDs, res); |
203 | sInput := ListGetElement(oid^.ASNIDs, res); |
204 | repeat |
204 | repeat |
205 | if QueryVal(sInput, |
205 | if QueryVal(sInput, |
206 | SINGLE_LINE_BOX_PADDING_INNER, |
206 | SINGLE_LINE_BOX_PADDING_INNER, |
207 | ScreenHeight div 2, |
207 | ScreenHeight div 2, |
208 | ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2, |
208 | ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2, |
209 | 1, |
209 | 1, |
210 | 'EDIT SINGLE ASN.1 ID', |
210 | 'EDIT SINGLE ASN.1 ID', |
211 | 2) then |
211 | 2) then |
212 | begin |
212 | begin |
213 | if sInput = '' then |
213 | if sInput = '' then |
214 | begin |
214 | begin |
215 | (* Empty input = Delete ASN.1 ID *) |
215 | (* Empty input = Delete ASN.1 ID *) |
216 | ListDeleteElementByIndex(oid^.ASNIDs, res); |
216 | ListDeleteElementByIndex(oid^.ASNIDs, res); |
217 | break; |
217 | break; |
218 | end |
218 | end |
219 | else if not ASN1IDValid(sInput) then |
219 | else if not ASN1IDValid(sInput) then |
220 | begin |
220 | begin |
221 | ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true); |
221 | ShowMessage('Invalid ASN1.ID! (Require -, a..z, A..Z, 0..9, begin with a-z)', 'ERROR', true); |
222 | _Pause; |
222 | _Pause; |
223 | end |
223 | end |
224 | else if AsnAlreadyExisting(oid, sInput) and |
224 | else if AsnAlreadyExisting(oid, sInput) and |
225 | not (ListGetElement(oid^.ASNIDs, res) = sInput) then |
225 | not (ListGetElement(oid^.ASNIDs, res) = sInput) then |
226 | begin |
226 | begin |
227 | ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true); |
227 | ShowMessage('ASN.1 identifier is already existing on this arc', 'ERROR', true); |
228 | _Pause; |
228 | _Pause; |
229 | end |
229 | end |
230 | else |
230 | else |
231 | begin |
231 | begin |
232 | ListSetElement(oid^.ASNIDs, res, sInput); |
232 | ListSetElement(oid^.ASNIDs, res, sInput); |
233 | break; |
233 | break; |
234 | end; |
234 | end; |
235 | end |
235 | end |
236 | else break; |
236 | else break; |
237 | until false; |
237 | until false; |
238 | end; |
238 | end; |
239 | until false; |
239 | until false; |
240 | end; |
240 | end; |
241 | 241 | ||
242 | function DescEditor(oid: POID): boolean; |
242 | function DescEditor(oid: POID): boolean; |
243 | var |
243 | var |
244 | sInput: string; |
244 | sInput: string; |
245 | begin |
245 | begin |
246 | DescEditor := false; |
246 | DescEditor := false; |
247 | 247 | ||
248 | DrawStatusBar('Note: Press Ctrl+Return for a line-break.'); |
248 | DrawStatusBar('Note: Press Ctrl+Return for a line-break.'); |
249 | sInput := oid^.description; |
249 | sInput := oid^.description; |
250 | if QueryVal(sInput, |
250 | if QueryVal(sInput, |
251 | DESCEDIT_PADDING, |
251 | DESCEDIT_PADDING, |
252 | ScreenHeight div 2 - DESCEDIT_LINES div 2, |
252 | ScreenHeight div 2 - DESCEDIT_LINES div 2, |
253 | ScreenWidth - (DESCEDIT_PADDING-1)*2, |
253 | ScreenWidth - (DESCEDIT_PADDING-1)*2, |
254 | DESCEDIT_LINES, |
254 | DESCEDIT_LINES, |
255 | 'EDIT DESCRIPTION', |
255 | 'EDIT DESCRIPTION', |
256 | 2) then |
256 | 2) then |
257 | begin |
257 | begin |
258 | oid^.description := sInput; |
258 | oid^.description := sInput; |
259 | DescEditor := true; (* request caller to save @oid *) |
259 | DescEditor := true; (* request caller to save @oid *) |
260 | end; |
260 | end; |
261 | end; |
261 | end; |
262 | 262 | ||
263 | function NextPossibleFileID: string; |
263 | function NextPossibleFileID: string; |
264 | var |
264 | var |
265 | DirInfo: SearchRec; |
265 | DirInfo: SearchRec; |
266 | list: PStringList; |
266 | list: PStringList; |
267 | iId: LongInt; |
267 | iId: LongInt; |
268 | sId: string; |
268 | sId: string; |
269 | begin |
269 | begin |
270 | (* Put all found files into a list *) |
270 | (* Put all found files into a list *) |
271 | CreateList(list); |
271 | CreateList(list); |
272 | FindFirst('????????.OID', Archive, DirInfo); |
272 | FindFirst('????????.OID', Archive, DirInfo); |
273 | while DosError = 0 do |
273 | while DosError = 0 do |
274 | begin |
274 | begin |
275 | sId := Copy(DirInfo.Name, 1, 8); |
275 | sId := Copy(DirInfo.Name, 1, 8); |
276 | ListAppend(list, sId); |
276 | ListAppend(list, sId); |
277 | FindNext(DirInfo); |
277 | FindNext(DirInfo); |
278 | end; |
278 | end; |
279 | 279 | ||
280 | (* Search for the first non existing item in the list *) |
280 | (* Search for the first non existing item in the list *) |
281 | sId := ''; |
281 | sId := ''; |
282 | for iId := 0 to 99999999 do |
282 | for iId := 0 to 99999999 do |
283 | begin |
283 | begin |
284 | sId := ZeroPad(iId, 8); |
284 | sId := ZeroPad(iId, 8); |
285 | if not ListContains(list, sId) then break; |
285 | if not ListContains(list, sId) then break; |
286 | end; |
286 | end; |
287 | NextPossibleFileId := sId; |
287 | NextPossibleFileId := sId; |
288 | FreeList(list); |
288 | FreeList(list); |
289 | end; |
289 | end; |
290 | 290 | ||
291 | function NumIdAlreadyExisting(parentOID: POID; sInput: string): boolean; |
291 | function NumIdAlreadyExisting(parentOID: POID; sInput: string): boolean; |
292 | var |
292 | var |
293 | searchDotNotation: string; |
293 | searchDotNotation: string; |
294 | sTmp: string; |
294 | sTmp: string; |
295 | i: integer; |
295 | i: integer; |
296 | begin |
296 | begin |
297 | if parentOID^.DotNotation = '' then |
297 | if parentOID^.DotNotation = '' then |
298 | searchDotNotation := sInput |
298 | searchDotNotation := sInput |
299 | else |
299 | else |
300 | searchDotNotation := parentOID^.DotNotation + '.' + sInput; |
300 | searchDotNotation := parentOID^.DotNotation + '.' + sInput; |
301 | for i := 0 to ListCount(parentOID^.SubIds)-1 do |
301 | for i := 0 to ListCount(parentOID^.SubIds)-1 do |
302 | begin |
302 | begin |
303 | sTmp := ListGetElement(parentOID^.SubIds, i); |
303 | sTmp := ListGetElement(parentOID^.SubIds, i); |
304 | if DotNotationPart(sTmp) = searchDotNotation then |
304 | if DotNotationPart(sTmp) = searchDotNotation then |
305 | begin |
305 | begin |
306 | NumIdAlreadyExisting := true; |
306 | NumIdAlreadyExisting := true; |
307 | exit; |
307 | exit; |
308 | end; |
308 | end; |
309 | end; |
309 | end; |
310 | NumIdAlreadyExisting := false; |
310 | NumIdAlreadyExisting := false; |
311 | end; |
311 | end; |
312 | 312 | ||
313 | function NumIdEditor(oid: POID; parentOID: POID): boolean; |
313 | function NumIdEditor(oid: POID; parentOID: POID): boolean; |
314 | var |
314 | var |
315 | sInput: string; |
315 | sInput: string; |
316 | begin |
316 | begin |
317 | NumIdEditor := false; |
317 | NumIdEditor := false; |
318 | sInput := ''; |
318 | sInput := ''; |
319 | 319 | ||
320 | repeat |
320 | repeat |
321 | if QueryVal(sInput, |
321 | if QueryVal(sInput, |
322 | SINGLE_LINE_BOX_PADDING_INNER, |
322 | SINGLE_LINE_BOX_PADDING_INNER, |
323 | ScreenHeight div 2, |
323 | ScreenHeight div 2, |
324 | ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2, |
324 | ScreenWidth - (SINGLE_LINE_BOX_PADDING_INNER-1)*2, |
325 | 1, |
325 | 1, |
326 | 'ENTER NUMERIC ID', |
326 | 'ENTER NUMERIC ID', |
327 | 2) then |
327 | 2) then |
328 | begin |
328 | begin |
329 | if sInput = '' then continue; |
329 | if sInput = '' then continue; |
330 | if not IsNumeric(sInput) then |
330 | if not IsPositiveInteger(sInput) then |
331 | begin |
331 | begin |
332 | ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true); |
332 | ShowMessage('Invalid numeric ID (must be a positive integer)', 'ERROR', true); |
333 | _Pause; |
333 | _Pause; |
334 | end |
334 | end |
335 | else if (parentOID^.DotNotation='') and (StrToInt(sInput) > 2) then |
335 | else if (parentOID^.DotNotation='') and (StrToInt(sInput) > 2) then |
336 | begin |
336 | begin |
337 | ShowMessage('Invalid numeric ID (root arc can only be 0, 1, or 2)', 'ERROR', true); |
337 | ShowMessage('Invalid numeric ID (root arc can only be 0, 1, or 2)', 'ERROR', true); |
338 | _Pause; |
338 | _Pause; |
339 | end |
339 | end |
340 | else if ((parentOID^.DotNotation='0') or (parentOID^.DotNotation='1')) and (StrToInt(sInput) > 39) then |
340 | else if ((parentOID^.DotNotation='0') or (parentOID^.DotNotation='1')) and (StrToInt(sInput) > 39) then |
341 | begin |
341 | begin |
342 | ShowMessage('Invalid numeric ID (root 0 and 1 must have sub-arc of 0..39)', 'ERROR', true); |
342 | ShowMessage('Invalid numeric ID (root 0 and 1 must have sub-arc of 0..39)', 'ERROR', true); |
343 | _Pause; |
343 | _Pause; |
344 | end |
344 | end |
345 | else if NumIdAlreadyExisting(parentOID, sInput) then |
345 | else if NumIdAlreadyExisting(parentOID, sInput) then |
346 | begin |
346 | begin |
347 | ShowMessage('This numeric ID is already used in this arc', 'ERROR', true); |
347 | ShowMessage('This numeric ID is already used in this arc', 'ERROR', true); |
348 | _Pause; |
348 | _Pause; |
349 | end |
349 | end |
350 | else |
350 | else |
351 | begin |
351 | begin |
352 | if parentOID^.DotNotation = '' then |
352 | if parentOID^.DotNotation = '' then |
353 | oid^.DotNotation := sInput |
353 | oid^.DotNotation := sInput |
354 | else |
354 | else |
355 | oid^.DotNotation := parentOID^.DotNotation + '.' + sInput; |
355 | oid^.DotNotation := parentOID^.DotNotation + '.' + sInput; |
356 | NumIdEditor := true; (* request caller to save @oid *) |
356 | NumIdEditor := true; (* request caller to save @oid *) |
357 | Exit; |
357 | Exit; |
358 | end; |
358 | end; |
359 | end |
359 | end |
360 | else |
360 | else |
361 | begin |
361 | begin |
362 | Exit; |
362 | Exit; |
363 | end; |
363 | end; |
364 | until false; |
364 | until false; |
365 | end; |
365 | end; |
366 | 366 | ||
367 | function NewOidEditor(oid: POID): boolean; |
367 | function NewOidEditor(oid: POID): boolean; |
368 | var |
368 | var |
369 | newfilename: string; |
369 | newfilename: string; |
370 | newOID: POID; |
370 | newOID: POID; |
371 | begin |
371 | begin |
372 | NewOidEditor := false; |
372 | NewOidEditor := false; |
373 | 373 | ||
374 | CreateOidDef(newOID); |
374 | CreateOidDef(newOID); |
375 | newOID^.FileId := NextPossibleFileID; |
375 | newOID^.FileId := NextPossibleFileID; |
376 | newOID^.Parent := oid^.FileId + oid^.DotNotation; |
376 | newOID^.Parent := oid^.FileId + oid^.DotNotation; |
377 | if NumIdEditor(newOID, oid) and |
377 | if NumIdEditor(newOID, oid) and |
378 | AsnEditor(newOID) and |
378 | AsnEditor(newOID) and |
379 | DescEditor(newOID) then |
379 | DescEditor(newOID) then |
380 | begin |
380 | begin |
381 | newfilename := newOID^.FileId + '.OID'; |
381 | newfilename := newOID^.FileId + '.OID'; |
382 | _WriteOidFile(newfilename, newOID); |
382 | _WriteOidFile(newfilename, newOID); |
383 | 383 | ||
384 | (* Add link to original file and enable the saving of it *) |
384 | (* Add link to original file and enable the saving of it *) |
385 | ListAppend(oid^.SubIds, newOID^.FileId + newOID^.DotNotation); |
385 | ListAppend(oid^.SubIds, newOID^.FileId + newOID^.DotNotation); |
386 | NewOidEditor := true; (* request caller to save @oid *) |
386 | NewOidEditor := true; (* request caller to save @oid *) |
387 | end; |
387 | end; |
388 | FreeOidDef(newOID); |
388 | FreeOidDef(newOID); |
389 | end; |
389 | end; |
390 | 390 | ||
391 | procedure DeleteChildrenRecursive(oid: POID); |
391 | procedure DeleteChildrenRecursive(oid: POID); |
392 | var |
392 | var |
393 | i: integer; |
393 | i: integer; |
394 | childOID: POID; |
394 | childOID: POID; |
395 | filenameChild: string; |
395 | filenameChild: string; |
396 | begin |
396 | begin |
397 | for i := 0 to ListCount(oid^.SubIds)-1 do |
397 | for i := 0 to ListCount(oid^.SubIds)-1 do |
398 | begin |
398 | begin |
399 | filenameChild := FileIdPart(ListGetElement(oid^.SubIds, i)) + '.OID'; |
399 | filenameChild := FileIdPart(ListGetElement(oid^.SubIds, i)) + '.OID'; |
400 | CreateOidDef(childOID); |
400 | CreateOidDef(childOID); |
401 | _ReadOidFile(filenameChild, childOID); |
401 | _ReadOidFile(filenameChild, childOID); |
402 | DeleteChildrenRecursive(childOID); |
402 | DeleteChildrenRecursive(childOID); |
403 | FreeOidDef(childOID); |
403 | FreeOidDef(childOID); |
404 | DeleteFile(filenameChild); |
404 | DeleteFile(filenameChild); |
405 | end; |
405 | end; |
406 | ListClear(oid^.SubIds); |
406 | ListClear(oid^.SubIds); |
407 | end; |
407 | end; |
408 | 408 | ||
409 | procedure DeleteOidRecursive(selfOID: POID); |
409 | procedure DeleteOidRecursive(selfOID: POID); |
410 | var |
410 | var |
411 | i: integer; |
411 | i: integer; |
412 | parentOID: POID; |
412 | parentOID: POID; |
413 | filenameSelf, filenameParent: string; |
413 | filenameSelf, filenameParent: string; |
414 | begin |
414 | begin |
415 | (* Remove all children and their files recursively *) |
415 | (* Remove all children and their files recursively *) |
416 | DeleteChildrenRecursive(selfOID); |
416 | DeleteChildrenRecursive(selfOID); |
417 | 417 | ||
418 | (* Remove forward reference in parent OID *) |
418 | (* Remove forward reference in parent OID *) |
419 | filenameParent := FileIdPart(selfOID^.Parent) + '.OID'; |
419 | filenameParent := FileIdPart(selfOID^.Parent) + '.OID'; |
420 | CreateOidDef(parentOID); |
420 | CreateOidDef(parentOID); |
421 | _ReadOidFile(filenameParent, parentOID); |
421 | _ReadOidFile(filenameParent, parentOID); |
422 | if ListDeleteElementByValue(parentOID^.SubIds, selfOID^.FileId + selfOID^.DotNotation) then |
422 | if ListDeleteElementByValue(parentOID^.SubIds, selfOID^.FileId + selfOID^.DotNotation) then |
423 | begin |
423 | begin |
424 | _WriteOidFile(filenameParent, parentOID); |
424 | _WriteOidFile(filenameParent, parentOID); |
425 | end; |
425 | end; |
426 | FreeOidDef(parentOID); |
426 | FreeOidDef(parentOID); |
427 | 427 | ||
428 | (* Delete own file *) |
428 | (* Delete own file *) |
429 | filenameSelf := selfOID^.FileId + '.OID'; |
429 | filenameSelf := selfOID^.FileId + '.OID'; |
430 | DeleteFile(filenameSelf); |
430 | DeleteFile(filenameSelf); |
431 | end; |
431 | end; |
432 | 432 | ||
433 | function _DeleteConfirmation: boolean; |
433 | function _DeleteConfirmation: boolean; |
434 | var |
434 | var |
435 | sc: Char; |
435 | sc: Char; |
436 | begin |
436 | begin |
437 | repeat |
437 | repeat |
438 | ShowMessage('Are you sure you want to delete this OID? (Y/N)', 'DELETE OID', true); |
438 | ShowMessage('Are you sure you want to delete this OID? (Y/N)', 'DELETE OID', true); |
439 | DrawStatusBar('Y=Yes, N=No'); |
439 | DrawStatusBar('Y=Yes, N=No'); |
440 | 440 | ||
441 | sc := ReadKey; |
441 | sc := ReadKey; |
442 | if sc = #0 then |
442 | if sc = #0 then |
443 | begin |
443 | begin |
444 | (* Extended key. Nothing we care about. *) |
444 | (* Extended key. Nothing we care about. *) |
445 | ReadKey; |
445 | ReadKey; |
446 | continue; |
446 | continue; |
447 | end; |
447 | end; |
448 | 448 | ||
449 | if UpCase(sc) = 'Y' then |
449 | if UpCase(sc) = 'Y' then |
450 | begin |
450 | begin |
451 | _DeleteConfirmation := true; |
451 | _DeleteConfirmation := true; |
452 | break; |
452 | break; |
453 | end |
453 | end |
454 | else if UpCase(sc) = 'N' then |
454 | else if UpCase(sc) = 'N' then |
455 | begin |
455 | begin |
456 | _DeleteConfirmation := false; |
456 | _DeleteConfirmation := false; |
457 | break; |
457 | break; |
458 | end; |
458 | end; |
459 | until false; |
459 | until false; |
460 | end; |
460 | end; |
461 | 461 | ||
462 | procedure _DrawOidTitleBar(filename: string; oid: POID); |
462 | procedure _DrawOidTitleBar(filename: string; oid: POID); |
463 | begin |
463 | begin |
464 | if oid^.DotNotation = '' then |
464 | if oid^.DotNotation = '' then |
465 | DrawTitleBar('OID ROOT', TITLEBAR_LEFT_TEXT, filename) |
465 | DrawTitleBar('OID ROOT', TITLEBAR_LEFT_TEXT, filename) |
466 | else |
466 | else |
467 | DrawTitleBar('OID ' + oid^.DotNotation, TITLEBAR_LEFT_TEXT, filename); |
467 | DrawTitleBar('OID ' + oid^.DotNotation, TITLEBAR_LEFT_TEXT, filename); |
468 | end; |
468 | end; |
469 | 469 | ||
470 | procedure DisplayOIDFile(filename: string); |
470 | procedure DisplayOIDFile(filename: string); |
471 | var |
471 | var |
472 | isRoot: boolean; |
472 | isRoot: boolean; |
473 | oid: POID; |
473 | oid: POID; |
474 | i, menuX, menuY: integer; |
474 | i, menuX, menuY: integer; |
475 | linesLeft, linesRequired: integer; |
475 | linesLeft, linesRequired: integer; |
476 | sTmp, subfile: string; |
476 | sTmp, subfile: string; |
477 | subsel, subfiles: PStringList; |
477 | subsel, subfiles: PStringList; |
478 | subselres: integer; |
478 | subselres: integer; |
479 | exitRequest: boolean; |
479 | exitRequest: boolean; |
480 | menuIdExit, menuIdAsnEdit, menuIdDescEdit, menuIdAdd, menuIdDelete: integer; |
480 | menuIdExit, menuIdAsnEdit, menuIdDescEdit, menuIdAdd, menuIdDelete: integer; |
481 | begin |
481 | begin |
482 | exitRequest := false; |
482 | exitRequest := false; |
483 | repeat |
483 | repeat |
484 | CreateOidDef(oid); |
484 | CreateOidDef(oid); |
485 | _ReadOidFile(filename, oid); |
485 | _ReadOidFile(filename, oid); |
486 | 486 | ||
487 | (* Print OID information *) |
487 | (* Print OID information *) |
488 | 488 | ||
489 | ClrScr; |
489 | ClrScr; |
490 | _DrawOidTitleBar(filename, oid); |
490 | _DrawOidTitleBar(filename, oid); |
491 | DrawStatusBar(DEFAULT_STATUSBAR); |
491 | DrawStatusBar(DEFAULT_STATUSBAR); |
492 | GotoXY(1,2); |
492 | GotoXY(1,2); |
493 | 493 | ||
494 | if oid^.DotNotation <> '' then |
494 | if oid^.DotNotation <> '' then |
495 | begin |
495 | begin |
496 | WriteLn('Dot-Notation:'); |
496 | WriteLn('Dot-Notation:'); |
497 | WriteLn(oid^.DotNotation); |
497 | WriteLn(oid^.DotNotation); |
498 | WriteLn(''); |
498 | WriteLn(''); |
499 | end; |
499 | end; |
500 | 500 | ||
501 | if Trim(oid^.Description) <> '' then |
501 | if Trim(oid^.Description) <> '' then |
502 | begin |
502 | begin |
503 | WriteLn('Description:'); |
503 | WriteLn('Description:'); |
504 | WriteLn(oid^.Description); |
504 | WriteLn(oid^.Description); |
505 | WriteLn(''); |
505 | WriteLn(''); |
506 | end; |
506 | end; |
507 | 507 | ||
508 | menuX := WhereX + 1; |
508 | menuX := WhereX + 1; |
509 | menuY := ScreenHeight - ACTIONMENU_SIZE - 1; |
509 | menuY := ScreenHeight - ACTIONMENU_SIZE - 1; |
510 | 510 | ||
511 | if ListCount(oid^.ASNIDs) > 0 then |
511 | if ListCount(oid^.ASNIDs) > 0 then |
512 | begin |
512 | begin |
513 | linesLeft := menuY - WhereY - 1; |
513 | linesLeft := menuY - WhereY - 1; |
514 | linesRequired := 1 + ListCount(oid^.ASNIds); |
514 | linesRequired := 1 + ListCount(oid^.ASNIds); |
515 | 515 | ||
516 | if LinesLeft < LinesRequired then |
516 | if LinesLeft < LinesRequired then |
517 | begin |
517 | begin |
518 | (* Compact display of ASN.1 identifiers *) |
518 | (* Compact display of ASN.1 identifiers *) |
519 | Write('ASN.1-Identifiers: '); |
519 | Write('ASN.1-Identifiers: '); |
520 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
520 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
521 | begin |
521 | begin |
522 | if i > 0 then Write(', '); |
522 | if i > 0 then Write(', '); |
523 | Write(ListGetElement(oid^.ASNIds, i)); |
523 | Write(ListGetElement(oid^.ASNIds, i)); |
524 | end; |
524 | end; |
525 | WriteLn(''); |
525 | WriteLn(''); |
526 | end |
526 | end |
527 | else |
527 | else |
528 | begin |
528 | begin |
529 | (* Long display of ASN.1 identifiers *) |
529 | (* Long display of ASN.1 identifiers *) |
530 | WriteLn('ASN.1-Identifiers:'); |
530 | WriteLn('ASN.1-Identifiers:'); |
531 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
531 | for i := 0 to ListCount(oid^.ASNIds)-1 do |
532 | begin |
532 | begin |
533 | WriteLn('- '+ListGetElement(oid^.ASNIds, i)); |
533 | WriteLn('- '+ListGetElement(oid^.ASNIds, i)); |
534 | end; |
534 | end; |
535 | WriteLn(''); |
535 | WriteLn(''); |
536 | end; |
536 | end; |
537 | end; |
537 | end; |
538 | 538 | ||
539 | (* Now prepare the menu entries *) |
539 | (* Now prepare the menu entries *) |
540 | 540 | ||
541 | CreateList(subsel); (* Contains the human readable OID name *) |
541 | CreateList(subsel); (* Contains the human readable OID name *) |
542 | CreateList(subfiles); (* Contains the file name *) |
542 | CreateList(subfiles); (* Contains the file name *) |
543 | 543 | ||
544 | if oid^.Parent = '' then |
544 | if oid^.Parent = '' then |
545 | begin |
545 | begin |
546 | isRoot := true; |
546 | isRoot := true; |
547 | end |
547 | end |
548 | else |
548 | else |
549 | begin |
549 | begin |
550 | isRoot := DotNotationPart(oid^.Parent) = oid^.DotNotation; |
550 | isRoot := DotNotationPart(oid^.Parent) = oid^.DotNotation; |
551 | end; |
551 | end; |
552 | 552 | ||
553 | if (oid^.Parent <> '') and not isRoot then |
553 | if (oid^.Parent <> '') and not isRoot then |
554 | begin |
554 | begin |
555 | sTmp := oid^.Parent; |
555 | sTmp := oid^.Parent; |
556 | subfile := FileIdPart(sTmp) + '.OID'; |
556 | subfile := FileIdPart(sTmp) + '.OID'; |
557 | ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(subfile)); |
557 | ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(subfile)); |
558 | ListAppend(subfiles, subfile); |
558 | ListAppend(subfiles, subfile); |
559 | end; |
559 | end; |
560 | 560 | ||
561 | if isRoot then |
561 | if isRoot then |
562 | begin |
562 | begin |
563 | menuIdExit := ListAppend(subsel, 'Back to main menu'); |
563 | menuIdExit := ListAppend(subsel, 'Back to main menu'); |
564 | ListAppend(subfiles, ''); |
564 | ListAppend(subfiles, ''); |
565 | end |
565 | end |
566 | else menuIdExit := -99; |
566 | else menuIdExit := -99; |
567 | 567 | ||
568 | for i := 0 to ListCount(oid^.SubIds)-1 do |
568 | for i := 0 to ListCount(oid^.SubIds)-1 do |
569 | begin |
569 | begin |
570 | sTmp := ListGetElement(oid^.SubIds, i); |
570 | sTmp := ListGetElement(oid^.SubIds, i); |
571 | subfile := FileIdPart(sTmp) + '.OID'; |
571 | subfile := FileIdPart(sTmp) + '.OID'; |
572 | ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(subfile)); |
572 | ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(subfile)); |
573 | ListAppend(subfiles, subfile); |
573 | ListAppend(subfiles, subfile); |
574 | end; |
574 | end; |
575 | 575 | ||
576 | if oid^.DotNotation <> '' then |
576 | if oid^.DotNotation <> '' then |
577 | begin |
577 | begin |
578 | menuIdAsnEdit := ListAppend(subsel, 'Edit ASN.1 identifiers'); |
578 | menuIdAsnEdit := ListAppend(subsel, 'Edit ASN.1 identifiers'); |
579 | ListAppend(subfiles, ''); |
579 | ListAppend(subfiles, ''); |
580 | end |
580 | end |
581 | else menuIdAsnEdit := -99; |
581 | else menuIdAsnEdit := -99; |
582 | 582 | ||
583 | menuIdDescEdit := ListAppend(subsel, 'Edit description'); |
583 | menuIdDescEdit := ListAppend(subsel, 'Edit description'); |
584 | ListAppend(subfiles, ''); |
584 | ListAppend(subfiles, ''); |
585 | 585 | ||
586 | menuIdAdd := ListAppend(subsel, 'Add child'); |
586 | menuIdAdd := ListAppend(subsel, 'Add child'); |
587 | ListAppend(subfiles, ''); |
587 | ListAppend(subfiles, ''); |
588 | 588 | ||
589 | if not isRoot then |
589 | if not isRoot then |
590 | begin |
590 | begin |
591 | menuIdDelete := ListAppend(subsel, 'Delete OID'); |
591 | menuIdDelete := ListAppend(subsel, 'Delete OID'); |
592 | ListAppend(subfiles, ''); |
592 | ListAppend(subfiles, ''); |
593 | end |
593 | end |
594 | else menuIdDelete := -99; |
594 | else menuIdDelete := -99; |
595 | 595 | ||
596 | (* Show menu *) |
596 | (* Show menu *) |
597 | 597 | ||
598 | subselres := DrawSelectionList(menuX, menuY, |
598 | subselres := DrawSelectionList(menuX, menuY, |
599 | ScreenWidth-2, |
599 | ScreenWidth-2, |
600 | ACTIONMENU_SIZE, |
600 | ACTIONMENU_SIZE, |
601 | subsel, |
601 | subsel, |
602 | true, |
602 | true, |
603 | 'SELECT ACTION', |
603 | 'SELECT ACTION', |
604 | 1); |
604 | 1); |
605 | 605 | ||
606 | (* Process user selection *) |
606 | (* Process user selection *) |
607 | 607 | ||
608 | if subselres = -1 then |
608 | if subselres = -1 then |
609 | begin |
609 | begin |
610 | exitRequest := true; |
610 | exitRequest := true; |
611 | end |
611 | end |
612 | else if subselres = menuIdAsnEdit then |
612 | else if subselres = menuIdAsnEdit then |
613 | begin |
613 | begin |
614 | if AsnEditor(oid) then |
614 | if AsnEditor(oid) then |
615 | _WriteOidFile(filename, oid); |
615 | _WriteOidFile(filename, oid); |
616 | end |
616 | end |
617 | else if subselres = menuIdDescEdit then |
617 | else if subselres = menuIdDescEdit then |
618 | begin |
618 | begin |
619 | if DescEditor(oid) then |
619 | if DescEditor(oid) then |
620 | _WriteOidFile(filename, oid); |
620 | _WriteOidFile(filename, oid); |
621 | end |
621 | end |
622 | else if subselres = menuIdAdd then |
622 | else if subselres = menuIdAdd then |
623 | begin |
623 | begin |
624 | if NewOidEditor(oid) then |
624 | if NewOidEditor(oid) then |
625 | _WriteOidFile(filename, oid); |
625 | _WriteOidFile(filename, oid); |
626 | end |
626 | end |
627 | else if subselres = menuIdDelete then |
627 | else if subselres = menuIdDelete then |
628 | begin |
628 | begin |
629 | if _DeleteConfirmation then |
629 | if _DeleteConfirmation then |
630 | begin |
630 | begin |
631 | filename := FileIdPart(oid^.Parent) + '.OID'; |
631 | filename := FileIdPart(oid^.Parent) + '.OID'; |
632 | DeleteOidRecursive(oid); |
632 | DeleteOidRecursive(oid); |
633 | end; |
633 | end; |
634 | end |
634 | end |
635 | else if subselres = menuIdExit then |
635 | else if subselres = menuIdExit then |
636 | begin |
636 | begin |
637 | exitRequest := true; |
637 | exitRequest := true; |
638 | end |
638 | end |
639 | else |
639 | else |
640 | begin |
640 | begin |
641 | (* Normal OID *) |
641 | (* Normal OID *) |
642 | filename := ListGetElement(subfiles, subselres); |
642 | filename := ListGetElement(subfiles, subselres); |
643 | end; |
643 | end; |
644 | FreeList(subsel); |
644 | FreeList(subsel); |
645 | FreeList(subfiles); |
645 | FreeList(subfiles); |
646 | 646 | ||
647 | FreeOidDef(oid); |
647 | FreeOidDef(oid); |
648 | until exitRequest; |
648 | until exitRequest; |
649 | end; |
649 | end; |
650 | 650 | ||
651 | procedure CreateInitOIDFile(filename: string); |
651 | procedure CreateInitOIDFile(filename: string); |
652 | var |
652 | var |
653 | oid: POID; |
653 | oid: POID; |
654 | begin |
654 | begin |
655 | CreateOidDef(oid); |
655 | CreateOidDef(oid); |
656 | oid^.Description := 'This is the root of the OID tree.' +#13#10 + |
656 | oid^.Description := 'This is the root of the OID tree.' +#13#10 + |
657 | #13#10 + |
657 | #13#10 + |
658 | 'Valid subsequent arcs are per definition:' + #13#10 + |
658 | 'Valid subsequent arcs are per definition:' + #13#10 + |
659 | '- 0 (itu-t)' + #13#10 + |
659 | '- 0 (itu-t)' + #13#10 + |
660 | '- 1 (iso)' + #13#10 + |
660 | '- 1 (iso)' + #13#10 + |
661 | '- 2 (joint-iso-itu-t)'; |
661 | '- 2 (joint-iso-itu-t)'; |
662 | oid^.FileId := ZeroPad(0, 8); |
662 | oid^.FileId := ZeroPad(0, 8); |
663 | oid^.DotNotation := ''; |
663 | oid^.DotNotation := ''; |
664 | oid^.Parent := ZeroPad(0, 8); |
664 | oid^.Parent := ZeroPad(0, 8); |
665 | _WriteOidFile(filename, oid); |
665 | _WriteOidFile(filename, oid); |
666 | FreeOidDef(oid); |
666 | FreeOidDef(oid); |
667 | end; |
667 | end; |
668 | 668 | ||
669 | procedure OP_ManageOIDs; |
669 | procedure OP_ManageOIDs; |
670 | var |
670 | var |
671 | initFile: string; |
671 | initFile: string; |
672 | begin |
672 | begin |
673 | ClrScr; |
673 | ClrScr; |
674 | DrawTitleBar('Manage Object Identifiers', TITLEBAR_LEFT_TEXT, ''); |
674 | DrawTitleBar('Manage Object Identifiers', TITLEBAR_LEFT_TEXT, ''); |
675 | DrawStatusBar('Loading data... please wait...'); |
675 | DrawStatusBar('Loading data... please wait...'); |
676 | 676 | ||
677 | initFile := ZeroPad(0, 8) + '.OID'; |
677 | initFile := ZeroPad(0, 8) + '.OID'; |
678 | if not FileExists(initFile) then |
678 | if not FileExists(initFile) then |
679 | begin |
679 | begin |
680 | CreateInitOIDFile(initFile); |
680 | CreateInitOIDFile(initFile); |
681 | end; |
681 | end; |
682 | DisplayOIDFile(initFile); |
682 | DisplayOIDFile(initFile); |
683 | end; |
683 | end; |
684 | 684 | ||
685 | procedure OP_ManageRAs; |
685 | procedure OP_ManageRAs; |
686 | begin |
686 | begin |
687 | ClrScr; |
687 | ClrScr; |
688 | DrawTitleBar('Manage Registration Authorities', TITLEBAR_LEFT_TEXT, ''); |
688 | DrawTitleBar('Manage Registration Authorities', TITLEBAR_LEFT_TEXT, ''); |
689 | DrawStatusBar(''); |
689 | DrawStatusBar(''); |
690 | 690 | ||
691 | (* TODO: Implement "Manage RAs" feature *) |
691 | (* TODO: Implement "Manage RAs" feature *) |
692 | end; |
692 | end; |
693 | 693 | ||
694 | procedure OP_ReturnToMSDOS; |
694 | procedure OP_ReturnToMSDOS; |
695 | begin |
695 | begin |
696 | ClrScr; |
696 | ClrScr; |
697 | end; |
697 | end; |
698 | 698 | ||
699 | procedure OP_MainMenu; |
699 | procedure OP_MainMenu; |
700 | var |
700 | var |
701 | menu: PStringList; |
701 | menu: PStringList; |
702 | menuRes, menuLeft, menuTop: integer; |
702 | menuRes, menuLeft, menuTop: integer; |
703 | menuIdOID, menuIdRA, menuIdExit: integer; |
703 | menuIdOID, menuIdRA, menuIdExit: integer; |
704 | begin |
704 | begin |
705 | repeat |
705 | repeat |
706 | ClrScr; |
706 | ClrScr; |
707 | 707 | ||
708 | DrawTitleBar('Welcome to OIDplus for DOS', '', ''); |
708 | DrawTitleBar('Welcome to OIDplus for DOS', '', ''); |
709 | DrawStatusBar(DEFAULT_STATUSBAR); |
709 | DrawStatusBar(DEFAULT_STATUSBAR); |
710 | GoToXY(ScreenWidth-Length(VERSIONINFO), ScreenHeight-1); |
710 | GoToXY(ScreenWidth-Length(VERSIONINFO), ScreenHeight-1); |
711 | Write(VERSIONINFO); |
711 | Write(VERSIONINFO); |
712 | 712 | ||
713 | CreateList(menu); |
713 | CreateList(menu); |
714 | 714 | ||
715 | menuIdOID := ListAppend(menu, 'Manage OIDs'); |
715 | menuIdOID := ListAppend(menu, 'Manage OIDs'); |
716 | menuIdRA := -99; (*ListAppend(menu, 'Manage RAs');*) |
716 | menuIdRA := -99; (*ListAppend(menu, 'Manage RAs');*) |
717 | menuIdExit := ListAppend(menu, 'Return to DOS'); |
717 | menuIdExit := ListAppend(menu, 'Return to DOS'); |
718 | 718 | ||
719 | menuLeft := round(ScreenWidth/2 -MAINMENU_WIDTH/2); |
719 | menuLeft := round(ScreenWidth/2 -MAINMENU_WIDTH/2); |
720 | menuTop := round(ScreenHeight/2-MAINMENU_HEIGHT/2); |
720 | menuTop := round(ScreenHeight/2-MAINMENU_HEIGHT/2); |
721 | menuRes := DrawSelectionList(menuLeft, menuTop, |
721 | menuRes := DrawSelectionList(menuLeft, menuTop, |
722 | MAINMENU_WIDTH, MAINMENU_HEIGHT, |
722 | MAINMENU_WIDTH, MAINMENU_HEIGHT, |
723 | menu, true, 'MAIN MENU', 2); |
723 | menu, true, 'MAIN MENU', 2); |
724 | FreeList(menu); |
724 | FreeList(menu); |
725 | 725 | ||
726 | if menuRes = menuIdOID then |
726 | if menuRes = menuIdOID then |
727 | begin |
727 | begin |
728 | OP_ManageOIDs; |
728 | OP_ManageOIDs; |
729 | end |
729 | end |
730 | else if menuRes = menuIdRA then |
730 | else if menuRes = menuIdRA then |
731 | begin |
731 | begin |
732 | OP_ManageRAs; |
732 | OP_ManageRAs; |
733 | end; |
733 | end; |
734 | until (menuRes = menuIdExit) or (MAINMENU_ALLOW_ESC and (menuRes = -1)); |
734 | until (menuRes = menuIdExit) or (MAINMENU_ALLOW_ESC and (menuRes = -1)); |
735 | 735 | ||
736 | OP_ReturnToMSDOS; |
736 | OP_ReturnToMSDOS; |
737 | end; |
737 | end; |
738 | 738 | ||
739 | begin |
739 | begin |
740 | OP_MainMenu; |
740 | OP_MainMenu; |
741 | end. |
741 | end. |
742 | 742 |