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 88 by Douglas Thrift, 2004-03-01T19:03:40-08:00 vs.
Revision 98 by Douglas Thrift, 2004-03-02T01:17:58-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 +                        }
27 +                }
28 +
29 +                try
30 +                {
31 +                        new HostUpdateSharp();
32 +                }
33 +                catch (Exception exception) { Console.Error.WriteLine(exception); }
34 +        }
35 +        public HostUpdateSharp()
36 +        {
37                  StringBuilder host = new StringBuilder("host=" + Dns.GetHostName());
38                  string url = "http://topsecret.douglasthrift.net/auth/hostupdate.cgi";
39  
# Line 24 | Line 42 | public class HostUpdateSharp
42                          host.Append(".local.douglasthrift.net");
43                  }
44  
45 +                WebHeaderCollection headers = new WebHeaderCollection();
46 +
47 +                headers.Add("Authorization", "Basic " + Convert.ToBase64String((new
48 +                        ASCIIEncoding()).GetBytes("HostUpdate:frell2003")));
49 +
50                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
51  
52                  request.Accept = "text/plain";
53                  request.ContentLength = host.Length;
54                  request.ContentType = "application/x-www-form-urlencoded";
55 <                request.Credentials = new NetworkCredential("HostUpdate", "frell2003");
55 >                request.Headers = headers;
56                  request.KeepAlive = false;
57                  request.Method = "POST";
35                request.PreAuthenticate = true;
58                  request.UserAgent = "Host Update Sharp/1.0 (" + platform() + ')';
59  
60                  StreamWriter post = new StreamWriter(request.GetRequestStream(),
# Line 46 | Line 68 | public class HostUpdateSharp
68                  StreamReader content = new StreamReader(response.GetResponseStream(),
69                          Encoding.ASCII);
70  
71 <                Console.Write(content.ReadToEnd());
71 > #if _FreeBSD_
72 >                if (debug) Console.Write(content.ReadToEnd());
73 > #else
74 >                if (debug) MessageBox.Show(content.ReadToEnd(), "Host Update Sharp",
75 >                        MessageBoxButtons.OK, MessageBoxIcon.Information);
76 > #endif
77 >
78 >                content.Close();
79          }
80 +        private static bool debug = false;
81   #if _FreeBSD_
82 <        private static string platform() { return "FreeBSD 4.9-STABLE i386"; }
82 >        private string platform() { return "FreeBSD 4.9-STABLE i386"; }
83   #else
84 <        private static string platform()
84 >        private string platform()
85          {
86                  OperatingSystem os = Environment.OSVersion;
87                  string system = "Unknown";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines