Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Canonicalize-CIDR/XPL0/canonicalize-cidr.xpl0
Normal file
32
Task/Canonicalize-CIDR/XPL0/canonicalize-cidr.xpl0
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
proc Canonicalize(IPAddr);
|
||||
char IPAddr;
|
||||
int N, I, HostBits;
|
||||
[Text(0, IPAddr);
|
||||
Text(0, " ^i-> "); \^i = tab
|
||||
OpenO(8);
|
||||
Text(8, IPAddr); \ASCII out
|
||||
OpenI(8);
|
||||
N:= 0;
|
||||
for I:= 0 to 3 do
|
||||
N:= N<<8 + IntIn(8); \binary in
|
||||
HostBits:= IntIn(8);
|
||||
N:= N & -1<<(32-HostBits);
|
||||
for I:= 3 downto 0 do
|
||||
[IntOut(0, N>>(I*8) & $FF);
|
||||
ChOut(0, if I = 0 then ^/ else ^.);
|
||||
];
|
||||
IntOut(0, HostBits);
|
||||
CrLf(0);
|
||||
];
|
||||
|
||||
int IPAddrs, I;
|
||||
[IPAddrs:= [
|
||||
"87.70.141.1/22",
|
||||
"36.18.154.103/12",
|
||||
"62.62.197.11/29",
|
||||
"67.137.119.181/4",
|
||||
"161.214.74.21/24",
|
||||
"184.232.176.184/18" ];
|
||||
for I:= 0 to 6-1 do
|
||||
Canonicalize(IPAddrs(I));
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue