SpiderScript! (with a sample script)
[tpg/acess2.git] / Usermode / Libraries / libspiderscript.so_src / Scripts / sample.isc
1
2 # Should I use brackets in this language?
3 # Well, considering that all whitespace is ignored, it might be an idea
4
5 # Well, it would make VVV a little simpler
6 # Just define a funciton with the name 'Sys.IO.Open'
7 # Not a namespace Sys, with a child Sys
8
9 $fp = Sys.IO.Open( "/Devices/ipstack" );
10 $ifname = Sys.IO.IOCtl( $fp, 4, "/Devices/ne2k/0" );
11 Sys.IO.Close($fp);
12
13 # Let's see:
14 #   b - Signed 8-bit integer, B - unsigned
15 #   w - 16 bit
16 #   l - 32 bit
17 #   q - 64 bit
18 #   f - 32-bit float
19 #   d - 64-bit double
20 #   Fields can be prefixed by a size for arrays (taking only one argument)
21 #   * indicates a variable size array
22 # E.g.
23 #  Sys.Mem.MakeStruct( "L*B", $len, $len, $str );
24 # Hmm.. that would mean I will need arrays... fuck it, do them later
25
26 function SetIPv4($ifaceName, $addr)
27 {
28         $fp = Sys.IO.Open( "/Devices/ipstack/$ifaceName" );
29         $data = Lang.MakeStruct( "l", 4 );
30         Sys.IO.IOCtl( $fp, 4, $data );
31         $data = Lang.Struct( "BBBB", $addr[0],  $addr[1],  $addr[2], $addr[3] );
32         Sys.IO.IOCtl( $fp, 6, $data );
33         Sys.IO.Close( $fp );
34 }
35
36 SetIPv4( $ifname, Lang.Array(10, 0, 2, 55) );

UCC git Repository :: git.ucc.asn.au