Subversion Repositories oidplus

Rev

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

Rev 747 Rev 748
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-15                         *)
6
(* Revision: 2022-02-19                         *)
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 18... Line 18...
18
  POID = ^TOID;
18
  POID = ^TOID;
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
    UnicodeLabels: PStringList;
23
    Description: string;
24
    Description: string;
24
    SubIds: PStringList; (* first 8 chars are FileId, followed by DotNotation *)
25
    SubIds: PStringList; (* first 8 chars are FileId, followed by DotNotation *)
25
    ParentFileId: string;
26
    ParentFileId: string;
26
    ParentDotNotation: string;
27
    ParentDotNotation: string;
27
  end;
28
  end;
Line 37... Line 38...
37
function DotNotationPart(s: string): string;
38
function DotNotationPart(s: string): string;
38
 
39
 
39
implementation
40
implementation
40
 
41
 
41
uses
42
uses
42
  VtsFuncs, OidUtils;
43
  VtsFuncs, OidUtils, Crt;
43
 
44
 
44
const
45
const
45
  WANT_VERS = '2022';
46
  WANT_VERS = '2022';
46
 
47
 
47
procedure CreateOidDef(var oid: POid);
48
procedure CreateOidDef(var oid: POid);
48
begin
49
begin
-
 
50
  oid := nil;
49
  GetMem(oid, SizeOf(TOID));
51
  GetMem(oid, SizeOf(TOID));
-
 
52
 
-
 
53
  if oid <> nil then
-
 
54
  begin
50
  oid^.FileId := '';
55
    oid^.FileId := '';
51
  oid^.DotNotation := '';
56
    oid^.DotNotation := '';
52
  oid^.Description := '';
57
    oid^.Description := '';
53
  oid^.ParentFileId := '';
58
    oid^.ParentFileId := '';
54
  oid^.ParentDotNotation := '';
59
    oid^.ParentDotNotation := '';
55
  CreateList(oid^.ASNIds);
60
    CreateList(oid^.ASNIds);
-
 
61
    CreateList(oid^.UnicodeLabels);
56
  CreateList(oid^.SubIds);
62
    CreateList(oid^.SubIds);
-
 
63
  end
-
 
64
  else
-
 
65
  begin
-
 
66
    Beep;
-
 
67
    WriteLn('CreateOidDef failed! (GetMem returned nil)');
-
 
68
    ReadKey;
-
 
69
  end;
57
end;
70
end;
58
 
71
 
59
procedure FreeOidDef(oid: POid);
72
procedure FreeOidDef(oid: POid);
60
begin
73
begin
-
 
74
  if oid <> nil then
-
 
75
  begin
61
  FreeList(oid^.ASNIds);
76
    FreeList(oid^.ASNIds);
-
 
77
    FreeList(oid^.UnicodeLabels);
62
  FreeList(oid^.SubIds);
78
    FreeList(oid^.SubIds);
63
  FreeMem(oid, SizeOf(TOID));
79
    FreeMem(oid, SizeOf(TOID));
-
 
80
    oid := nil;
-
 
81
  end
-
 
82
  else
-
 
83
  begin
-
 
84
    Beep;
-
 
85
    WriteLn('FreeOidDef failed! (Argument is nil)');
-
 
86
    ReadKey;
-
 
87
  end;
64
end;
88
end;
65
 
89
 
66
procedure ClearOidDef(oid: POid);
90
procedure ClearOidDef(oid: POid);
67
begin
91
begin
68
  oid^.FileId := '';
92
  oid^.FileId := '';
69
  oid^.DotNotation := '';
93
  oid^.DotNotation := '';
70
  oid^.Description := '';
94
  oid^.Description := '';
71
  oid^.ParentFileId := '';
95
  oid^.ParentFileId := '';
72
  oid^.ParentDotNotation := '';
96
  oid^.ParentDotNotation := '';
73
  ListClear(oid^.ASNIds);
97
  ListClear(oid^.ASNIds);
-
 
98
  ListClear(oid^.UnicodeLabels);
74
  ListClear(oid^.SubIds);
99
  ListClear(oid^.SubIds);
75
end;
100
end;
76
 
101
 
77
procedure ListBubbleSortSubIds(oid: POid);
102
procedure ListBubbleSortSubIds(oid: POid);
78
var
103
var
Line 140... Line 165...
140
  begin
165
  begin
141
    sTmp := ListGetElement(oid^.AsnIds, i);
166
    sTmp := ListGetElement(oid^.AsnIds, i);
142
    WriteLn(f, 'ASN1' + sTmp);
167
    WriteLn(f, 'ASN1' + sTmp);
143
  end;
168
  end;
144
 
169
 
-
 
170
  for i := 0 to ListCount(oid^.UnicodeLabels)-1 do
-
 
171
  begin
-
 
172
    sTmp := ListGetElement(oid^.UnicodeLabels, i);
-
 
173
    WriteLn(f, 'UNIL' + sTmp);
-
 
174
  end;
-
 
175
 
145
  desc := Trim(oid^.Description);
176
  desc := Trim(oid^.Description);
146
  if desc <> '' then
177
  if desc <> '' then
147
  begin
178
  begin
148
    CreateList(lines);
179
    CreateList(lines);
149
    SplitStrToList(desc, lines, #13#10);
180
    SplitStrToList(desc, lines, #13#10);
Line 212... Line 243...
212
    if cmd = 'ASN1' then
243
    if cmd = 'ASN1' then
213
    begin
244
    begin
214
      ListAppend(oid^.ASNIds, line);
245
      ListAppend(oid^.ASNIds, line);
215
    end;
246
    end;
216
 
247
 
-
 
248
    if cmd = 'UNIL' then
-
 
249
    begin
-
 
250
      ListAppend(oid^.UnicodeLabels, line);
-
 
251
    end;
-
 
252
 
217
    if cmd = 'DESC' then
253
    if cmd = 'DESC' then
218
    begin
254
    begin
219
      oid^.Description := oid^.Description + line + #13#10;
255
      oid^.Description := oid^.Description + line + #13#10;
220
    end;
256
    end;
221
  end;
257
  end;