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 90 by Douglas Thrift, 2004-03-01T19:40:25-08:00 vs.
Revision 100 by Douglas Thrift, 2004-03-02T01:35:17-08:00

# Line 16 | Line 16 | public class HostUpdateSharp
16   {
17          public static void Main(string[] args)
18          {
19 +                foreach (string arg in args)
20 +                {
21 +                        switch (arg)
22 +                        {
23 +                        case "-D":
24 +                                debug = true;
25 +                                break;
26 +                        default:
27 +                                uname = arg;
28 +                                break;
29 +                        }
30 +                }
31 +
32                  try
33                  {
34                          new HostUpdateSharp();
# Line 32 | Line 45 | public class HostUpdateSharp
45                          host.Append(".local.douglasthrift.net");
46                  }
47  
48 +                WebHeaderCollection headers = new WebHeaderCollection();
49 +
50 +                headers.Add("Authorization", "Basic " + Convert.ToBase64String((new
51 +                        ASCIIEncoding()).GetBytes("HostUpdate:frell2003")));
52 +
53                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
54  
55                  request.Accept = "text/plain";
56                  request.ContentLength = host.Length;
57                  request.ContentType = "application/x-www-form-urlencoded";
58 <                request.Credentials = new NetworkCredential("HostUpdate", "frell2003");
58 >                request.Headers = headers;
59                  request.KeepAlive = false;
60                  request.Method = "POST";
43                request.PreAuthenticate = true;
61                  request.UserAgent = "Host Update Sharp/1.0 (" + platform() + ')';
62  
63                  StreamWriter post = new StreamWriter(request.GetRequestStream(),
# Line 54 | Line 71 | public class HostUpdateSharp
71                  StreamReader content = new StreamReader(response.GetResponseStream(),
72                          Encoding.ASCII);
73  
74 <                Console.Write(content.ReadToEnd());
74 > #if _FreeBSD_
75 >                if (debug) Console.Write(content.ReadToEnd());
76 > #else
77 >                if (debug) MessageBox.Show(content.ReadToEnd(), "Host Update Sharp",
78 >                        MessageBoxButtons.OK, MessageBoxIcon.Information);
79 > #endif
80 >
81                  content.Close();
82          }
83 +        private static bool debug = false;
84 +        private static string uname = "";
85   #if _FreeBSD_
86 <        private string platform() { return "FreeBSD 4.9-STABLE i386"; }
62 < #else
63 <        private string platform()
86 >        private static string platform()
87          {
88 <                OperatingSystem os = Environment.OSVersion;
66 <                string system = "Unknown";
67 <
68 <                switch (os.Platform)
88 >                if (uname == "")
89                  {
90 <                case PlatformID.Win32NT:
71 <                        system = "Windows NT";
72 <                        break;
73 <                case PlatformID.Win32Windows:
74 <                        system = "Windows";
75 <                        break;
90 >                        "Unknown 0.0 x86";
91                  }
92 <
93 <                int major = os.Version.Major, minor = os.Version.Minor;
94 <                string version = os + "";
95 <
96 <                switch (system)
92 >        }
93 > #else
94 >        private static string platform()
95 >        {
96 >                if (uname == "")
97                  {
98 <                case "Windows NT":
99 <                        switch (major)
98 >                        OperatingSystem os = Environment.OSVersion;
99 >                        string system = "Unknown";
100 >
101 >                        switch (os.Platform)
102                          {
103 <                        case 5:
104 <                                switch (minor)
105 <                                {
106 <                                case 0:
107 <                                        version = "Windows 2000";
91 <                                        break;
92 <                                case 1:
93 <                                        version = "Windows XP";
94 <                                        break;
95 <                                case 2:
96 <                                        version = "Windows .NET Server";
97 <                                        break;
98 <                                }
103 >                        case PlatformID.Win32NT:
104 >                                system = "Windows NT";
105 >                                break;
106 >                        case PlatformID.Win32Windows:
107 >                                system = "Windows";
108                                  break;
109                          }
110 <                        break;
111 <                case "Windows":
112 <                        if (major == 4)
104 <                        {
105 <                                switch (minor)
106 <                                {
107 <                                case 10:
108 <                                        version = " Windows 98";
109 <                                        break;
110 <                                case 90:
111 <                                        version = " Windows ME";
112 <                                        break;
113 <                                }
114 <                        }
115 <                        break;
110 >
111 >                        uname = system + ' ' + os.Version.Major + '.' + os.Version.Minor +
112 >                                " x86";
113                  }
114  
115 <                return system + ' ' + major + '.' + minor + " [" + version + "] ix86";
115 >                return uname;
116          }
117   #endif
118   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines