Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 744 → Rev 745

/trunk_dos/OIDFILE.PAS
3,7 → 3,7
(************************************************)
(* OIDFILE.PAS *)
(* Author: Daniel Marschall *)
(* Revision: 2022-02-14 *)
(* Revision: 2022-02-15 *)
(* License: Apache 2.0 *)
(* This file contains: *)
(* - Functions to handle an OID ASCII format *)
21,8 → 21,9
DotNotation: string;
ASNIds: PStringList;
Description: string;
SubIds: PStringList; (* first 8 chars are FileId, followed by Dot-Notation *)
Parent: string; (* First 8 chars are FileId, followed by Dot-Notation *)
SubIds: PStringList; (* first 8 chars are FileId, followed by DotNotation *)
ParentFileId: string;
ParentDotNotation: string;
end;
 
procedure CreateOidDef(var oid: POid);
31,7 → 32,7
function WriteOidFile(filename: string; oid: POid): boolean;
function ReadOidFile(filename: string; oid: POid): boolean;
 
(* For the fields "SubIds" and "Parent" *)
(* For the strings in the list "SubIds": *)
function FileIdPart(s: string): string;
function DotNotationPart(s: string): string;
 
49,7 → 50,8
oid^.FileId := '';
oid^.DotNotation := '';
oid^.Description := '';
oid^.Parent := '';
oid^.ParentFileId := '';
oid^.ParentDotNotation := '';
CreateList(oid^.ASNIds);
CreateList(oid^.SubIds);
end;
63,8 → 65,13
 
procedure ClearOidDef(oid: POid);
begin
FreeOidDef(oid);
CreateOidDef(oid);
oid^.FileId := '';
oid^.DotNotation := '';
oid^.Description := '';
oid^.ParentFileId := '';
oid^.ParentDotNotation := '';
ListClear(oid^.ASNIds);
ListClear(oid^.SubIds);
end;
 
procedure ListBubbleSortSubIds(oid: POid);
118,7 → 125,7
 
WriteLn(f, 'SELF' + oid^.FileId + oid^.DotNotation);
 
WriteLn(f, 'SUPR' + oid^.Parent);
WriteLn(f, 'SUPR' + oid^.ParentFileId + oid^.ParentDotNotation);
 
(* Sort sub IDs *)
ListBubbleSortSubIds(oid);
193,7 → 200,8
 
if cmd = 'SUPR' then
begin
oid^.Parent := line;
oid^.ParentFileId := FileIdPart(line);
oid^.ParentDotNotation := DotNotationPart(line);
end;
 
if cmd = 'CHLD' then
/trunk_dos/OIDPLUS.PAS
386,7 → 386,8
 
CreateOidDef(newOID);
newOID^.FileId := NextPossibleFileID;
newOID^.Parent := oid^.FileId + oid^.DotNotation;
newOID^.ParentFileId := oid^.FileId;
newOID^.ParentDotNotation := oid^.DotNotation;
if NumIdEditor(newOID, oid) and
AsnEditor(newOID) and
DescEditor(newOID) then
415,7 → 416,8
begin
CreateOidDef(childOID);
if _ReadOidFile(filenameChild, childOID, false) and
(childOID^.Parent = oid^.FileId + oid^.DotNotation) then
(childOID^.ParentFileId = oid^.FileId) and
(childOID^.ParentDotNotation = oid^.DotNotation) then
begin
DeleteChildrenRecursive(childOID);
end;
437,7 → 439,7
 
(* Remove forward reference in parent OID *)
(* (this is the most important part) *)
filenameParent := FileIdPart(selfOID^.Parent) + OID_EXTENSION;
filenameParent := selfOID^.ParentFileId + OID_EXTENSION;
if FileExists(filenameParent) then
begin
CreateOidDef(parentOID);
575,30 → 577,29
CreateList(subsel); (* Contains the human-readable OID name *)
CreateList(subfiles); (* Contains the file name *)
 
if oid^.Parent = '' then
if oid^.ParentFileId = '' then
begin
isRoot := true;
end
else
begin
isRoot := DotNotationPart(oid^.Parent) = oid^.DotNotation;
isRoot := oid^.ParentDotNotation = oid^.DotNotation;
end;
 
if (oid^.Parent <> '') and not isRoot then
if (oid^.ParentFileId <> '') and not isRoot then
begin
sTmp := oid^.Parent;
subfile := FileIdPart(sTmp) + OID_EXTENSION;
subfile := oid^.ParentFileId + OID_EXTENSION;
if FileExists(subfile) then
begin
CreateOidDef(tmpOID);
if not _ReadOidFile(subfile, tmpOID, true) then
begin
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + ' (READ ERROR)');
ListAppend(subsel, 'Go to parent ' + oid^.ParentDotNotation + ' (READ ERROR)');
ListAppend(subfiles, 'ERROR: '+subfile+' Read error or file invalid');
end
else
begin
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID));
ListAppend(subsel, 'Go to parent ' + oid^.ParentDotNotation + _ShowASNIds(tmpOID));
ListAppend(subfiles, subfile);
end;
FreeOidDef(tmpOID);
605,7 → 606,7
end
else
begin
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + ' (FILE NOT FOUND)');
ListAppend(subsel, 'Go to parent ' + oid^.ParentDotNotation + ' (FILE NOT FOUND)');
ListAppend(subfiles, 'ERROR: File '+subfile+' was not found');
end;
end;
629,7 → 630,8
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + ' (READ ERROR)');
ListAppend(subfiles, 'ERROR: Read error at file '+subfile+', or file is invalid.');
end
else if tmpOID^.Parent <> oid^.FileId + oid^.DotNotation then
else if (tmpOID^.ParentFileId <> oid^.FileId) or
(tmpOID^.ParentDotNotation <> oid^.DotNotation) then
begin
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + ' (BAD BACKREF)');
ListAppend(subfiles, 'ERROR: File '+subfile+' has a wrong back-reference.');
703,7 → 705,7
begin
if _DeleteConfirmation then
begin
sTmp := FileIdPart(oid^.Parent) + OID_EXTENSION;
sTmp := oid^.ParentFileId + OID_EXTENSION;
DeleteOidRecursive(oid);
if FileExists(sTmp) then
begin
757,7 → 759,8
'- 2 (joint-iso-itu-t)';
oid^.FileId := ZeroPad(0, 8);
oid^.DotNotation := '';
oid^.Parent := ZeroPad(0, 8);
oid^.ParentFileId := ZeroPad(0, 8);
oid^.ParentDotNotation := '';
CreateRootOIDFile := _WriteOidFile(filename, oid, ShowErrorMessage);
FreeOidDef(oid);
end;
866,7 → 869,8
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH);
WriteLn(F, sTmp);
end
else if suboid^.Parent <> oid^.FileId + oid^.DotNotation then
else if (suboid^.ParentFileId <> oid^.FileId) or
(suboid^.ParentDotNotation <> oid^.DotNotation) then
begin
(* This can happen if a file is missing, and then another OID gets this filename since the number seems to be free *)
sTmp := 'ERROR: BAD BACKREF AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!';