Oberon/A2/Oberon.TFTPTool.Mod

MODULE TFTPTool IN Oberon;	(** be **) IMPORT In, Out, IP IN A2, TFTP IN A2; PROCEDURE Send*; VAR fnl, fnr&#58; ARRAY 128 OF CHAR; fipstr&#58; ARRAY 64 OF CHAR; fip&#58; IP.Adr; BEGIN &#9;In.Open; In.String(fnl); In.String(fnr); In.String(fipstr); &#9;IF In.Done THEN &#9;&#9;fip &#58;&#61; IP.StrToAdr(fipstr); &#9;&#9;IF (&#126;IP.IsNilAdr(fip)) THEN &#9;&#9;&#9;Out.String("Sending &#39;"); Out.String(fnl); Out.String("&#39; to "); Out.String(fipstr); Out.String("..."); &#9;&#9;&#9;IF TFTP.Send(fnl, fnr, fip) THEN Out.String(" success.") &#9;&#9;&#9;ELSE Out.String("error; check kernel log.") &#9;&#9;&#9;END &#9;&#9;ELSE Out.String("Invalid IP") &#9;&#9;END &#9;ELSE Out.String(&#39;Invalid parameters. Syntax&#58; TestTFTP.Send "&#60;localfilename&#62;" "&#60;remotefilename&#62;" "&#60;ip&#62;"&#39;) &#9;END; &#9;Out.Ln END Send; PROCEDURE Receive*; VAR fnl, fnr&#58; ARRAY 128 OF CHAR; fipstr&#58; ARRAY 64 OF CHAR; fip&#58; IP.Adr; BEGIN &#9;In.Open; In.String(fnr); In.String(fnl); In.String(fipstr); &#9;IF In.Done THEN &#9;&#9;fip &#58;&#61; IP.StrToAdr(fipstr); &#9;&#9;IF (&#126;IP.IsNilAdr(fip)) THEN &#9;&#9;&#9;Out.String("Receiving &#39;"); Out.String(fnl); Out.String("&#39; from "); Out.String(fipstr); Out.String("..."); &#9;&#9;&#9;IF TFTP.Receive(fnr, fnl, fip) THEN Out.String(" success.") &#9;&#9;&#9;ELSE Out.String("error; check kernel log.") &#9;&#9;&#9;END &#9;&#9;ELSE Out.String("Invalid IP") &#9;&#9;END &#9;ELSE Out.String(&#39;Invalid parameters. Syntax&#58; TestTFTP.Receive "&#60;remotefilename&#62;" "&#60;localfilename&#62;" "&#60;ip&#62;"&#39;) &#9;END; &#9;Out.Ln END Receive; END TFTPTool. System.Free TestTFTP TFTP &#126; TFTP.TraceLevel1 TFTP.TraceLevel2 TFTP.TraceLevel3 TFTPTool.Send "AOS&#58;AosOberon.zip" "FAT&#58;/AosOberon.zip" "10.0.0.4" &#126; TFTPTool.Receive "FAT&#58;/AosOberon.zip" "AOS&#58;AosOberon.zip" "10.0.0.4" &#126;