home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / rpc3.9 / part13 < prev    next >
SHell self-extracting ARchive  |  1988-02-27  |  49.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: SHell self-extracting ARchive (archive/shar).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail text default
99% file C source text default
98% file Nim source code, ASCII text default (weak)
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 53 75 62 6a 65 63 74 3a | 20 20 76 31 33 69 30 39 |Subject:| v13i09|
|00000010| 30 3a 20 20 53 75 6e 20 | 52 50 43 2c 20 72 65 6c |0: Sun |RPC, rel|
|00000020| 65 61 73 65 20 33 2e 39 | 2c 20 50 61 72 74 31 33 |ease 3.9|, Part13|
|00000030| 2f 31 35 0a 4e 65 77 73 | 67 72 6f 75 70 73 3a 20 |/15.News|groups: |
|00000040| 63 6f 6d 70 2e 73 6f 75 | 72 63 65 73 2e 75 6e 69 |comp.sou|rces.uni|
|00000050| 78 0a 53 65 6e 64 65 72 | 3a 20 73 6f 75 72 63 65 |x.Sender|: source|
|00000060| 73 0a 41 70 70 72 6f 76 | 65 64 3a 20 72 73 61 6c |s.Approv|ed: rsal|
|00000070| 7a 40 75 75 6e 65 74 2e | 55 55 2e 4e 45 54 0a 0a |z@uunet.|UU.NET..|
|00000080| 53 75 62 6d 69 74 74 65 | 64 2d 62 79 3a 20 53 74 |Submitte|d-by: St|
|00000090| 65 70 68 65 6e 20 58 2e | 20 4e 61 68 6d 20 3c 73 |ephen X.| Nahm <s|
|000000a0| 78 6e 40 53 75 6e 2e 43 | 4f 4d 3e 0a 50 6f 73 74 |xn@Sun.C|OM>.Post|
|000000b0| 69 6e 67 2d 6e 75 6d 62 | 65 72 3a 20 56 6f 6c 75 |ing-numb|er: Volu|
|000000c0| 6d 65 20 31 33 2c 20 49 | 73 73 75 65 20 39 30 0a |me 13, I|ssue 90.|
|000000d0| 41 72 63 68 69 76 65 2d | 6e 61 6d 65 3a 20 72 70 |Archive-|name: rp|
|000000e0| 63 33 2e 39 2f 70 61 72 | 74 31 33 0a 0a 23 21 20 |c3.9/par|t13..#! |
|000000f0| 2f 62 69 6e 2f 73 68 0a | 23 20 54 68 69 73 20 69 |/bin/sh.|# This i|
|00000100| 73 20 61 20 73 68 65 6c | 6c 20 61 72 63 68 69 76 |s a shel|l archiv|
|00000110| 65 2e 20 54 6f 20 65 78 | 74 72 61 63 74 2c 20 72 |e. To ex|tract, r|
|00000120| 65 6d 6f 76 65 20 74 68 | 65 20 68 65 61 64 65 72 |emove th|e header|
|00000130| 20 61 6e 64 20 74 79 70 | 65 20 22 73 68 20 66 69 | and typ|e "sh fi|
|00000140| 6c 65 6e 61 6d 65 22 0a | 23 0a 63 64 20 64 6f 63 |lename".|#.cd doc|
|00000150| 0a 65 63 68 6f 20 78 20 | 2d 20 78 64 72 2e 6e 74 |.echo x |- xdr.nt|
|00000160| 73 2e 6d 73 0a 73 65 64 | 20 2d 65 20 27 73 2f 5e |s.ms.sed| -e 's/^|
|00000170| 58 2f 2f 27 20 3e 20 78 | 64 72 2e 6e 74 73 2e 6d |X//' > x|dr.nts.m|
|00000180| 73 20 3c 3c 27 46 75 6e | 6b 79 5f 53 74 75 66 66 |s <<'Fun|ky_Stuff|
|00000190| 27 0a 58 2e 5c 22 20 40 | 28 23 29 78 64 72 2e 6e |'.X.\" @|(#)xdr.n|
|000001a0| 74 73 2e 6d 73 09 31 2e | 32 20 38 37 2f 31 31 2f |ts.ms.1.|2 87/11/|
|000001b0| 30 39 20 33 2e 39 20 52 | 50 43 53 52 43 0a 58 2e |09 3.9 R|PCSRC.X.|
|000001c0| 64 65 20 42 54 0a 58 2e | 69 66 20 5c 5c 6e 25 3d |de BT.X.|if \\n%=|
|000001d0| 31 20 2e 74 6c 20 27 27 | 2d 20 25 20 2d 27 27 0a |1 .tl ''|- % -''.|
|000001e0| 58 2e 2e 0a 58 2e 4e 44 | 0a 58 2e 5c 22 20 70 72 |X...X.ND|.X.\" pr|
|000001f0| 65 76 65 6e 74 20 65 78 | 63 65 73 73 20 75 6e 64 |event ex|cess und|
|00000200| 65 72 6c 69 6e 69 6e 67 | 20 69 6e 20 6e 72 6f 66 |erlining| in nrof|
|00000210| 66 0a 58 2e 69 66 20 6e | 20 2e 66 70 20 32 20 52 |f.X.if n| .fp 2 R|
|00000220| 0a 58 2e 4f 48 20 27 65 | 58 74 65 72 6e 61 6c 20 |.X.OH 'e|Xternal |
|00000230| 44 61 74 61 20 52 65 70 | 72 65 73 65 6e 74 61 74 |Data Rep|resentat|
|00000240| 69 6f 6e 3a 20 53 75 6e | 20 54 65 63 68 6e 69 63 |ion: Sun| Technic|
|00000250| 61 6c 20 4e 6f 74 65 73 | 27 27 50 61 67 65 20 25 |al Notes|''Page %|
|00000260| 27 0a 58 2e 45 48 20 27 | 50 61 67 65 20 25 27 27 |'.X.EH '|Page %''|
|00000270| 65 58 74 65 72 6e 61 6c | 20 44 61 74 61 20 52 65 |eXternal| Data Re|
|00000280| 70 72 65 73 65 6e 74 61 | 74 69 6f 6e 3a 20 53 75 |presenta|tion: Su|
|00000290| 6e 20 54 65 63 68 6e 69 | 63 61 6c 20 4e 6f 74 65 |n Techni|cal Note|
|000002a0| 73 27 0a 58 2e 69 66 20 | 5c 5c 6e 25 3d 31 20 2e |s'.X.if |\\n%=1 .|
|000002b0| 62 70 0a 58 2e 53 48 0a | 5c 26 65 58 74 65 72 6e |bp.X.SH.|\&eXtern|
|000002c0| 61 6c 20 44 61 74 61 20 | 52 65 70 72 65 73 65 6e |al Data |Represen|
|000002d0| 74 61 74 69 6f 6e 3a 20 | 53 75 6e 20 54 65 63 68 |tation: |Sun Tech|
|000002e0| 6e 69 63 61 6c 20 4e 6f | 74 65 73 0a 58 2e 49 58 |nical No|tes.X.IX|
|000002f0| 20 58 44 52 20 22 53 75 | 6e 20 74 65 63 68 6e 69 | XDR "Su|n techni|
|00000300| 63 61 6c 20 6e 6f 74 65 | 73 22 0a 58 2e 4c 50 0a |cal note|s".X.LP.|
|00000310| 54 68 69 73 20 63 68 61 | 70 74 65 72 20 63 6f 6e |This cha|pter con|
|00000320| 74 61 69 6e 73 20 74 65 | 63 68 6e 69 63 61 6c 20 |tains te|chnical |
|00000330| 6e 6f 74 65 73 20 6f 6e | 20 53 75 6e 27 73 20 69 |notes on| Sun's i|
|00000340| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 20 6f 66 |mplement|ation of|
|00000350| 20 74 68 65 0a 65 58 74 | 65 72 6e 61 6c 20 44 61 | the.eXt|ernal Da|
|00000360| 74 61 20 52 65 70 72 65 | 73 65 6e 74 61 74 69 6f |ta Repre|sentatio|
|00000370| 6e 20 28 58 44 52 29 20 | 73 74 61 6e 64 61 72 64 |n (XDR) |standard|
|00000380| 2c 20 61 20 73 65 74 20 | 6f 66 20 6c 69 62 72 61 |, a set |of libra|
|00000390| 72 79 20 72 6f 75 74 69 | 6e 65 73 20 0a 74 68 61 |ry routi|nes .tha|
|000003a0| 74 20 61 6c 6c 6f 77 20 | 61 20 43 20 70 72 6f 67 |t allow |a C prog|
|000003b0| 72 61 6d 6d 65 72 20 74 | 6f 20 64 65 73 63 72 69 |rammer t|o descri|
|000003c0| 62 65 20 61 72 62 69 74 | 72 61 72 79 20 64 61 74 |be arbit|rary dat|
|000003d0| 61 20 73 74 72 75 63 74 | 75 72 65 73 20 69 6e 20 |a struct|ures in |
|000003e0| 61 20 0a 6d 61 63 68 69 | 6e 65 2d 69 6e 64 65 70 |a .machi|ne-indep|
|000003f0| 65 6e 64 65 6e 74 20 66 | 61 73 68 69 6f 6e 2e 20 |endent f|ashion. |
|00000400| 20 46 6f 72 20 61 20 66 | 6f 72 6d 61 6c 20 73 70 | For a f|ormal sp|
|00000410| 65 63 69 66 69 63 61 74 | 69 6f 6e 20 6f 66 20 74 |ecificat|ion of t|
|00000420| 68 65 20 58 44 52 0a 73 | 74 61 6e 64 61 72 64 2c |he XDR.s|tandard,|
|00000430| 20 73 65 65 20 74 68 65 | 0a 5c 66 49 65 58 74 65 | see the|.\fIeXte|
|00000440| 72 6e 61 6c 20 44 61 74 | 61 20 52 65 70 72 65 73 |rnal Dat|a Repres|
|00000450| 65 6e 74 61 74 69 6f 6e | 20 53 74 61 6e 64 61 72 |entation| Standar|
|00000460| 64 5c 66 50 5c 2e 0a 58 | 44 52 20 69 73 20 74 68 |d\fP\..X|DR is th|
|00000470| 65 20 62 61 63 6b 62 6f | 6e 65 20 6f 66 20 53 75 |e backbo|ne of Su|
|00000480| 6e 27 73 20 52 65 6d 6f | 74 65 20 50 72 6f 63 65 |n's Remo|te Proce|
|00000490| 64 75 72 65 20 43 61 6c | 6c 20 70 61 63 6b 61 67 |dure Cal|l packag|
|000004a0| 65 2c 20 69 6e 20 74 68 | 65 20 0a 73 65 6e 73 65 |e, in th|e .sense|
|000004b0| 20 74 68 61 74 20 64 61 | 74 61 20 66 6f 72 20 72 | that da|ta for r|
|000004c0| 65 6d 6f 74 65 20 70 72 | 6f 63 65 64 75 72 65 20 |emote pr|ocedure |
|000004d0| 63 61 6c 6c 73 20 69 73 | 20 74 72 61 6e 73 6d 69 |calls is| transmi|
|000004e0| 74 74 65 64 20 75 73 69 | 6e 67 20 74 68 65 20 0a |tted usi|ng the .|
|000004f0| 73 74 61 6e 64 61 72 64 | 2e 20 20 58 44 52 20 6c |standard|. XDR l|
|00000500| 69 62 72 61 72 79 20 72 | 6f 75 74 69 6e 65 73 20 |ibrary r|outines |
|00000510| 73 68 6f 75 6c 64 20 62 | 65 20 75 73 65 64 20 74 |should b|e used t|
|00000520| 6f 20 74 72 61 6e 73 6d | 69 74 20 64 61 74 61 0a |o transm|it data.|
|00000530| 74 68 61 74 20 69 73 20 | 61 63 63 65 73 73 65 64 |that is |accessed|
|00000540| 20 28 72 65 61 64 20 6f | 72 20 77 72 69 74 74 65 | (read o|r writte|
|00000550| 6e 29 20 62 79 20 6d 6f | 72 65 20 74 68 61 6e 20 |n) by mo|re than |
|00000560| 6f 6e 65 20 74 79 70 65 | 20 6f 66 20 6d 61 63 68 |one type| of mach|
|00000570| 69 6e 65 2e 5c 2a 2a 0a | 58 2e 46 53 0a 58 2e 49 |ine.\**.|X.FS.X.I|
|00000580| 58 20 58 44 52 20 22 73 | 79 73 74 65 6d 20 72 6f |X XDR "s|ystem ro|
|00000590| 75 74 69 6e 65 73 22 0a | 46 6f 72 20 61 20 63 6f |utines".|For a co|
|000005a0| 6d 70 65 74 65 20 73 70 | 65 63 69 66 69 63 61 74 |mpete sp|ecificat|
|000005b0| 69 6f 6e 20 6f 66 20 74 | 68 65 20 73 79 73 74 65 |ion of t|he syste|
|000005c0| 6d 20 65 58 74 65 72 6e | 61 6c 20 44 61 74 61 20 |m eXtern|al Data |
|000005d0| 52 65 70 72 65 73 65 6e | 74 61 74 69 6f 6e 0a 72 |Represen|tation.r|
|000005e0| 6f 75 74 69 6e 65 73 2c | 20 73 65 65 20 74 68 65 |outines,| see the|
|000005f0| 20 0a 58 2e 49 20 78 64 | 72 20 28 33 4e 29 0a 6d | .X.I xd|r (3N).m|
|00000600| 61 6e 75 61 6c 20 70 61 | 67 65 2e 0a 58 2e 46 45 |anual pa|ge..X.FE|
|00000610| 0a 58 2e 4c 50 0a 54 68 | 69 73 20 63 68 61 70 74 |.X.LP.Th|is chapt|
|00000620| 65 72 20 63 6f 6e 74 61 | 69 6e 73 20 61 20 73 68 |er conta|ins a sh|
|00000630| 6f 72 74 20 74 75 74 6f | 72 69 61 6c 20 6f 76 65 |ort tuto|rial ove|
|00000640| 72 76 69 65 77 20 6f 66 | 20 74 68 65 20 58 44 52 |rview of| the XDR|
|00000650| 20 6c 69 62 72 61 72 79 | 20 0a 72 6f 75 74 69 6e | library| .routin|
|00000660| 65 73 2c 20 61 20 67 75 | 69 64 65 20 74 6f 20 61 |es, a gu|ide to a|
|00000670| 63 63 65 73 73 69 6e 67 | 20 63 75 72 72 65 6e 74 |ccessing| current|
|00000680| 6c 79 20 61 76 61 69 6c | 61 62 6c 65 20 58 44 52 |ly avail|able XDR|
|00000690| 20 73 74 72 65 61 6d 73 | 2c 20 61 6e 64 0a 69 6e | streams|, and.in|
|000006a0| 66 6f 72 6d 61 74 69 6f | 6e 20 6f 6e 20 64 65 66 |formatio|n on def|
|000006b0| 69 6e 69 6e 67 20 6e 65 | 77 20 73 74 72 65 61 6d |ining ne|w stream|
|000006c0| 73 20 61 6e 64 20 64 61 | 74 61 20 74 79 70 65 73 |s and da|ta types|
|000006d0| 2e 20 20 58 44 52 20 77 | 61 73 20 64 65 73 69 67 |. XDR w|as desig|
|000006e0| 6e 65 64 0a 74 6f 20 77 | 6f 72 6b 20 61 63 72 6f |ned.to w|ork acro|
|000006f0| 73 73 20 64 69 66 66 65 | 72 65 6e 74 20 6c 61 6e |ss diffe|rent lan|
|00000700| 67 75 61 67 65 73 2c 20 | 6f 70 65 72 61 74 69 6e |guages, |operatin|
|00000710| 67 20 73 79 73 74 65 6d | 73 2c 20 61 6e 64 20 6d |g system|s, and m|
|00000720| 61 63 68 69 6e 65 20 0a | 61 72 63 68 69 74 65 63 |achine .|architec|
|00000730| 74 75 72 65 73 2e 20 20 | 4d 6f 73 74 20 75 73 65 |tures. |Most use|
|00000740| 72 73 20 28 70 61 72 74 | 69 63 75 6c 61 72 6c 79 |rs (part|icularly|
|00000750| 20 52 50 43 20 75 73 65 | 72 73 29 20 77 69 6c 6c | RPC use|rs) will|
|00000760| 20 6e 65 65 64 20 6f 6e | 6c 79 20 74 68 65 0a 69 | need on|ly the.i|
|00000770| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 69 6e 20 73 65 |nformati|on in se|
|00000780| 63 74 69 6f 6e 73 20 31 | 2c 20 32 20 61 6e 64 20 |ctions 1|, 2 and |
|00000790| 33 20 6f 66 20 74 68 69 | 73 20 64 6f 63 75 6d 65 |3 of thi|s docume|
|000007a0| 6e 74 2e 0a 50 72 6f 67 | 72 61 6d 6d 65 72 73 20 |nt..Prog|rammers |
|000007b0| 77 69 73 68 69 6e 67 20 | 74 6f 20 69 6d 70 6c 65 |wishing |to imple|
|000007c0| 6d 65 6e 74 20 52 50 43 | 20 61 6e 64 20 58 44 52 |ment RPC| and XDR|
|000007d0| 20 6f 6e 20 6e 65 77 20 | 6d 61 63 68 69 6e 65 73 | on new |machines|
|000007e0| 0a 77 69 6c 6c 20 6e 65 | 65 64 20 74 68 65 20 69 |.will ne|ed the i|
|000007f0| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 69 6e 20 74 68 |nformati|on in th|
|00000800| 65 20 72 65 73 74 20 6f | 66 20 74 68 69 73 20 64 |e rest o|f this d|
|00000810| 6f 63 75 6d 65 6e 74 2c | 20 61 6e 64 20 65 73 70 |ocument,| and esp|
|00000820| 65 63 69 61 6c 6c 79 20 | 74 68 65 0a 5c 66 49 65 |ecially |the.\fIe|
|00000830| 58 74 65 72 6e 61 6c 20 | 44 61 74 61 20 52 65 70 |Xternal |Data Rep|
|00000840| 72 65 73 65 6e 74 61 74 | 69 6f 6e 20 53 74 61 6e |resentat|ion Stan|
|00000850| 64 61 72 64 5c 66 50 5c | 2e 0a 58 2e 53 48 0a 58 |dard\fP\|..X.SH.X|
|00000860| 2e 49 0a 4e 4f 54 45 3a | 0a 5c 66 42 72 70 63 67 |.I.NOTE:|.\fBrpcg|
|00000870| 65 6e 20 5c 66 49 63 61 | 6e 20 62 65 20 75 73 65 |en \fIca|n be use|
|00000880| 64 20 74 6f 20 77 72 69 | 74 65 20 58 44 52 20 72 |d to wri|te XDR r|
|00000890| 6f 75 74 69 6e 65 73 20 | 65 76 65 6e 20 69 6e 20 |outines |even in |
|000008a0| 63 61 73 65 73 20 77 68 | 65 72 65 20 6e 6f 20 52 |cases wh|ere no R|
|000008b0| 50 43 0a 63 61 6c 6c 73 | 20 61 72 65 20 62 65 69 |PC.calls| are bei|
|000008c0| 6e 67 20 6d 61 64 65 2e | 0a 58 2e 4c 50 0a 4f 6e |ng made.|.X.LP.On|
|000008d0| 20 53 75 6e 20 73 79 73 | 74 65 6d 73 2c 0a 43 20 | Sun sys|tems,.C |
|000008e0| 70 72 6f 67 72 61 6d 73 | 20 74 68 61 74 20 77 61 |programs| that wa|
|000008f0| 6e 74 20 74 6f 20 75 73 | 65 20 58 44 52 20 72 6f |nt to us|e XDR ro|
|00000900| 75 74 69 6e 65 73 0a 6d | 75 73 74 20 69 6e 63 6c |utines.m|ust incl|
|00000910| 75 64 65 20 74 68 65 20 | 66 69 6c 65 0a 58 2e 49 |ude the |file.X.I|
|00000920| 20 3c 72 70 63 2f 72 70 | 63 2e 68 3e 20 2c 0a 77 | <rpc/rp|c.h> ,.w|
|00000930| 68 69 63 68 20 63 6f 6e | 74 61 69 6e 73 20 61 6c |hich con|tains al|
|00000940| 6c 20 74 68 65 20 6e 65 | 63 65 73 73 61 72 79 20 |l the ne|cessary |
|00000950| 69 6e 74 65 72 66 61 63 | 65 73 20 74 6f 20 74 68 |interfac|es to th|
|00000960| 65 20 58 44 52 20 73 79 | 73 74 65 6d 2e 0a 53 69 |e XDR sy|stem..Si|
|00000970| 6e 63 65 20 74 68 65 20 | 43 20 6c 69 62 72 61 72 |nce the |C librar|
|00000980| 79 0a 58 2e 49 20 6c 69 | 62 63 2e 61 0a 63 6f 6e |y.X.I li|bc.a.con|
|00000990| 74 61 69 6e 73 20 61 6c | 6c 20 74 68 65 20 58 44 |tains al|l the XD|
|000009a0| 52 20 72 6f 75 74 69 6e | 65 73 2c 20 63 6f 6d 70 |R routin|es, comp|
|000009b0| 69 6c 65 20 61 73 20 6e | 6f 72 6d 61 6c 2e 0a 58 |ile as n|ormal..X|
|000009c0| 2e 44 53 0a 25 20 5c 66 | 42 63 63 5c 30 5c 66 49 |.DS.% \f|Bcc\0\fI|
|000009d0| 70 72 6f 67 72 61 6d 5c | 66 50 2e 63 5c 66 49 0a |program\|fP.c\fI.|
|000009e0| 58 2e 44 45 0a 58 2e 0a | 58 2e 6e 65 20 33 69 0a |X.DE.X..|X.ne 3i.|
|000009f0| 58 2e 4e 48 20 30 0a 5c | 26 4a 75 73 74 69 66 69 |X.NH 0.\|&Justifi|
|00000a00| 63 61 74 69 6f 6e 0a 58 | 2e 49 58 20 22 6a 75 73 |cation.X|.IX "jus|
|00000a10| 74 69 66 69 63 61 74 69 | 6f 6e 20 66 6f 72 20 58 |tificati|on for X|
|00000a20| 44 52 22 0a 58 2e 49 58 | 20 22 72 65 61 73 6f 6e |DR".X.IX| "reason|
|00000a30| 20 66 6f 72 20 58 44 52 | 22 0a 58 2e 4c 50 0a 43 | for XDR|".X.LP.C|
|00000a40| 6f 6e 73 69 64 65 72 20 | 74 68 65 20 66 6f 6c 6c |onsider |the foll|
|00000a50| 6f 77 69 6e 67 20 74 77 | 6f 20 70 72 6f 67 72 61 |owing tw|o progra|
|00000a60| 6d 73 2c 0a 58 2e 49 20 | 77 72 69 74 65 72 0a 58 |ms,.X.I |writer.X|
|00000a70| 2e 69 65 20 74 20 2e 44 | 53 0a 58 2e 65 6c 20 2e |.ie t .D|S.X.el .|
|00000a80| 44 53 20 4c 0a 58 2e 66 | 74 20 43 57 0a 23 69 6e |DS L.X.f|t CW.#in|
|00000a90| 63 6c 75 64 65 20 3c 73 | 74 64 69 6f 2e 68 3e 0a |clude <s|tdio.h>.|
|00000aa0| 58 2e 73 70 2e 35 0a 6d | 61 69 6e 28 29 09 09 09 |X.sp.5.m|ain()...|
|00000ab0| 2f 2a 20 5c 66 49 77 72 | 69 74 65 72 2e 63 5c 66 |/* \fIwr|iter.c\f|
|00000ac0| 50 20 2a 2f 0a 7b 0a 09 | 6c 6f 6e 67 20 69 3b 0a |P */.{..|long i;.|
|00000ad0| 58 2e 73 70 2e 35 0a 09 | 66 6f 72 20 28 69 20 3d |X.sp.5..|for (i =|
|00000ae0| 20 30 3b 20 69 20 3c 20 | 38 3b 20 69 2b 2b 29 20 | 0; i < |8; i++) |
|00000af0| 7b 0a 09 09 69 66 20 28 | 66 77 72 69 74 65 28 28 |{...if (|fwrite((|
|00000b00| 63 68 61 72 20 2a 29 26 | 69 2c 20 73 69 7a 65 6f |char *)&|i, sizeo|
|00000b10| 66 28 69 29 2c 20 31 2c | 20 73 74 64 6f 75 74 29 |f(i), 1,| stdout)|
|00000b20| 20 21 3d 20 31 29 20 7b | 0a 09 09 09 66 70 72 69 | != 1) {|....fpri|
|00000b30| 6e 74 66 28 73 74 64 65 | 72 72 2c 20 22 66 61 69 |ntf(stde|rr, "fai|
|00000b40| 6c 65 64 21 5c 65 6e 22 | 29 3b 0a 09 09 09 65 78 |led!\en"|);....ex|
|00000b50| 69 74 28 31 29 3b 0a 09 | 09 7d 0a 09 7d 0a 7d 0a |it(1);..|.}..}.}.|
|00000b60| 58 2e 44 45 0a 61 6e 64 | 0a 58 2e 49 20 72 65 61 |X.DE.and|.X.I rea|
|00000b70| 64 65 72 0a 58 2e 69 65 | 20 74 20 2e 44 53 0a 58 |der.X.ie| t .DS.X|
|00000b80| 2e 65 6c 20 2e 44 53 20 | 4c 0a 58 2e 66 74 20 43 |.el .DS |L.X.ft C|
|00000b90| 57 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 64 69 |W.#inclu|de <stdi|
|00000ba0| 6f 2e 68 3e 0a 58 2e 73 | 70 2e 35 0a 6d 61 69 6e |o.h>.X.s|p.5.main|
|00000bb0| 28 29 09 09 09 2f 2a 20 | 5c 66 49 72 65 61 64 65 |().../* |\fIreade|
|00000bc0| 72 2e 63 5c 66 50 20 2a | 2f 0a 7b 0a 09 6c 6f 6e |r.c\fP *|/.{..lon|
|00000bd0| 67 20 69 2c 20 6a 3b 0a | 58 2e 73 70 2e 35 0a 09 |g i, j;.|X.sp.5..|
|00000be0| 66 6f 72 20 28 6a 20 3d | 20 30 3b 20 6a 20 3c 20 |for (j =| 0; j < |
|00000bf0| 38 3b 20 6a 2b 2b 29 20 | 7b 0a 09 09 69 66 20 28 |8; j++) |{...if (|
|00000c00| 66 72 65 61 64 28 28 63 | 68 61 72 20 2a 29 26 69 |fread((c|har *)&i|
|00000c10| 2c 20 73 69 7a 65 6f 66 | 20 28 69 29 2c 20 31 2c |, sizeof| (i), 1,|
|00000c20| 20 73 74 64 69 6e 29 20 | 21 3d 20 31 29 20 7b 0a | stdin) |!= 1) {.|
|00000c30| 09 09 09 66 70 72 69 6e | 74 66 28 73 74 64 65 72 |...fprin|tf(stder|
|00000c40| 72 2c 20 22 66 61 69 6c | 65 64 21 5c 65 6e 22 29 |r, "fail|ed!\en")|
|00000c50| 3b 0a 09 09 09 65 78 69 | 74 28 31 29 3b 0a 09 09 |;....exi|t(1);...|
|00000c60| 7d 0a 09 09 70 72 69 6e | 74 66 28 22 25 6c 64 20 |}...prin|tf("%ld |
|00000c70| 22 2c 20 69 29 3b 0a 09 | 7d 0a 09 70 72 69 6e 74 |", i);..|}..print|
|00000c80| 66 28 22 5c 65 6e 22 29 | 3b 0a 7d 0a 58 2e 44 45 |f("\en")|;.}.X.DE|
|00000c90| 0a 54 68 65 20 74 77 6f | 20 70 72 6f 67 72 61 6d |.The two| program|
|00000ca0| 73 20 61 70 70 65 61 72 | 20 74 6f 20 62 65 20 70 |s appear| to be p|
|00000cb0| 6f 72 74 61 62 6c 65 2c | 20 62 65 63 61 75 73 65 |ortable,| because|
|00000cc0| 20 28 61 29 20 74 68 65 | 79 20 70 61 73 73 0a 58 | (a) the|y pass.X|
|00000cd0| 2e 49 20 6c 69 6e 74 0a | 63 68 65 63 6b 69 6e 67 |.I lint.|checking|
|00000ce0| 2c 20 61 6e 64 20 28 62 | 29 20 74 68 65 79 20 65 |, and (b|) they e|
|00000cf0| 78 68 69 62 69 74 20 74 | 68 65 20 73 61 6d 65 20 |xhibit t|he same |
|00000d00| 62 65 68 61 76 69 6f 72 | 20 77 68 65 6e 20 65 78 |behavior| when ex|
|00000d10| 65 63 75 74 65 64 0a 6f | 6e 20 74 77 6f 20 64 69 |ecuted.o|n two di|
|00000d20| 66 66 65 72 65 6e 74 20 | 68 61 72 64 77 61 72 65 |fferent |hardware|
|00000d30| 20 61 72 63 68 69 74 65 | 63 74 75 72 65 73 2c 20 | archite|ctures, |
|00000d40| 61 20 53 75 6e 20 61 6e | 64 20 61 20 56 41 58 2e |a Sun an|d a VAX.|
|00000d50| 0a 58 2e 4c 50 0a 50 69 | 70 69 6e 67 20 74 68 65 |.X.LP.Pi|ping the|
|00000d60| 20 6f 75 74 70 75 74 20 | 6f 66 20 74 68 65 0a 58 | output |of the.X|
|00000d70| 2e 49 20 77 72 69 74 65 | 72 20 0a 70 72 6f 67 72 |.I write|r .progr|
|00000d80| 61 6d 20 74 6f 20 74 68 | 65 0a 58 2e 49 20 72 65 |am to th|e.X.I re|
|00000d90| 61 64 65 72 20 0a 70 72 | 6f 67 72 61 6d 20 67 69 |ader .pr|ogram gi|
|00000da0| 76 65 73 20 69 64 65 6e | 74 69 63 61 6c 20 72 65 |ves iden|tical re|
|00000db0| 73 75 6c 74 73 20 6f 6e | 20 61 20 53 75 6e 20 6f |sults on| a Sun o|
|00000dc0| 72 20 61 20 56 41 58 2e | 0a 58 2e 44 53 0a 58 2e |r a VAX.|.X.DS.X.|
|00000dd0| 66 74 20 43 57 0a 73 75 | 6e 25 20 77 72 69 74 65 |ft CW.su|n% write|
|00000de0| 72 20 7c 20 72 65 61 64 | 65 72 0a 30 20 31 20 32 |r | read|er.0 1 2|
|00000df0| 20 33 20 34 20 35 20 36 | 20 37 0a 73 75 6e 25 0a | 3 4 5 6| 7.sun%.|
|00000e00| 0a 76 61 78 25 20 77 72 | 69 74 65 72 20 7c 20 72 |.vax% wr|iter | r|
|00000e10| 65 61 64 65 72 0a 30 20 | 31 20 32 20 33 20 34 20 |eader.0 |1 2 3 4 |
|00000e20| 35 20 36 20 37 0a 76 61 | 78 25 0a 58 2e 44 45 0a |5 6 7.va|x%.X.DE.|
|00000e30| 57 69 74 68 20 74 68 65 | 20 61 64 76 65 6e 74 20 |With the| advent |
|00000e40| 6f 66 20 6c 6f 63 61 6c | 20 61 72 65 61 20 6e 65 |of local| area ne|
|00000e50| 74 77 6f 72 6b 73 20 61 | 6e 64 20 34 2e 32 42 53 |tworks a|nd 4.2BS|
|00000e60| 44 20 63 61 6d 65 20 74 | 68 65 20 63 6f 6e 63 65 |D came t|he conce|
|00000e70| 70 74 20 0a 6f 66 20 60 | 60 6e 65 74 77 6f 72 6b |pt .of `|`network|
|00000e80| 20 70 69 70 65 73 27 27 | 20 5c 28 65 6d 20 61 20 | pipes''| \(em a |
|00000e90| 70 72 6f 63 65 73 73 20 | 70 72 6f 64 75 63 65 73 |process |produces|
|00000ea0| 20 64 61 74 61 20 6f 6e | 20 6f 6e 65 20 6d 61 63 | data on| one mac|
|00000eb0| 68 69 6e 65 2c 0a 61 6e | 64 20 61 20 73 65 63 6f |hine,.an|d a seco|
|00000ec0| 6e 64 20 70 72 6f 63 65 | 73 73 20 63 6f 6e 73 75 |nd proce|ss consu|
|00000ed0| 6d 65 73 20 64 61 74 61 | 20 6f 6e 20 61 6e 6f 74 |mes data| on anot|
|00000ee0| 68 65 72 20 6d 61 63 68 | 69 6e 65 2e 0a 41 20 6e |her mach|ine..A n|
|00000ef0| 65 74 77 6f 72 6b 20 70 | 69 70 65 20 63 61 6e 20 |etwork p|ipe can |
|00000f00| 62 65 20 63 6f 6e 73 74 | 72 75 63 74 65 64 20 77 |be const|ructed w|
|00000f10| 69 74 68 0a 58 2e 49 20 | 77 72 69 74 65 72 20 0a |ith.X.I |writer .|
|00000f20| 61 6e 64 0a 58 2e 49 20 | 72 65 61 64 65 72 20 2e |and.X.I |reader .|
|00000f30| 0a 48 65 72 65 20 61 72 | 65 20 74 68 65 20 72 65 |.Here ar|e the re|
|00000f40| 73 75 6c 74 73 20 69 66 | 20 74 68 65 20 66 69 72 |sults if| the fir|
|00000f50| 73 74 20 70 72 6f 64 75 | 63 65 73 20 64 61 74 61 |st produ|ces data|
|00000f60| 20 6f 6e 20 61 20 53 75 | 6e 2c 0a 61 6e 64 20 74 | on a Su|n,.and t|
|00000f70| 68 65 20 73 65 63 6f 6e | 64 20 63 6f 6e 73 75 6d |he secon|d consum|
|00000f80| 65 73 20 64 61 74 61 20 | 6f 6e 20 61 20 56 41 58 |es data |on a VAX|
|00000f90| 2e 0a 58 2e 44 53 0a 58 | 2e 66 74 20 43 57 0a 73 |..X.DS.X|.ft CW.s|
|00000fa0| 75 6e 25 20 77 72 69 74 | 65 72 20 7c 20 72 73 68 |un% writ|er | rsh|
|00000fb0| 20 76 61 78 20 72 65 61 | 64 65 72 0a 30 20 31 36 | vax rea|der.0 16|
|00000fc0| 37 37 37 32 31 36 20 33 | 33 35 35 34 34 33 32 20 |777216 3|3554432 |
|00000fd0| 35 30 33 33 31 36 34 38 | 20 36 37 31 30 38 38 36 |50331648| 6710886|
|00000fe0| 34 20 38 33 38 38 36 30 | 38 30 20 31 30 30 36 36 |4 838860|80 10066|
|00000ff0| 33 32 39 36 0a 31 31 37 | 34 34 30 35 31 32 0a 73 |3296.117|440512.s|
|00001000| 75 6e 25 0a 58 2e 44 45 | 0a 49 64 65 6e 74 69 63 |un%.X.DE|.Identic|
|00001010| 61 6c 20 72 65 73 75 6c | 74 73 20 63 61 6e 20 62 |al resul|ts can b|
|00001020| 65 20 6f 62 74 61 69 6e | 65 64 20 62 79 20 65 78 |e obtain|ed by ex|
|00001030| 65 63 75 74 69 6e 67 0a | 58 2e 49 20 77 72 69 74 |ecuting.|X.I writ|
|00001040| 65 72 20 0a 6f 6e 20 74 | 68 65 20 56 41 58 20 61 |er .on t|he VAX a|
|00001050| 6e 64 0a 58 2e 49 20 72 | 65 61 64 65 72 20 0a 6f |nd.X.I r|eader .o|
|00001060| 6e 20 74 68 65 20 53 75 | 6e 2e 0a 54 68 65 73 65 |n the Su|n..These|
|00001070| 20 72 65 73 75 6c 74 73 | 20 6f 63 63 75 72 20 62 | results| occur b|
|00001080| 65 63 61 75 73 65 20 74 | 68 65 20 62 79 74 65 20 |ecause t|he byte |
|00001090| 6f 72 64 65 72 69 6e 67 | 0a 6f 66 20 6c 6f 6e 67 |ordering|.of long|
|000010a0| 20 69 6e 74 65 67 65 72 | 73 20 64 69 66 66 65 72 | integer|s differ|
|000010b0| 73 20 62 65 74 77 65 65 | 6e 20 74 68 65 20 56 41 |s betwee|n the VA|
|000010c0| 58 20 61 6e 64 20 74 68 | 65 20 53 75 6e 2c 0a 65 |X and th|e Sun,.e|
|000010d0| 76 65 6e 20 74 68 6f 75 | 67 68 20 77 6f 72 64 20 |ven thou|gh word |
|000010e0| 73 69 7a 65 20 69 73 20 | 74 68 65 20 73 61 6d 65 |size is |the same|
|000010f0| 2e 0a 4e 6f 74 65 20 74 | 68 61 74 20 24 31 36 37 |..Note t|hat $167|
|00001100| 37 37 32 31 36 24 20 69 | 73 20 24 32 20 73 75 70 |77216$ i|s $2 sup|
|00001110| 20 32 34 24 20 5c 28 65 | 6d 0a 77 68 65 6e 20 66 | 24$ \(e|m.when f|
|00001120| 6f 75 72 20 62 79 74 65 | 73 20 61 72 65 20 72 65 |our byte|s are re|
|00001130| 76 65 72 73 65 64 2c 20 | 74 68 65 20 31 20 77 69 |versed, |the 1 wi|
|00001140| 6e 64 73 20 75 70 20 69 | 6e 20 74 68 65 20 32 34 |nds up i|n the 24|
|00001150| 74 68 20 62 69 74 2e 0a | 58 2e 4c 50 0a 57 68 65 |th bit..|X.LP.Whe|
|00001160| 6e 65 76 65 72 20 64 61 | 74 61 20 69 73 20 73 68 |never da|ta is sh|
|00001170| 61 72 65 64 20 62 79 20 | 74 77 6f 20 6f 72 20 6d |ared by |two or m|
|00001180| 6f 72 65 20 6d 61 63 68 | 69 6e 65 20 74 79 70 65 |ore mach|ine type|
|00001190| 73 2c 0a 74 68 65 72 65 | 20 69 73 20 61 20 6e 65 |s,.there| is a ne|
|000011a0| 65 64 20 66 6f 72 20 70 | 6f 72 74 61 62 6c 65 20 |ed for p|ortable |
|000011b0| 64 61 74 61 2e 0a 50 72 | 6f 67 72 61 6d 73 20 63 |data..Pr|ograms c|
|000011c0| 61 6e 20 62 65 20 6d 61 | 64 65 20 64 61 74 61 2d |an be ma|de data-|
|000011d0| 70 6f 72 74 61 62 6c 65 | 20 62 79 20 72 65 70 6c |portable| by repl|
|000011e0| 61 63 69 6e 67 20 74 68 | 65 0a 58 2e 49 20 72 65 |acing th|e.X.I re|
|000011f0| 61 64 0a 61 6e 64 0a 58 | 2e 49 20 77 72 69 74 65 |ad.and.X|.I write|
|00001200| 0a 63 61 6c 6c 73 20 77 | 69 74 68 20 63 61 6c 6c |.calls w|ith call|
|00001210| 73 20 74 6f 20 61 6e 20 | 58 44 52 20 6c 69 62 72 |s to an |XDR libr|
|00001220| 61 72 79 20 72 6f 75 74 | 69 6e 65 0a 58 2e 49 20 |ary rout|ine.X.I |
|00001230| 78 64 72 5f 6c 6f 6e 67 | 0a 61 20 66 69 6c 74 65 |xdr_long|.a filte|
|00001240| 72 20 74 68 61 74 20 6b | 6e 6f 77 73 20 74 68 65 |r that k|nows the|
|00001250| 20 73 74 61 6e 64 61 72 | 64 20 72 65 70 72 65 73 | standar|d repres|
|00001260| 65 6e 74 61 74 69 6f 6e | 0a 6f 66 20 61 20 6c 6f |entation|.of a lo|
|00001270| 6e 67 20 69 6e 74 65 67 | 65 72 20 69 6e 20 69 74 |ng integ|er in it|
|00001280| 73 20 65 78 74 65 72 6e | 61 6c 20 66 6f 72 6d 2e |s extern|al form.|
|00001290| 0a 48 65 72 65 20 61 72 | 65 20 74 68 65 20 72 65 |.Here ar|e the re|
|000012a0| 76 69 73 65 64 20 76 65 | 72 73 69 6f 6e 73 20 6f |vised ve|rsions o|
|000012b0| 66 0a 58 2e 49 20 77 72 | 69 74 65 72 20 3a 0a 58 |f.X.I wr|iter :.X|
|000012c0| 2e 69 65 20 74 20 2e 44 | 53 0a 58 2e 65 6c 20 2e |.ie t .D|S.X.el .|
|000012d0| 44 53 20 4c 0a 58 2e 66 | 74 20 43 57 0a 23 69 6e |DS L.X.f|t CW.#in|
|000012e0| 63 6c 75 64 65 20 3c 73 | 74 64 69 6f 2e 68 3e 0a |clude <s|tdio.h>.|
|000012f0| 23 69 6e 63 6c 75 64 65 | 20 3c 72 70 63 2f 72 70 |#include| <rpc/rp|
|00001300| 63 2e 68 3e 09 2f 2a 20 | 5c 66 49 78 64 72 20 69 |c.h>./* |\fIxdr i|
|00001310| 73 20 61 20 73 75 62 2d | 6c 69 62 72 61 72 79 20 |s a sub-|library |
|00001320| 6f 66 20 72 70 63 5c 66 | 50 20 2a 2f 0a 58 2e 73 |of rpc\f|P */.X.s|
|00001330| 70 2e 35 0a 6d 61 69 6e | 28 29 09 09 2f 2a 20 5c |p.5.main|()../* \|
|00001340| 66 49 77 72 69 74 65 72 | 2e 63 5c 66 50 20 2a 2f |fIwriter|.c\fP */|
|00001350| 0a 7b 0a 09 58 44 52 20 | 78 64 72 73 3b 0a 09 6c |.{..XDR |xdrs;..l|
|00001360| 6f 6e 67 20 69 3b 0a 58 | 2e 73 70 2e 35 0a 09 78 |ong i;.X|.sp.5..x|
|00001370| 64 72 73 74 64 69 6f 5f | 63 72 65 61 74 65 28 26 |drstdio_|create(&|
|00001380| 78 64 72 73 2c 20 73 74 | 64 6f 75 74 2c 20 58 44 |xdrs, st|dout, XD|
|00001390| 52 5f 45 4e 43 4f 44 45 | 29 3b 0a 09 66 6f 72 20 |R_ENCODE|);..for |
|000013a0| 28 69 20 3d 20 30 3b 20 | 69 20 3c 20 38 3b 20 69 |(i = 0; |i < 8; i|
|000013b0| 2b 2b 29 20 7b 0a 09 09 | 69 66 20 28 21 78 64 72 |++) {...|if (!xdr|
|000013c0| 5f 6c 6f 6e 67 28 26 78 | 64 72 73 2c 20 26 69 29 |_long(&x|drs, &i)|
|000013d0| 29 20 7b 0a 09 09 09 66 | 70 72 69 6e 74 66 28 73 |) {....f|printf(s|
|000013e0| 74 64 65 72 72 2c 20 22 | 66 61 69 6c 65 64 21 5c |tderr, "|failed!\|
|000013f0| 65 6e 22 29 3b 0a 09 09 | 09 65 78 69 74 28 31 29 |en");...|.exit(1)|
|00001400| 3b 0a 09 09 7d 0a 09 7d | 0a 7d 0a 58 2e 44 45 0a |;...}..}|.}.X.DE.|
|00001410| 61 6e 64 0a 58 2e 49 20 | 72 65 61 64 65 72 20 3a |and.X.I |reader :|
|00001420| 0a 58 2e 69 65 20 74 20 | 2e 44 53 0a 58 2e 65 6c |.X.ie t |.DS.X.el|
|00001430| 20 2e 44 53 20 4c 0a 58 | 2e 66 74 20 43 57 0a 23 | .DS L.X|.ft CW.#|
|00001440| 69 6e 63 6c 75 64 65 20 | 3c 73 74 64 69 6f 2e 68 |include |<stdio.h|
|00001450| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 3c 72 70 63 2f |>.#inclu|de <rpc/|
|00001460| 72 70 63 2e 68 3e 09 2f | 2a 20 5c 66 49 78 64 72 |rpc.h>./|* \fIxdr|
|00001470| 20 69 73 20 61 20 73 75 | 62 2d 6c 69 62 72 61 72 | is a su|b-librar|
|00001480| 79 20 6f 66 20 72 70 63 | 5c 66 50 20 2a 2f 0a 58 |y of rpc|\fP */.X|
|00001490| 2e 73 70 2e 35 0a 6d 61 | 69 6e 28 29 09 09 2f 2a |.sp.5.ma|in()../*|
|000014a0| 20 5c 66 49 72 65 61 64 | 65 72 2e 63 5c 66 50 20 | \fIread|er.c\fP |
|000014b0| 2a 2f 0a 7b 0a 09 58 44 | 52 20 78 64 72 73 3b 0a |*/.{..XD|R xdrs;.|
|000014c0| 09 6c 6f 6e 67 20 69 2c | 20 6a 3b 0a 58 2e 73 70 |.long i,| j;.X.sp|
|000014d0| 2e 35 0a 09 78 64 72 73 | 74 64 69 6f 5f 63 72 65 |.5..xdrs|tdio_cre|
|000014e0| 61 74 65 28 26 78 64 72 | 73 2c 20 73 74 64 69 6e |ate(&xdr|s, stdin|
|000014f0| 2c 20 58 44 52 5f 44 45 | 43 4f 44 45 29 3b 0a 09 |, XDR_DE|CODE);..|
|00001500| 66 6f 72 20 28 6a 20 3d | 20 30 3b 20 6a 20 3c 20 |for (j =| 0; j < |
|00001510| 38 3b 20 6a 2b 2b 29 20 | 7b 0a 09 09 69 66 20 28 |8; j++) |{...if (|
|00001520| 21 78 64 72 5f 6c 6f 6e | 67 28 26 78 64 72 73 2c |!xdr_lon|g(&xdrs,|
|00001530| 20 26 69 29 29 20 7b 0a | 09 09 09 66 70 72 69 6e | &i)) {.|...fprin|
|00001540| 74 66 28 73 74 64 65 72 | 72 2c 20 22 66 61 69 6c |tf(stder|r, "fail|
|00001550| 65 64 21 5c 65 6e 22 29 | 3b 0a 09 09 09 65 78 69 |ed!\en")|;....exi|
|00001560| 74 28 31 29 3b 0a 09 09 | 7d 0a 09 09 70 72 69 6e |t(1);...|}...prin|
|00001570| 74 66 28 22 25 6c 64 20 | 22 2c 20 69 29 3b 0a 09 |tf("%ld |", i);..|
|00001580| 7d 0a 09 70 72 69 6e 74 | 66 28 22 5c 65 6e 22 29 |}..print|f("\en")|
|00001590| 3b 0a 7d 0a 58 2e 44 45 | 0a 54 68 65 20 6e 65 77 |;.}.X.DE|.The new|
|000015a0| 20 70 72 6f 67 72 61 6d | 73 20 77 65 72 65 20 65 | program|s were e|
|000015b0| 78 65 63 75 74 65 64 20 | 6f 6e 20 61 20 53 75 6e |xecuted |on a Sun|
|000015c0| 2c 0a 6f 6e 20 61 20 56 | 41 58 2c 20 61 6e 64 20 |,.on a V|AX, and |
|000015d0| 66 72 6f 6d 20 61 20 53 | 75 6e 20 74 6f 20 61 20 |from a S|un to a |
|000015e0| 56 41 58 3b 0a 74 68 65 | 20 72 65 73 75 6c 74 73 |VAX;.the| results|
|000015f0| 20 61 72 65 20 73 68 6f | 77 6e 20 62 65 6c 6f 77 | are sho|wn below|
|00001600| 2e 0a 58 2e 44 53 0a 58 | 2e 66 74 20 43 57 0a 73 |..X.DS.X|.ft CW.s|
|00001610| 75 6e 25 20 77 72 69 74 | 65 72 20 7c 20 72 65 61 |un% writ|er | rea|
|00001620| 64 65 72 0a 30 20 31 20 | 32 20 33 20 34 20 35 20 |der.0 1 |2 3 4 5 |
|00001630| 36 20 37 0a 73 75 6e 25 | 0a 0a 76 61 78 25 20 77 |6 7.sun%|..vax% w|
|00001640| 72 69 74 65 72 20 7c 20 | 72 65 61 64 65 72 0a 30 |riter | |reader.0|
|00001650| 20 31 20 32 20 33 20 34 | 20 35 20 36 20 37 0a 76 | 1 2 3 4| 5 6 7.v|
|00001660| 61 78 25 0a 0a 73 75 6e | 25 20 77 72 69 74 65 72 |ax%..sun|% writer|
|00001670| 20 7c 20 72 73 68 20 76 | 61 78 20 72 65 61 64 65 | | rsh v|ax reade|
|00001680| 72 0a 30 20 31 20 32 20 | 33 20 34 20 35 20 36 20 |r.0 1 2 |3 4 5 6 |
|00001690| 37 0a 73 75 6e 25 0a 58 | 2e 44 45 0a 58 2e 53 48 |7.sun%.X|.DE.X.SH|
|000016a0| 0a 58 2e 49 58 20 22 70 | 6f 72 74 61 62 6c 65 20 |.X.IX "p|ortable |
|000016b0| 64 61 74 61 22 0a 58 2e | 49 0a 4e 4f 54 45 3a 0a |data".X.|I.NOTE:.|
|000016c0| 49 6e 74 65 67 65 72 73 | 20 61 72 65 20 6a 75 73 |Integers| are jus|
|000016d0| 74 20 74 68 65 20 74 69 | 70 20 6f 66 20 74 68 65 |t the ti|p of the|
|000016e0| 20 70 6f 72 74 61 62 6c | 65 2d 64 61 74 61 20 69 | portabl|e-data i|
|000016f0| 63 65 62 65 72 67 2e 20 | 20 41 72 62 69 74 72 61 |ceberg. | Arbitra|
|00001700| 72 79 0a 64 61 74 61 20 | 73 74 72 75 63 74 75 72 |ry.data |structur|
|00001710| 65 73 20 70 72 65 73 65 | 6e 74 20 70 6f 72 74 61 |es prese|nt porta|
|00001720| 62 69 6c 69 74 79 20 70 | 72 6f 62 6c 65 6d 73 2c |bility p|roblems,|
|00001730| 20 70 61 72 74 69 63 75 | 6c 61 72 6c 79 20 77 69 | particu|larly wi|
|00001740| 74 68 0a 72 65 73 70 65 | 63 74 20 74 6f 20 61 6c |th.respe|ct to al|
|00001750| 69 67 6e 6d 65 6e 74 20 | 61 6e 64 20 70 6f 69 6e |ignment |and poin|
|00001760| 74 65 72 73 2e 20 20 41 | 6c 69 67 6e 6d 65 6e 74 |ters. A|lignment|
|00001770| 20 6f 6e 20 77 6f 72 64 | 20 62 6f 75 6e 64 61 72 | on word| boundar|
|00001780| 69 65 73 0a 6d 61 79 20 | 63 61 75 73 65 20 74 68 |ies.may |cause th|
|00001790| 65 20 73 69 7a 65 20 6f | 66 20 61 20 73 74 72 75 |e size o|f a stru|
|000017a0| 63 74 75 72 65 20 74 6f | 20 76 61 72 79 20 66 72 |cture to| vary fr|
|000017b0| 6f 6d 20 6d 61 63 68 69 | 6e 65 20 74 6f 20 6d 61 |om machi|ne to ma|
|000017c0| 63 68 69 6e 65 2e 0a 41 | 6e 64 20 70 6f 69 6e 74 |chine..A|nd point|
|000017d0| 65 72 73 2c 20 77 68 69 | 63 68 20 61 72 65 20 76 |ers, whi|ch are v|
|000017e0| 65 72 79 20 63 6f 6e 76 | 65 6e 69 65 6e 74 20 74 |ery conv|enient t|
|000017f0| 6f 20 75 73 65 2c 20 68 | 61 76 65 20 6e 6f 20 6d |o use, h|ave no m|
|00001800| 65 61 6e 69 6e 67 0a 6f | 75 74 73 69 64 65 20 74 |eaning.o|utside t|
|00001810| 68 65 20 6d 61 63 68 69 | 6e 65 20 77 68 65 72 65 |he machi|ne where|
|00001820| 20 74 68 65 79 20 61 72 | 65 20 64 65 66 69 6e 65 | they ar|e define|
|00001830| 64 2e 5c 66 50 0a 58 2e | 4c 50 0a 58 2e 4e 48 20 |d.\fP.X.|LP.X.NH |
|00001840| 31 0a 5c 26 41 20 43 61 | 6e 6f 6e 69 63 61 6c 20 |1.\&A Ca|nonical |
|00001850| 53 74 61 6e 64 61 72 64 | 0a 58 2e 49 58 20 58 44 |Standard|.X.IX XD|
|00001860| 52 20 22 63 61 6e 6f 6e | 69 63 61 6c 20 73 74 61 |R "canon|ical sta|
|00001870| 6e 64 61 72 64 22 0a 58 | 2e 4c 50 0a 58 44 52 27 |ndard".X|.LP.XDR'|
|00001880| 73 20 61 70 70 72 6f 61 | 63 68 20 74 6f 20 73 74 |s approa|ch to st|
|00001890| 61 6e 64 61 72 64 69 7a | 69 6e 67 20 64 61 74 61 |andardiz|ing data|
|000018a0| 20 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 73 | represe|ntations|
|000018b0| 20 69 73 20 0a 58 2e 49 | 20 63 61 6e 6f 6e 69 63 | is .X.I| canonic|
|000018c0| 61 6c 20 2e 0a 54 68 61 | 74 20 69 73 2c 20 58 44 |al ..Tha|t is, XD|
|000018d0| 52 20 64 65 66 69 6e 65 | 73 20 61 20 73 69 6e 67 |R define|s a sing|
|000018e0| 6c 65 20 62 79 74 65 20 | 6f 72 64 65 72 20 28 42 |le byte |order (B|
|000018f0| 69 67 20 45 6e 64 69 61 | 6e 29 2c 20 61 20 73 69 |ig Endia|n), a si|
|00001900| 6e 67 6c 65 0a 66 6c 6f | 61 74 69 6e 67 2d 70 6f |ngle.flo|ating-po|
|00001910| 69 6e 74 20 72 65 70 72 | 65 73 65 6e 74 61 74 69 |int repr|esentati|
|00001920| 6f 6e 20 28 49 45 45 45 | 29 2c 20 61 6e 64 20 73 |on (IEEE|), and s|
|00001930| 6f 20 6f 6e 2e 20 20 41 | 6e 79 20 70 72 6f 67 72 |o on. A|ny progr|
|00001940| 61 6d 20 72 75 6e 6e 69 | 6e 67 20 6f 6e 0a 61 6e |am runni|ng on.an|
|00001950| 79 20 6d 61 63 68 69 6e | 65 20 63 61 6e 20 75 73 |y machin|e can us|
|00001960| 65 20 58 44 52 20 74 6f | 20 63 72 65 61 74 65 20 |e XDR to| create |
|00001970| 70 6f 72 74 61 62 6c 65 | 20 64 61 74 61 20 62 79 |portable| data by|
|00001980| 20 74 72 61 6e 73 6c 61 | 74 69 6e 67 20 69 74 73 | transla|ting its|
|00001990| 0a 6c 6f 63 61 6c 20 72 | 65 70 72 65 73 65 6e 74 |.local r|epresent|
|000019a0| 61 74 69 6f 6e 20 74 6f | 20 74 68 65 20 58 44 52 |ation to| the XDR|
|000019b0| 20 73 74 61 6e 64 61 72 | 64 20 72 65 70 72 65 73 | standar|d repres|
|000019c0| 65 6e 74 61 74 69 6f 6e | 73 3b 20 73 69 6d 69 6c |entation|s; simil|
|000019d0| 61 72 6c 79 2c 20 61 6e | 79 0a 70 72 6f 67 72 61 |arly, an|y.progra|
|000019e0| 6d 20 72 75 6e 6e 69 6e | 67 20 6f 6e 20 61 6e 79 |m runnin|g on any|
|000019f0| 20 6d 61 63 68 69 6e 65 | 20 63 61 6e 20 72 65 61 | machine| can rea|
|00001a00| 64 20 70 6f 72 74 61 62 | 6c 65 20 64 61 74 61 20 |d portab|le data |
|00001a10| 62 79 20 74 72 61 6e 73 | 6c 61 74 69 6e 67 20 74 |by trans|lating t|
|00001a20| 68 65 0a 58 44 52 20 73 | 74 61 6e 64 61 72 64 20 |he.XDR s|tandard |
|00001a30| 72 65 70 72 65 73 65 6e | 74 61 69 6f 6e 73 20 74 |represen|taions t|
|00001a40| 6f 20 69 74 73 20 6c 6f | 63 61 6c 20 65 71 75 69 |o its lo|cal equi|
|00001a50| 76 61 6c 65 6e 74 73 2e | 20 20 54 68 65 20 73 69 |valents.| The si|
|00001a60| 6e 67 6c 65 20 73 74 61 | 6e 64 61 72 64 0a 63 6f |ngle sta|ndard.co|
|00001a70| 6d 70 6c 65 74 65 6c 79 | 20 64 65 63 6f 75 70 6c |mpletely| decoupl|
|00001a80| 65 73 20 70 72 6f 67 72 | 61 6d 73 20 74 68 61 74 |es progr|ams that|
|00001a90| 20 63 72 65 61 74 65 20 | 6f 72 20 73 65 6e 64 20 | create |or send |
|00001aa0| 70 6f 72 74 61 62 6c 65 | 20 64 61 74 61 20 66 72 |portable| data fr|
|00001ab0| 6f 6d 20 74 68 6f 73 65 | 0a 74 68 61 74 20 75 73 |om those|.that us|
|00001ac0| 65 20 6f 72 20 72 65 63 | 65 69 76 65 20 70 6f 72 |e or rec|eive por|
|00001ad0| 74 61 62 6c 65 20 64 61 | 74 61 2e 20 20 54 68 65 |table da|ta. The|
|00001ae0| 20 61 64 76 65 6e 74 20 | 6f 66 20 61 20 6e 65 77 | advent |of a new|
|00001af0| 20 6d 61 63 68 69 6e 65 | 20 6f 72 20 61 20 6e 65 | machine| or a ne|
|00001b00| 77 0a 6c 61 6e 67 75 61 | 67 65 20 68 61 73 20 6e |w.langua|ge has n|
|00001b10| 6f 20 65 66 66 65 63 74 | 20 6f 70 6e 20 74 68 65 |o effect| opn the|
|00001b20| 20 63 6f 6d 6d 75 6e 69 | 74 79 20 6f 66 20 65 78 | communi|ty of ex|
|00001b30| 69 73 74 69 6e 67 20 70 | 6f 72 74 61 62 6c 65 20 |isting p|ortable |
|00001b40| 64 61 74 61 20 63 72 65 | 61 74 6f 72 73 0a 61 6e |data cre|ators.an|
|00001b50| 64 20 75 73 65 72 73 2e | 20 20 41 20 6e 65 77 20 |d users.| A new |
|00001b60| 6d 61 63 68 69 6e 65 20 | 6a 6f 69 6e 73 20 74 68 |machine |joins th|
|00001b70| 69 73 20 63 6f 6d 6d 75 | 6e 69 74 79 20 62 65 20 |is commu|nity be |
|00001b80| 62 65 69 6e 67 20 60 60 | 74 61 75 67 68 74 27 27 |being ``|taught''|
|00001b90| 20 68 6f 77 20 74 6f 0a | 63 6f 6e 76 65 72 74 20 | how to.|convert |
|00001ba0| 74 68 65 20 73 74 61 6e | 64 61 72 64 20 72 65 70 |the stan|dard rep|
|00001bb0| 72 65 73 65 6e 74 61 74 | 69 6f 6e 73 20 61 6e 64 |resentat|ions and|
|00001bc0| 20 69 74 73 20 6c 6f 63 | 61 6c 20 72 65 70 72 65 | its loc|al repre|
|00001bd0| 73 65 6e 74 61 74 69 6f | 6e 73 3b 20 74 68 65 0a |sentatio|ns; the.|
|00001be0| 6c 6f 63 61 6c 20 72 65 | 70 72 65 73 65 6e 74 61 |local re|presenta|
|00001bf0| 74 69 6f 6e 73 20 6f 66 | 20 6f 74 68 65 72 20 6d |tions of| other m|
|00001c00| 61 63 68 69 6e 65 73 20 | 61 72 65 20 69 72 72 65 |achines |are irre|
|00001c10| 6c 65 76 61 6e 74 2e 20 | 20 43 6f 6e 76 65 72 73 |levant. | Convers|
|00001c20| 65 6c 79 2c 20 74 6f 0a | 65 78 69 73 74 69 6e 67 |ely, to.|existing|
|00001c30| 20 70 72 6f 67 72 61 6d | 73 20 72 75 6e 6e 69 6e | program|s runnin|
|00001c40| 67 20 6f 6e 20 6f 74 68 | 65 72 20 6d 61 63 68 69 |g on oth|er machi|
|00001c50| 6e 65 73 2c 20 74 68 65 | 20 6c 6f 63 61 6c 20 72 |nes, the| local r|
|00001c60| 65 70 72 65 73 65 6e 74 | 61 74 69 6f 6e 73 20 6f |epresent|ations o|
|00001c70| 66 0a 74 68 65 20 6e 65 | 77 20 6d 61 63 68 69 6e |f.the ne|w machin|
|00001c80| 65 20 61 72 65 20 61 6c | 73 6f 20 69 72 72 65 6c |e are al|so irrel|
|00001c90| 65 76 61 6e 74 3b 20 73 | 75 63 68 20 70 72 6f 67 |evant; s|uch prog|
|00001ca0| 72 61 6d 73 20 63 61 6e | 20 69 6d 6d 65 64 69 61 |rams can| immedia|
|00001cb0| 74 65 6c 79 20 72 65 61 | 64 0a 70 6f 72 74 61 62 |tely rea|d.portab|
|00001cc0| 6c 65 20 64 61 74 61 20 | 70 72 6f 64 75 63 65 64 |le data |produced|
|00001cd0| 20 62 79 20 74 68 65 20 | 6e 65 77 20 6d 61 63 68 | by the |new mach|
|00001ce0| 69 6e 65 20 62 65 63 61 | 75 73 65 20 73 75 63 68 |ine beca|use such|
|00001cf0| 20 64 61 74 61 20 63 6f | 6e 66 6f 72 6d 73 20 74 | data co|nforms t|
|00001d00| 6f 20 74 68 65 0a 63 61 | 6e 6f 6e 69 63 61 6c 20 |o the.ca|nonical |
|00001d10| 73 74 61 6e 64 61 72 64 | 73 20 74 68 61 74 20 74 |standard|s that t|
|00001d20| 68 65 79 20 61 6c 72 65 | 61 64 79 20 75 6e 64 65 |hey alre|ady unde|
|00001d30| 72 73 74 61 6e 64 2e 0a | 58 2e 4c 50 0a 54 68 65 |rstand..|X.LP.The|
|00001d40| 72 65 20 61 72 65 20 73 | 74 72 6f 6e 67 20 70 72 |re are s|trong pr|
|00001d50| 65 63 65 64 65 6e 74 73 | 20 66 6f 72 20 58 44 52 |ecedents| for XDR|
|00001d60| 27 73 20 63 61 6e 6f 6e | 69 63 61 6c 20 61 70 70 |'s canon|ical app|
|00001d70| 72 6f 61 63 68 2e 20 20 | 46 6f 72 20 65 78 61 6d |roach. |For exam|
|00001d80| 70 6c 65 2c 0a 54 43 50 | 2f 49 50 2c 20 55 44 50 |ple,.TCP|/IP, UDP|
|00001d90| 2f 49 50 2c 20 58 4e 53 | 2c 20 45 74 68 65 72 6e |/IP, XNS|, Ethern|
|00001da0| 65 74 2c 20 61 6e 64 2c | 20 69 6e 64 65 65 64 2c |et, and,| indeed,|
|00001db0| 20 61 6c 6c 20 70 72 6f | 74 6f 63 6f 6c 73 20 62 | all pro|tocols b|
|00001dc0| 65 6c 6f 77 20 6c 61 79 | 65 72 20 66 69 76 65 0a |elow lay|er five.|
|00001dd0| 6f 66 20 74 68 65 20 49 | 53 4f 20 6d 6f 64 65 6c |of the I|SO model|
|00001de0| 2c 20 61 72 65 20 63 61 | 6e 6f 6e 69 63 61 6c 20 |, are ca|nonical |
|00001df0| 70 72 6f 74 6f 63 6f 6c | 73 2e 20 20 54 68 65 20 |protocol|s. The |
|00001e00| 61 64 76 61 6e 74 61 67 | 65 20 6f 66 20 61 6e 79 |advantag|e of any|
|00001e10| 20 63 61 6e 6f 6e 69 63 | 61 6c 20 0a 61 70 70 72 | canonic|al .appr|
|00001e20| 6f 61 63 68 20 69 73 20 | 73 69 6d 70 6c 69 63 69 |oach is |simplici|
|00001e30| 74 79 3b 20 69 6e 20 74 | 68 65 20 63 61 73 65 20 |ty; in t|he case |
|00001e40| 6f 66 20 58 44 52 2c 20 | 61 20 73 69 6e 67 6c 65 |of XDR, |a single|
|00001e50| 20 73 65 74 20 6f 66 20 | 63 6f 6e 76 65 72 73 69 | set of |conversi|
|00001e60| 6f 6e 20 0a 72 6f 75 74 | 69 6e 65 73 20 69 73 20 |on .rout|ines is |
|00001e70| 77 72 69 74 74 65 6e 20 | 6f 6e 63 65 20 61 6e 64 |written |once and|
|00001e80| 20 69 73 20 6e 65 76 65 | 72 20 74 6f 75 63 68 65 | is neve|r touche|
|00001e90| 64 20 61 67 61 69 6e 2e | 20 20 54 68 65 20 63 61 |d again.| The ca|
|00001ea0| 6e 6f 6e 69 63 61 6c 20 | 61 70 70 72 6f 61 63 68 |nonical |approach|
|00001eb0| 20 0a 68 61 73 20 61 20 | 64 69 73 61 64 76 61 6e | .has a |disadvan|
|00001ec0| 74 61 67 65 2c 20 62 75 | 74 20 69 74 20 69 73 20 |tage, bu|t it is |
|00001ed0| 75 6e 69 6d 70 6f 72 74 | 61 6e 74 20 69 6e 20 72 |unimport|ant in r|
|00001ee0| 65 61 6c 2d 77 6f 72 6c | 64 20 64 61 74 61 20 74 |eal-worl|d data t|
|00001ef0| 72 61 6e 73 66 65 72 20 | 0a 61 70 70 6c 69 63 61 |ransfer |.applica|
|00001f00| 74 69 6f 6e 73 2e 20 20 | 53 75 70 70 6f 73 65 20 |tions. |Suppose |
|00001f10| 74 77 6f 20 4c 69 74 74 | 6c 65 2d 45 6e 64 69 61 |two Litt|le-Endia|
|00001f20| 6e 20 6d 61 63 68 69 6e | 65 73 20 61 72 65 20 74 |n machin|es are t|
|00001f30| 72 61 6e 73 66 65 72 72 | 69 6e 67 20 69 6e 74 65 |ransferr|ing inte|
|00001f40| 67 65 72 73 0a 61 63 63 | 6f 72 64 69 6e 67 20 74 |gers.acc|ording t|
|00001f50| 6f 20 74 68 65 20 58 44 | 52 20 73 74 61 6e 64 61 |o the XD|R standa|
|00001f60| 72 64 2e 20 20 54 68 65 | 20 73 65 6e 64 69 6e 67 |rd. The| sending|
|00001f70| 20 6d 61 63 68 69 6e 65 | 20 63 6f 6e 76 65 72 74 | machine| convert|
|00001f80| 73 20 74 68 65 20 69 6e | 74 65 67 65 72 73 20 0a |s the in|tegers .|
|00001f90| 66 72 6f 6d 20 4c 69 74 | 74 6c 65 2d 45 6e 64 69 |from Lit|tle-Endi|
|00001fa0| 61 6e 20 62 79 74 65 20 | 6f 72 64 65 72 20 74 6f |an byte |order to|
|00001fb0| 20 58 44 52 20 28 42 69 | 67 2d 45 6e 64 69 61 6e | XDR (Bi|g-Endian|
|00001fc0| 29 20 62 79 74 65 20 6f | 72 64 65 72 3b 20 74 68 |) byte o|rder; th|
|00001fd0| 65 20 72 65 63 65 69 76 | 69 6e 67 0a 6d 61 63 68 |e receiv|ing.mach|
|00001fe0| 69 6e 65 20 70 65 72 66 | 6f 72 6d 73 20 74 68 65 |ine perf|orms the|
|00001ff0| 20 72 65 76 65 72 73 65 | 20 63 6f 6e 76 65 72 73 | reverse| convers|
|00002000| 69 6f 6e 2e 20 20 42 65 | 63 61 75 73 65 20 62 6f |ion. Be|cause bo|
|00002010| 74 68 20 6d 61 63 68 69 | 6e 65 73 20 6f 62 73 65 |th machi|nes obse|
|00002020| 72 76 65 20 74 68 65 0a | 73 61 6d 65 20 62 79 74 |rve the.|same byt|
|00002030| 65 20 6f 72 64 65 72 2c | 20 74 68 65 69 72 20 63 |e order,| their c|
|00002040| 6f 6e 76 65 72 73 69 6f | 6e 73 20 61 72 65 20 75 |onversio|ns are u|
|00002050| 6e 6e 65 63 65 73 73 61 | 72 79 2e 20 20 54 68 65 |nnecessa|ry. The|
|00002060| 20 70 6f 69 6e 74 2c 20 | 68 6f 77 65 76 65 72 2c | point, |however,|
|00002070| 20 69 73 0a 6e 6f 74 20 | 6e 65 63 65 73 73 69 74 | is.not |necessit|
|00002080| 79 2c 20 62 75 74 20 63 | 6f 73 74 20 61 73 20 63 |y, but c|ost as c|
|00002090| 6f 6d 70 61 72 65 64 20 | 74 6f 20 74 68 65 20 61 |ompared |to the a|
|000020a0| 6c 74 65 72 6e 61 74 69 | 76 65 2e 0a 58 2e 4c 50 |lternati|ve..X.LP|
|000020b0| 0a 54 68 65 20 74 69 6d | 65 20 73 70 65 6e 74 20 |.The tim|e spent |
|000020c0| 63 6f 6e 76 65 72 74 69 | 6e 67 20 74 6f 20 61 6e |converti|ng to an|
|000020d0| 64 20 66 72 6f 6d 20 61 | 20 63 61 6e 6f 6e 69 63 |d from a| canonic|
|000020e0| 61 6c 20 72 65 70 72 65 | 73 65 6e 74 61 74 69 6f |al repre|sentatio|
|000020f0| 6e 20 69 73 0a 69 6e 73 | 69 67 6e 69 66 69 63 61 |n is.ins|ignifica|
|00002100| 6e 74 2c 20 65 73 70 65 | 63 69 61 6c 6c 79 20 69 |nt, espe|cially i|
|00002110| 6e 20 6e 65 74 77 6f 72 | 6b 69 6e 67 20 61 70 70 |n networ|king app|
|00002120| 6c 69 63 61 74 69 6f 6e | 73 2e 20 20 4d 6f 73 74 |lication|s. Most|
|00002130| 20 6f 66 20 74 68 65 20 | 74 69 6d 65 20 0a 72 65 | of the |time .re|
|00002140| 71 75 69 72 65 64 20 74 | 6f 20 70 72 65 70 61 72 |quired t|o prepar|
|00002150| 65 20 61 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |e a data| structu|
|00002160| 72 65 20 66 6f 72 20 74 | 72 61 6e 73 66 65 72 20 |re for t|ransfer |
|00002170| 69 73 20 6e 6f 74 20 73 | 70 65 6e 74 20 69 6e 20 |is not s|pent in |
|00002180| 63 6f 6e 76 65 72 73 69 | 6f 6e 20 0a 62 75 74 20 |conversi|on .but |
|00002190| 69 6e 20 74 72 61 76 65 | 72 73 69 6e 67 20 74 68 |in trave|rsing th|
|000021a0| 65 20 65 6c 65 6d 65 6e | 74 73 20 6f 66 20 74 68 |e elemen|ts of th|
|000021b0| 65 20 64 61 74 61 20 73 | 74 72 75 63 74 75 72 65 |e data s|tructure|
|000021c0| 2e 20 20 54 6f 20 74 72 | 61 6e 73 6d 69 74 20 61 |. To tr|ansmit a|
|000021d0| 20 74 72 65 65 2c 20 0a | 66 6f 72 20 65 78 61 6d | tree, .|for exam|
|000021e0| 70 6c 65 2c 20 65 61 63 | 68 20 6c 65 61 66 20 6d |ple, eac|h leaf m|
|000021f0| 75 73 74 20 62 65 20 76 | 69 73 69 74 65 64 20 61 |ust be v|isited a|
|00002200| 6e 64 20 65 61 63 68 20 | 65 6c 65 6d 65 6e 74 20 |nd each |element |
|00002210| 69 6e 20 61 20 6c 65 61 | 66 20 72 65 63 6f 72 64 |in a lea|f record|
|00002220| 20 6d 75 73 74 0a 62 65 | 20 63 6f 70 69 65 64 20 | must.be| copied |
|00002230| 74 6f 20 61 20 62 75 66 | 66 65 72 20 61 6e 64 20 |to a buf|fer and |
|00002240| 61 6c 69 67 6e 65 64 20 | 74 68 65 72 65 3b 20 73 |aligned |there; s|
|00002250| 74 6f 72 61 67 65 20 66 | 6f 72 20 74 68 65 20 6c |torage f|or the l|
|00002260| 65 61 66 20 6d 61 79 20 | 68 61 76 65 20 74 6f 20 |eaf may |have to |
|00002270| 62 65 0a 64 65 61 6c 6c | 6f 63 61 74 65 64 20 61 |be.deall|ocated a|
|00002280| 73 20 77 65 6c 6c 2e 20 | 20 53 69 6d 69 6c 61 72 |s well. | Similar|
|00002290| 6c 79 2c 20 74 6f 20 72 | 65 63 65 69 76 65 20 61 |ly, to r|eceive a|
|000022a0| 20 74 72 65 65 2c 20 73 | 74 6f 72 61 67 65 20 6d | tree, s|torage m|
|000022b0| 75 73 74 20 62 65 20 0a | 61 6c 6c 6f 63 61 74 65 |ust be .|allocate|
|000022c0| 64 20 66 6f 72 20 65 61 | 63 68 20 6c 65 61 66 2c |d for ea|ch leaf,|
|000022d0| 20 64 61 74 61 20 6d 75 | 73 74 20 62 65 20 6d 6f | data mu|st be mo|
|000022e0| 76 65 64 20 66 72 6f 6d | 20 74 68 65 20 62 75 66 |ved from| the buf|
|000022f0| 66 65 72 20 74 6f 20 74 | 68 65 20 6c 65 61 66 20 |fer to t|he leaf |
|00002300| 61 6e 64 0a 70 72 6f 70 | 65 72 6c 79 20 61 6c 69 |and.prop|erly ali|
|00002310| 67 6e 65 64 2c 20 61 6e | 64 20 70 6f 69 6e 74 65 |gned, an|d pointe|
|00002320| 72 73 20 6d 75 73 74 20 | 62 65 20 63 6f 6e 73 74 |rs must |be const|
|00002330| 72 75 63 74 65 64 20 74 | 6f 20 6c 69 6e 6b 20 74 |ructed t|o link t|
|00002340| 68 65 20 6c 65 61 76 65 | 73 20 0a 74 6f 67 65 74 |he leave|s .toget|
|00002350| 68 65 72 2e 20 20 45 76 | 65 72 79 20 6d 61 63 68 |her. Ev|ery mach|
|00002360| 69 6e 65 20 70 61 79 73 | 20 74 68 65 20 63 6f 73 |ine pays| the cos|
|00002370| 74 20 6f 66 20 74 72 61 | 76 65 72 73 69 6e 67 20 |t of tra|versing |
|00002380| 61 6e 64 20 63 6f 70 79 | 69 6e 67 20 64 61 74 61 |and copy|ing data|
|00002390| 0a 73 74 72 75 63 74 75 | 72 65 73 20 77 68 65 74 |.structu|res whet|
|000023a0| 68 65 72 20 6f 72 20 6e | 6f 74 20 63 6f 6e 76 65 |her or n|ot conve|
|000023b0| 72 73 69 6f 6e 20 69 73 | 20 72 65 71 75 69 72 65 |rsion is| require|
|000023c0| 64 2e 20 20 49 6e 20 6e | 65 74 77 6f 72 6b 69 6e |d. In n|etworkin|
|000023d0| 67 20 0a 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 2c |g .appli|cations,|
|000023e0| 20 63 6f 6d 6d 75 6e 69 | 63 61 74 69 6f 6e 73 20 | communi|cations |
|000023f0| 6f 76 65 72 68 65 61 64 | 5c 28 65 6d 74 68 65 20 |overhead|\(emthe |
|00002400| 74 69 6d 65 20 72 65 71 | 75 69 72 65 64 20 74 6f |time req|uired to|
|00002410| 20 6d 6f 76 65 20 74 68 | 65 20 64 61 74 61 0a 64 | move th|e data.d|
|00002420| 6f 77 6e 20 74 68 72 6f | 75 67 68 20 74 68 65 20 |own thro|ugh the |
|00002430| 73 65 6e 64 65 72 27 73 | 20 70 72 6f 74 6f 63 6f |sender's| protoco|
|00002440| 6c 20 6c 61 79 65 72 73 | 2c 20 61 63 72 6f 73 73 |l layers|, across|
|00002450| 20 74 68 65 20 6e 65 74 | 77 6f 72 6b 20 61 6e 64 | the net|work and|
|00002460| 20 75 70 20 74 68 72 6f | 75 67 68 20 0a 74 68 65 | up thro|ugh .the|
|00002470| 20 72 65 63 65 69 76 65 | 72 27 73 20 70 72 6f 74 | receive|r's prot|
|00002480| 6f 63 6f 6c 20 6c 61 79 | 65 72 73 5c 28 65 6d 64 |ocol lay|ers\(emd|
|00002490| 77 61 72 66 73 20 63 6f | 6e 76 65 72 73 69 6f 6e |warfs co|nversion|
|000024a0| 20 6f 76 65 72 68 65 61 | 64 2e 0a 58 2e 4e 48 20 | overhea|d..X.NH |
|000024b0| 31 0a 5c 26 54 68 65 20 | 58 44 52 20 4c 69 62 72 |1.\&The |XDR Libr|
|000024c0| 61 72 79 0a 58 2e 49 58 | 20 22 6c 69 62 72 61 72 |ary.X.IX| "librar|
|000024d0| 79 20 6f 66 20 58 44 52 | 20 72 6f 75 74 69 6e 65 |y of XDR| routine|
|000024e0| 73 22 0a 58 2e 49 58 20 | 22 58 44 52 22 20 22 6c |s".X.IX |"XDR" "l|
|000024f0| 69 62 72 61 72 79 22 0a | 58 2e 4c 50 0a 54 68 65 |ibrary".|X.LP.The|
|00002500| 20 58 44 52 20 6c 69 62 | 72 61 72 79 20 6e 6f 74 | XDR lib|rary not|
|00002510| 20 6f 6e 6c 79 20 73 6f | 6c 76 65 73 20 64 61 74 | only so|lves dat|
|00002520| 61 20 70 6f 72 74 61 62 | 69 6c 69 74 79 20 70 72 |a portab|ility pr|
|00002530| 6f 62 6c 65 6d 73 2c 20 | 69 74 20 61 6c 73 6f 0a |oblems, |it also.|
|00002540| 61 6c 6c 6f 77 73 20 79 | 6f 75 20 74 6f 20 77 72 |allows y|ou to wr|
|00002550| 69 74 65 20 61 6e 64 20 | 72 65 61 64 20 61 72 62 |ite and |read arb|
|00002560| 69 74 72 61 72 79 20 43 | 20 63 6f 6e 73 74 72 75 |itrary C| constru|
|00002570| 63 74 73 20 69 6e 20 61 | 20 63 6f 6e 73 69 73 74 |cts in a| consist|
|00002580| 65 6e 74 2c 20 0a 73 70 | 65 63 69 66 69 65 64 2c |ent, .sp|ecified,|
|00002590| 20 77 65 6c 6c 2d 64 6f | 63 75 6d 65 6e 74 65 64 | well-do|cumented|
|000025a0| 20 6d 61 6e 6e 65 72 2e | 20 20 54 68 75 73 2c 20 | manner.| Thus, |
|000025b0| 69 74 20 63 61 6e 20 6d | 61 6b 65 20 73 65 6e 73 |it can m|ake sens|
|000025c0| 65 20 74 6f 20 75 73 65 | 20 74 68 65 20 0a 6c 69 |e to use| the .li|
|000025d0| 62 72 61 72 79 20 65 76 | 65 6e 20 77 68 65 6e 20 |brary ev|en when |
|000025e0| 74 68 65 20 64 61 74 61 | 20 69 73 20 6e 6f 74 20 |the data| is not |
|000025f0| 73 68 61 72 65 64 20 61 | 6d 6f 6e 67 20 6d 61 63 |shared a|mong mac|
|00002600| 68 69 6e 65 73 20 6f 6e | 20 61 20 6e 65 74 77 6f |hines on| a netwo|
|00002610| 72 6b 2e 0a 58 2e 4c 50 | 0a 54 68 65 20 58 44 52 |rk..X.LP|.The XDR|
|00002620| 20 6c 69 62 72 61 72 79 | 20 68 61 73 20 66 69 6c | library| has fil|
|00002630| 74 65 72 20 72 6f 75 74 | 69 6e 65 73 20 66 6f 72 |ter rout|ines for|
|00002640| 0a 73 74 72 69 6e 67 73 | 20 28 6e 75 6c 6c 2d 74 |.strings| (null-t|
|00002650| 65 72 6d 69 6e 61 74 65 | 64 20 61 72 72 61 79 73 |erminate|d arrays|
|00002660| 20 6f 66 20 62 79 74 65 | 73 29 2c 0a 73 74 72 75 | of byte|s),.stru|
|00002670| 63 74 75 72 65 73 2c 20 | 75 6e 69 6f 6e 73 2c 20 |ctures, |unions, |
|00002680| 61 6e 64 20 61 72 72 61 | 79 73 2c 20 74 6f 20 6e |and arra|ys, to n|
|00002690| 61 6d 65 20 61 20 66 65 | 77 2e 0a 55 73 69 6e 67 |ame a fe|w..Using|
|000026a0| 20 6d 6f 72 65 20 70 72 | 69 6d 69 74 69 76 65 20 | more pr|imitive |
|000026b0| 72 6f 75 74 69 6e 65 73 | 2c 0a 79 6f 75 20 63 61 |routines|,.you ca|
|000026c0| 6e 20 77 72 69 74 65 20 | 79 6f 75 72 20 6f 77 6e |n write |your own|
|000026d0| 20 73 70 65 63 69 66 69 | 63 20 58 44 52 20 72 6f | specifi|c XDR ro|
|000026e0| 75 74 69 6e 65 73 0a 74 | 6f 20 64 65 73 63 72 69 |utines.t|o descri|
|000026f0| 62 65 20 61 72 62 69 74 | 72 61 72 79 20 64 61 74 |be arbit|rary dat|
|00002700| 61 20 73 74 72 75 63 74 | 75 72 65 73 2c 0a 69 6e |a struct|ures,.in|
|00002710| 63 6c 75 64 69 6e 67 20 | 65 6c 65 6d 65 6e 74 73 |cluding |elements|
|00002720| 20 6f 66 20 61 72 72 61 | 79 73 2c 20 61 72 6d 73 | of arra|ys, arms|
|00002730| 20 6f 66 20 75 6e 69 6f | 6e 73 2c 0a 6f 72 20 6f | of unio|ns,.or o|
|00002740| 62 6a 65 63 74 73 20 70 | 6f 69 6e 74 65 64 20 61 |bjects p|ointed a|
|00002750| 74 20 66 72 6f 6d 20 6f | 74 68 65 72 20 73 74 72 |t from o|ther str|
|00002760| 75 63 74 75 72 65 73 2e | 0a 54 68 65 20 73 74 72 |uctures.|.The str|
|00002770| 75 63 74 75 72 65 73 20 | 74 68 65 6d 73 65 6c 76 |uctures |themselv|
|00002780| 65 73 20 6d 61 79 20 63 | 6f 6e 74 61 69 6e 20 61 |es may c|ontain a|
|00002790| 72 72 61 79 73 20 6f 66 | 20 61 72 62 69 74 72 61 |rrays of| arbitra|
|000027a0| 72 79 20 65 6c 65 6d 65 | 6e 74 73 2c 0a 6f 72 20 |ry eleme|nts,.or |
|000027b0| 70 6f 69 6e 74 65 72 73 | 20 74 6f 20 6f 74 68 65 |pointers| to othe|
|000027c0| 72 20 73 74 72 75 63 74 | 75 72 65 73 2e 0a 58 2e |r struct|ures..X.|
|000027d0| 4c 50 0a 4c 65 74 27 73 | 20 65 78 61 6d 69 6e 65 |LP.Let's| examine|
|000027e0| 20 74 68 65 20 74 77 6f | 20 70 72 6f 67 72 61 6d | the two| program|
|000027f0| 73 20 6d 6f 72 65 20 63 | 6c 6f 73 65 6c 79 2e 0a |s more c|losely..|
|00002800| 54 68 65 72 65 20 69 73 | 20 61 20 66 61 6d 69 6c |There is| a famil|
|00002810| 79 20 6f 66 20 58 44 52 | 20 73 74 72 65 61 6d 20 |y of XDR| stream |
|00002820| 63 72 65 61 74 69 6f 6e | 20 72 6f 75 74 69 6e 65 |creation| routine|
|00002830| 73 0a 69 6e 20 77 68 69 | 63 68 20 65 61 63 68 20 |s.in whi|ch each |
|00002840| 6d 65 6d 62 65 72 20 74 | 72 65 61 74 73 20 74 68 |member t|reats th|
|00002850| 65 20 73 74 72 65 61 6d | 20 6f 66 20 62 69 74 73 |e stream| of bits|
|00002860| 20 64 69 66 66 65 72 65 | 6e 74 6c 79 2e 0a 49 6e | differe|ntly..In|
|00002870| 20 6f 75 72 20 65 78 61 | 6d 70 6c 65 2c 20 64 61 | our exa|mple, da|
|00002880| 74 61 20 69 73 20 6d 61 | 6e 69 70 75 6c 61 74 65 |ta is ma|nipulate|
|00002890| 64 20 75 73 69 6e 67 20 | 73 74 61 6e 64 61 72 64 |d using |standard|
|000028a0| 20 49 2f 4f 20 72 6f 75 | 74 69 6e 65 73 2c 0a 73 | I/O rou|tines,.s|
|000028b0| 6f 20 77 65 20 75 73 65 | 0a 58 2e 49 20 78 64 72 |o we use|.X.I xdr|
|000028c0| 73 74 64 69 6f 5f 63 72 | 65 61 74 65 2e 0a 54 68 |stdio_cr|eate..Th|
|000028d0| 65 20 70 61 72 61 6d 65 | 74 65 72 73 20 74 6f 20 |e parame|ters to |
|000028e0| 58 44 52 20 73 74 72 65 | 61 6d 20 63 72 65 61 74 |XDR stre|am creat|
|000028f0| 69 6f 6e 20 72 6f 75 74 | 69 6e 65 73 0a 76 61 72 |ion rout|ines.var|
|00002900| 79 20 61 63 63 6f 72 64 | 69 6e 67 20 74 6f 20 74 |y accord|ing to t|
|00002910| 68 65 69 72 20 66 75 6e | 63 74 69 6f 6e 2e 0a 49 |heir fun|ction..I|
|00002920| 6e 20 6f 75 72 20 65 78 | 61 6d 70 6c 65 2c 0a 58 |n our ex|ample,.X|
|00002930| 2e 49 20 78 64 72 73 74 | 64 69 6f 5f 63 72 65 61 |.I xdrst|dio_crea|
|00002940| 74 65 20 0a 74 61 6b 65 | 73 20 61 20 70 6f 69 6e |te .take|s a poin|
|00002950| 74 65 72 20 74 6f 20 61 | 6e 20 58 44 52 20 73 74 |ter to a|n XDR st|
|00002960| 72 75 63 74 75 72 65 20 | 74 68 61 74 20 69 74 20 |ructure |that it |
|00002970| 69 6e 69 74 69 61 6c 69 | 7a 65 73 2c 0a 61 20 70 |initiali|zes,.a p|
|00002980| 6f 69 6e 74 65 72 20 74 | 6f 20 61 0a 58 2e 49 20 |ointer t|o a.X.I |
|00002990| 46 49 4c 45 20 0a 74 68 | 61 74 20 74 68 65 20 69 |FILE .th|at the i|
|000029a0| 6e 70 75 74 20 6f 72 20 | 6f 75 74 70 75 74 20 69 |nput or |output i|
|000029b0| 73 20 70 65 72 66 6f 72 | 6d 65 64 20 6f 6e 2c 20 |s perfor|med on, |
|000029c0| 61 6e 64 20 74 68 65 20 | 6f 70 65 72 61 74 69 6f |and the |operatio|
|000029d0| 6e 2e 0a 54 68 65 20 6f | 70 65 72 61 74 69 6f 6e |n..The o|peration|
|000029e0| 20 6d 61 79 20 62 65 0a | 58 2e 49 20 58 44 52 5f | may be.|X.I XDR_|
|000029f0| 45 4e 43 4f 44 45 0a 66 | 6f 72 20 73 65 72 69 61 |ENCODE.f|or seria|
|00002a00| 6c 69 7a 69 6e 67 20 69 | 6e 20 74 68 65 0a 58 2e |lizing i|n the.X.|
|00002a10| 49 20 77 72 69 74 65 72 | 20 0a 70 72 6f 67 72 61 |I writer| .progra|
|00002a20| 6d 2c 20 6f 72 0a 58 2e | 49 20 58 44 52 5f 44 45 |m, or.X.|I XDR_DE|
|00002a30| 43 4f 44 45 0a 66 6f 72 | 20 64 65 73 65 72 69 61 |CODE.for| deseria|
|00002a40| 6c 69 7a 69 6e 67 20 69 | 6e 20 74 68 65 0a 58 2e |lizing i|n the.X.|
|00002a50| 49 20 72 65 61 64 65 72 | 20 0a 70 72 6f 67 72 61 |I reader| .progra|
|00002a60| 6d 2e 0a 58 2e 4c 50 0a | 4e 6f 74 65 3a 20 52 50 |m..X.LP.|Note: RP|
|00002a70| 43 20 75 73 65 72 73 20 | 6e 65 76 65 72 20 6e 65 |C users |never ne|
|00002a80| 65 64 20 74 6f 20 63 72 | 65 61 74 65 20 58 44 52 |ed to cr|eate XDR|
|00002a90| 20 73 74 72 65 61 6d 73 | 3b 0a 74 68 65 20 52 50 | streams|;.the RP|
|00002aa0| 43 20 73 79 73 74 65 6d | 20 69 74 73 65 6c 66 20 |C system| itself |
|00002ab0| 63 72 65 61 74 65 73 20 | 74 68 65 73 65 20 73 74 |creates |these st|
|00002ac0| 72 65 61 6d 73 2c 0a 77 | 68 69 63 68 20 61 72 65 |reams,.w|hich are|
|00002ad0| 20 74 68 65 6e 20 70 61 | 73 73 65 64 20 74 6f 20 | then pa|ssed to |
|00002ae0| 74 68 65 20 75 73 65 72 | 73 2e 0a 58 2e 4c 50 0a |the user|s..X.LP.|
|00002af0| 54 68 65 0a 58 2e 49 20 | 78 64 72 5f 6c 6f 6e 67 |The.X.I |xdr_long|
|00002b00| 0a 70 72 69 6d 69 74 69 | 76 65 20 69 73 20 63 68 |.primiti|ve is ch|
|00002b10| 61 72 61 63 74 65 72 69 | 73 74 69 63 20 6f 66 20 |aracteri|stic of |
|00002b20| 6d 6f 73 74 20 58 44 52 | 20 6c 69 62 72 61 72 79 |most XDR| library|
|00002b30| 20 0a 70 72 69 6d 69 74 | 69 76 65 73 20 61 6e 64 | .primit|ives and|
|00002b40| 20 61 6c 6c 20 63 6c 69 | 65 6e 74 20 58 44 52 20 | all cli|ent XDR |
|00002b50| 72 6f 75 74 69 6e 65 73 | 2e 0a 46 69 72 73 74 2c |routines|..First,|
|00002b60| 20 74 68 65 20 72 6f 75 | 74 69 6e 65 20 72 65 74 | the rou|tine ret|
|00002b70| 75 72 6e 73 0a 58 2e 49 | 20 46 41 4c 53 45 20 0a |urns.X.I| FALSE .|
|00002b80| 28 30 29 20 69 66 20 69 | 74 20 66 61 69 6c 73 2c |(0) if i|t fails,|
|00002b90| 20 61 6e 64 0a 58 2e 49 | 20 54 52 55 45 20 0a 28 | and.X.I| TRUE .(|
|00002ba0| 31 29 20 69 66 20 69 74 | 20 73 75 63 63 65 65 64 |1) if it| succeed|
|00002bb0| 73 2e 0a 53 65 63 6f 6e | 64 2c 20 66 6f 72 20 65 |s..Secon|d, for e|
|00002bc0| 61 63 68 20 64 61 74 61 | 20 74 79 70 65 2c 0a 58 |ach data| type,.X|
|00002bd0| 2e 49 20 78 78 78 20 2c | 0a 74 68 65 72 65 20 69 |.I xxx ,|.there i|
|00002be0| 73 20 61 6e 20 61 73 73 | 6f 63 69 61 74 65 64 20 |s an ass|ociated |
|00002bf0| 58 44 52 20 72 6f 75 74 | 69 6e 65 20 6f 66 20 74 |XDR rout|ine of t|
|00002c00| 68 65 20 66 6f 72 6d 3a | 0a 58 2e 44 53 0a 58 2e |he form:|.X.DS.X.|
|00002c10| 66 74 20 43 57 0a 78 64 | 72 5f 78 78 78 28 78 64 |ft CW.xd|r_xxx(xd|
|00002c20| 72 73 2c 20 78 70 29 0a | 09 58 44 52 20 2a 78 64 |rs, xp).|.XDR *xd|
|00002c30| 72 73 3b 0a 09 78 78 78 | 20 2a 78 70 3b 0a 7b 0a |rs;..xxx| *xp;.{.|
|00002c40| 7d 0a 58 2e 44 45 0a 49 | 6e 20 6f 75 72 20 63 61 |}.X.DE.I|n our ca|
|00002c50| 73 65 2c 0a 58 2e 49 20 | 78 78 78 20 0a 69 73 20 |se,.X.I |xxx .is |
|00002c60| 6c 6f 6e 67 2c 20 61 6e | 64 20 74 68 65 20 63 6f |long, an|d the co|
|00002c70| 72 72 65 73 70 6f 6e 64 | 69 6e 67 20 58 44 52 20 |rrespond|ing XDR |
|00002c80| 72 6f 75 74 69 6e 65 20 | 69 73 0a 61 20 70 72 69 |routine |is.a pri|
|00002c90| 6d 69 74 69 76 65 2c 0a | 58 2e 49 20 78 64 72 5f |mitive,.|X.I xdr_|
|00002ca0| 6c 6f 6e 67 0a 54 68 65 | 20 63 6c 69 65 6e 74 20 |long.The| client |
|00002cb0| 63 6f 75 6c 64 20 61 6c | 73 6f 20 64 65 66 69 6e |could al|so defin|
|00002cc0| 65 20 61 6e 20 61 72 62 | 69 74 72 61 72 79 20 73 |e an arb|itrary s|
|00002cd0| 74 72 75 63 74 75 72 65 | 0a 58 2e 49 20 78 78 78 |tructure|.X.I xxx|
|00002ce0| 20 0a 69 6e 20 77 68 69 | 63 68 20 63 61 73 65 20 | .in whi|ch case |
|00002cf0| 74 68 65 20 63 6c 69 65 | 6e 74 20 77 6f 75 6c 64 |the clie|nt would|
|00002d00| 20 61 6c 73 6f 20 73 75 | 70 70 6c 79 20 74 68 65 | also su|pply the|
|00002d10| 20 72 6f 75 74 69 6e 65 | 0a 58 2e 49 20 78 64 72 | routine|.X.I xdr|
|00002d20| 5f 78 78 78 20 2c 0a 64 | 65 73 63 72 69 62 69 6e |_xxx ,.d|escribin|
|00002d30| 67 20 65 61 63 68 20 66 | 69 65 6c 64 20 62 79 20 |g each f|ield by |
|00002d40| 63 61 6c 6c 69 6e 67 20 | 58 44 52 20 72 6f 75 74 |calling |XDR rout|
|00002d50| 69 6e 65 73 0a 6f 66 20 | 74 68 65 20 61 70 70 72 |ines.of |the appr|
|00002d60| 6f 70 72 69 61 74 65 20 | 74 79 70 65 2e 0a 49 6e |opriate |type..In|
|00002d70| 20 61 6c 6c 20 63 61 73 | 65 73 20 74 68 65 20 66 | all cas|es the f|
|00002d80| 69 72 73 74 20 70 61 72 | 61 6d 65 74 65 72 2c 0a |irst par|ameter,.|
|00002d90| 58 2e 49 20 78 64 72 73 | 20 0a 63 61 6e 20 62 65 |X.I xdrs| .can be|
|00002da0| 20 74 72 65 61 74 65 64 | 20 61 73 20 61 6e 20 6f | treated| as an o|
|00002db0| 70 61 71 75 65 20 68 61 | 6e 64 6c 65 2c 0a 61 6e |paque ha|ndle,.an|
|00002dc0| 64 20 70 61 73 73 65 64 | 20 74 6f 20 74 68 65 20 |d passed| to the |
|00002dd0| 70 72 69 6d 69 74 69 76 | 65 20 72 6f 75 74 69 6e |primitiv|e routin|
|00002de0| 65 73 2e 0a 58 2e 4c 50 | 0a 58 44 52 20 72 6f 75 |es..X.LP|.XDR rou|
|00002df0| 74 69 6e 65 73 20 61 72 | 65 20 64 69 72 65 63 74 |tines ar|e direct|
|00002e00| 69 6f 6e 20 69 6e 64 65 | 70 65 6e 64 65 6e 74 3b |ion inde|pendent;|
|00002e10| 0a 74 68 61 74 20 69 73 | 2c 20 74 68 65 20 73 61 |.that is|, the sa|
|00002e20| 6d 65 20 72 6f 75 74 69 | 6e 65 73 20 61 72 65 20 |me routi|nes are |
|00002e30| 63 61 6c 6c 65 64 20 74 | 6f 20 73 65 72 69 61 6c |called t|o serial|
|00002e40| 69 7a 65 20 6f 72 20 64 | 65 73 65 72 69 61 6c 69 |ize or d|eseriali|
|00002e50| 7a 65 20 64 61 74 61 2e | 0a 54 68 69 73 20 66 65 |ze data.|.This fe|
|00002e60| 61 74 75 72 65 20 69 73 | 20 63 72 69 74 69 63 61 |ature is| critica|
|00002e70| 6c 20 74 6f 20 73 6f 66 | 74 77 61 72 65 20 65 6e |l to sof|tware en|
|00002e80| 67 69 6e 65 65 72 69 6e | 67 20 6f 66 20 70 6f 72 |gineerin|g of por|
|00002e90| 74 61 62 6c 65 20 64 61 | 74 61 2e 0a 54 68 65 20 |table da|ta..The |
|00002ea0| 69 64 65 61 20 69 73 20 | 74 6f 20 63 61 6c 6c 20 |idea is |to call |
|00002eb0| 74 68 65 20 73 61 6d 65 | 20 72 6f 75 74 69 6e 65 |the same| routine|
|00002ec0| 20 66 6f 72 20 65 69 74 | 68 65 72 20 6f 70 65 72 | for eit|her oper|
|00002ed0| 61 74 69 6f 6e 20 5c 28 | 65 6d 0a 74 68 69 73 20 |ation \(|em.this |
|00002ee0| 61 6c 6d 6f 73 74 20 67 | 75 61 72 61 6e 74 65 65 |almost g|uarantee|
|00002ef0| 73 20 74 68 61 74 20 73 | 65 72 69 61 6c 69 7a 65 |s that s|erialize|
|00002f00| 64 20 64 61 74 61 20 63 | 61 6e 20 61 6c 73 6f 20 |d data c|an also |
|00002f10| 62 65 20 64 65 73 65 72 | 69 61 6c 69 7a 65 64 2e |be deser|ialized.|
|00002f20| 0a 4f 6e 65 20 72 6f 75 | 74 69 6e 65 20 69 73 20 |.One rou|tine is |
|00002f30| 75 73 65 64 20 62 79 20 | 62 6f 74 68 20 70 72 6f |used by |both pro|
|00002f40| 64 75 63 65 72 20 61 6e | 64 20 63 6f 6e 73 75 6d |ducer an|d consum|
|00002f50| 65 72 20 6f 66 20 6e 65 | 74 77 6f 72 6b 65 64 20 |er of ne|tworked |
|00002f60| 64 61 74 61 2e 0a 54 68 | 69 73 20 69 73 20 69 6d |data..Th|is is im|
|00002f70| 70 6c 65 6d 65 6e 74 65 | 64 20 62 79 20 61 6c 77 |plemente|d by alw|
|00002f80| 61 79 73 20 70 61 73 73 | 69 6e 67 20 74 68 65 20 |ays pass|ing the |
|00002f90| 61 64 64 72 65 73 73 0a | 6f 66 20 61 6e 20 6f 62 |address.|of an ob|
|00002fa0| 6a 65 63 74 20 72 61 74 | 68 65 72 20 74 68 61 6e |ject rat|her than|
|00002fb0| 20 74 68 65 20 6f 62 6a | 65 63 74 20 69 74 73 65 | the obj|ect itse|
|00002fc0| 6c 66 20 5c 28 65 6d 0a | 6f 6e 6c 79 20 69 6e 20 |lf \(em.|only in |
|00002fd0| 74 68 65 20 63 61 73 65 | 20 6f 66 20 64 65 73 65 |the case| of dese|
|00002fe0| 72 69 61 6c 69 7a 61 74 | 69 6f 6e 20 69 73 20 74 |rializat|ion is t|
|00002ff0| 68 65 20 6f 62 6a 65 63 | 74 20 6d 6f 64 69 66 69 |he objec|t modifi|
|00003000| 65 64 2e 0a 54 68 69 73 | 20 66 65 61 74 75 72 65 |ed..This| feature|
|00003010| 20 69 73 20 6e 6f 74 20 | 73 68 6f 77 6e 20 69 6e | is not |shown in|
|00003020| 20 6f 75 72 20 74 72 69 | 76 69 61 6c 20 65 78 61 | our tri|vial exa|
|00003030| 6d 70 6c 65 2c 0a 62 75 | 74 20 69 74 73 20 76 61 |mple,.bu|t its va|
|00003040| 6c 75 65 20 62 65 63 6f | 6d 65 73 20 6f 62 76 69 |lue beco|mes obvi|
|00003050| 6f 75 73 20 77 68 65 6e | 20 6e 6f 6e 74 72 69 76 |ous when| nontriv|
|00003060| 69 61 6c 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |ial data| structu|
|00003070| 72 65 73 0a 61 72 65 20 | 70 61 73 73 65 64 20 61 |res.are |passed a|
|00003080| 6d 6f 6e 67 20 6d 61 63 | 68 69 6e 65 73 2e 20 20 |mong mac|hines. |
|00003090| 49 66 20 6e 65 65 64 65 | 64 2c 20 74 68 65 20 75 |If neede|d, the u|
|000030a0| 73 65 72 20 63 61 6e 20 | 6f 62 74 61 69 6e 20 74 |ser can |obtain t|
|000030b0| 68 65 20 0a 64 69 72 65 | 63 74 69 6f 6e 20 6f 66 |he .dire|ction of|
|000030c0| 20 74 68 65 20 58 44 52 | 20 6f 70 65 72 61 74 69 | the XDR| operati|
|000030d0| 6f 6e 2e 20 20 53 65 65 | 20 74 68 65 0a 5c 66 49 |on. See| the.\fI|
|000030e0| 58 44 52 20 4f 70 65 72 | 61 74 69 6f 6e 20 44 69 |XDR Oper|ation Di|
|000030f0| 72 65 63 74 69 6f 6e 73 | 5c 66 50 0a 73 65 63 74 |rections|\fP.sect|
|00003100| 69 6f 6e 20 6f 66 20 74 | 68 69 73 20 63 68 61 70 |ion of t|his chap|
|00003110| 74 65 72 20 66 6f 72 20 | 64 65 74 61 69 6c 73 2e |ter for |details.|
|00003120| 0a 58 2e 4c 50 0a 4c 65 | 74 27 73 20 6c 6f 6f 6b |.X.LP.Le|t's look|
|00003130| 20 61 74 20 61 20 73 6c | 69 67 68 74 6c 79 20 6d | at a sl|ightly m|
|00003140| 6f 72 65 20 63 6f 6d 70 | 6c 69 63 61 74 65 64 20 |ore comp|licated |
|00003150| 65 78 61 6d 70 6c 65 2e | 0a 41 73 73 75 6d 65 20 |example.|.Assume |
|00003160| 74 68 61 74 20 61 20 70 | 65 72 73 6f 6e 27 73 20 |that a p|erson's |
|00003170| 67 72 6f 73 73 20 61 73 | 73 65 74 73 20 61 6e 64 |gross as|sets and|
|00003180| 20 6c 69 61 62 69 6c 69 | 74 69 65 73 0a 61 72 65 | liabili|ties.are|
|00003190| 20 74 6f 20 62 65 20 65 | 78 63 68 61 6e 67 65 64 | to be e|xchanged|
|000031a0| 20 61 6d 6f 6e 67 20 70 | 72 6f 63 65 73 73 65 73 | among p|rocesses|
|000031b0| 2e 0a 41 6c 73 6f 20 61 | 73 73 75 6d 65 20 74 68 |..Also a|ssume th|
|000031c0| 61 74 20 74 68 65 73 65 | 20 76 61 6c 75 65 73 20 |at these| values |
|000031d0| 61 72 65 20 69 6d 70 6f | 72 74 61 6e 74 20 65 6e |are impo|rtant en|
|000031e0| 6f 75 67 68 0a 74 6f 20 | 77 61 72 72 61 6e 74 20 |ough.to |warrant |
|000031f0| 74 68 65 69 72 20 6f 77 | 6e 20 64 61 74 61 20 74 |their ow|n data t|
|00003200| 79 70 65 3a 0a 58 2e 69 | 65 20 74 20 2e 44 53 0a |ype:.X.i|e t .DS.|
|00003210| 58 2e 65 6c 20 2e 44 53 | 20 4c 0a 58 2e 66 74 20 |X.el .DS| L.X.ft |
|00003220| 43 57 0a 73 74 72 75 63 | 74 20 67 6e 75 6d 62 65 |CW.struc|t gnumbe|
|00003230| 72 73 20 7b 0a 09 6c 6f | 6e 67 20 67 5f 61 73 73 |rs {..lo|ng g_ass|
|00003240| 65 74 73 3b 0a 09 6c 6f | 6e 67 20 67 5f 6c 69 61 |ets;..lo|ng g_lia|
|00003250| 62 69 6c 69 74 69 65 73 | 3b 0a 7d 3b 0a 58 2e 44 |bilities|;.};.X.D|
|00003260| 45 0a 54 68 65 20 63 6f | 72 72 65 73 70 6f 6e 64 |E.The co|rrespond|
|00003270| 69 6e 67 20 58 44 52 20 | 72 6f 75 74 69 6e 65 20 |ing XDR |routine |
|00003280| 64 65 73 63 72 69 62 69 | 6e 67 20 74 68 69 73 20 |describi|ng this |
|00003290| 73 74 72 75 63 74 75 72 | 65 20 77 6f 75 6c 64 20 |structur|e would |
|000032a0| 62 65 3a 0a 58 2e 69 65 | 20 74 20 2e 44 53 0a 58 |be:.X.ie| t .DS.X|
|000032b0| 2e 65 6c 20 2e 44 53 20 | 4c 0a 58 2e 66 74 20 43 |.el .DS |L.X.ft C|
|000032c0| 57 0a 62 6f 6f 6c 5f 74 | 20 20 09 09 2f 2a 20 5c |W.bool_t| ../* \|
|000032d0| 66 49 54 52 55 45 20 69 | 73 20 73 75 63 63 65 73 |fITRUE i|s succes|
|000032e0| 73 2c 20 46 41 4c 53 45 | 20 69 73 20 66 61 69 6c |s, FALSE| is fail|
|000032f0| 75 72 65 5c 66 50 20 2a | 2f 0a 78 64 72 5f 67 6e |ure\fP *|/.xdr_gn|
|00003300| 75 6d 62 65 72 73 28 78 | 64 72 73 2c 20 67 70 29 |umbers(x|drs, gp)|
|00003310| 0a 09 58 44 52 20 2a 78 | 64 72 73 3b 0a 09 73 74 |..XDR *x|drs;..st|
|00003320| 72 75 63 74 20 67 6e 75 | 6d 62 65 72 73 20 2a 67 |ruct gnu|mbers *g|
|00003330| 70 3b 0a 7b 0a 09 69 66 | 20 28 78 64 72 5f 6c 6f |p;.{..if| (xdr_lo|
|00003340| 6e 67 28 78 64 72 73 2c | 20 26 67 70 2d 3e 67 5f |ng(xdrs,| &gp->g_|
|00003350| 61 73 73 65 74 73 29 20 | 26 26 0a 09 20 20 20 20 |assets) |&&.. |
|00003360| 78 64 72 5f 6c 6f 6e 67 | 28 78 64 72 73 2c 20 26 |xdr_long|(xdrs, &|
|00003370| 67 70 2d 3e 67 5f 6c 69 | 61 62 69 6c 69 74 69 65 |gp->g_li|abilitie|
|00003380| 73 29 29 0a 09 09 72 65 | 74 75 72 6e 28 54 52 55 |s))...re|turn(TRU|
|00003390| 45 29 3b 0a 09 72 65 74 | 75 72 6e 28 46 41 4c 53 |E);..ret|urn(FALS|
|000033a0| 45 29 3b 0a 7d 0a 58 2e | 44 45 0a 4e 6f 74 65 20 |E);.}.X.|DE.Note |
|000033b0| 74 68 61 74 20 74 68 65 | 20 70 61 72 61 6d 65 74 |that the| paramet|
|000033c0| 65 72 0a 58 2e 49 20 78 | 64 72 73 20 0a 69 73 20 |er.X.I x|drs .is |
|000033d0| 6e 65 76 65 72 20 69 6e | 73 70 65 63 74 65 64 20 |never in|spected |
|000033e0| 6f 72 20 6d 6f 64 69 66 | 69 65 64 3b 0a 69 74 20 |or modif|ied;.it |
|000033f0| 69 73 20 6f 6e 6c 79 20 | 70 61 73 73 65 64 20 6f |is only |passed o|
|00003400| 6e 20 74 6f 20 74 68 65 | 20 73 75 62 63 6f 6d 70 |n to the| subcomp|
|00003410| 6f 6e 65 6e 74 20 72 6f | 75 74 69 6e 65 73 2e 0a |onent ro|utines..|
|00003420| 49 74 20 69 73 20 69 6d | 70 65 72 61 74 69 76 65 |It is im|perative|
|00003430| 20 74 6f 20 69 6e 73 70 | 65 63 74 20 74 68 65 20 | to insp|ect the |
|00003440| 72 65 74 75 72 6e 20 76 | 61 6c 75 65 20 6f 66 20 |return v|alue of |
|00003450| 65 61 63 68 20 58 44 52 | 20 72 6f 75 74 69 6e 65 |each XDR| routine|
|00003460| 20 63 61 6c 6c 2c 0a 61 | 6e 64 20 74 6f 20 67 69 | call,.a|nd to gi|
|00003470| 76 65 20 75 70 20 69 6d | 6d 65 64 69 61 74 65 6c |ve up im|mediatel|
|00003480| 79 20 61 6e 64 20 72 65 | 74 75 72 6e 0a 58 2e 49 |y and re|turn.X.I|
|00003490| 20 46 41 4c 53 45 20 0a | 69 66 20 74 68 65 20 73 | FALSE .|if the s|
|000034a0| 75 62 72 6f 75 74 69 6e | 65 20 66 61 69 6c 73 2e |ubroutin|e fails.|
|000034b0| 0a 58 2e 4c 50 0a 54 68 | 69 73 20 65 78 61 6d 70 |.X.LP.Th|is examp|
|000034c0| 6c 65 20 61 6c 73 6f 20 | 73 68 6f 77 73 20 74 68 |le also |shows th|
|000034d0| 61 74 20 74 68 65 20 74 | 79 70 65 0a 58 2e 49 20 |at the t|ype.X.I |
|000034e0| 62 6f 6f 6c 5f 74 0a 69 | 73 20 64 65 63 6c 61 72 |bool_t.i|s declar|
|000034f0| 65 64 20 61 73 20 61 6e | 20 69 6e 74 65 67 65 72 |ed as an| integer|
|00003500| 20 77 68 6f 73 65 20 6f | 6e 6c 79 20 76 61 6c 75 | whose o|nly valu|
|00003510| 65 73 20 61 72 65 0a 58 | 2e 49 20 54 52 55 45 20 |es are.X|.I TRUE |
|00003520| 0a 28 31 29 20 61 6e 64 | 0a 58 2e 49 20 46 41 4c |.(1) and|.X.I FAL|
|00003530| 53 45 20 0a 28 30 29 2e | 20 20 54 68 69 73 20 64 |SE .(0).| This d|
|00003540| 6f 63 75 6d 65 6e 74 20 | 75 73 65 73 20 74 68 65 |ocument |uses the|
|00003550| 20 66 6f 6c 6c 6f 77 69 | 6e 67 20 64 65 66 69 6e | followi|ng defin|
|00003560| 69 74 69 6f 6e 73 3a 0a | 58 2e 69 65 20 74 20 2e |itions:.|X.ie t .|
|00003570| 44 53 0a 58 2e 65 6c 20 | 2e 44 53 20 4c 0a 58 2e |DS.X.el |.DS L.X.|
|00003580| 66 74 20 43 57 0a 23 64 | 65 66 69 6e 65 20 62 6f |ft CW.#d|efine bo|
|00003590| 6f 6c 5f 74 09 69 6e 74 | 0a 23 64 65 66 69 6e 65 |ol_t.int|.#define|
|000035a0| 20 54 52 55 45 09 31 0a | 23 64 65 66 69 6e 65 20 | TRUE.1.|#define |
|000035b0| 46 41 4c 53 45 09 30 0a | 58 2e 73 70 2e 35 0a 23 |FALSE.0.|X.sp.5.#|
|000035c0| 64 65 66 69 6e 65 20 65 | 6e 75 6d 5f 74 20 69 6e |define e|num_t in|
|000035d0| 74 09 2f 2a 20 5c 66 49 | 65 6e 75 6d 5f 74 20 75 |t./* \fI|enum_t u|
|000035e0| 73 65 64 20 66 6f 72 20 | 67 65 6e 65 72 69 63 20 |sed for |generic |
|000035f0| 65 6e 75 6d 73 5c 66 50 | 20 2a 2f 0a 58 2e 44 45 |enums\fP| */.X.DE|
|00003600| 0a 58 2e 4c 50 0a 4b 65 | 65 70 69 6e 67 20 74 68 |.X.LP.Ke|eping th|
|00003610| 65 73 65 20 63 6f 6e 76 | 65 6e 74 69 6f 6e 73 20 |ese conv|entions |
|00003620| 69 6e 20 6d 69 6e 64 2c | 0a 58 2e 49 20 78 64 72 |in mind,|.X.I xdr|
|00003630| 5f 67 6e 75 6d 62 65 72 | 73 0a 63 61 6e 20 62 65 |_gnumber|s.can be|
|00003640| 20 72 65 77 72 69 74 74 | 65 6e 20 61 73 20 66 6f | rewritt|en as fo|
|00003650| 6c 6c 6f 77 73 3a 0a 58 | 2e 69 65 20 74 20 2e 44 |llows:.X|.ie t .D|
|00003660| 53 0a 58 2e 65 6c 20 2e | 44 53 20 4c 0a 58 2e 66 |S.X.el .|DS L.X.f|
|00003670| 74 20 43 57 0a 78 64 72 | 5f 67 6e 75 6d 62 65 72 |t CW.xdr|_gnumber|
|00003680| 73 28 78 64 72 73 2c 20 | 67 70 29 0a 09 58 44 52 |s(xdrs, |gp)..XDR|
|00003690| 20 2a 78 64 72 73 3b 0a | 09 73 74 72 75 63 74 20 | *xdrs;.|.struct |
|000036a0| 67 6e 75 6d 62 65 72 73 | 20 2a 67 70 3b 0a 7b 0a |gnumbers| *gp;.{.|
|000036b0| 09 72 65 74 75 72 6e 28 | 78 64 72 5f 6c 6f 6e 67 |.return(|xdr_long|
|000036c0| 28 78 64 72 73 2c 20 26 | 67 70 2d 3e 67 5f 61 73 |(xdrs, &|gp->g_as|
|000036d0| 73 65 74 73 29 20 26 26 | 0a 09 09 78 64 72 5f 6c |sets) &&|...xdr_l|
|000036e0| 6f 6e 67 28 78 64 72 73 | 2c 20 26 67 70 2d 3e 67 |ong(xdrs|, &gp->g|
|000036f0| 5f 6c 69 61 62 69 6c 69 | 74 69 65 73 29 29 3b 0a |_liabili|ties));.|
|00003700| 7d 0a 58 2e 44 45 0a 54 | 68 69 73 20 64 6f 63 75 |}.X.DE.T|his docu|
|00003710| 6d 65 6e 74 20 75 73 65 | 73 20 62 6f 74 68 20 63 |ment use|s both c|
|00003720| 6f 64 69 6e 67 20 73 74 | 79 6c 65 73 2e 0a 58 2e |oding st|yles..X.|
|00003730| 0a 58 2e 4e 48 20 31 0a | 5c 26 58 44 52 20 4c 69 |.X.NH 1.|\&XDR Li|
|00003740| 62 72 61 72 79 20 50 72 | 69 6d 69 74 69 76 65 73 |brary Pr|imitives|
|00003750| 0a 58 2e 49 58 20 22 6c | 69 62 72 61 72 79 20 70 |.X.IX "l|ibrary p|
|00003760| 72 69 6d 69 74 69 76 65 | 73 20 66 6f 72 20 58 44 |rimitive|s for XD|
|00003770| 52 22 0a 58 2e 49 58 20 | 22 58 44 52 20 22 6c 69 |R".X.IX |"XDR "li|
|00003780| 62 72 61 72 79 20 70 72 | 69 6d 69 74 69 76 65 73 |brary pr|imitives|
|00003790| 22 0a 58 2e 4c 50 0a 54 | 68 69 73 20 73 65 63 74 |".X.LP.T|his sect|
|000037a0| 69 6f 6e 20 67 69 76 65 | 73 20 61 20 73 79 6e 6f |ion give|s a syno|
|000037b0| 70 73 69 73 20 6f 66 20 | 65 61 63 68 20 58 44 52 |psis of |each XDR|
|000037c0| 20 70 72 69 6d 69 74 69 | 76 65 2e 0a 49 74 20 73 | primiti|ve..It s|
|000037d0| 74 61 72 74 73 20 77 69 | 74 68 20 62 61 73 69 63 |tarts wi|th basic|
|000037e0| 20 64 61 74 61 20 74 79 | 70 65 73 20 61 6e 64 20 | data ty|pes and |
|000037f0| 6d 6f 76 65 73 20 6f 6e | 20 74 6f 20 63 6f 6e 73 |moves on| to cons|
|00003800| 74 72 75 63 74 65 64 20 | 64 61 74 61 20 74 79 70 |tructed |data typ|
|00003810| 65 73 2e 0a 46 69 6e 61 | 6c 6c 79 2c 20 58 44 52 |es..Fina|lly, XDR|
|00003820| 20 75 74 69 6c 69 74 69 | 65 73 20 61 72 65 20 64 | utiliti|es are d|
|00003830| 69 73 63 75 73 73 65 64 | 2e 0a 54 68 65 20 69 6e |iscussed|..The in|
|00003840| 74 65 72 66 61 63 65 20 | 74 6f 20 74 68 65 73 65 |terface |to these|
|00003850| 20 70 72 69 6d 69 74 69 | 76 65 73 0a 61 6e 64 20 | primiti|ves.and |
|00003860| 75 74 69 6c 69 74 69 65 | 73 20 69 73 20 64 65 66 |utilitie|s is def|
|00003870| 69 6e 65 64 20 69 6e 20 | 74 68 65 20 69 6e 63 6c |ined in |the incl|
|00003880| 75 64 65 20 66 69 6c 65 | 0a 58 2e 49 20 3c 72 70 |ude file|.X.I <rp|
|00003890| 63 2f 78 64 72 2e 68 3e | 20 2c 0a 61 75 74 6f 6d |c/xdr.h>| ,.autom|
|000038a0| 61 74 69 63 61 6c 6c 79 | 20 69 6e 63 6c 75 64 65 |atically| include|
|000038b0| 64 20 62 79 0a 58 2e 49 | 20 3c 72 70 63 2f 72 70 |d by.X.I| <rpc/rp|
|000038c0| 63 2e 68 3e 20 2e 0a 58 | 2e 0a 58 2e 4e 48 20 32 |c.h> ..X|..X.NH 2|
|000038d0| 0a 5c 26 4e 75 6d 62 65 | 72 20 46 69 6c 74 65 72 |.\&Numbe|r Filter|
|000038e0| 73 0a 58 2e 49 58 20 22 | 58 44 52 20 6c 69 62 72 |s.X.IX "|XDR libr|
|000038f0| 61 72 79 22 20 22 6e 75 | 6d 62 65 72 20 66 69 6c |ary" "nu|mber fil|
|00003900| 74 65 72 73 22 0a 58 2e | 4c 50 0a 54 68 65 20 58 |ters".X.|LP.The X|
|00003910| 44 52 20 6c 69 62 72 61 | 72 79 20 70 72 6f 76 69 |DR libra|ry provi|
|00003920| 64 65 73 20 70 72 69 6d | 69 74 69 76 65 73 20 74 |des prim|itives t|
|00003930| 6f 20 74 72 61 6e 73 6c | 61 74 65 20 62 65 74 77 |o transl|ate betw|
|00003940| 65 65 6e 20 6e 75 6d 62 | 65 72 73 0a 61 6e 64 20 |een numb|ers.and |
|00003950| 74 68 65 69 72 20 63 6f | 72 72 65 73 70 6f 6e 64 |their co|rrespond|
|00003960| 69 6e 67 20 65 78 74 65 | 72 6e 61 6c 20 72 65 70 |ing exte|rnal rep|
|00003970| 72 65 73 65 6e 74 61 74 | 69 6f 6e 73 2e 0a 50 72 |resentat|ions..Pr|
|00003980| 69 6d 69 74 69 76 65 73 | 20 63 6f 76 65 72 20 74 |imitives| cover t|
|00003990| 68 65 20 73 65 74 20 6f | 66 20 6e 75 6d 62 65 72 |he set o|f number|
|000039a0| 73 20 69 6e 3a 0a 58 2e | 45 51 0a 5b 73 69 67 6e |s in:.X.|EQ.[sign|
|000039b0| 65 64 2c 20 75 6e 73 69 | 67 6e 65 64 5d 20 2a 20 |ed, unsi|gned] * |
|000039c0| 5b 73 68 6f 72 74 2c 20 | 69 6e 74 2c 20 6c 6f 6e |[short, |int, lon|
|000039d0| 67 5d 0a 58 2e 45 4e 0a | 53 70 65 63 69 66 69 63 |g].X.EN.|Specific|
|000039e0| 61 6c 6c 79 2c 20 74 68 | 65 20 65 69 67 68 74 20 |ally, th|e eight |
|000039f0| 70 72 69 6d 69 74 69 76 | 65 73 20 61 72 65 3a 0a |primitiv|es are:.|
|00003a00| 58 2e 44 53 0a 58 2e 66 | 74 20 43 57 0a 62 6f 6f |X.DS.X.f|t CW.boo|
|00003a10| 6c 5f 74 20 78 64 72 5f | 63 68 61 72 28 78 64 72 |l_t xdr_|char(xdr|
|00003a20| 73 2c 20 63 70 29 0a 09 | 58 44 52 20 2a 78 64 72 |s, cp)..|XDR *xdr|
|00003a30| 73 3b 0a 09 63 68 61 72 | 20 2a 63 70 3b 0a 58 2e |s;..char| *cp;.X.|
|00003a40| 73 70 2e 35 0a 62 6f 6f | 6c 5f 74 20 78 64 72 5f |sp.5.boo|l_t xdr_|
|00003a50| 75 5f 63 68 61 72 28 78 | 64 72 73 2c 20 75 63 70 |u_char(x|drs, ucp|
|00003a60| 29 0a 09 58 44 52 20 2a | 78 64 72 73 3b 0a 09 75 |)..XDR *|xdrs;..u|
|00003a70| 6e 73 69 67 6e 65 64 20 | 63 68 61 72 20 2a 75 63 |nsigned |char *uc|
|00003a80| 70 3b 0a 58 2e 73 70 2e | 35 0a 62 6f 6f 6c 5f 74 |p;.X.sp.|5.bool_t|
|00003a90| 20 78 64 72 5f 69 6e 74 | 28 78 64 72 73 2c 20 69 | xdr_int|(xdrs, i|
|00003aa0| 70 29 0a 09 58 44 52 20 | 2a 78 64 72 73 3b 0a 09 |p)..XDR |*xdrs;..|
|00003ab0| 69 6e 74 20 2a 69 70 3b | 0a 58 2e 73 70 2e 35 0a |int *ip;|.X.sp.5.|
|00003ac0| 62 6f 6f 6c 5f 74 20 78 | 64 72 5f 75 5f 69 6e 74 |bool_t x|dr_u_int|
|00003ad0| 28 78 64 72 73 2c 20 75 | 70 29 0a 09 58 44 52 20 |(xdrs, u|p)..XDR |
|00003ae0| 2a 78 64 72 73 3b 0a 09 | 75 6e 73 69 67 6e 65 64 |*xdrs;..|unsigned|
|00003af0| 20 2a 75 70 3b 0a 58 2e | 73 70 2e 35 0a 62 6f 6f | *up;.X.|sp.5.boo|
|00003b00| 6c 5f 74 20 78 64 72 5f | 6c 6f 6e 67 28 78 64 72 |l_t xdr_|long(xdr|
|00003b10| 73 2c 20 6c 69 70 29 0a | 09 58 44 52 20 2a 78 64 |s, lip).|.XDR *xd|
|00003b20| 72 73 3b 0a 09 6c 6f 6e | 67 20 2a 6c 69 70 3b 0a |rs;..lon|g *lip;.|
|00003b30| 58 2e 73 70 2e 35 0a 62 | 6f 6f 6c 5f 74 20 78 64 |X.sp.5.b|ool_t xd|
|00003b40| 72 5f 75 5f 6c 6f 6e 67 | 28 78 64 72 73 2c 20 6c |r_u_long|(xdrs, l|
|00003b50| 75 70 29 0a 09 58 44 52 | 20 2a 78 64 72 73 3b 0a |up)..XDR| *xdrs;.|
|00003b60| 09 75 5f 6c 6f 6e 67 20 | 2a 6c 75 70 3b 0a 58 2e |.u_long |*lup;.X.|
|00003b70| 73 70 2e 35 0a 62 6f 6f | 6c 5f 74 20 78 64 72 5f |sp.5.boo|l_t xdr_|
|00003b80| 73 68 6f 72 74 28 78 64 | 72 73 2c 20 73 69 70 29 |short(xd|rs, sip)|
|00003b90| 0a 09 58 44 52 20 2a 78 | 64 72 73 3b 0a 09 73 68 |..XDR *x|drs;..sh|
|00003ba0| 6f 72 74 20 2a 73 69 70 | 3b 0a 58 2e 73 70 2e 35 |ort *sip|;.X.sp.5|
|00003bb0| 0a 62 6f 6f 6c 5f 74 20 | 78 64 72 5f 75 5f 73 68 |.bool_t |xdr_u_sh|
|00003bc0| 6f 72 74 28 78 64 72 73 | 2c 20 73 75 70 29 0a 09 |ort(xdrs|, sup)..|
|00003bd0| 58 44 52 20 2a 78 64 72 | 73 3b 0a 09 75 5f 73 68 |XDR *xdr|s;..u_sh|
|00003be0| 6f 72 74 20 2a 73 75 70 | 3b 0a 58 2e 44 45 0a 54 |ort *sup|;.X.DE.T|
|00003bf0| 68 65 20 66 69 72 73 74 | 20 70 61 72 61 6d 65 74 |he first| paramet|
|00003c00| 65 72 2c 0a 58 2e 49 20 | 78 64 72 73 20 2c 0a 69 |er,.X.I |xdrs ,.i|
|00003c10| 73 20 61 6e 20 58 44 52 | 20 73 74 72 65 61 6d 20 |s an XDR| stream |
|00003c20| 68 61 6e 64 6c 65 2e 0a | 54 68 65 20 73 65 63 6f |handle..|The seco|
|00003c30| 6e 64 20 70 61 72 61 6d | 65 74 65 72 20 69 73 20 |nd param|eter is |
|00003c40| 74 68 65 20 61 64 64 72 | 65 73 73 20 6f 66 20 74 |the addr|ess of t|
|00003c50| 68 65 20 6e 75 6d 62 65 | 72 0a 74 68 61 74 20 70 |he numbe|r.that p|
|00003c60| 72 6f 76 69 64 65 73 20 | 64 61 74 61 20 74 6f 20 |rovides |data to |
|00003c70| 74 68 65 20 73 74 72 65 | 61 6d 20 6f 72 20 72 65 |the stre|am or re|
|00003c80| 63 65 69 76 65 73 20 64 | 61 74 61 20 66 72 6f 6d |ceives d|ata from|
|00003c90| 20 69 74 2e 0a 41 6c 6c | 20 72 6f 75 74 69 6e 65 | it..All| routine|
|00003ca0| 73 20 72 65 74 75 72 6e | 0a 58 2e 49 20 54 52 55 |s return|.X.I TRU|
|00003cb0| 45 20 0a 69 66 20 74 68 | 65 79 20 63 6f 6d 70 6c |E .if th|ey compl|
|00003cc0| 65 74 65 20 73 75 63 63 | 65 73 73 66 75 6c 6c 79 |ete succ|essfully|
|00003cd0| 2c 20 61 6e 64 0a 58 2e | 49 20 46 41 4c 53 45 20 |, and.X.|I FALSE |
|00003ce0| 0a 6f 74 68 65 72 77 69 | 73 65 2e 0a 58 2e 0a 58 |.otherwi|se..X..X|
|00003cf0| 2e 4e 48 20 32 0a 5c 26 | 46 6c 6f 61 74 69 6e 67 |.NH 2.\&|Floating|
|00003d00| 20 50 6f 69 6e 74 20 46 | 69 6c 74 65 72 73 0a 58 | Point F|ilters.X|
|00003d10| 2e 49 58 20 22 58 44 52 | 20 6c 69 62 72 61 72 79 |.IX "XDR| library|
|00003d20| 22 20 22 66 6c 6f 61 74 | 69 6e 67 20 70 6f 69 6e |" "float|ing poin|
|00003d30| 74 20 66 69 6c 74 65 72 | 73 22 0a 58 2e 4c 50 0a |t filter|s".X.LP.|
|00003d40| 54 68 65 20 58 44 52 20 | 6c 69 62 72 61 72 79 20 |The XDR |library |
|00003d50| 61 6c 73 6f 20 70 72 6f | 76 69 64 65 73 20 70 72 |also pro|vides pr|
|00003d60| 69 6d 69 74 69 76 65 20 | 72 6f 75 74 69 6e 65 73 |imitive |routines|
|00003d70| 0a 66 6f 72 20 43 27 73 | 20 66 6c 6f 61 74 69 6e |.for C's| floatin|
|00003d80| 67 20 70 6f 69 6e 74 20 | 74 79 70 65 73 3a 0a 58 |g point |types:.X|
|00003d90| 2e 44 53 0a 58 2e 66 74 | 20 43 57 0a 62 6f 6f 6c |.DS.X.ft| CW.bool|
|00003da0| 5f 74 20 78 64 72 5f 66 | 6c 6f 61 74 28 78 64 72 |_t xdr_f|loat(xdr|
|00003db0| 73 2c 20 66 70 29 0a 09 | 58 44 52 20 2a 78 64 72 |s, fp)..|XDR *xdr|
|00003dc0| 73 3b 0a 09 66 6c 6f 61 | 74 20 2a 66 70 3b 0a 58 |s;..floa|t *fp;.X|
|00003dd0| 2e 73 70 2e 35 0a 62 6f | 6f 6c 5f 74 20 78 64 72 |.sp.5.bo|ol_t xdr|
|00003de0| 5f 64 6f 75 62 6c 65 28 | 78 64 72 73 2c 20 64 70 |_double(|xdrs, dp|
|00003df0| 29 0a 09 58 44 52 20 2a | 78 64 72 73 3b 0a 09 64 |)..XDR *|xdrs;..d|
|00003e00| 6f 75 62 6c 65 20 2a 64 | 70 3b 0a 58 2e 44 45 0a |ouble *d|p;.X.DE.|
|00003e10| 54 68 65 20 66 69 72 73 | 74 20 70 61 72 61 6d 65 |The firs|t parame|
|00003e20| 74 65 72 2c 0a 58 2e 49 | 20 78 64 72 73 20 0a 69 |ter,.X.I| xdrs .i|
|00003e30| 73 20 61 6e 20 58 44 52 | 20 73 74 72 65 61 6d 20 |s an XDR| stream |
|00003e40| 68 61 6e 64 6c 65 2e 0a | 54 68 65 20 73 65 63 6f |handle..|The seco|
|00003e50| 6e 64 20 70 61 72 61 6d | 65 74 65 72 20 69 73 20 |nd param|eter is |
|00003e60| 74 68 65 20 61 64 64 72 | 65 73 73 0a 6f 66 20 74 |the addr|ess.of t|
|00003e70| 68 65 20 66 6c 6f 61 74 | 69 6e 67 20 70 6f 69 6e |he float|ing poin|
|00003e80| 74 20 6e 75 6d 62 65 72 | 20 74 68 61 74 20 70 72 |t number| that pr|
|00003e90| 6f 76 69 64 65 73 20 64 | 61 74 61 20 74 6f 20 74 |ovides d|ata to t|
|00003ea0| 68 65 20 73 74 72 65 61 | 6d 0a 6f 72 20 72 65 63 |he strea|m.or rec|
|00003eb0| 65 69 76 65 73 20 64 61 | 74 61 20 66 72 6f 6d 20 |eives da|ta from |
|00003ec0| 69 74 2e 0a 41 6c 6c 20 | 72 6f 75 74 69 6e 65 73 |it..All |routines|
|00003ed0| 20 72 65 74 75 72 6e 0a | 58 2e 49 20 54 52 55 45 | return.|X.I TRUE|
|00003ee0| 20 0a 69 66 20 74 68 65 | 79 20 63 6f 6d 70 6c 65 | .if the|y comple|
|00003ef0| 74 65 20 73 75 63 63 65 | 73 73 66 75 6c 6c 79 2c |te succe|ssfully,|
|00003f00| 20 61 6e 64 0a 58 2e 49 | 20 46 41 4c 53 45 20 0a | and.X.I| FALSE .|
|00003f10| 6f 74 68 65 72 77 69 73 | 65 2e 0a 58 2e 4c 50 0a |otherwis|e..X.LP.|
|00003f20| 4e 6f 74 65 3a 20 53 69 | 6e 63 65 20 74 68 65 20 |Note: Si|nce the |
|00003f30| 6e 75 6d 62 65 72 73 20 | 61 72 65 20 72 65 70 72 |numbers |are repr|
|00003f40| 65 73 65 6e 74 65 64 20 | 69 6e 20 49 45 45 45 20 |esented |in IEEE |
|00003f50| 66 6c 6f 61 74 69 6e 67 | 20 70 6f 69 6e 74 2c 0a |floating| point,.|
|00003f60| 72 6f 75 74 69 6e 65 73 | 20 6d 61 79 20 66 61 69 |routines| may fai|
|00003f70| 6c 20 77 68 65 6e 20 64 | 65 63 6f 64 69 6e 67 20 |l when d|ecoding |
|00003f80| 61 20 76 61 6c 69 64 20 | 49 45 45 45 20 72 65 70 |a valid |IEEE rep|
|00003f90| 72 65 73 65 6e 74 61 74 | 69 6f 6e 0a 69 6e 74 6f |resentat|ion.into|
|00003fa0| 20 61 20 6d 61 63 68 69 | 6e 65 2d 73 70 65 63 69 | a machi|ne-speci|
|00003fb0| 66 69 63 20 72 65 70 72 | 65 73 65 6e 74 61 74 69 |fic repr|esentati|
|00003fc0| 6f 6e 2c 20 6f 72 20 76 | 69 63 65 2d 76 65 72 73 |on, or v|ice-vers|
|00003fd0| 61 2e 0a 58 2e 0a 58 2e | 4e 48 20 32 0a 5c 26 45 |a..X..X.|NH 2.\&E|
|00003fe0| 6e 75 6d 65 72 61 74 69 | 6f 6e 20 46 69 6c 74 65 |numerati|on Filte|
|00003ff0| 72 73 0a 58 2e 49 58 20 | 22 58 44 52 20 6c 69 62 |rs.X.IX |"XDR lib|
|00004000| 72 61 72 79 22 20 22 65 | 6e 75 6d 65 72 61 74 69 |rary" "e|numerati|
|00004010| 6f 6e 20 66 69 6c 74 65 | 72 73 22 0a 58 2e 4c 50 |on filte|rs".X.LP|
|00004020| 0a 54 68 65 20 58 44 52 | 20 6c 69 62 72 61 72 79 |.The XDR| library|
|00004030| 20 70 72 6f 76 69 64 65 | 73 20 61 20 70 72 69 6d | provide|s a prim|
|00004040| 69 74 69 76 65 20 66 6f | 72 20 67 65 6e 65 72 69 |itive fo|r generi|
|00004050| 63 20 65 6e 75 6d 65 72 | 61 74 69 6f 6e 73 2e 0a |c enumer|ations..|
|00004060| 54 68 65 20 70 72 69 6d | 69 74 69 76 65 20 61 73 |The prim|itive as|
|00004070| 73 75 6d 65 73 20 74 68 | 61 74 20 61 20 43 0a 58 |sumes th|at a C.X|
|00004080| 2e 49 20 65 6e 75 6d 20 | 0a 68 61 73 20 74 68 65 |.I enum |.has the|
|00004090| 20 73 61 6d 65 20 72 65 | 70 72 65 73 65 6e 74 61 | same re|presenta|
|000040a0| 74 69 6f 6e 20 69 6e 73 | 69 64 65 20 74 68 65 20 |tion ins|ide the |
|000040b0| 6d 61 63 68 69 6e 65 20 | 61 73 20 61 20 43 20 69 |machine |as a C i|
|000040c0| 6e 74 65 67 65 72 2e 0a | 54 68 65 20 62 6f 6f 6c |nteger..|The bool|
|000040d0| 65 61 6e 20 74 79 70 65 | 20 69 73 20 61 6e 20 69 |ean type| is an i|
|000040e0| 6d 70 6f 72 74 61 6e 74 | 20 69 6e 73 74 61 6e 63 |mportant| instanc|
|000040f0| 65 20 6f 66 20 74 68 65 | 0a 58 2e 49 20 65 6e 75 |e of the|.X.I enu|
|00004100| 6d 20 2e 0a 54 68 65 20 | 65 78 74 65 72 6e 61 6c |m ..The |external|
|00004110| 20 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 20 | represe|ntation |
|00004120| 6f 66 20 61 20 62 6f 6f | 6c 65 61 6e 20 69 73 20 |of a boo|lean is |
|00004130| 61 6c 77 61 79 73 0a 58 | 2e 49 20 54 52 55 45 20 |always.X|.I TRUE |
|00004140| 0a 28 31 29 20 6f 72 20 | 0a 58 2e 49 20 46 41 4c |.(1) or |.X.I FAL|
|00004150| 53 45 20 0a 28 30 29 2e | 0a 58 2e 44 53 0a 58 2e |SE .(0).|.X.DS.X.|
|00004160| 66 74 20 43 57 0a 23 64 | 65 66 69 6e 65 20 62 6f |ft CW.#d|efine bo|
|00004170| 6f 6c 5f 74 09 69 6e 74 | 0a 23 64 65 66 69 6e 65 |ol_t.int|.#define|
|00004180| 20 46 41 4c 53 45 09 30 | 0a 23 64 65 66 69 6e 65 | FALSE.0|.#define|
|00004190| 20 54 52 55 45 09 31 0a | 58 2e 73 70 2e 35 0a 23 | TRUE.1.|X.sp.5.#|
|000041a0| 64 65 66 69 6e 65 20 65 | 6e 75 6d 5f 74 20 69 6e |define e|num_t in|
|000041b0| 74 0a 58 2e 73 70 2e 35 | 0a 62 6f 6f 6c 5f 74 20 |t.X.sp.5|.bool_t |
|000041c0| 78 64 72 5f 65 6e 75 6d | 28 78 64 72 73 2c 20 65 |xdr_enum|(xdrs, e|
|000041d0| 70 29 0a 09 58 44 52 20 | 2a 78 64 72 73 3b 0a 09 |p)..XDR |*xdrs;..|
|000041e0| 65 6e 75 6d 5f 74 20 2a | 65 70 3b 0a 58 2e 73 70 |enum_t *|ep;.X.sp|
|000041f0| 2e 35 0a 62 6f 6f 6c 5f | 74 20 78 64 72 5f 62 6f |.5.bool_|t xdr_bo|
|00004200| 6f 6c 28 78 64 72 73 2c | 20 62 70 29 0a 09 58 44 |ol(xdrs,| bp)..XD|
|00004210| 52 20 2a 78 64 72 73 3b | 0a 09 62 6f 6f 6c 5f 74 |R *xdrs;|..bool_t|
|00004220| 20 2a 62 70 3b 0a 58 2e | 44 45 0a 54 68 65 20 73 | *bp;.X.|DE.The s|
|00004230| 65 63 6f 6e 64 20 70 61 | 72 61 6d 65 74 65 72 73 |econd pa|rameters|
|00004240| 0a 58 2e 49 20 65 70 0a | 61 6e 64 0a 58 2e 49 20 |.X.I ep.|and.X.I |
|00004250| 62 70 0a 61 72 65 20 61 | 64 64 72 65 73 73 65 73 |bp.are a|ddresses|
|00004260| 20 6f 66 20 74 68 65 20 | 61 73 73 6f 63 69 61 74 | of the |associat|
|00004270| 65 64 20 74 79 70 65 0a | 74 68 61 74 20 70 72 6f |ed type.|that pro|
|00004280| 76 69 64 65 73 20 64 61 | 74 61 20 74 6f 2c 20 6f |vides da|ta to, o|
|00004290| 72 20 72 65 63 65 69 76 | 65 73 20 64 61 74 61 20 |r receiv|es data |
|000042a0| 66 72 6f 6d 2c 20 74 68 | 65 20 73 74 72 65 61 6d |from, th|e stream|
|000042b0| 0a 58 2e 49 20 78 64 72 | 73 0a 54 68 65 20 72 6f |.X.I xdr|s.The ro|
|000042c0| 75 74 69 6e 65 20 72 65 | 74 75 72 6e 73 0a 58 2e |utine re|turns.X.|
|000042d0| 49 20 46 41 4c 53 45 20 | 0a 69 66 20 74 68 65 20 |I FALSE |.if the |
|000042e0| 6e 75 6d 62 65 72 20 6f | 66 20 63 68 61 72 61 63 |number o|f charac|
|000042f0| 74 65 72 73 20 65 78 63 | 65 65 64 73 0a 58 2e 49 |ters exc|eeds.X.I|
|00004300| 20 6d 61 78 6c 65 6e 67 | 74 68 20 2c 0a 61 6e 64 | maxleng|th ,.and|
|00004310| 0a 58 2e 49 20 54 52 55 | 45 20 0a 69 66 20 69 74 |.X.I TRU|E .if it|
|00004320| 20 64 6f 65 73 6e 27 74 | 2e 0a 58 2e 0a 58 2e 4e | doesn't|..X..X.N|
|00004330| 48 20 32 0a 5c 26 4e 6f | 20 44 61 74 61 0a 58 2e |H 2.\&No| Data.X.|
|00004340| 49 58 20 22 58 44 52 20 | 6c 69 62 72 61 72 79 22 |IX "XDR |library"|
|00004350| 20 22 6e 6f 20 64 61 74 | 61 22 0a 58 2e 4c 50 0a | "no dat|a".X.LP.|
|00004360| 4f 63 63 61 73 69 6f 6e | 61 6c 6c 79 2c 20 61 6e |Occasion|ally, an|
|00004370| 20 58 44 52 20 72 6f 75 | 74 69 6e 65 20 6d 75 73 | XDR rou|tine mus|
|00004380| 74 20 62 65 20 73 75 70 | 70 6c 69 65 64 20 74 6f |t be sup|plied to|
|00004390| 20 74 68 65 20 52 50 43 | 20 73 79 73 74 65 6d 2c | the RPC| system,|
|000043a0| 0a 65 76 65 6e 20 77 68 | 65 6e 20 6e 6f 20 64 61 |.even wh|en no da|
|000043b0| 74 61 20 69 73 20 70 61 | 73 73 65 64 20 6f 72 20 |ta is pa|ssed or |
|000043c0| 72 65 71 75 69 72 65 64 | 2e 0a 54 68 65 20 6c 69 |required|..The li|
|000043d0| 62 72 61 72 79 20 70 72 | 6f 76 69 64 65 73 20 73 |brary pr|ovides s|
|000043e0| 75 63 68 20 61 20 72 6f | 75 74 69 6e 65 3a 0a 58 |uch a ro|utine:.X|
|000043f0| 2e 44 53 0a 58 2e 66 74 | 20 43 57 0a 62 6f 6f 6c |.DS.X.ft| CW.bool|
|00004400| 5f 74 20 78 64 72 5f 76 | 6f 69 64 28 29 3b 20 20 |_t xdr_v|oid(); |
|00004410| 2f 2a 20 5c 66 49 61 6c | 77 61 79 73 20 72 65 74 |/* \fIal|ways ret|
|00004420| 75 72 6e 73 20 54 52 55 | 45 5c 66 50 20 2a 2f 0a |urns TRU|E\fP */.|
|00004430| 58 2e 44 45 0a 58 2e 0a | 58 2e 4e 48 20 32 0a 5c |X.DE.X..|X.NH 2.\|
|00004440| 26 43 6f 6e 73 74 72 75 | 63 74 65 64 20 44 61 74 |&Constru|cted Dat|
|00004450| 61 20 54 79 70 65 20 46 | 69 6c 74 65 72 73 0a 58 |a Type F|ilters.X|
|00004460| 2e 49 58 20 22 58 44 52 | 20 6c 69 62 72 61 72 79 |.IX "XDR| library|
|00004470| 22 20 22 63 6f 6e 73 74 | 72 75 63 74 65 64 20 64 |" "const|ructed d|
|00004480| 61 74 61 20 74 79 70 65 | 20 66 69 6c 74 65 72 73 |ata type| filters|
|00004490| 22 0a 58 2e 4c 50 0a 43 | 6f 6e 73 74 72 75 63 74 |".X.LP.C|onstruct|
|000044a0| 65 64 20 6f 72 20 63 6f | 6d 70 6f 75 6e 64 20 64 |ed or co|mpound d|
|000044b0| 61 74 61 20 74 79 70 65 | 20 70 72 69 6d 69 74 69 |ata type| primiti|
|000044c0| 76 65 73 0a 72 65 71 75 | 69 72 65 20 6d 6f 72 65 |ves.requ|ire more|
|000044d0| 20 70 61 72 61 6d 65 74 | 65 72 73 20 61 6e 64 20 | paramet|ers and |
|000044e0| 70 65 72 66 6f 72 6d 20 | 6d 6f 72 65 20 63 6f 6d |perform |more com|
|000044f0| 70 6c 69 63 61 74 65 64 | 20 66 75 6e 63 74 69 6f |plicated| functio|
|00004500| 6e 73 0a 74 68 65 6e 20 | 74 68 65 20 70 72 69 6d |ns.then |the prim|
|00004510| 69 74 69 76 65 73 20 64 | 69 73 63 75 73 73 65 64 |itives d|iscussed|
|00004520| 20 61 62 6f 76 65 2e 0a | 54 68 69 73 20 73 65 63 | above..|This sec|
|00004530| 74 69 6f 6e 20 69 6e 63 | 6c 75 64 65 73 20 70 72 |tion inc|ludes pr|
|00004540| 69 6d 69 74 69 76 65 73 | 20 66 6f 72 0a 73 74 72 |imitives| for.str|
|00004550| 69 6e 67 73 2c 20 61 72 | 72 61 79 73 2c 20 75 6e |ings, ar|rays, un|
|00004560| 69 6f 6e 73 2c 20 61 6e | 64 20 70 6f 69 6e 74 65 |ions, an|d pointe|
|00004570| 72 73 20 74 6f 20 73 74 | 72 75 63 74 75 72 65 73 |rs to st|ructures|
|00004580| 2e 0a 58 2e 4c 50 0a 43 | 6f 6e 73 74 72 75 63 74 |..X.LP.C|onstruct|
|00004590| 65 64 20 64 61 74 61 20 | 74 79 70 65 20 70 72 69 |ed data |type pri|
|000045a0| 6d 69 74 69 76 65 73 20 | 6d 61 79 20 75 73 65 20 |mitives |may use |
|000045b0| 6d 65 6d 6f 72 79 20 6d | 61 6e 61 67 65 6d 65 6e |memory m|anagemen|
|000045c0| 74 2e 0a 49 6e 20 6d 61 | 6e 79 20 63 61 73 65 73 |t..In ma|ny cases|
|000045d0| 2c 20 6d 65 6d 6f 72 79 | 20 69 73 20 61 6c 6c 6f |, memory| is allo|
|000045e0| 63 61 74 65 64 20 77 68 | 65 6e 20 64 65 73 65 72 |cated wh|en deser|
|000045f0| 69 61 6c 69 7a 69 6e 67 | 20 64 61 74 61 20 77 69 |ializing| data wi|
|00004600| 74 68 0a 58 2e 49 20 58 | 44 52 5f 44 45 43 4f 44 |th.X.I X|DR_DECOD|
|00004610| 45 0a 54 68 65 72 65 66 | 6f 72 65 2c 20 74 68 65 |E.Theref|ore, the|
|00004620| 20 58 44 52 20 70 61 63 | 6b 61 67 65 20 6d 75 73 | XDR pac|kage mus|
|00004630| 74 20 70 72 6f 76 69 64 | 65 20 6d 65 61 6e 73 20 |t provid|e means |
|00004640| 74 6f 20 64 65 61 6c 6c | 6f 63 61 74 65 20 6d 65 |to deall|ocate me|
|00004650| 6d 6f 72 79 2e 0a 54 68 | 69 73 20 69 73 20 64 6f |mory..Th|is is do|
|00004660| 6e 65 20 62 79 20 61 6e | 20 58 44 52 20 6f 70 65 |ne by an| XDR ope|
|00004670| 72 61 74 69 6f 6e 2c 0a | 58 2e 49 20 58 44 52 5f |ration,.|X.I XDR_|
|00004680| 46 52 45 45 0a 54 6f 20 | 72 65 76 69 65 77 2c 20 |FREE.To |review, |
|00004690| 74 68 65 20 74 68 72 65 | 65 20 58 44 52 20 64 69 |the thre|e XDR di|
|000046a0| 72 65 63 74 69 6f 6e 61 | 6c 20 6f 70 65 72 61 74 |rectiona|l operat|
|000046b0| 69 6f 6e 73 20 61 72 65 | 0a 58 2e 49 20 58 44 52 |ions are|.X.I XDR|
|000046c0| 5f 45 4e 43 4f 44 45 20 | 2c 0a 58 2e 49 20 58 44 |_ENCODE |,.X.I XD|
|000046d0| 52 5f 44 45 43 4f 44 45 | 0a 61 6e 64 0a 58 2e 49 |R_DECODE|.and.X.I|
|000046e0| 20 58 44 52 5f 46 52 45 | 45 20 2e 0a 58 2e 0a 58 | XDR_FRE|E ..X..X|
|000046f0| 2e 4e 48 20 33 0a 5c 26 | 53 74 72 69 6e 67 73 0a |.NH 3.\&|Strings.|
|00004700| 58 2e 49 58 20 22 58 44 | 52 20 6c 69 62 72 61 72 |X.IX "XD|R librar|
|00004710| 79 22 20 22 73 74 72 69 | 6e 67 73 22 0a 58 2e 49 |y" "stri|ngs".X.I|
|00004720| 58 20 22 73 74 72 69 6e | 67 73 22 0a 58 2e 4c 50 |X "strin|gs".X.LP|
|00004730| 0a 49 6e 20 43 2c 20 61 | 20 73 74 72 69 6e 67 20 |.In C, a| string |
|00004740| 69 73 20 64 65 66 69 6e | 65 64 20 61 73 20 61 20 |is defin|ed as a |
|00004750| 73 65 71 75 65 6e 63 65 | 20 6f 66 20 62 79 74 65 |sequence| of byte|
|00004760| 73 0a 74 65 72 6d 69 6e | 61 74 65 64 20 62 79 20 |s.termin|ated by |
|00004770| 61 20 6e 75 6c 6c 20 62 | 79 74 65 2c 0a 77 68 69 |a null b|yte,.whi|
|00004780| 63 68 20 69 73 20 6e 6f | 74 20 63 6f 6e 73 69 64 |ch is no|t consid|
|00004790| 65 72 65 64 20 77 68 65 | 6e 20 63 61 6c 63 75 6c |ered whe|n calcul|
|000047a0| 61 74 69 6e 67 20 73 74 | 72 69 6e 67 20 6c 65 6e |ating st|ring len|
|000047b0| 67 74 68 2e 0a 48 6f 77 | 65 76 65 72 2c 20 77 68 |gth..How|ever, wh|
|000047c0| 65 6e 20 61 20 73 74 72 | 69 6e 67 20 69 73 20 70 |en a str|ing is p|
|000047d0| 61 73 73 65 64 20 6f 72 | 20 6d 61 6e 69 70 75 6c |assed or| manipul|
|000047e0| 61 74 65 64 2c 0a 61 20 | 70 6f 69 6e 74 65 72 20 |ated,.a |pointer |
|000047f0| 74 6f 20 69 74 20 69 73 | 20 65 6d 70 6c 6f 79 65 |to it is| employe|
|00004800| 64 2e 0a 54 68 65 72 65 | 66 6f 72 65 2c 20 74 68 |d..There|fore, th|
|00004810| 65 20 58 44 52 20 6c 69 | 62 72 61 72 79 20 64 65 |e XDR li|brary de|
|00004820| 66 69 6e 65 73 20 61 20 | 73 74 72 69 6e 67 20 74 |fines a |string t|
|00004830| 6f 20 62 65 20 61 0a 58 | 2e 49 20 22 63 68 61 72 |o be a.X|.I "char|
|00004840| 0a 61 6e 64 20 6e 6f 74 | 20 61 20 73 65 71 75 65 |.and not| a seque|
|00004850| 6e 63 65 20 6f 66 20 63 | 68 61 72 61 63 74 65 72 |nce of c|haracter|
|00004860| 73 2e 0a 54 68 65 20 65 | 78 74 65 72 6e 61 6c 20 |s..The e|xternal |
|00004870| 72 65 70 72 65 73 65 6e | 74 61 74 69 6f 6e 20 6f |represen|tation o|
|00004880| 66 20 61 20 73 74 72 69 | 6e 67 20 69 73 20 64 72 |f a stri|ng is dr|
|00004890| 61 73 74 69 63 61 6c 6c | 79 20 64 69 66 66 65 72 |asticall|y differ|
|000048a0| 65 6e 74 0a 66 72 6f 6d | 20 69 74 73 20 69 6e 74 |ent.from| its int|
|000048b0| 65 72 6e 61 6c 20 72 65 | 70 72 65 73 65 6e 74 61 |ernal re|presenta|
|000048c0| 74 69 6f 6e 2e 0a 45 78 | 74 65 72 6e 61 6c 6c 79 |tion..Ex|ternally|
|000048d0| 2c 20 73 74 72 69 6e 67 | 73 20 61 72 65 20 72 65 |, string|s are re|
|000048e0| 70 72 65 73 65 6e 74 65 | 64 20 61 73 0a 73 65 71 |presente|d as.seq|
|000048f0| 75 65 6e 63 65 73 20 6f | 66 20 41 53 43 49 49 20 |uences o|f ASCII |
|00004900| 63 68 61 72 61 63 74 65 | 72 73 2c 0a 77 68 69 6c |characte|rs,.whil|
|00004910| 65 20 69 6e 74 65 72 6e | 61 6c 6c 79 2c 20 74 68 |e intern|ally, th|
|00004920| 65 79 20 61 72 65 20 72 | 65 70 72 65 73 65 6e 74 |ey are r|epresent|
|00004930| 65 64 20 77 69 74 68 20 | 63 68 61 72 61 63 74 65 |ed with |characte|
|00004940| 72 20 70 6f 69 6e 74 65 | 72 73 2e 0a 43 6f 6e 76 |r pointe|rs..Conv|
|00004950| 65 72 73 69 6f 6e 20 62 | 65 74 77 65 65 6e 20 74 |ersion b|etween t|
|00004960| 68 65 20 74 77 6f 20 72 | 65 70 72 65 73 65 6e 74 |he two r|epresent|
|00004970| 61 74 69 6f 6e 73 0a 69 | 73 20 61 63 63 6f 6d 70 |ations.i|s accomp|
|00004980| 6c 69 73 68 65 64 20 77 | 69 74 68 20 74 68 65 20 |lished w|ith the |
|00004990| 72 6f 75 74 69 6e 65 0a | 58 2e 49 20 78 64 72 5f |routine.|X.I xdr_|
|000049a0| 73 74 72 69 6e 67 2e 0a | 58 2e 44 53 0a 58 2e 66 |string..|X.DS.X.f|
|000049b0| 74 20 43 57 0a 62 6f 6f | 6c 5f 74 20 78 64 72 5f |t CW.boo|l_t xdr_|
|000049c0| 73 74 72 69 6e 67 28 78 | 64 72 73 2c 20 73 70 2c |string(x|drs, sp,|
|000049d0| 20 6d 61 78 6c 65 6e 67 | 74 68 29 0a 09 58 44 52 | maxleng|th)..XDR|
|000049e0| 20 2a 78 64 72 73 3b 0a | 09 63 68 61 72 20 2a 2a | *xdrs;.|.char **|
|000049f0| 73 70 3b 0a 09 75 5f 69 | 6e 74 20 6d 61 78 6c 65 |sp;..u_i|nt maxle|
|00004a00| 6e 67 74 68 3b 0a 58 2e | 44 45 0a 54 68 65 20 66 |ngth;.X.|DE.The f|
|00004a10| 69 72 73 74 20 70 61 72 | 61 6d 65 74 65 72 0a 58 |irst par|ameter.X|
|00004a20| 2e 49 20 78 64 72 73 20 | 0a 69 73 20 74 68 65 20 |.I xdrs |.is the |
|00004a30| 58 44 52 20 73 74 72 65 | 61 6d 20 68 61 6e 64 6c |XDR stre|am handl|
|00004a40| 65 2e 0a 54 68 65 20 73 | 65 63 6f 6e 64 20 70 61 |e..The s|econd pa|
|00004a50| 72 61 6d 65 74 65 72 0a | 58 2e 49 20 73 70 20 0a |rameter.|X.I sp .|
|00004a60| 69 73 20 61 20 70 6f 69 | 6e 74 65 72 20 74 6f 20 |is a poi|nter to |
|00004a70| 61 20 73 74 72 69 6e 67 | 20 28 74 79 70 65 0a 58 |a string| (type.X|
|00004a80| 2e 49 20 22 63 68 61 72 | 0a 54 68 65 20 74 68 69 |.I "char|.The thi|
|00004a90| 72 64 20 70 61 72 61 6d | 65 74 65 72 0a 58 2e 49 |rd param|eter.X.I|
|00004aa0| 20 6d 61 78 6c 65 6e 67 | 74 68 20 0a 73 70 65 63 | maxleng|th .spec|
|00004ab0| 69 66 69 65 73 20 74 68 | 65 20 6d 61 78 69 6d 75 |ifies th|e maximu|
|00004ac0| 6d 20 6e 75 6d 62 65 72 | 20 6f 66 20 62 79 74 65 |m number| of byte|
|00004ad0| 73 20 61 6c 6c 6f 77 65 | 64 20 64 75 72 69 6e 67 |s allowe|d during|
|00004ae0| 20 65 6e 63 6f 64 69 6e | 67 20 6f 72 20 64 65 63 | encodin|g or dec|
|00004af0| 6f 64 69 6e 67 3b 0a 69 | 74 73 20 76 61 6c 75 65 |oding;.i|ts value|
|00004b00| 20 69 73 20 75 73 75 61 | 6c 6c 79 20 73 70 65 63 | is usua|lly spec|
|00004b10| 69 66 69 65 64 20 62 79 | 20 61 20 70 72 6f 74 6f |ified by| a proto|
|00004b20| 63 6f 6c 2e 0a 46 6f 72 | 20 65 78 61 6d 70 6c 65 |col..For| example|
|00004b30| 2c 20 61 20 70 72 6f 74 | 6f 63 6f 6c 20 73 70 65 |, a prot|ocol spe|
|00004b40| 63 69 66 69 63 61 74 69 | 6f 6e 20 6d 61 79 20 73 |cificati|on may s|
|00004b50| 61 79 0a 74 68 61 74 20 | 61 20 66 69 6c 65 20 6e |ay.that |a file n|
|00004b60| 61 6d 65 20 6d 61 79 20 | 62 65 20 6e 6f 20 6c 6f |ame may |be no lo|
|00004b70| 6e 67 65 72 20 74 68 61 | 6e 20 32 35 35 20 63 68 |nger tha|n 255 ch|
|00004b80| 61 72 61 63 74 65 72 73 | 2e 0a 54 68 65 20 72 6f |aracters|..The ro|
|00004b90| 75 74 69 6e 65 20 72 65 | 74 75 72 6e 73 0a 58 2e |utine re|turns.X.|
|00004ba0| 49 20 46 41 4c 53 45 20 | 0a 69 66 20 74 68 65 20 |I FALSE |.if the |
|00004bb0| 6e 75 6d 62 65 72 20 6f | 66 20 63 68 61 72 61 63 |number o|f charac|
|00004bc0| 74 65 72 73 20 65 78 63 | 65 65 64 73 0a 58 2e 49 |ters exc|eeds.X.I|
|00004bd0| 20 6d 61 78 6c 65 6e 67 | 74 68 20 2c 0a 61 6e 64 | maxleng|th ,.and|
|00004be0| 0a 58 2e 49 20 54 52 55 | 45 20 0a 69 66 20 69 74 |.X.I TRU|E .if it|
|00004bf0| 20 64 6f 65 73 6e 27 74 | 2e 0a 58 2e 4c 50 0a 54 | doesn't|..X.LP.T|
|00004c00| 68 65 20 62 65 68 61 76 | 69 6f 72 20 6f 66 0a 58 |he behav|ior of.X|
|00004c10| 2e 49 20 78 64 72 5f 73 | 74 72 69 6e 67 0a 69 73 |.I xdr_s|tring.is|
|00004c20| 20 73 69 6d 69 6c 61 72 | 20 74 6f 20 74 68 65 20 | similar| to the |
|00004c30| 62 65 68 61 76 69 6f 72 | 20 6f 66 20 6f 74 68 65 |behavior| of othe|
|00004c40| 72 20 72 6f 75 74 69 6e | 65 73 0a 64 69 73 63 75 |r routin|es.discu|
|00004c50| 73 73 65 64 20 69 6e 20 | 74 68 69 73 20 73 65 63 |ssed in |this sec|
|00004c60| 74 69 6f 6e 2e 20 20 54 | 68 65 20 64 69 72 65 63 |tion. T|he direc|
|00004c70| 74 69 6f 6e 0a 58 2e 49 | 20 58 44 52 5f 45 4e 43 |tion.X.I| XDR_ENC|
|00004c80| 4f 44 45 20 0a 69 73 20 | 65 61 73 69 65 73 74 20 |ODE .is |easiest |
|00004c90| 74 6f 20 75 6e 64 65 72 | 73 74 61 6e 64 2e 20 20 |to under|stand. |
|00004ca0| 54 68 65 20 70 61 72 61 | 6d 65 74 65 72 0a 58 2e |The para|meter.X.|
|00004cb0| 49 20 73 70 20 0a 70 6f | 69 6e 74 73 20 74 6f 20 |I sp .po|ints to |
|00004cc0| 61 20 73 74 72 69 6e 67 | 20 6f 66 20 61 20 63 65 |a string| of a ce|
|00004cd0| 72 74 61 69 6e 20 6c 65 | 6e 67 74 68 3b 0a 69 66 |rtain le|ngth;.if|
|00004ce0| 20 74 68 65 20 73 74 72 | 69 6e 67 20 64 6f 65 73 | the str|ing does|
|00004cf0| 20 6e 6f 74 20 65 78 63 | 65 65 64 0a 58 2e 49 20 | not exc|eed.X.I |
|00004d00| 6d 61 78 6c 65 6e 67 74 | 68 20 2c 0a 74 68 65 20 |maxlengt|h ,.the |
|00004d10| 62 79 74 65 73 20 61 72 | 65 20 73 65 72 69 61 6c |bytes ar|e serial|
|00004d20| 69 7a 65 64 2e 0a 58 2e | 4c 50 0a 54 68 65 20 65 |ized..X.|LP.The e|
|00004d30| 66 66 65 63 74 20 6f 66 | 20 64 65 73 65 72 69 61 |ffect of| deseria|
|00004d40| 6c 69 7a 69 6e 67 20 61 | 20 73 74 72 69 6e 67 20 |lizing a| string |
|00004d50| 69 73 20 73 75 62 74 6c | 65 2e 0a 46 69 72 73 74 |is subtl|e..First|
|00004d60| 20 74 68 65 20 6c 65 6e | 67 74 68 20 6f 66 20 74 | the len|gth of t|
|00004d70| 68 65 20 69 6e 63 6f 6d | 69 6e 67 20 73 74 72 69 |he incom|ing stri|
|00004d80| 6e 67 20 69 73 20 64 65 | 74 65 72 6d 69 6e 65 64 |ng is de|termined|
|00004d90| 3b 0a 69 74 20 6d 75 73 | 74 20 6e 6f 74 20 65 78 |;.it mus|t not ex|
|00004da0| 63 65 65 64 0a 58 2e 49 | 20 6d 61 78 6c 65 6e 67 |ceed.X.I| maxleng|
|00004db0| 74 68 20 2e 0a 4e 65 78 | 74 0a 58 2e 49 20 73 70 |th ..Nex|t.X.I sp|
|00004dc0| 20 0a 69 73 20 64 65 72 | 65 66 65 72 65 6e 63 65 | .is der|eference|
|00004dd0| 64 3b 20 69 66 20 74 68 | 65 20 74 68 65 20 76 61 |d; if th|e the va|
|00004de0| 6c 75 65 20 69 73 0a 58 | 2e 49 20 4e 55 4c 4c 20 |lue is.X|.I NULL |
|00004df0| 2c 0a 74 68 65 6e 20 61 | 20 73 74 72 69 6e 67 20 |,.then a| string |
|00004e00| 6f 66 20 74 68 65 20 61 | 70 70 72 6f 70 72 69 61 |of the a|ppropria|
|00004e10| 74 65 20 6c 65 6e 67 74 | 68 20 69 73 20 61 6c 6c |te lengt|h is all|
|00004e20| 6f 63 61 74 65 64 20 61 | 6e 64 0a 58 2e 49 20 2a |ocated a|nd.X.I *|
|00004e30| 73 70 20 0a 69 73 20 73 | 65 74 20 74 6f 20 74 68 |sp .is s|et to th|
|00004e40| 69 73 20 73 74 72 69 6e | 67 2e 0a 49 66 20 74 68 |is strin|g..If th|
|00004e50| 65 20 6f 72 69 67 69 6e | 61 6c 20 76 61 6c 75 65 |e origin|al value|
|00004e60| 20 6f 66 0a 58 2e 49 20 | 2a 73 70 20 0a 69 73 20 | of.X.I |*sp .is |
|00004e70| 6e 6f 6e 2d 6e 75 6c 6c | 2c 20 74 68 65 6e 20 74 |non-null|, then t|
|00004e80| 68 65 20 58 44 52 20 70 | 61 63 6b 61 67 65 20 61 |he XDR p|ackage a|
|00004e90| 73 73 75 6d 65 73 0a 74 | 68 61 74 20 61 20 74 61 |ssumes.t|hat a ta|
|00004ea0| 72 67 65 74 20 61 72 65 | 61 20 68 61 73 20 62 65 |rget are|a has be|
|00004eb0| 65 6e 20 61 6c 6c 6f 63 | 61 74 65 64 2c 0a 77 68 |en alloc|ated,.wh|
|00004ec0| 69 63 68 20 63 61 6e 20 | 68 6f 6c 64 20 73 74 72 |ich can |hold str|
|00004ed0| 69 6e 67 73 20 6e 6f 20 | 6c 6f 6e 67 65 72 20 74 |ings no |longer t|
|00004ee0| 68 61 6e 0a 58 2e 49 20 | 6d 61 78 6c 65 6e 67 74 |han.X.I |maxlengt|
|00004ef0| 68 20 2e 0a 49 6e 20 65 | 69 74 68 65 72 20 63 61 |h ..In e|ither ca|
|00004f00| 73 65 2c 20 74 68 65 20 | 73 74 72 69 6e 67 20 69 |se, the |string i|
|00004f10| 73 20 64 65 63 6f 64 65 | 64 20 69 6e 74 6f 20 74 |s decode|d into t|
|00004f20| 68 65 20 74 61 72 67 65 | 74 20 61 72 65 61 2e 0a |he targe|t area..|
|00004f30| 54 68 65 20 72 6f 75 74 | 69 6e 65 20 74 68 65 6e |The rout|ine then|
|00004f40| 20 61 70 70 65 6e 64 73 | 20 61 20 6e 75 6c 6c 20 | appends| a null |
|00004f50| 63 68 61 72 61 63 74 65 | 72 20 74 6f 20 74 68 65 |characte|r to the|
|00004f60| 20 73 74 72 69 6e 67 2e | 0a 58 2e 4c 50 0a 49 6e | string.|.X.LP.In|
|00004f70| 20 74 68 65 0a 58 2e 49 | 20 58 44 52 5f 46 52 45 | the.X.I| XDR_FRE|
|00004f80| 45 20 0a 6f 70 65 72 61 | 74 69 6f 6e 2c 20 74 68 |E .opera|tion, th|
|00004f90| 65 20 73 74 72 69 6e 67 | 20 69 73 20 6f 62 74 61 |e string| is obta|
|00004fa0| 69 6e 65 64 20 62 79 20 | 64 65 72 65 66 65 72 65 |ined by |derefere|
|00004fb0| 6e 63 69 6e 67 0a 58 2e | 49 20 73 70 20 2e 0a 49 |ncing.X.|I sp ..I|
|00004fc0| 66 20 74 68 65 20 73 74 | 72 69 6e 67 20 69 73 20 |f the st|ring is |
|00004fd0| 6e 6f 74 0a 58 2e 49 20 | 4e 55 4c 4c 20 2c 0a 69 |not.X.I |NULL ,.i|
|00004fe0| 74 20 69 73 20 66 72 65 | 65 64 20 61 6e 64 0a 58 |t is fre|ed and.X|
|00004ff0| 2e 49 20 2a 73 70 20 0a | 69 73 20 73 65 74 20 74 |.I *sp .|is set t|
|00005000| 6f 0a 58 2e 49 20 4e 55 | 4c 4c 20 2e 0a 49 6e 20 |o.X.I NU|LL ..In |
|00005010| 74 68 69 73 20 6f 70 65 | 72 61 74 69 6f 6e 2c 0a |this ope|ration,.|
|00005020| 58 2e 49 20 78 64 72 5f | 73 74 72 69 6e 67 20 0a |X.I xdr_|string .|
|00005030| 69 67 6e 6f 72 65 73 20 | 74 68 65 0a 58 2e 49 20 |ignores |the.X.I |
|00005040| 6d 61 78 6c 65 6e 67 74 | 68 20 0a 70 61 72 61 6d |maxlengt|h .param|
|00005050| 65 74 65 72 2e 0a 58 2e | 0a 58 2e 4e 48 20 33 0a |eter..X.|.X.NH 3.|
|00005060| 5c 26 42 79 74 65 20 41 | 72 72 61 79 73 0a 58 2e |\&Byte A|rrays.X.|
|00005070| 49 58 20 22 58 44 52 20 | 6c 69 62 72 61 72 79 22 |IX "XDR |library"|
|00005080| 20 22 62 79 74 65 20 61 | 72 72 61 79 73 22 0a 58 | "byte a|rrays".X|
|00005090| 2e 49 58 20 22 62 79 74 | 65 20 61 72 72 61 79 73 |.IX "byt|e arrays|
|000050a0| 22 0a 58 2e 4c 50 0a 4f | 66 74 65 6e 20 76 61 72 |".X.LP.O|ften var|
|000050b0| 69 61 62 6c 65 2d 6c 65 | 6e 67 74 68 20 61 72 72 |iable-le|ngth arr|
|000050c0| 61 79 73 20 6f 66 20 62 | 79 74 65 73 20 61 72 65 |ays of b|ytes are|
|000050d0| 20 70 72 65 66 65 72 61 | 62 6c 65 20 74 6f 20 73 | prefera|ble to s|
|000050e0| 74 72 69 6e 67 73 2e 0a | 42 79 74 65 20 61 72 72 |trings..|Byte arr|
|000050f0| 61 79 73 20 64 69 66 66 | 65 72 20 66 72 6f 6d 20 |ays diff|er from |
|00005100| 73 74 72 69 6e 67 73 20 | 69 6e 20 74 68 65 20 66 |strings |in the f|
|00005110| 6f 6c 6c 6f 77 69 6e 67 | 20 74 68 72 65 65 20 77 |ollowing| three w|
|00005120| 61 79 73 3a 20 0a 31 29 | 20 74 68 65 20 6c 65 6e |ays: .1)| the len|
|00005130| 67 74 68 20 6f 66 20 74 | 68 65 20 61 72 72 61 79 |gth of t|he array|
|00005140| 20 28 74 68 65 20 62 79 | 74 65 20 63 6f 75 6e 74 | (the by|te count|
|00005150| 29 20 69 73 20 65 78 70 | 6c 69 63 69 74 6c 79 0a |) is exp|licitly.|
|00005160| 6c 6f 63 61 74 65 64 20 | 69 6e 20 61 6e 20 75 6e |located |in an un|
|00005170| 73 69 67 6e 65 64 20 69 | 6e 74 65 67 65 72 2c 0a |signed i|nteger,.|
|00005180| 32 29 20 74 68 65 20 62 | 79 74 65 20 73 65 71 75 |2) the b|yte sequ|
|00005190| 65 6e 63 65 20 69 73 20 | 6e 6f 74 20 74 65 72 6d |ence is |not term|
|000051a0| 69 6e 61 74 65 64 20 62 | 79 20 61 20 6e 75 6c 6c |inated b|y a null|
|000051b0| 20 63 68 61 72 61 63 74 | 65 72 2c 20 61 6e 64 0a | charact|er, and.|
|000051c0| 33 29 20 74 68 65 20 65 | 78 74 65 72 6e 61 6c 20 |3) the e|xternal |
|000051d0| 72 65 70 72 65 73 65 6e | 74 61 74 69 6f 6e 20 6f |represen|tation o|
|000051e0| 66 20 74 68 65 20 62 79 | 74 65 73 20 69 73 20 74 |f the by|tes is t|
|000051f0| 68 65 20 73 61 6d 65 20 | 61 73 20 74 68 65 69 72 |he same |as their|
|00005200| 0a 69 6e 74 65 72 6e 61 | 6c 20 72 65 70 72 65 73 |.interna|l repres|
|00005210| 65 6e 74 61 74 69 6f 6e | 2e 0a 54 68 65 20 70 72 |entation|..The pr|
|00005220| 69 6d 69 74 69 76 65 0a | 58 2e 49 20 78 64 72 5f |imitive.|X.I xdr_|
|00005230| 62 79 74 65 73 0a 63 6f | 6e 76 65 72 74 73 20 62 |bytes.co|nverts b|
|00005240| 65 74 77 65 65 6e 20 74 | 68 65 20 69 6e 74 65 72 |etween t|he inter|
|00005250| 6e 61 6c 20 61 6e 64 20 | 65 78 74 65 72 6e 61 6c |nal and |external|
|00005260| 0a 72 65 70 72 65 73 65 | 6e 74 61 74 69 6f 6e 73 |.represe|ntations|
|00005270| 20 6f 66 20 62 79 74 65 | 20 61 72 72 61 79 73 3a | of byte| arrays:|
|00005280| 0a 58 2e 44 53 0a 58 2e | 66 74 20 43 57 0a 62 6f |.X.DS.X.|ft CW.bo|
|00005290| 6f 6c 5f 74 20 78 64 72 | 5f 62 79 74 65 73 28 78 |ol_t xdr|_bytes(x|
|000052a0| 64 72 73 2c 20 62 70 70 | 2c 20 6c 70 2c 20 6d 61 |drs, bpp|, lp, ma|
|000052b0| 78 6c 65 6e 67 74 68 29 | 0a 20 20 20 20 58 44 52 |xlength)|. XDR|
|000052c0| 20 2a 78 64 72 73 3b 0a | 20 20 20 20 63 68 61 72 | *xdrs;.| char|
|000052d0| 20 2a 2a 62 70 70 3b 0a | 20 20 20 20 75 5f 69 6e | **bpp;.| u_in|
|000052e0| 74 20 2a 6c 70 3b 0a 20 | 20 20 20 75 5f 69 6e 74 |t *lp;. | u_int|
|000052f0| 20 6d 61 78 6c 65 6e 67 | 74 68 3b 0a 58 2e 44 45 | maxleng|th;.X.DE|
|00005300| 0a 54 68 65 20 75 73 61 | 67 65 20 6f 66 20 74 68 |.The usa|ge of th|
|00005310| 65 20 66 69 72 73 74 2c | 20 73 65 63 6f 6e 64 20 |e first,| second |
|00005320| 61 6e 64 20 66 6f 75 72 | 74 68 20 70 61 72 61 6d |and four|th param|
|00005330| 65 74 65 72 73 0a 61 72 | 65 20 69 64 65 6e 74 69 |eters.ar|e identi|
|00005340| 63 61 6c 20 74 6f 20 74 | 68 65 20 66 69 72 73 74 |cal to t|he first|
|00005350| 2c 20 73 65 63 6f 6e 64 | 20 61 6e 64 20 74 68 69 |, second| and thi|
|00005360| 72 64 20 70 61 72 61 6d | 65 74 65 72 73 20 6f 66 |rd param|eters of|
|00005370| 0a 58 2e 49 20 78 64 72 | 5f 73 74 72 69 6e 67 20 |.X.I xdr|_string |
|00005380| 2c 0a 72 65 73 70 65 63 | 74 69 76 65 6c 79 2e 0a |,.respec|tively..|
|00005390| 54 68 65 20 6c 65 6e 67 | 74 68 20 6f 66 20 74 68 |The leng|th of th|
|000053a0| 65 20 62 79 74 65 20 61 | 72 65 61 20 69 73 20 6f |e byte a|rea is o|
|000053b0| 62 74 61 69 6e 65 64 20 | 62 79 20 64 65 72 65 66 |btained |by deref|
|000053c0| 65 72 65 6e 63 69 6e 67 | 0a 58 2e 49 20 6c 70 20 |erencing|.X.I lp |
|000053d0| 0a 77 68 65 6e 20 73 65 | 72 69 61 6c 69 7a 69 6e |.when se|rializin|
|000053e0| 67 3b 0a 58 2e 49 20 2a | 6c 70 20 0a 69 73 20 73 |g;.X.I *|lp .is s|
|000053f0| 65 74 20 74 6f 20 74 68 | 65 20 62 79 74 65 20 6c |et to th|e byte l|
|00005400| 65 6e 67 74 68 20 77 68 | 65 6e 20 64 65 73 65 72 |ength wh|en deser|
|00005410| 69 61 6c 69 7a 69 6e 67 | 2e 0a 58 2e 0a 58 2e 4e |ializing|..X..X.N|
|00005420| 48 20 33 0a 5c 26 41 72 | 72 61 79 73 0a 58 2e 49 |H 3.\&Ar|rays.X.I|
|00005430| 58 20 22 58 44 52 20 6c | 69 62 72 61 72 79 22 20 |X "XDR l|ibrary" |
|00005440| 22 61 72 72 61 79 73 22 | 0a 58 2e 49 58 20 22 61 |"arrays"|.X.IX "a|
|00005450| 72 72 61 79 73 22 0a 58 | 2e 4c 50 0a 54 68 65 20 |rrays".X|.LP.The |
|00005460| 58 44 52 20 6c 69 62 72 | 61 72 79 20 70 61 63 6b |XDR libr|ary pack|
|00005470| 61 67 65 20 70 72 6f 76 | 69 64 65 73 20 61 20 70 |age prov|ides a p|
|00005480| 72 69 6d 69 74 69 76 65 | 0a 66 6f 72 20 68 61 6e |rimitive|.for han|
|00005490| 64 6c 69 6e 67 20 61 72 | 72 61 79 73 20 6f 66 20 |dling ar|rays of |
|000054a0| 61 72 62 69 74 72 61 72 | 79 20 65 6c 65 6d 65 6e |arbitrar|y elemen|
|000054b0| 74 73 2e 0a 54 68 65 0a | 58 2e 49 20 78 64 72 5f |ts..The.|X.I xdr_|
|000054c0| 62 79 74 65 73 0a 72 6f | 75 74 69 6e 65 20 74 72 |bytes.ro|utine tr|
|000054d0| 65 61 74 73 20 61 20 73 | 75 62 73 65 74 20 6f 66 |eats a s|ubset of|
|000054e0| 20 67 65 6e 65 72 69 63 | 20 61 72 72 61 79 73 2c | generic| arrays,|
|000054f0| 0a 69 6e 20 77 68 69 63 | 68 20 74 68 65 20 73 69 |.in whic|h the si|
|00005500| 7a 65 20 6f 66 20 61 72 | 72 61 79 20 65 6c 65 6d |ze of ar|ray elem|
|00005510| 65 6e 74 73 20 69 73 20 | 6b 6e 6f 77 6e 20 74 6f |ents is |known to|
|00005520| 20 62 65 20 31 2c 0a 61 | 6e 64 20 74 68 65 20 65 | be 1,.a|nd the e|
|00005530| 78 74 65 72 6e 61 6c 20 | 64 65 73 63 72 69 70 74 |xternal |descript|
|00005540| 69 6f 6e 20 6f 66 20 65 | 61 63 68 20 65 6c 65 6d |ion of e|ach elem|
|00005550| 65 6e 74 20 69 73 20 62 | 75 69 6c 74 2d 69 6e 2e |ent is b|uilt-in.|
|00005560| 0a 54 68 65 20 67 65 6e | 65 72 69 63 20 61 72 72 |.The gen|eric arr|
|00005570| 61 79 20 70 72 69 6d 69 | 74 69 76 65 2c 0a 58 2e |ay primi|tive,.X.|
|00005580| 49 20 78 64 72 5f 61 72 | 72 61 79 0a 72 65 71 75 |I xdr_ar|ray.requ|
|00005590| 69 72 65 73 20 70 61 72 | 61 6d 65 74 65 72 73 20 |ires par|ameters |
|000055a0| 69 64 65 6e 74 69 63 61 | 6c 20 74 6f 20 74 68 6f |identica|l to tho|
|000055b0| 73 65 20 6f 66 0a 58 2e | 49 20 78 64 72 5f 62 79 |se of.X.|I xdr_by|
|000055c0| 74 65 73 0a 70 6c 75 73 | 20 74 77 6f 20 6d 6f 72 |tes.plus| two mor|
|000055d0| 65 3a 0a 74 68 65 20 73 | 69 7a 65 20 6f 66 20 61 |e:.the s|ize of a|
|000055e0| 72 72 61 79 20 65 6c 65 | 6d 65 6e 74 73 2c 0a 61 |rray ele|ments,.a|
|000055f0| 6e 64 20 61 6e 20 58 44 | 52 20 72 6f 75 74 69 6e |nd an XD|R routin|
|00005600| 65 20 74 6f 20 68 61 6e | 64 6c 65 20 65 61 63 68 |e to han|dle each|
|00005610| 20 6f 66 20 74 68 65 20 | 65 6c 65 6d 65 6e 74 73 | of the |elements|
|00005620| 2e 0a 54 68 69 73 20 72 | 6f 75 74 69 6e 65 20 69 |..This r|outine i|
|00005630| 73 20 63 61 6c 6c 65 64 | 20 74 6f 20 65 6e 63 6f |s called| to enco|
|00005640| 64 65 20 6f 72 20 64 65 | 63 6f 64 65 0a 65 61 63 |de or de|code.eac|
|00005650| 68 20 65 6c 65 6d 65 6e | 74 20 6f 66 20 74 68 65 |h elemen|t of the|
|00005660| 20 61 72 72 61 79 2e 0a | 58 2e 44 53 0a 58 2e 66 | array..|X.DS.X.f|
|00005670| 74 20 43 57 0a 62 6f 6f | 6c 5f 74 0a 78 64 72 5f |t CW.boo|l_t.xdr_|
|00005680| 61 72 72 61 79 28 78 64 | 72 73 2c 20 61 70 2c 20 |array(xd|rs, ap, |
|00005690| 6c 70 2c 20 6d 61 78 6c | 65 6e 67 74 68 2c 20 65 |lp, maxl|ength, e|
|000056a0| 6c 65 6d 65 6e 74 73 69 | 7a 2c 20 78 64 72 5f 65 |lementsi|z, xdr_e|
|000056b0| 6c 65 6d 65 6e 74 29 0a | 20 20 20 20 58 44 52 20 |lement).| XDR |
|000056c0| 2a 78 64 72 73 3b 0a 20 | 20 20 20 63 68 61 72 20 |*xdrs;. | char |
|000056d0| 2a 2a 61 70 3b 0a 20 20 | 20 20 75 5f 69 6e 74 20 |**ap;. | u_int |
|000056e0| 2a 6c 70 3b 0a 20 20 20 | 20 75 5f 69 6e 74 20 6d |*lp;. | u_int m|
|000056f0| 61 78 6c 65 6e 67 74 68 | 3b 0a 20 20 20 20 75 5f |axlength|;. u_|
|00005700| 69 6e 74 20 65 6c 65 6d | 65 6e 74 73 69 7a 3b 0a |int elem|entsiz;.|
|00005710| 20 20 20 20 62 6f 6f 6c | 5f 74 20 28 2a 78 64 72 | bool|_t (*xdr|
|00005720| 5f 65 6c 65 6d 65 6e 74 | 29 28 29 3b 0a 58 2e 44 |_element|)();.X.D|
|00005730| 45 0a 54 68 65 20 70 61 | 72 61 6d 65 74 65 72 0a |E.The pa|rameter.|
|00005740| 58 2e 49 20 61 70 20 0a | 69 73 20 74 68 65 20 61 |X.I ap .|is the a|
|00005750| 64 64 72 65 73 73 20 6f | 66 20 74 68 65 20 70 6f |ddress o|f the po|
|00005760| 69 6e 74 65 72 20 74 6f | 20 74 68 65 20 61 72 72 |inter to| the arr|
|00005770| 61 79 2e 0a 49 66 0a 58 | 2e 49 20 2a 61 70 20 0a |ay..If.X|.I *ap .|
|00005780| 69 73 0a 58 2e 49 20 4e | 55 4c 4c 20 0a 77 68 65 |is.X.I N|ULL .whe|
|00005790| 6e 20 74 68 65 20 61 72 | 72 61 79 20 69 73 20 62 |n the ar|ray is b|
|000057a0| 65 69 6e 67 20 64 65 73 | 65 72 69 61 6c 69 7a 65 |eing des|erialize|
|000057b0| 64 2c 0a 58 44 52 20 61 | 6c 6c 6f 63 61 74 65 73 |d,.XDR a|llocates|
|000057c0| 20 61 6e 20 61 72 72 61 | 79 20 6f 66 20 74 68 65 | an arra|y of the|
|000057d0| 20 61 70 70 72 6f 70 72 | 69 61 74 65 20 73 69 7a | appropr|iate siz|
|000057e0| 65 20 61 6e 64 20 73 65 | 74 73 0a 58 2e 49 20 2a |e and se|ts.X.I *|
|000057f0| 61 70 20 0a 74 6f 20 74 | 68 61 74 20 61 72 72 61 |ap .to t|hat arra|
|00005800| 79 2e 0a 54 68 65 20 65 | 6c 65 6d 65 6e 74 20 63 |y..The e|lement c|
|00005810| 6f 75 6e 74 20 6f 66 20 | 74 68 65 20 61 72 72 61 |ount of |the arra|
|00005820| 79 20 69 73 20 6f 62 74 | 61 69 6e 65 64 20 66 72 |y is obt|ained fr|
|00005830| 6f 6d 0a 58 2e 49 20 2a | 6c 70 20 0a 77 68 65 6e |om.X.I *|lp .when|
|00005840| 20 74 68 65 20 61 72 72 | 61 79 20 69 73 20 73 65 | the arr|ay is se|
|00005850| 72 69 61 6c 69 7a 65 64 | 3b 0a 58 2e 49 20 2a 6c |rialized|;.X.I *l|
|00005860| 70 20 0a 69 73 20 73 65 | 74 20 74 6f 20 74 68 65 |p .is se|t to the|
|00005870| 20 61 72 72 61 79 20 6c | 65 6e 67 74 68 20 77 68 | array l|ength wh|
|00005880| 65 6e 20 74 68 65 20 61 | 72 72 61 79 20 69 73 20 |en the a|rray is |
|00005890| 64 65 73 65 72 69 61 6c | 69 7a 65 64 2e 20 0a 54 |deserial|ized. .T|
|000058a0| 68 65 20 70 61 72 61 6d | 65 74 65 72 0a 58 2e 49 |he param|eter.X.I|
|000058b0| 20 6d 61 78 6c 65 6e 67 | 74 68 20 0a 69 73 20 74 | maxleng|th .is t|
|000058c0| 68 65 20 6d 61 78 69 6d | 75 6d 20 6e 75 6d 62 65 |he maxim|um numbe|
|000058d0| 72 20 6f 66 20 65 6c 65 | 6d 65 6e 74 73 20 74 68 |r of ele|ments th|
|000058e0| 61 74 20 74 68 65 20 61 | 72 72 61 79 20 69 73 20 |at the a|rray is |
|000058f0| 61 6c 6c 6f 77 65 64 20 | 74 6f 20 68 61 76 65 3b |allowed |to have;|
|00005900| 0a 58 2e 49 20 65 6c 65 | 6d 65 6e 74 73 69 7a 0a |.X.I ele|mentsiz.|
|00005910| 69 73 20 74 68 65 20 62 | 79 74 65 20 73 69 7a 65 |is the b|yte size|
|00005920| 20 6f 66 20 65 61 63 68 | 20 65 6c 65 6d 65 6e 74 | of each| element|
|00005930| 20 6f 66 20 74 68 65 20 | 61 72 72 61 79 0a 28 74 | of the |array.(t|
|00005940| 68 65 20 43 20 66 75 6e | 63 74 69 6f 6e 0a 58 2e |he C fun|ction.X.|
|00005950| 49 20 73 69 7a 65 6f 66 | 0a 63 61 6e 20 62 65 20 |I sizeof|.can be |
|00005960| 75 73 65 64 20 74 6f 20 | 6f 62 74 61 69 6e 20 74 |used to |obtain t|
|00005970| 68 69 73 20 76 61 6c 75 | 65 29 2e 0a 54 68 65 20 |his valu|e)..The |
|00005980| 72 6f 75 74 69 6e 65 0a | 58 2e 49 20 78 64 72 5f |routine.|X.I xdr_|
|00005990| 65 6c 65 6d 65 6e 74 0a | 69 73 20 63 61 6c 6c 65 |element.|is calle|
|000059a0| 64 20 74 6f 20 73 65 72 | 69 61 6c 69 7a 65 2c 20 |d to ser|ialize, |
|000059b0| 64 65 73 65 72 69 61 6c | 69 7a 65 2c 20 6f 72 20 |deserial|ize, or |
|000059c0| 66 72 65 65 0a 65 61 63 | 68 20 65 6c 65 6d 65 6e |free.eac|h elemen|
|000059d0| 74 20 6f 66 20 74 68 65 | 20 61 72 72 61 79 2e 0a |t of the| array..|
|000059e0| 58 2e 0a 58 2e 4c 50 0a | 42 65 66 6f 72 65 20 64 |X..X.LP.|Before d|
|000059f0| 65 66 69 6e 69 6e 67 20 | 6d 6f 72 65 20 63 6f 6e |efining |more con|
|00005a00| 73 74 72 75 63 74 65 64 | 20 64 61 74 61 20 74 79 |structed| data ty|
|00005a10| 70 65 73 2c 20 69 74 20 | 69 73 20 61 70 70 72 6f |pes, it |is appro|
|00005a20| 70 72 69 61 74 65 20 74 | 6f 20 0a 70 72 65 73 65 |priate t|o .prese|
|00005a30| 6e 74 20 74 68 72 65 65 | 20 65 78 61 6d 70 6c 65 |nt three| example|
|00005a40| 73 2e 0a 58 2e 4c 50 0a | 58 2e 49 20 22 45 78 61 |s..X.LP.|X.I "Exa|
|00005a50| 6d 70 6c 65 20 41 3a 22 | 0a 58 2e 62 72 0a 41 20 |mple A:"|.X.br.A |
|00005a60| 75 73 65 72 20 6f 6e 20 | 61 20 6e 65 74 77 6f 72 |user on |a networ|
|00005a70| 6b 65 64 20 6d 61 63 68 | 69 6e 65 20 63 61 6e 20 |ked mach|ine can |
|00005a80| 62 65 20 69 64 65 6e 74 | 69 66 69 65 64 20 62 79 |be ident|ified by|
|00005a90| 20 0a 28 61 29 20 74 68 | 65 20 6d 61 63 68 69 6e | .(a) th|e machin|
|00005aa0| 65 20 6e 61 6d 65 2c 20 | 73 75 63 68 20 61 73 0a |e name, |such as.|
|00005ab0| 58 2e 49 20 6b 72 79 70 | 74 6f 6e 20 3a 0a 73 65 |X.I kryp|ton :.se|
|00005ac0| 65 20 74 68 65 0a 58 2e | 49 20 67 65 74 68 6f 73 |e the.X.|I gethos|
|00005ad0| 74 6e 61 6d 65 20 0a 6d | 61 6e 20 70 61 67 65 3b |tname .m|an page;|
|00005ae0| 20 28 62 29 20 74 68 65 | 20 75 73 65 72 27 73 20 | (b) the| user's |
|00005af0| 55 49 44 3a 20 73 65 65 | 20 74 68 65 0a 58 2e 49 |UID: see| the.X.I|
|00005b00| 20 67 65 74 65 75 69 64 | 20 0a 6d 61 6e 20 70 61 | geteuid| .man pa|
|00005b10| 67 65 3b 20 61 6e 64 20 | 28 63 29 20 74 68 65 20 |ge; and |(c) the |
|00005b20| 67 72 6f 75 70 20 6e 75 | 6d 62 65 72 73 20 74 6f |group nu|mbers to|
|00005b30| 20 77 68 69 63 68 20 74 | 68 65 20 75 73 65 72 20 | which t|he user |
|00005b40| 62 65 6c 6f 6e 67 73 3a | 20 0a 73 65 65 20 74 68 |belongs:| .see th|
|00005b50| 65 0a 58 2e 49 20 67 65 | 74 67 72 6f 75 70 73 20 |e.X.I ge|tgroups |
|00005b60| 0a 6d 61 6e 20 70 61 67 | 65 2e 20 20 41 20 73 74 |.man pag|e. A st|
|00005b70| 72 75 63 74 75 72 65 20 | 77 69 74 68 20 74 68 69 |ructure |with thi|
|00005b80| 73 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 61 6e |s inform|ation an|
|00005b90| 64 20 69 74 73 20 61 73 | 73 6f 63 69 61 74 65 64 |d its as|sociated|
|00005ba0| 20 0a 58 44 52 20 72 6f | 75 74 69 6e 65 20 63 6f | .XDR ro|utine co|
|00005bb0| 75 6c 64 20 62 65 20 63 | 6f 64 65 64 20 6c 69 6b |uld be c|oded lik|
|00005bc0| 65 20 74 68 69 73 3a 0a | 58 2e 69 65 20 74 20 2e |e this:.|X.ie t .|
|00005bd0| 44 53 0a 58 2e 65 6c 20 | 2e 44 53 20 4c 0a 58 2e |DS.X.el |.DS L.X.|
|00005be0| 66 74 20 43 57 0a 73 74 | 72 75 63 74 20 6e 65 74 |ft CW.st|ruct net|
|00005bf0| 75 73 65 72 20 7b 0a 20 | 20 20 20 63 68 61 72 20 |user {. | char |
|00005c00| 20 20 20 2a 6e 75 5f 6d | 61 63 68 69 6e 65 6e 61 | *nu_m|achinena|
|00005c10| 6d 65 3b 0a 20 20 20 20 | 69 6e 74 20 20 20 20 20 |me;. |int |
|00005c20| 6e 75 5f 75 69 64 3b 0a | 20 20 20 20 75 5f 69 6e |nu_uid;.| u_in|
|00005c30| 74 20 20 20 6e 75 5f 67 | 6c 65 6e 3b 0a 20 20 20 |t nu_g|len;. |
|00005c40| 20 69 6e 74 20 20 20 20 | 20 2a 6e 75 5f 67 69 64 | int | *nu_gid|
|00005c50| 73 3b 0a 7d 3b 0a 23 64 | 65 66 69 6e 65 20 4e 4c |s;.};.#d|efine NL|
|00005c60| 45 4e 20 32 35 35 20 20 | 20 20 2f 2a 20 5c 66 49 |EN 255 | /* \fI|
|00005c70| 6d 61 63 68 69 6e 65 20 | 6e 61 6d 65 73 20 3c 20 |machine |names < |
|00005c80| 32 35 36 20 63 68 61 72 | 73 5c 66 50 20 2a 2f 0a |256 char|s\fP */.|
|00005c90| 23 64 65 66 69 6e 65 20 | 4e 47 52 50 53 20 32 30 |#define |NGRPS 20|
|00005ca0| 20 20 20 20 2f 2a 20 5c | 66 49 75 73 65 72 20 63 | /* \|fIuser c|
|00005cb0| 61 6e 27 74 20 62 65 20 | 69 6e 20 3e 20 32 30 20 |an't be |in > 20 |
|00005cc0| 67 72 6f 75 70 73 5c 66 | 50 20 2a 2f 0a 58 2e 73 |groups\f|P */.X.s|
|00005cd0| 70 2e 35 0a 62 6f 6f 6c | 5f 74 0a 78 64 72 5f 6e |p.5.bool|_t.xdr_n|
|00005ce0| 65 74 75 73 65 72 28 78 | 64 72 73 2c 20 6e 75 70 |etuser(x|drs, nup|
|00005cf0| 29 0a 20 20 20 20 58 44 | 52 20 2a 78 64 72 73 3b |). XD|R *xdrs;|
|00005d00| 0a 20 20 20 20 73 74 72 | 75 63 74 20 6e 65 74 75 |. str|uct netu|
|00005d10| 73 65 72 20 2a 6e 75 70 | 3b 0a 7b 0a 20 20 20 20 |ser *nup|;.{. |
|00005d20| 72 65 74 75 72 6e 28 78 | 64 72 5f 73 74 72 69 6e |return(x|dr_strin|
|00005d30| 67 28 78 64 72 73 2c 20 | 26 6e 75 70 2d 3e 6e 75 |g(xdrs, |&nup->nu|
|00005d40| 5f 6d 61 63 68 69 6e 65 | 6e 61 6d 65 2c 20 4e 4c |_machine|name, NL|
|00005d50| 45 4e 29 20 26 26 0a 20 | 20 20 20 20 20 20 20 78 |EN) &&. | x|
|00005d60| 64 72 5f 69 6e 74 28 78 | 64 72 73 2c 20 26 6e 75 |dr_int(x|drs, &nu|
|00005d70| 70 2d 3e 6e 75 5f 75 69 | 64 29 20 26 26 0a 20 20 |p->nu_ui|d) &&. |
|00005d80| 20 20 20 20 20 20 78 64 | 72 5f 61 72 72 61 79 28 | xd|r_array(|
|00005d90| 78 64 72 73 2c 20 26 6e | 75 70 2d 3e 6e 75 5f 67 |xdrs, &n|up->nu_g|
|00005da0| 69 64 73 2c 20 26 6e 75 | 70 2d 3e 6e 75 5f 67 6c |ids, &nu|p->nu_gl|
|00005db0| 65 6e 2c 20 0a 20 20 20 | 20 20 20 20 20 4e 47 52 |en, . | NGR|
|00005dc0| 50 53 2c 20 73 69 7a 65 | 6f 66 20 28 69 6e 74 29 |PS, size|of (int)|
|00005dd0| 2c 20 78 64 72 5f 69 6e | 74 29 29 3b 0a 7d 0a 58 |, xdr_in|t));.}.X|
|00005de0| 2e 44 45 0a 58 2e 4c 50 | 0a 58 2e 49 20 22 45 78 |.DE.X.LP|.X.I "Ex|
|00005df0| 61 6d 70 6c 65 20 42 3a | 22 0a 58 2e 62 72 0a 41 |ample B:|".X.br.A|
|00005e00| 20 70 61 72 74 79 20 6f | 66 20 6e 65 74 77 6f 72 | party o|f networ|
|00005e10| 6b 20 75 73 65 72 73 20 | 63 6f 75 6c 64 20 62 65 |k users |could be|
|00005e20| 20 69 6d 70 6c 65 6d 65 | 6e 74 65 64 0a 61 73 20 | impleme|nted.as |
|00005e30| 61 6e 20 61 72 72 61 79 | 20 6f 66 0a 58 2e 49 20 |an array| of.X.I |
|00005e40| 6e 65 74 75 73 65 72 0a | 73 74 72 75 63 74 75 72 |netuser.|structur|
|00005e50| 65 2e 0a 54 68 65 20 64 | 65 63 6c 61 72 61 74 69 |e..The d|eclarati|
|00005e60| 6f 6e 20 61 6e 64 20 69 | 74 73 20 61 73 73 6f 63 |on and i|ts assoc|
|00005e70| 69 61 74 65 64 20 58 44 | 52 20 72 6f 75 74 69 6e |iated XD|R routin|
|00005e80| 65 73 0a 61 72 65 20 61 | 73 20 66 6f 6c 6c 6f 77 |es.are a|s follow|
|00005e90| 73 3a 0a 58 2e 69 65 20 | 74 20 2e 44 53 0a 58 2e |s:.X.ie |t .DS.X.|
|00005ea0| 65 6c 20 2e 44 53 20 4c | 0a 58 2e 66 74 20 43 57 |el .DS L|.X.ft CW|
|00005eb0| 0a 73 74 72 75 63 74 20 | 70 61 72 74 79 20 7b 0a |.struct |party {.|
|00005ec0| 20 20 20 20 75 5f 69 6e | 74 20 70 5f 6c 65 6e 3b | u_in|t p_len;|
|00005ed0| 0a 20 20 20 20 73 74 72 | 75 63 74 20 6e 65 74 75 |. str|uct netu|
|00005ee0| 73 65 72 20 2a 70 5f 6e | 75 73 65 72 73 3b 0a 7d |ser *p_n|users;.}|
|00005ef0| 3b 0a 23 64 65 66 69 6e | 65 20 50 4c 45 4e 20 35 |;.#defin|e PLEN 5|
|00005f00| 30 30 20 20 20 20 2f 2a | 20 5c 66 49 6d 61 78 20 |00 /*| \fImax |
|00005f10| 6e 75 6d 62 65 72 20 6f | 66 20 75 73 65 72 73 20 |number o|f users |
|00005f20| 69 6e 20 61 20 70 61 72 | 74 79 5c 66 50 20 2a 2f |in a par|ty\fP */|
|00005f30| 0a 58 2e 73 70 2e 35 0a | 62 6f 6f 6c 5f 74 0a 78 |.X.sp.5.|bool_t.x|
|00005f40| 64 72 5f 70 61 72 74 79 | 28 78 64 72 73 2c 20 70 |dr_party|(xdrs, p|
|00005f50| 70 29 0a 20 20 20 20 58 | 44 52 20 2a 78 64 72 73 |p). X|DR *xdrs|
|00005f60| 3b 0a 20 20 20 20 73 74 | 72 75 63 74 20 70 61 72 |;. st|ruct par|
|00005f70| 74 79 20 2a 70 70 3b 0a | 7b 0a 20 20 20 20 72 65 |ty *pp;.|{. re|
|00005f80| 74 75 72 6e 28 78 64 72 | 5f 61 72 72 61 79 28 78 |turn(xdr|_array(x|
|00005f90| 64 72 73 2c 20 26 70 70 | 2d 3e 70 5f 6e 75 73 65 |drs, &pp|->p_nuse|
|00005fa0| 72 73 2c 20 26 70 70 2d | 3e 70 5f 6c 65 6e 2c 20 |rs, &pp-|>p_len, |
|00005fb0| 50 4c 45 4e 2c 0a 20 20 | 20 20 20 20 20 20 73 69 |PLEN,. | si|
|00005fc0| 7a 65 6f 66 20 28 73 74 | 72 75 63 74 20 6e 65 74 |zeof (st|ruct net|
|00005fd0| 75 73 65 72 29 2c 20 78 | 64 72 5f 6e 65 74 75 73 |user), x|dr_netus|
|00005fe0| 65 72 29 29 3b 0a 7d 0a | 58 2e 44 45 0a 58 2e 4c |er));.}.|X.DE.X.L|
|00005ff0| 50 0a 58 2e 49 20 22 45 | 78 61 6d 70 6c 65 20 43 |P.X.I "E|xample C|
|00006000| 3a 22 0a 58 2e 62 72 0a | 54 68 65 20 77 65 6c 6c |:".X.br.|The well|
|00006010| 2d 6b 6e 6f 77 6e 20 70 | 61 72 61 6d 65 74 65 72 |-known p|arameter|
|00006020| 73 20 74 6f 0a 58 2e 49 | 20 6d 61 69 6e 20 2c 0a |s to.X.I| main ,.|
|00006030| 58 2e 49 20 61 72 67 63 | 0a 61 6e 64 0a 58 2e 49 |X.I argc|.and.X.I|
|00006040| 20 61 72 67 76 0a 63 61 | 6e 20 62 65 20 63 6f 6d | argv.ca|n be com|
|00006050| 62 69 6e 65 64 20 69 6e | 74 6f 20 61 20 73 74 72 |bined in|to a str|
|00006060| 75 63 74 75 72 65 2e 0a | 41 6e 20 61 72 72 61 79 |ucture..|An array|
|00006070| 20 6f 66 20 74 68 65 73 | 65 20 73 74 72 75 63 74 | of thes|e struct|
|00006080| 75 72 65 73 20 63 61 6e | 20 6d 61 6b 65 20 75 70 |ures can| make up|
|00006090| 20 61 20 68 69 73 74 6f | 72 79 20 6f 66 20 63 6f | a histo|ry of co|
|000060a0| 6d 6d 61 6e 64 73 2e 0a | 54 68 65 20 64 65 63 6c |mmands..|The decl|
|000060b0| 61 72 61 74 69 6f 6e 73 | 20 61 6e 64 20 58 44 52 |arations| and XDR|
|000060c0| 20 72 6f 75 74 69 6e 65 | 73 20 6d 69 67 68 74 20 | routine|s might |
|000060d0| 6c 6f 6f 6b 20 6c 69 6b | 65 3a 0a 58 2e 69 65 20 |look lik|e:.X.ie |
|000060e0| 74 20 2e 44 53 0a 58 2e | 65 6c 20 2e 44 53 20 4c |t .DS.X.|el .DS L|
|000060f0| 0a 58 2e 66 74 20 43 57 | 0a 73 74 72 75 63 74 20 |.X.ft CW|.struct |
|00006100| 63 6d 64 20 7b 0a 20 20 | 20 20 75 5f 69 6e 74 20 |cmd {. | u_int |
|00006110| 63 5f 61 72 67 63 3b 0a | 20 20 20 20 63 68 61 72 |c_argc;.| char|
|00006120| 20 2a 2a 63 5f 61 72 67 | 76 3b 0a 7d 3b 0a 23 64 | **c_arg|v;.};.#d|
|00006130| 65 66 69 6e 65 20 41 4c | 45 4e 20 31 30 30 30 20 |efine AL|EN 1000 |
|00006140| 20 20 2f 2a 20 5c 66 49 | 61 72 67 73 20 63 61 6e | /* \fI|args can|
|00006150| 6e 6f 74 20 62 65 20 3e | 20 31 30 30 30 20 63 68 |not be >| 1000 ch|
|00006160| 61 72 73 5c 66 50 20 2a | 2f 0a 23 64 65 66 69 6e |ars\fP *|/.#defin|
|00006170| 65 20 4e 41 52 47 43 20 | 31 30 30 20 20 20 2f 2a |e NARGC |100 /*|
|00006180| 20 5c 66 49 63 6f 6d 6d | 61 6e 64 73 20 63 61 6e | \fIcomm|ands can|
|00006190| 6e 6f 74 20 68 61 76 65 | 20 3e 20 31 30 30 20 61 |not have| > 100 a|
|000061a0| 72 67 73 5c 66 50 20 2a | 2f 0a 0a 73 74 72 75 63 |rgs\fP *|/..struc|
|000061b0| 74 20 68 69 73 74 6f 72 | 79 20 7b 0a 20 20 20 20 |t histor|y {. |
|000061c0| 75 5f 69 6e 74 20 68 5f | 6c 65 6e 3b 0a 20 20 20 |u_int h_|len;. |
|000061d0| 20 73 74 72 75 63 74 20 | 63 6d 64 20 2a 68 5f 63 | struct |cmd *h_c|
|000061e0| 6d 64 73 3b 0a 7d 3b 0a | 23 64 65 66 69 6e 65 20 |mds;.};.|#define |
|000061f0| 4e 43 4d 44 53 20 37 35 | 20 20 20 20 2f 2a 20 5c |NCMDS 75| /* \|
|00006200| 66 49 68 69 73 74 6f 72 | 79 20 69 73 20 6e 6f 20 |fIhistor|y is no |
|00006210| 6d 6f 72 65 20 74 68 61 | 6e 20 37 35 20 63 6f 6d |more tha|n 75 com|
|00006220| 6d 61 6e 64 73 5c 66 50 | 20 2a 2f 0a 0a 62 6f 6f |mands\fP| */..boo|
|00006230| 6c 5f 74 0a 78 64 72 5f | 77 72 61 70 5f 73 74 72 |l_t.xdr_|wrap_str|
|00006240| 69 6e 67 28 78 64 72 73 | 2c 20 73 70 29 0a 20 20 |ing(xdrs|, sp). |
|00006250| 20 20 58 44 52 20 2a 78 | 64 72 73 3b 0a 20 20 20 | XDR *x|drs;. |
|00006260| 20 63 68 61 72 20 2a 2a | 73 70 3b 0a 7b 0a 20 20 | char **|sp;.{. |
|00006270| 20 20 72 65 74 75 72 6e | 28 78 64 72 5f 73 74 72 | return|(xdr_str|
|00006280| 69 6e 67 28 78 64 72 73 | 2c 20 73 70 2c 20 41 4c |ing(xdrs|, sp, AL|
|00006290| 45 4e 29 29 3b 0a 7d 0a | 58 2e 44 45 0a 58 2e 69 |EN));.}.|X.DE.X.i|
|000062a0| 65 20 74 20 2e 44 53 0a | 58 2e 65 6c 20 2e 44 53 |e t .DS.|X.el .DS|
|000062b0| 20 4c 0a 58 2e 66 74 20 | 43 57 0a 62 6f 6f 6c 5f | L.X.ft |CW.bool_|
|000062c0| 74 0a 78 64 72 5f 63 6d | 64 28 78 64 72 73 2c 20 |t.xdr_cm|d(xdrs, |
|000062d0| 63 70 29 0a 20 20 20 20 | 58 44 52 20 2a 78 64 72 |cp). |XDR *xdr|
|000062e0| 73 3b 0a 20 20 20 20 73 | 74 72 75 63 74 20 63 6d |s;. s|truct cm|
|000062f0| 64 20 2a 63 70 3b 0a 7b | 0a 20 20 20 20 72 65 74 |d *cp;.{|. ret|
|00006300| 75 72 6e 28 78 64 72 5f | 61 72 72 61 79 28 78 64 |urn(xdr_|array(xd|
|00006310| 72 73 2c 20 26 63 70 2d | 3e 63 5f 61 72 67 76 2c |rs, &cp-|>c_argv,|
|00006320| 20 26 63 70 2d 3e 63 5f | 61 72 67 63 2c 20 4e 41 | &cp->c_|argc, NA|
|00006330| 52 47 43 2c 0a 20 20 20 | 20 20 20 20 20 73 69 7a |RGC,. | siz|
|00006340| 65 6f 66 20 28 63 68 61 | 72 20 2a 29 2c 20 78 64 |eof (cha|r *), xd|
|00006350| 72 5f 77 72 61 70 5f 73 | 74 72 69 6e 67 29 29 3b |r_wrap_s|tring));|
|00006360| 0a 7d 0a 58 2e 44 45 0a | 58 2e 69 65 20 74 20 2e |.}.X.DE.|X.ie t .|
|00006370| 44 53 0a 58 2e 65 6c 20 | 2e 44 53 20 4c 0a 58 2e |DS.X.el |.DS L.X.|
|00006380| 66 74 20 43 57 0a 62 6f | 6f 6c 5f 74 0a 78 64 72 |ft CW.bo|ol_t.xdr|
|00006390| 5f 68 69 73 74 6f 72 79 | 28 78 64 72 73 2c 20 68 |_history|(xdrs, h|
|000063a0| 70 29 0a 20 20 20 20 58 | 44 52 20 2a 78 64 72 73 |p). X|DR *xdrs|
|000063b0| 3b 0a 20 20 20 20 73 74 | 72 75 63 74 20 68 69 73 |;. st|ruct his|
|000063c0| 74 6f 72 79 20 2a 68 70 | 3b 0a 7b 0a 20 20 20 20 |tory *hp|;.{. |
|000063d0| 72 65 74 75 72 6e 28 78 | 64 72 5f 61 72 72 61 79 |return(x|dr_array|
|000063e0| 28 78 64 72 73 2c 20 26 | 68 70 2d 3e 68 5f 63 6d |(xdrs, &|hp->h_cm|
|000063f0| 64 73 2c 20 26 68 70 2d | 3e 68 5f 6c 65 6e 2c 20 |ds, &hp-|>h_len, |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.