ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/HostUpdateSharp/HostUpdateSharp.cs
(Generate patch)

Comparing HostUpdateSharp/HostUpdateSharp.cs (file contents):
Revision 87 by Douglas Thrift, 2004-03-01T17:22:53-08:00 vs.
Revision 88 by Douglas Thrift, 2004-03-01T19:03:40-08:00

# Line 8 | Line 8 | using System;
8   using System.IO;
9   using System.Net;
10   using System.Text;
11 + #if !_FreeBSD_
12 + using System.Windows.Forms;
13 + #endif
14  
15   public class HostUpdateSharp
16   {
17          public static void Main(string[] args)
18          {
16 #if _FreeBSD_
17                String os = "FreeBSD 4.9-STABLE i386";
18 #else
19                OperatingSystem os = Environment.OSVersion;
20 #endif
19                  StringBuilder host = new StringBuilder("host=" + Dns.GetHostName());
20                  string url = "http://topsecret.douglasthrift.net/auth/hostupdate.cgi";
21  
22 <                if (host.ToString().IndexOf('.') < 0)
22 >                if ((host + "").IndexOf('.') < 0)
23                  {
24                          host.Append(".local.douglasthrift.net");
25                  }
26  
29                Console.WriteLine(host);
30                Console.WriteLine(os);
31
27                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
28  
29                  request.Accept = "text/plain";
# Line 38 | Line 33 | public class HostUpdateSharp
33                  request.KeepAlive = false;
34                  request.Method = "POST";
35                  request.PreAuthenticate = true;
36 <                request.UserAgent = "Host Update Sharp/1.0 (" + os + ")";
36 >                request.UserAgent = "Host Update Sharp/1.0 (" + platform() + ')';
37 >
38 >                StreamWriter post = new StreamWriter(request.GetRequestStream(),
39 >                        Encoding.ASCII);
40 >
41 >                post.Write(host);
42 >                post.Close();
43 >
44 >                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
45 >
46 >                StreamReader content = new StreamReader(response.GetResponseStream(),
47 >                        Encoding.ASCII);
48 >
49 >                Console.Write(content.ReadToEnd());
50          }
51 + #if _FreeBSD_
52 +        private static string platform() { return "FreeBSD 4.9-STABLE i386"; }
53 + #else
54 +        private static string platform()
55 +        {
56 +                OperatingSystem os = Environment.OSVersion;
57 +                string system = "Unknown";
58 +
59 +                switch (os.Platform)
60 +                {
61 +                case PlatformID.Win32NT:
62 +                        system = "Windows NT";
63 +                        break;
64 +                case PlatformID.Win32Windows:
65 +                        system = "Windows";
66 +                        break;
67 +                }
68 +
69 +                int major = os.Version.Major, minor = os.Version.Minor;
70 +                string version = os + "";
71 +
72 +                switch (system)
73 +                {
74 +                case "Windows NT":
75 +                        switch (major)
76 +                        {
77 +                        case 5:
78 +                                switch (minor)
79 +                                {
80 +                                case 0:
81 +                                        version = "Windows 2000";
82 +                                        break;
83 +                                case 1:
84 +                                        version = "Windows XP";
85 +                                        break;
86 +                                case 2:
87 +                                        version = "Windows .NET Server";
88 +                                        break;
89 +                                }
90 +                                break;
91 +                        }
92 +                        break;
93 +                case "Windows":
94 +                        if (major == 4)
95 +                        {
96 +                                switch (minor)
97 +                                {
98 +                                case 10:
99 +                                        version = " Windows 98";
100 +                                        break;
101 +                                case 90:
102 +                                        version = " Windows ME";
103 +                                        break;
104 +                                }
105 +                        }
106 +                        break;
107 +                }
108 +
109 +                return system + ' ' + major + '.' + minor + " [" + version + "] ix86";
110 +        }
111 + #endif
112   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines