Rev 733 | Rev 735 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 733 | Rev 734 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | unit OIDFILE; |
1 | unit OIDFILE; |
2 | 2 | ||
3 | (************************************************) |
3 | (************************************************) |
4 | (* OIDFILE.PAS *) |
4 | (* OIDFILE.PAS *) |
5 | (* Author: Daniel Marschall *) |
5 | (* Author: Daniel Marschall *) |
6 | (* Revision: 2022-02-13 *) |
6 | (* Revision: 2022-02-14 *) |
7 | (* License: Apache 2.0 *) |
7 | (* License: Apache 2.0 *) |
8 | (* This file contains: *) |
8 | (* This file contains: *) |
9 | (* - Functions to handle an OID ASCII format *) |
9 | (* - Functions to handle an OID ASCII format *) |
10 | (************************************************) |
10 | (************************************************) |
11 | 11 | ||
Line 19... | Line 19... | ||
19 | TOID = record |
19 | TOID = record |
20 | FileId: string; |
20 | FileId: string; |
21 | DotNotation: string; |
21 | DotNotation: string; |
22 | ASNIds: PStringList; |
22 | ASNIds: PStringList; |
23 | Description: string; |
23 | Description: string; |
24 | SubIds: PStringList; |
24 | SubIds: PStringList; (* first 8 chars are FileId, followed by Dot-Notation *) |
25 | Parent: string; |
25 | Parent: string; (* First 8 chars are FileId, followed by Dot-Notation *) |
26 | end; |
26 | end; |
27 | 27 | ||
- | 28 | procedure InitOidDef(oid: POid); |
|
28 | procedure FreeOidDef(oid: POid); |
29 | procedure FreeOidDef(oid: POid); |
- | 30 | procedure ClearOidDef(oid: POid); |
|
29 | procedure WriteOidFile(filename: string; oid: POid); |
31 | procedure WriteOidFile(filename: string; oid: POid); |
30 | procedure InitOidDef(oid: POid); |
- | |
31 | procedure ReadOidFile(filename: string; oid: POid); |
32 | procedure ReadOidFile(filename: string; oid: POid); |
32 | 33 | ||
33 | implementation |
34 | implementation |
34 | 35 | ||
35 | uses |
36 | uses |
36 | VtsFuncs; |
37 | VtsFuncs; |
37 | 38 | ||
38 | const |
39 | const |
39 | WANT_VERS = '2022'; |
40 | WANT_VERS = '2022'; |
40 | 41 | ||
- | 42 | procedure InitOidDef(oid: POid); |
|
- | 43 | begin |
|
- | 44 | oid^.FileId := ''; |
|
- | 45 | oid^.DotNotation := ''; |
|
- | 46 | oid^.Description := ''; |
|
- | 47 | oid^.Parent := ''; |
|
- | 48 | InitList(oid^.ASNIds); |
|
- | 49 | InitList(oid^.SubIds); |
|
- | 50 | end; |
|
- | 51 | ||
41 | procedure FreeOidDef(oid: POid); |
52 | procedure FreeOidDef(oid: POid); |
42 | begin |
53 | begin |
43 | FreeList(oid^.ASNIds); |
54 | FreeList(oid^.ASNIds); |
44 | FreeList(oid^.SubIds); |
55 | FreeList(oid^.SubIds); |
45 | end; |
56 | end; |
46 | 57 | ||
- | 58 | procedure ClearOidDef(oid: POid); |
|
- | 59 | begin |
|
- | 60 | FreeOidDef(oid); |
|
- | 61 | InitOidDef(oid); |
|
- | 62 | end; |
|
- | 63 | ||
47 | procedure WriteOidFile(filename: string; oid: POid); |
64 | procedure WriteOidFile(filename: string; oid: POid); |
48 | var |
65 | var |
49 | f: Text; |
66 | f: Text; |
50 | i: integer; |
67 | i: integer; |
51 | lines: PStringList; |
68 | lines: PStringList; |
Line 87... | Line 104... | ||
87 | end; |
104 | end; |
88 | 105 | ||
89 | Close(f); |
106 | Close(f); |
90 | end; |
107 | end; |
91 | 108 | ||
92 | procedure InitOidDef(oid: POid); |
- | |
93 | begin |
- | |
94 | oid^.FileId := ''; |
- | |
95 | oid^.DotNotation := ''; |
- | |
96 | oid^.Description := ''; |
- | |
97 | oid^.Parent := ''; |
- | |
98 | InitList(oid^.ASNIds); |
- | |
99 | InitList(oid^.SubIds); |
- | |
100 | end; |
- | |
101 | - | ||
102 | procedure ReadOidFile(filename: string; oid: POid); |
109 | procedure ReadOidFile(filename: string; oid: POid); |
103 | var |
110 | var |
104 | f: Text; |
111 | f: Text; |
105 | line, cmd: string; |
112 | line, cmd: string; |
106 | version: string; |
113 | version: string; |
107 | begin |
114 | begin |
108 | FreeOidDef(oid); |
115 | ClearOidDef(oid); |
109 | InitOidDef(oid); |
- | |
110 | version := ''; |
116 | version := ''; |
111 | 117 | ||
112 | Assign(f, filename); |
118 | Assign(f, filename); |
113 | Reset(f); |
119 | Reset(f); |
114 | while not EOF(f) do |
120 | while not EOF(f) do |
Line 155... | Line 161... | ||
155 | 161 | ||
156 | (* Check if something is not correct *) |
162 | (* Check if something is not correct *) |
157 | if (version <> WANT_VERS) or (oid^.FileId = '') then |
163 | if (version <> WANT_VERS) or (oid^.FileId = '') then |
158 | begin |
164 | begin |
159 | (* Invalidate everything *) |
165 | (* Invalidate everything *) |
160 | FreeOidDef(oid); |
166 | ClearOidDef(oid); |
161 | InitOidDef(oid); |
- | |
162 | end; |
167 | end; |
163 | 168 | ||
164 | Close(f); |
169 | Close(f); |
165 | end; |
170 | end; |
166 | 171 |