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 92 by Douglas Thrift, 2004-03-01T23:23:39-08:00

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines