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 77 by Douglas Thrift, 2004-02-28T00:37:46-08:00 vs.
Revision 88 by Douglas Thrift, 2004-03-01T19:03:40-08:00

# Line 7 | Line 7
7   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 < namespace DouglasThrift.HostUpdateSharp
15 > public class HostUpdateSharp
16   {
17 <        public class HostUpdateSharp
17 >        public static void Main(string[] args)
18          {
19 <                public static void Main(string[] args)
19 >                StringBuilder host = new StringBuilder("host=" + Dns.GetHostName());
20 >                string url = "http://topsecret.douglasthrift.net/auth/hostupdate.cgi";
21 >
22 >                if ((host + "").IndexOf('.') < 0)
23 >                {
24 >                        host.Append(".local.douglasthrift.net");
25 >                }
26 >
27 >                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
28 >
29 >                request.Accept = "text/plain";
30 >                request.ContentLength = host.Length;
31 >                request.ContentType = "application/x-www-form-urlencoded";
32 >                request.Credentials = new NetworkCredential("HostUpdate", "frell2003");
33 >                request.KeepAlive = false;
34 >                request.Method = "POST";
35 >                request.PreAuthenticate = true;
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 <                        //
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