Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/system/Basis/Implementation/Sockets/host-db.sml
ViewVC logotype

Diff of /sml/trunk/src/system/Basis/Implementation/Sockets/host-db.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1392, Wed Sep 24 21:56:14 2003 UTC revision 1393, Fri Sep 26 17:00:32 2003 UTC
# Line 15  Line 15 
15    
16      fun netdbFun x = CInterface.c_function "SMLNJ-Sockets" x      fun netdbFun x = CInterface.c_function "SMLNJ-Sockets" x
17    
18      type in_addr = PreSock.in_addr      type in_addr = Socket.in_addr
19      type addr_family = PreSock.addr_family      type addr_family = Socket.AF.addr_family
20    
21      datatype entry = HOSTENT of {      datatype entry = HOSTENT of {
22            name : string,            name : string,
# Line 37  Line 37 
37    
38    (* Host DB query functions *)    (* Host DB query functions *)
39      local      local
40        type hostent = (string * string list * PreSock.af * PreSock.addr list)        type hostent = (string * string list * Socket.af * Socket.addr list)
41        fun getHostEnt NONE = NONE        fun getHostEnt NONE = NONE
42          | getHostEnt (SOME(name, aliases, addrType, addrs)) = SOME(HOSTENT{          | getHostEnt (SOME(name, aliases, addrType, addrs)) = SOME(HOSTENT{
43                name = name, aliases = aliases,                name = name, aliases = aliases,
44                addrType = PreSock.AF addrType,                addrType = Socket.AF.AF addrType,
45                addrs = List.map PreSock.INADDR addrs                addrs = List.map Socket.INADDR addrs
46              })              })
47        val getHostByName' : string -> hostent option = netdbFun "getHostByName"        val getHostByName' : string -> hostent option = netdbFun "getHostByName"
48        val getHostByAddr' : PreSock.addr -> hostent option = netdbFun "getHostByAddr"        val getHostByAddr' : Socket.addr -> hostent option = netdbFun "getHostByAddr"
49      in      in
50      val getByName = getHostEnt o getHostByName'      val getByName = getHostEnt o getHostByName'
51      fun getByAddr (PreSock.INADDR addr) = getHostEnt(getHostByAddr' addr)      fun getByAddr (Socket.INADDR addr) = getHostEnt(getHostByAddr' addr)
52      end (* local *)      end (* local *)
53    
54      fun scan getc strm = let      fun scan getc strm = let
55            fun w2b w = Word8.fromLargeWord(SysW.toLargeWord w)            fun w2b w = Word8.fromLargeWord(SysW.toLargeWord w)
56            fun getB (w, shft) = SysW.andb(SysW.>>(w, shft), 0wxFF)            fun getB (w, shft) = SysW.andb(SysW.>>(w, shft), 0wxFF)
57            fun mkAddr (a, b, c, d) = PreSock.INADDR(Word8Vector.fromList[            fun mkAddr (a, b, c, d) = Socket.INADDR(Word8Vector.fromList[
58                    w2b a, w2b b, w2b c, w2b d                    w2b a, w2b b, w2b c, w2b d
59                  ])                  ])
60            in            in
61              case (PreSock.toWords getc strm)              case (Socket.toWords getc strm)
62               of SOME([a, b, c, d], strm) =>               of SOME([a, b, c, d], strm) =>
63                    SOME(mkAddr(a, b, c, d), strm)                    SOME(mkAddr(a, b, c, d), strm)
64                | SOME([a, b, c], strm) =>                | SOME([a, b, c], strm) =>
# Line 73  Line 73 
73    
74      val fromString = StringCvt.scanString scan      val fromString = StringCvt.scanString scan
75    
76      fun toString (PreSock.INADDR addr) = let      fun toString (Socket.INADDR addr) = let
77            fun get i = Word8Vector.sub(addr, i)            fun get i = Word8Vector.sub(addr, i)
78            in            in
79              PreSock.fromBytes(get 0, get 1, get 2, get 3)              Socket.fromBytes(get 0, get 1, get 2, get 3)
80            end            end
81    
82      val getHostName : unit -> string = netdbFun "getHostName"      val getHostName : unit -> string = netdbFun "getHostName"

Legend:
Removed from v.1392  
changed lines
  Added in v.1393

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0