eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SunRPC::XDRCoder':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: XDRCoder (in SunRPC)


Inheritance:

   Object
   |
   +--SunRPC::XDRCoder

Package:
stx:goodies/communication
Category:
Net-Communication-SunRPC
Version:
rev: 1.24 date: 2018/01/19 22:53:24
user: cg
file: SunRPC_XDRCoder.st directory: goodies/communication
module: stx stc-classLibrary: communication
Author:
Claus Gittinger

Description:


XDR (eXternal Data Representation) encoder and decoder.
Encodes/decodes objects to/from the wire-protocol format.
Only a limited subset of object types is supported (see XDR documentation)

    


Related information:

    http://tools.ietf.org/html/rfc4506

Class protocol:

instance creation
o  from: data

o  new


Instance protocol:

accessing
o  contents
return the data buffered so far

usage example(s):

     (self new
        uint:16r12345678;
        contents) printOn:Transcript base:16

decoding
o  decodeArrayWithType: arrayType

o  decodeBoolean

o  decodeChar

o  decodeInt

o  decodeLong

o  decodeOpaqueWithType: stringType
fixed size

o  decodeOptionalWithType: optionalType

o  decodeShort

o  decodeStringWithType: stringType
fixed size

o  decodeStructWithType: structType

o  decodeStructWithType: structType ignoreLast: ignoreLast

o  decodeUnionWithType: unionType
must be enum then

o  decodeUnsignedChar

o  decodeUnsignedInt

o  decodeUnsignedLong

o  decodeUnsignedShort

encoding
o  decodeEnumWithType: enumType

o  encodeArray: anArray type: arrayType with: aParameter

o  encodeBoolean: value with: aParameter

o  encodeChar: value with: aParameter

o  encodeEnum: value type: enumType with: aParameter

o  encodeInt: value with: aParameter

o  encodeLong: value with: aParameter

o  encodeOpaque: value type: opaqueType with: dummyParameter
fixed size

o  encodeOptional: value type: optionalType with: dummyParameter

o  encodeShort: value with: aParameter

o  encodeString: value type: stringType with: dummyParameter
fixed size

o  encodeStruct: value type: structType with: dummyParameter

o  encodeStruct: value type: structType with: dummyParameter ignoreLast: ignoreLast

o  encodeUnion: value type: unionType with: dummyParameter
must be enum then

o  encodeUnsignedChar: value with: aParameter

o  encodeUnsignedInt: value with: aParameter

o  encodeUnsignedLong: value with: aParameter

o  encodeUnsignedShort: value with: aParameter

o  encodeVoid: value with: aParameter
nothing encoded for void

initialization
o  initialize

o  initializeFor: data

packing
o  packArray: aCollection using: selector
self new
packArray:#(1 2 3) using:#uint:;
contents

o  packBool: aBool
self new
packBool:true;
contents

o  packDouble: aFloat
self new
packDouble:1.2345;
contents

o  packEnum: aNumberOrSymbol

o  packFloat: aFloat
self new
packFloat:1.2345;
contents

o  packHyper: aNumber
self new
packHyper:-1;
contents

o  packInt: aNumber
self new
packInt:-1;
contents

o  packList: aCollection using: selectorOrBlock
self new
packList:#(1 2 3) using:#packUint:;
contents

o  packList: aCollection using: selectorOrBlock with: aParameter

o  packOpaque: something
self new
packOpaque:'abcdefg';
contents

o  packString: aString
self new
packString:'abcdefg';
contents

o  packUhyper: aLongNumber
self packUnsignedHyper:aLongNumber.

usage example(s):

     self new
        packUhyper:16r123456789abcdef0;
        contents     

o  packUint: aNumber
self packUnsignedInt:aNumber

usage example(s):

     self new
        packUint:16r12345678;
        contents

o  packUnsignedHyper: aLongNumber
self new
packUnsignedHyper:16r123456789abcdef0;
contents

o  packUnsignedInt: aNumber
self new
packUnsignedInt:16r12345678;
contents

packing - private
o  packFArray: aCollection using: selector
self new
packArray:#(1 2 3) using:#uint:;
contents

o  packFString: aString
}

packing-rpc packages
o  packAcceptedReply: hdr
procedure specific results...

o  packAuth: auth
AUTH_NULL

o  packAuthUnix: authUnix

o  packCallHeader: hdr

o  packDeniedReply: hdr
low supported version

o  packReplyHeader: hdr

queries
o  atEnd

unpacking
o  unpackArrayUsing: selector
|data|

data :=
XDRCoder new
packArray:#('a' 'b' 'c' 'd') using:#packString:;
contents.

(XDRCoder from:data) unpackArrayUsing:#unpackString

o  unpackBool
if proceeded, anything non-0 is treated as a true

o  unpackDouble
self error:'not yet implemented'.

o  unpackEnum
self unpackUnsignedInt

o  unpackFloat
self error:'not yet implemented'.

o  unpackHyper
|data|

data :=
XDRCoder new
packHyper:16r1234567890123456;
contents.

(XDRCoder from:data) unpackHyper hexPrintString

o  unpackInt
|data|

data :=
XDRCoder new
packInt:-1234;
contents.

(XDRCoder from:data) unpackInt

o  unpackListUsing: selectorOrBlock
|data|

data :=
XDRCoder new
packList:#('a' 'b' 'c' 'd') using:#packString:;
contents.

(XDRCoder from:data) unpackListUsing:#unpackString

o  unpackListUsing: selectorOrBlock with: aParameter

o  unpackOpaque
|data|

data :=
XDRCoder new
packString:'hello';
contents.

(XDRCoder from:data) unpackOpaque

o  unpackOpaqueBytes: nBytes
|data|

data :=
XDRCoder new
packString:'hello';
contents.

(XDRCoder from:data) unpackOpaque

o  unpackString
}

o  unpackUhyper
^ self unpackUnsignedHyper

o  unpackUint
|data|

data :=
XDRCoder new
packUint:1234;
contents.

(XDRCoder from:data) unpackUint

o  unpackUnsignedHyper
|hi low|

o  unpackUnsignedInt
|data|

data :=
XDRCoder new
packUnsignedInt:1234;
contents.

(XDRCoder from:data) unpackUnsignedInt

unpacking-rpc packages
o  unpackAuth

o  unpackAuthUnixFrom: opaqueData

o  unpackCallHeader
should send a reply here

o  unpackReplyHeader



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 09:27:11 GMT