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 76 by Douglas Thrift, 2004-02-28T00:34:19-08:00 vs.
Revision 93 by Douglas Thrift, 2004-03-01T23:37:27-08:00

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

Comparing HostUpdateSharp/HostUpdateSharp.cs (property svn:eol-style):
Revision 76 by Douglas Thrift, 2004-02-28T00:34:19-08:00 vs.
Revision 93 by Douglas Thrift, 2004-03-01T23:37:27-08:00

# Line 0 | Line 1
1 + native

Comparing HostUpdateSharp/HostUpdateSharp.cs (property svn:keywords):
Revision 76 by Douglas Thrift, 2004-02-28T00:34:19-08:00 vs.
Revision 93 by Douglas Thrift, 2004-03-01T23:37:27-08:00

# Line 0 | Line 1
1 + Id

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines