EnglishРусский  

   ..

   ftp.g

   http.g

   ping.g

   proxy.g

   socket.g

   strinet.g

Bookmark and Share

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

 1 
 2 include : $"..\registry\registry.g"
 3 
 4 define <export>
 5 {
 6    PROXY_HTTP  = 0x0001   
 7    PROXY_FTP   = 0x0002
 8    PROXY_ALL   = 0x0003       // для всех протоколов
 9    PROXY_EXPLORER  = 0x0080   // Взять данные из Explorera
10 }
11 
12 operator proxyinfo =( proxyinfo left right )
13 {
14    left.host = right.host
15    left.port = right.port
16    left.enable = right.enable
17    return left
18 }
19 
20 func uint inet_proxy( uint flag, str proxyname )
21 {
22    arrstr     shostport
23    proxyinfo  ieproxy
24    str        regie  stemp
25    uint       i
26    
27    regie = $"Software\Microsoft\Windows\CurrentVersion\Internet Settings"
28    
29    ieproxy.enable = 1
30    if flag & $PROXY_EXPLORER
31    {
32       ieproxy.enable = reggetnumdef( $HKEY_CURRENT_USER, regie,
33                                      "ProxyEnable", 0 )
34       stemp.regget( $HKEY_CURRENT_USER, regie, "ProxyServer" )
35    }
36    else : stemp = proxyname
37 
38    stemp.split( shostport, ':', $SPLIT_FIRST | $SPLIT_NOSYS )
39    ieproxy.host = shostport[0]
40    if *shostport > 1 : ieproxy.port = uint( shostport[1] )  
41 
42    if flag & $PROXY_HTTP : proxy[ $INET_HTTP ] = ieproxy
43    if flag & $PROXY_FTP : proxy[ $INET_FTP ] = ieproxy
44 
45    return 1
46 }
47 
48 method uint socket.urlconnect( str url host path )
49 {
50    str   port
51    uint  protocol = $INET_HTTP
52    uint  defport = 80
53    
54    this.flag &= ~$SOCKF_PROXY
55    if url.iurl( host, port, path ) == $INET_FTP 
56    {
57       this.flag |= $SOCKF_FTP
58    } 
59    if this.flag & $SOCKF_FTP : protocol = $INET_FTP; defport = 21
60 
61    if proxy[ protocol ].enable
62    {
63       this.flag |= $SOCKF_PROXY
64       this.host = proxy[ protocol ].host
65       this.port = proxy[ protocol ].port
66    }
67    else
68    {
69       this.host = host
70       this.port = ?( !*port, defport, uint( port ))
71    }
72    if *port : host += ":\(port)"
73 //   print("URL: \(this.host):\(this.port)\n")   
74    return this.connect()
75 }
76 
77 func uint inet_proxyenable( uint flag, uint enable )
78 {
79    uint i
80 
81    if flag & $PROXY_HTTP 
82    {
83       if !*proxy[ $INET_HTTP ].host : return 0
84       proxy[ $INET_HTTP ].enable = enable
85    }
86    if flag & $PROXY_FTP 
87    {
88       if !*proxy[ $INET_FTP ].host : return 0
89       proxy[ $INET_FTP ].enable = enable
90    }
91    return 1   
92 }