Article View: comp.lang.modula2
Article #1102Best way to handle variable length fields within records
From: Pieter Muller
Date: Tue, 21 Aug 1990 16:57
Date: Tue, 21 Aug 1990 16:57
34 lines
1631 bytes
1631 bytes
Novell uses the following type of request packet in their Netware API:
Request :RECORD
Len :Types.Word;
Func :Types.Byte;
ObjT :Types.Word;
ONameLen :Types.Byte;
OName :ARRAY [1..47] OF CHAR;
Seq :Types.iDWord;
PNameLen :Types.Byte;
PName :ARRAY [1..15] OF CHAR;
END;
My problem is that OName is really a variable length field, and if
it is shorter than 47 characters, the rest of the record has to be moved down
to pack it tightly. The same goes for PName.
At the moment I use JPI's Lib.Move to move the end of the RECORD in on
itself, but this is rather messy.
What is the most elegant way to program this in Modula-2?
(BTW Someone suggested the following workaround for this specific Netware
function: I can pad OName with zeros and set ONameLen to 47. But this is
even more messy because it doesn't follow Novell's specs.)
-- Pieter
--
uucp: uunet!m2xenix!puddle!5!492!11!Pieter.Muller
Internet: Pieter.Muller@f11.n492.z5.fidonet.org
Technical Details
Message-ID:
<128.26D29D2B@puddle.fidonet.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!f11.n492.z5.fidonet.org!Pieter.MullerShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!f11.n492.z5.fidonet.org!Pieter.Muller From: Pieter.Muller@f11.n492.z5.fidonet.org (Pieter Muller) Newsgroups: comp.lang.modula2 Subject: Best way to handle variable length fields within records Message-ID: <128.26D29D2B@puddle.fidonet.org> Date: 21 Aug 90 16:57:00 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 5:492/11 Lines: 34