Author: robertj
Date: 2007-10-21 18:39:07 -0400 (Sun, 21 Oct 2007)
New Revision: 87877

Added:
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs.in
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/Makefile.am
   
branches/robertj/xsp/src/Mono.WebServer.FastCgi/Mono.WebServer.FastCgi.sources
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/main.cs
Removed:
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/server.cs
Modified:
   branches/robertj/xsp/src/ChangeLog
   branches/robertj/xsp/src/Makefile.am
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.cs
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.xml
   branches/robertj/xsp/src/Mono.WebServer.FastCgi/Responder.cs
Log:
2007-10-22  Robert Jordan  <[EMAIL PROTECTED]>

        * Makefile.am: FastCGI -> FastCgi.

        * Mono.WebServer.FastCgi/Makefile.am:
        * Mono.WebServer.FastCgi/*.sources:
        * Mono.WebServer.FastCgi/AssemblyInfo.cs.in:
        Create.
        
        * Mono.WebServer.FastCgi/ConfigurationManager.xml:
        Add some default values to be able to get rid of
        the exe.config file. Comment out the automapping settings.
        
        * Mono.WebServer.FastCgi/ConfigurationManager.cs:
        Implement ImportSettings (). Support for default settings
        specified in ConfigurationManaged.xml.
        
        * Mono.WebServer.FastCgi/main.cs:
        * Mono.WebServer.FastCgi/Responder.cs:
        Take the ApplicationManager
        out of the build until its automapping issues are fixed.
        
        * Mono.WebServer.FastCgi/server.cs: Rename to main.cs



Modified: branches/robertj/xsp/src/ChangeLog
===================================================================
--- branches/robertj/xsp/src/ChangeLog  2007-10-21 22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/ChangeLog  2007-10-21 22:39:07 UTC (rev 87877)
@@ -1,5 +1,29 @@
 2007-10-22  Robert Jordan  <[EMAIL PROTECTED]>
 
+       * Makefile.am: FastCGI -> FastCgi.
+
+       * Mono.WebServer.FastCgi/Makefile.am:
+       * Mono.WebServer.FastCgi/*.sources:
+       * Mono.WebServer.FastCgi/AssemblyInfo.cs.in:
+       Create.
+       
+       * Mono.WebServer.FastCgi/ConfigurationManager.xml:
+       Add some default values to be able to get rid of
+       the exe.config file. Comment out the automapping settings.
+       
+       * Mono.WebServer.FastCgi/ConfigurationManager.cs:
+       Implement ImportSettings (). Support for default settings
+       specified in ConfigurationManaged.xml.
+       
+       * Mono.WebServer.FastCgi/main.cs:
+       * Mono.WebServer.FastCgi/Responder.cs:
+       Take the ApplicationManager
+       out of the build until its automapping issues are fixed.
+       
+       * Mono.WebServer.FastCgi/server.cs: Rename to main.cs
+
+2007-10-22  Robert Jordan  <[EMAIL PROTECTED]>
+
        * Mono.WebServer.FastCgi: Import Brian's files from his google
        repository. Flatten hierarchies to adhere to mono's standards.
        Disintegrate the Mono.FastCgi assembly.

Modified: branches/robertj/xsp/src/Makefile.am
===================================================================
--- branches/robertj/xsp/src/Makefile.am        2007-10-21 22:26:08 UTC (rev 
87876)
+++ branches/robertj/xsp/src/Makefile.am        2007-10-21 22:39:07 UTC (rev 
87877)
@@ -1,7 +1,7 @@
 if XSP_ONLY
 SUBDIRS=Mono.WebServer Mono.WebServer.XSP
 else
-SUBDIRS=Mono.WebServer Mono.WebServer.XSP Mono.WebServer.Apache 
Mono.WebServer.FastCGI
+SUBDIRS=Mono.WebServer Mono.WebServer.XSP Mono.WebServer.Apache 
Mono.WebServer.FastCgi
 endif
 
 EXTRA_DIST = mono.pub mono.snk

Deleted: branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs     
2007-10-21 22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs     
2007-10-21 22:39:07 UTC (rev 87877)
@@ -1,6 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-[assembly:AssemblyTitle("Mono.FastCgi Library")]
-[assembly:AssemblyDescription("A .NET implementation of the FastCGI 1.0 
Specification")]
-[assembly:AssemblyCopyright("2007 Brian Nickel")]

Added: branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs.in
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs.in  
2007-10-21 22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs.in  
2007-10-21 22:39:07 UTC (rev 87877)
@@ -0,0 +1,9 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("@VERSION@")]
+[assembly: AssemblyTitle("Mono.WebServer.FastCGI")]
+[assembly: AssemblyDescription("FastCGI Backend for XSP")]
+[assembly: AssemblyCopyright("2007 Brian Nickel")]
+[assembly: AssemblyDelaySign(true)]
+[assembly: AssemblyKeyFile("@top_srcdir@/src/mono.pub")]


Property changes on: 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/AssemblyInfo.cs.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.cs
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.cs     
2007-10-21 22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.cs     
2007-10-21 22:39:07 UTC (rev 87877)
@@ -20,12 +20,35 @@
                
                private NameValueCollection xml_args =
                        new NameValueCollection ();
+
+               private NameValueCollection default_args =
+                       new NameValueCollection ();
                
                public ConfigurationManager (Assembly asm, string resource)
                {
                        XmlDocument doc = new XmlDocument ();
                        doc.Load (asm.GetManifestResourceStream (resource));
+                       ImportSettings (doc, default_args, true, false);
+
+               }
+
+               void ImportSettings (XmlDocument doc, NameValueCollection 
collection,
+                                    bool allowDuplicates, bool 
insertEmptyValue)
+               {
                        elems = doc.GetElementsByTagName ("Setting");
+                       foreach (XmlElement setting in elems) {
+                               string name = GetXmlValue (setting, "Name");
+                               string value = GetXmlValue (setting, "Value");
+                               if (name.Length == 0)
+                                       throw AppExcept (except_bad_elem,
+                                               name, value);
+
+                               if (!allowDuplicates && collection [name] != 
null)
+                                       throw AppExcept (except_xml_duplicate, 
name);
+
+                               if (insertEmptyValue ||  value.Length > 0)
+                                       collection [name] = value;
+                       }
                }
                
                private XmlElement GetSetting (string name)
@@ -47,6 +70,7 @@
                        string value;
                        if ((value = cmd_args [name]) != null) return value;
                        if ((value = xml_args [name]) != null) return value;
+                       if ((value = default_args [name]) != null) return value;
                        
                        string app_setting = GetXmlValue (setting,
                                "AppSetting");
@@ -154,8 +178,8 @@
                }
                
                private ApplicationException AppExcept (Exception except,
-                                                       string message,
-                                                       params object [] args)
+                                                       string message,
+                                                       params object [] args)
                {
                        return new ApplicationException (string.Format (
                                CultureInfo.InvariantCulture, message, args),
@@ -163,7 +187,7 @@
                }
                
                private ApplicationException AppExcept (string message,
-                                                       params object [] args)
+                                                       params object [] args)
                {
                        return new ApplicationException (string.Format (
                                CultureInfo.InvariantCulture, message, args));
@@ -203,11 +227,12 @@
                                string type = GetXmlValue (setting,
                                        "Type").ToUpper (
                                                CultureInfo.InvariantCulture);
-                               
+
+                               string name = GetXmlValue (setting, "Name"); 
                                string arg = string.Format (
                                        CultureInfo.InvariantCulture,
                                        "  /{0}{1}",
-                                       GetXmlValue (setting, "Name"),
+                                       name,
                                        type == "BOOL" ? "[=True|=False]" :
                                                "=" + type);
                                
@@ -224,6 +249,9 @@
                                        string val = AppSettings [app_setting];
                                        
                                        if (val == null || val.Length == 0)
+                                               val = default_args [name];
+
+                                       if (val == null || val.Length == 0)
                                                val = "none";
                                        
                                        values.Add (" Default Value: " + val);
@@ -379,20 +407,7 @@
                {
                        XmlDocument doc = new XmlDocument ();
                        doc.Load (filename);
-                       foreach (XmlElement setting in
-                               doc.GetElementsByTagName ("Setting")) {
-                               string name = GetXmlValue (setting, "Name");
-                               string value = GetXmlValue (setting, "Value");
-                               if (name.Length == 0)
-                                       throw AppExcept (except_bad_elem,
-                                               name, value);
-                                       
-                               if (xml_args [name] != null)
-                                       throw AppExcept (except_xml_duplicate,
-                                               name);
-                                       
-                               xml_args.Add (name, value);
-                       }
+                       ImportSettings (doc, xml_args, false, true);
                }
                
                private int PrefixLength (string arg)

Modified: 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.xml
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.xml    
2007-10-21 22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/ConfigurationManager.xml    
2007-10-21 22:39:07 UTC (rev 87877)
@@ -42,7 +42,7 @@
        <!-- SOCKET SETTINGS -->
        
        <Setting Name="socket" Type="String" AppSetting="MonoSocketType"
-               ConsoleVisible="True">
+               ConsoleVisible="True" Value="pipe">
                <Description>
                        <para>Specifies the type of socket to listen on. Valid
                        values are "pipe", "unix", and "tcp".</para>
@@ -80,7 +80,7 @@
        </Setting>
        
        <Setting Name="filename" AppSetting="MonoUnixSocket" Type="String"
-               ConsoleVisible="True">
+               ConsoleVisible="True" Value="/tmp/fastcgi-mono-server">
                <Description>
                        <para>Specifies a unix socket filename to listen on.<br 
/>
                        To use this argument, "socket" must be set to 
"unix".</para>
@@ -184,20 +184,21 @@
                        </example>
                </Description>
        </Setting>
-       
+
+<!--   
        <Setting Name="automappaths" AppSetting="MonoAutomapPaths"
-               Type="Bool" ConsoleVisible="True">
+               Type="Bool" ConsoleVisible="True" Value="False">
                <Description>
                        <para>Automatically registers applications as they are
                        encountered, provided pages exist in standard
                        locations.</para>
                </Description>
        </Setting>
-       
+-->    
        <!-- FASTCGI SETTINGS -->
        
        <Setting Name="maxconns" AppSetting="FastCgiMaxConnections"
-               Type="UInt16" ConsoleVisible="True" WebVisible="True">
+               Type="UInt16" ConsoleVisible="True" WebVisible="True" 
Value="1024">
                <Description>
                        <para>Specifies the maximum number of concurrent
                        connections the server should accept.</para>
@@ -205,7 +206,7 @@
        </Setting>
        
        <Setting Name="maxreqs" AppSetting="FastCgiMaxRequests" Type="UInt16"
-               ConsoleVisible="True" WebVisible="True">
+               ConsoleVisible="True" WebVisible="True" Value="1024">
                <Description>
                        <para>Specifies the maximum number of concurrent
                        requests the server should accept.</para>

Added: branches/robertj/xsp/src/Mono.WebServer.FastCgi/Makefile.am
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/Makefile.am 2007-10-21 
22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/Makefile.am 2007-10-21 
22:39:07 UTC (rev 87877)
@@ -0,0 +1,44 @@
+builddir=$(top_builddir)/src/Mono.WebServer.FastCgi
+
+MCSFLAGS= -debug+ -debug:full -nologo -nowarn:618 $(WEBTRACING) -unsafe+ \
+       -resource:ConfigurationManager.xml
+
+GACUTIL1=$(GACUTIL) -package 1.0
+
+if NET_2_0
+XSP2_EXE = fastcgi-mono-server2.exe
+GACUTIL2=$(GACUTIL) -package 2.0
+endif
+
+noinst_SCRIPTS=fastcgi-mono-server.exe fastcgi-mono-server.exe $(XSP2_EXE)
+
+CLEANFILES = *.exe *.mdb
+
+# 
+references = -r:System.Web.dll -r:../Mono.WebServer/Mono.WebServer.dll 
-r:Mono.Security.dll -r:Mono.Posix.dll
+references2 = -r:System.Web.dll -r:System.Configuration.dll 
-r:../Mono.WebServer/Mono.WebServer2.dll -r:Mono.Security.dll -r:Mono.Posix.dll
+
+sources = $(addprefix $(srcdir)/, $(shell cat Mono.WebServer.FastCgi.sources))
+build_sources = $(addprefix $(srcdir)/, $(sources))
+
+EXTRA_DIST = $(sources) AssemblyInfo.cs.in
+
+fastcgi-mono-server.exe: $(build_sources)
+       $(MCS) $(MCSFLAGS) $(references) /out:$@ $(build_sources)
+       $(SN) -q -R $(builddir)/$@ $(builddir)/../mono.snk
+
+fastcgi-mono-server2.exe: $(build_sources)
+       $(GMCS) -d:NET_2_0 $(MCSFLAGS) $(references2) /out:$@ $(build_sources)
+       $(SN) -q -R $(builddir)/$@ $(builddir)/../mono.snk
+
+install-data-local:
+       $(GACUTIL1) $(GACUTIL_FLAGS) -i $(builddir)/fastcgi-mono-server.exe
+
+#if NET_2_0
+       $(GACUTIL2) $(GACUTIL_FLAGS) -i $(builddir)/fastcgi-mono-server2.exe
+#endif
+
+uninstall-local:
+       -for i in fastcgi-mono-server fastcgi-mono-server2 ; do \
+               $(GACUTIL) $(GACUTIL_FLAGS) -u $i ; \
+       done


Property changes on: branches/robertj/xsp/src/Mono.WebServer.FastCgi/Makefile.am
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/Mono.WebServer.FastCgi.sources
===================================================================
--- 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/Mono.WebServer.FastCgi.sources  
    2007-10-21 22:26:08 UTC (rev 87876)
+++ 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/Mono.WebServer.FastCgi.sources  
    2007-10-21 22:39:07 UTC (rev 87877)
@@ -0,0 +1,24 @@
+ApplicationHost.cs
+AssemblyInfo.cs
+BeginRequestBody.cs
+ConfigurationManager.cs
+Connection.cs
+EndRequestBody.cs
+ISocketAbstraction.cs
+Logger.cs
+main.cs
+NameValuePair.cs
+Record.cs
+Request.cs
+Responder.cs
+ResponderRequest.cs
+Server.cs
+SocketFactory.cs
+StandardSocket.cs
+Strings.cs
+TcpSocket.cs
+UnixSocket.cs
+UnknownTypeBody.cs
+UnmanagedSocket.cs
+WebSource.cs
+WorkerRequest.cs


Property changes on: 
branches/robertj/xsp/src/Mono.WebServer.FastCgi/Mono.WebServer.FastCgi.sources
___________________________________________________________________
Name: svn:eol-style
   + LF

Modified: branches/robertj/xsp/src/Mono.WebServer.FastCgi/Responder.cs
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/Responder.cs        
2007-10-21 22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/Responder.cs        
2007-10-21 22:39:07 UTC (rev 87877)
@@ -81,7 +81,7 @@
                        request.SendOutputText (PhysicalPath + "\r\n");
                */
                        
-                       ApplicationHost host = Server.GetApplicationForPath (
+                       VPathToHost host = Server.GetApplicationForPath (
                                HostName, PortNumber, Path, PhysicalPath);
                        
                        // If the host is null, the server was unable to
@@ -94,7 +94,7 @@
                        }
                        
                        try {
-                               host.ProcessRequest (this);
+                               ((ApplicationHost)host.AppHost).ProcessRequest 
(this);
                        } catch (Exception e) {
                                Logger.Write (LogLevel.Error,
                                        "ERROR PROCESSING REQUEST: " + e);

Copied: branches/robertj/xsp/src/Mono.WebServer.FastCgi/main.cs (from rev 
87875, branches/robertj/xsp/src/Mono.WebServer.FastCgi/server.cs)
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/server.cs   2007-10-21 
22:21:35 UTC (rev 87875)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/main.cs     2007-10-21 
22:39:07 UTC (rev 87877)
@@ -0,0 +1,369 @@
+//
+// server.cs: Web Server that uses ASP.NET hosting
+//
+// Authors:
+//   Brian Nickel ([EMAIL PROTECTED])
+//   Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//
+// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
+// (C) Copyright 2004 Novell, Inc. (http://www.novell.com)
+// (C) Copyright 2007 Brian Nickel
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Specialized;
+using System.Diagnostics;
+using System.IO;
+using System.Net;
+using System.Reflection;
+using System.Web.Hosting;
+using Mono.WebServer;
+using Mono.FastCgi;
+
+namespace Mono.WebServer.FastCgi
+{
+       public class Server
+       {
+               static void ShowVersion ()
+               {
+                       Assembly assembly = Assembly.GetExecutingAssembly ();
+                       string version = assembly.GetName ().Version.ToString 
();
+                       object att;
+                       
+                       // att = assembly.GetCustomAttributes (
+                       //      typeof (AssemblyTitleAttribute), false) [0];
+                       // string title =
+                       //      ((AssemblyTitleAttribute) att).Title;
+                       
+                       att = assembly.GetCustomAttributes (
+                               typeof (AssemblyCopyrightAttribute), false) [0];
+                       string copyright =
+                               ((AssemblyCopyrightAttribute) att).Copyright;
+                       
+                       att = assembly.GetCustomAttributes (
+                               typeof (AssemblyDescriptionAttribute), false) 
[0];
+                       string description =
+                               ((AssemblyDescriptionAttribute) 
att).Description;
+                       
+                       Console.WriteLine ("{0} {1}\n(c) {2}\n{3}",
+                               Path.GetFileName (assembly.Location), version,
+                               copyright, description);
+               }
+
+               static void ShowHelp ()
+               {
+                       string name = Path.GetFileName (
+                               Assembly.GetExecutingAssembly ().Location);
+                       
+                       ShowVersion ();
+                       Console.WriteLine ();
+                       Console.WriteLine ("Usage is:\n");
+                       Console.WriteLine ("    {0} [...]", name);
+                       Console.WriteLine ();
+                       configmanager.PrintHelp ();
+               }
+
+               private static ApplicationServer appserver;
+               private static ConfigurationManager configmanager;
+
+               public static VPathToHost GetApplicationForPath (string vhost,
+                                                                 int port,
+                                                                 string path,
+                                                                 string 
realPath)
+               {
+                       return appserver.GetApplicationForPath (vhost,  port, 
path, false);
+               }
+
+               public static int Main (string [] args)
+               {
+                       // Load the configuration file stored in the
+                       // executable's resources.
+                       configmanager = new ConfigurationManager (
+                               typeof (Server).Assembly,
+                               "ConfigurationManager.xml");
+                       
+                       configmanager.LoadCommandLineArgs (args);
+                       
+                       // Show the help and exit.
+                       if ((bool) configmanager ["help"] ||
+                               (bool) configmanager ["?"]) {
+                               ShowHelp ();
+                               return 0;
+                       }
+                       
+                       // Show the version and exit.
+                       if ((bool) configmanager ["version"]) {
+                               ShowVersion ();
+                               return 0;
+                       }
+                       
+                       try {
+                               string config_file = (string)
+                                       configmanager ["configfile"];
+                               if (config_file != null)
+                                       configmanager.LoadXmlConfig (
+                                               config_file);
+                       } catch (ApplicationException e) {
+                               Console.WriteLine (e.Message);
+                               return 1;
+                       } catch (System.Xml.XmlException e) {
+                               Console.WriteLine (
+                                       "Error reading XML configuration: {0}",
+                                       e.Message);
+                               return 1;
+                       }
+                       
+                       try {
+                               string log_level = (string)
+                                       configmanager ["loglevels"];
+                               
+                               if (log_level != null)
+                                       Logger.Level = (LogLevel)
+                                               Enum.Parse (typeof (LogLevel),
+                                                       log_level);
+                       } catch {
+                               Console.WriteLine ("Failed to parse log 
levels.");
+                               Console.WriteLine ("Using default levels: {0}",
+                                       Logger.Level);
+                       }
+                       
+                       try {
+                               string log_file = (string)
+                                       configmanager ["logfile"];
+                               
+                               if (log_file != null)
+                                       Logger.Open (log_file);
+                       } catch (Exception e) {
+                               Console.WriteLine ("Error opening log file: 
{0}",
+                                       e.Message);
+                               Console.WriteLine ("Events will not be 
logged.");
+                       }
+                       
+                       Logger.WriteToConsole = (bool) configmanager 
["printlog"];
+
+                       // Send the trace to the console.
+                       Trace.Listeners.Add (
+                               new TextWriterTraceListener (Console.Out));
+                       Console.WriteLine (
+                               Assembly.GetExecutingAssembly ().GetName 
().Name);
+                       
+                       
+                       // Create the socket.
+                       Socket socket;
+                       
+                       // Socket strings are in the format
+                       // "type[:ARG1[:ARG2[:...]]]".
+                       string socket_type = configmanager ["socket"] as string;
+                       if (socket_type == null)
+                               socket_type = "pipe";
+                       
+                       string [] socket_parts = socket_type.Split (
+                               new char [] {':'}, 3);
+                       
+                       switch (socket_parts [0].ToLower ()) {
+                       case "pipe":
+                               try {
+                                       socket = SocketFactory.CreatePipeSocket 
(
+                                               IntPtr.Zero);
+                               } catch (System.Net.Sockets.SocketException){
+                                       Console.WriteLine (
+                                               "Error: Pipe socket is not 
bound.");
+                                       return 1;
+                               }
+                               break;
+                       
+                       // The FILE sockets is of the format
+                       // "file[:PATH]".
+                       case "unix":
+                       case "file":
+                               if (socket_parts.Length == 2)
+                                       configmanager ["filename"] =
+                                               socket_parts [1];
+                               
+                               string path = (string) configmanager 
["filename"];
+                               
+                               try {
+                                       socket = SocketFactory.CreateUnixSocket 
(
+                                               path);
+                               } catch (System.Net.Sockets.SocketException e){
+                                       Console.WriteLine (
+                                               "Error creating the socket: 
{0}",
+                                               e.Message);
+                                       return 1;
+                               }
+                               
+                               Console.WriteLine ("Listening on file: {0}",
+                                       path);
+                               break;
+                       
+                       // The TCP socket is of the format
+                       // "tcp[[:ADDRESS]:PORT]".
+                       case "tcp":
+                               if (socket_parts.Length > 1)
+                                       configmanager ["port"] = socket_parts [
+                                               socket_parts.Length - 1];
+                               
+                               if (socket_parts.Length == 3)
+                                       configmanager ["address"] =
+                                               socket_parts [1];
+                               
+                               ushort port;
+                               try {
+                                       port = (ushort) configmanager ["port"];
+                               } catch (ApplicationException e) {
+                                       Console.WriteLine (e.Message);
+                                       return 1;
+                               }
+                               
+                               string address_str =
+                                       (string) configmanager ["address"];
+                               IPAddress address;
+                               
+                               try {
+                                       address = IPAddress.Parse (address_str);
+                               } catch {
+                                       Console.WriteLine (
+                                               "Error in argument \"address\". 
\"{0}\" cannot be converted to an IP address.",
+                                               address_str);
+                                       return 1;
+                               }
+                               
+                               try {
+                                       socket = SocketFactory.CreateTcpSocket (
+                                               address, port);
+                               } catch (System.Net.Sockets.SocketException e){
+                                       Console.WriteLine (
+                                               "Error creating the socket: 
{0}",
+                                               e.Message);
+                                       return 1;
+                               }
+                               
+                               Console.WriteLine ("Listening on port: {0}",
+                                       address_str);
+                               Console.WriteLine ("Listening on address: {0}",
+                                       port);
+                               break;
+                               
+                       default:
+                               Console.WriteLine (
+                                       "Error in argument \"socket\". \"{0}\" 
is not a supported type. Use \"pipe\", \"tcp\" or \"unix\".",
+                                       socket_parts [0]);
+                               return 1;
+                       }
+                       
+                       string root_dir = configmanager ["root"] as string;
+                       if (root_dir != null && root_dir.Length != 0) {
+                               try {
+                                       Environment.CurrentDirectory = root_dir;
+                               } catch (Exception e) {
+                                       Console.WriteLine ("Error: {0}",
+                                               e.Message);
+                                       return 1;
+                               }
+                       }
+                       
+                       root_dir = Environment.CurrentDirectory;
+                       bool auto_map = false; //(bool) configmanager 
["automappaths"];
+                        WebSource webSource = new WebSource ();
+                       appserver = new ApplicationServer (webSource);
+                       appserver.Verbose = (bool) configmanager ["verbose"];
+                       
+                       string applications = (string)
+                               configmanager ["applications"];
+                       string app_config_file;
+                       string app_config_dir;
+                       
+                       try {
+                               app_config_file = (string)
+                                       configmanager ["appconfigfile"];
+                               app_config_dir = (string)
+                                       configmanager ["appconfigdir"];
+                       } catch (ApplicationException e) {
+                               Console.WriteLine (e.Message);
+                               return 1;
+                       }
+                       
+                       if (applications != null)
+                               appserver.AddApplicationsFromCommandLine (
+                                       applications);
+                       
+                       if (app_config_file != null)
+                               appserver.AddApplicationsFromConfigFile (
+                                       app_config_file);
+                       
+                       if (app_config_dir != null)
+                               appserver.AddApplicationsFromConfigDirectory (
+                                       app_config_dir);
+
+                       if (applications == null && app_config_dir == null &&
+                               app_config_file == null && !auto_map) {
+                               Console.WriteLine (
+                                       "There are no applications defined, and 
path mapping is disabled.");
+                               Console.WriteLine (
+                                       "Define an application using 
/applications, /appconfigfile, /appconfigdir");
+                               /*
+                               Console.WriteLine (
+                                       "or by enabling application mapping 
with /automappaths=True.");
+                               */
+                               return 1;
+                       }
+                       
+                       Console.WriteLine ("Root directory: {0}", root_dir);
+                       Mono.FastCgi.Server server = new Mono.FastCgi.Server (
+                               socket);
+                       
+                       server.SetResponder (typeof (Responder));
+                       
+                       server.MaxConnections = (ushort)
+                               configmanager ["maxconns"];
+                       server.MaxRequests = (ushort)
+                               configmanager ["maxreqs"];
+                       server.MultiplexConnections = (bool)
+                               configmanager ["multiplex"];
+                       
+                       Console.WriteLine ("Max connections: {0}",
+                               server.MaxConnections);
+                       Console.WriteLine ("Max requests: {0}",
+                               server.MaxRequests);
+                       Console.WriteLine ("Multiplex connections: {0}",
+                               server.MultiplexConnections);
+                       
+                       bool stopable = (bool) configmanager ["stopable"];
+                       if (!stopable)
+                               Console.WriteLine (
+                                       "Use /stopable=True to enable stopping 
from the console.");
+                       
+                       server.Start (stopable);
+                       
+                       configmanager = null;
+                       
+                       if (stopable) {
+                               Console.WriteLine (
+                                       "Hit Return to stop the server.");
+                               Console.ReadLine ();
+                               server.Stop ();
+                       }
+                       
+                       return 0;
+               }
+       }
+}

Deleted: branches/robertj/xsp/src/Mono.WebServer.FastCgi/server.cs
===================================================================
--- branches/robertj/xsp/src/Mono.WebServer.FastCgi/server.cs   2007-10-21 
22:26:08 UTC (rev 87876)
+++ branches/robertj/xsp/src/Mono.WebServer.FastCgi/server.cs   2007-10-21 
22:39:07 UTC (rev 87877)
@@ -1,370 +0,0 @@
-//
-// server.cs: Web Server that uses ASP.NET hosting
-//
-// Authors:
-//   Brian Nickel ([EMAIL PROTECTED])
-//   Gonzalo Paniagua Javier ([EMAIL PROTECTED])
-//
-// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
-// (C) Copyright 2004 Novell, Inc. (http://www.novell.com)
-// (C) Copyright 2007 Brian Nickel
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Specialized;
-using System.Diagnostics;
-using System.IO;
-using System.Net;
-using System.Reflection;
-using System.Web.Hosting;
-using Mono.WebServer;
-using Mono.FastCgi;
-
-namespace Mono.WebServer.FastCgi
-{
-       public class Server
-       {
-               static void ShowVersion ()
-               {
-                       Assembly assembly = Assembly.GetExecutingAssembly ();
-                       string version = assembly.GetName ().Version.ToString 
();
-                       object att;
-                       
-                       // att = assembly.GetCustomAttributes (
-                       //      typeof (AssemblyTitleAttribute), false) [0];
-                       // string title =
-                       //      ((AssemblyTitleAttribute) att).Title;
-                       
-                       att = assembly.GetCustomAttributes (
-                               typeof (AssemblyCopyrightAttribute), false) [0];
-                       string copyright =
-                               ((AssemblyCopyrightAttribute) att).Copyright;
-                       
-                       att = assembly.GetCustomAttributes (
-                               typeof (AssemblyDescriptionAttribute), false) 
[0];
-                       string description =
-                               ((AssemblyDescriptionAttribute) 
att).Description;
-                       
-                       Console.WriteLine ("{0} {1}\n(c) {2}\n{3}",
-                               Path.GetFileName (assembly.Location), version,
-                               copyright, description);
-               }
-
-               static void ShowHelp ()
-               {
-                       string name = Path.GetFileName (
-                               Assembly.GetExecutingAssembly ().Location);
-                       
-                       ShowVersion ();
-                       Console.WriteLine ();
-                       Console.WriteLine ("Usage is:\n");
-                       Console.WriteLine ("    {0} [...]", name);
-                       Console.WriteLine ();
-                       configmanager.PrintHelp ();
-               }
-
-               private static ApplicationManager appmanager;
-               private static ConfigurationManager configmanager;
-               
-               public static ApplicationHost GetApplicationForPath (string 
vhost,
-                                                                    int port,
-                                                                    string 
path,
-                                                                    string 
realPath)
-               {
-                       VPathToHost h = appmanager.GetApplicationForPath (vhost,
-                               port, path, realPath);
-                       
-                       return h == null ? null : h.AppHost as ApplicationHost;
-               }
-               
-               public static int Main (string [] args)
-               {
-                       // Load the configuration file stored in the
-                       // executable's resources.
-                       configmanager = new ConfigurationManager (
-                               typeof (Server).Assembly,
-                               "ConfigurationManager.xml");
-                       
-                       configmanager.LoadCommandLineArgs (args);
-                       
-                       // Show the help and exit.
-                       if ((bool) configmanager ["help"] ||
-                               (bool) configmanager ["?"]) {
-                               ShowHelp ();
-                               return 0;
-                       }
-                       
-                       // Show the version and exit.
-                       if ((bool) configmanager ["version"]) {
-                               ShowVersion ();
-                               return 0;
-                       }
-                       
-                       try {
-                               string config_file = (string)
-                                       configmanager ["configfile"];
-                               if (config_file != null)
-                                       configmanager.LoadXmlConfig (
-                                               config_file);
-                       } catch (ApplicationException e) {
-                               Console.WriteLine (e.Message);
-                               return 1;
-                       } catch (System.Xml.XmlException e) {
-                               Console.WriteLine (
-                                       "Error reading XML configuration: {0}",
-                                       e.Message);
-                               return 1;
-                       }
-                       
-                       try {
-                               string log_level = (string)
-                                       configmanager ["loglevels"];
-                               
-                               if (log_level != null)
-                                       Logger.Level = (LogLevel)
-                                               Enum.Parse (typeof (LogLevel),
-                                                       log_level);
-                       } catch {
-                               Console.WriteLine ("Failed to parse log 
levels.");
-                               Console.WriteLine ("Using default levels: {0}",
-                                       Logger.Level);
-                       }
-                       
-                       try {
-                               string log_file = (string)
-                                       configmanager ["logfile"];
-                               
-                               if (log_file != null)
-                                       Logger.Open (log_file);
-                       } catch (Exception e) {
-                               Console.WriteLine ("Error opening log file: 
{0}",
-                                       e.Message);
-                               Console.WriteLine ("Events will not be 
logged.");
-                       }
-                       
-                       Logger.WriteToConsole = (bool) configmanager 
["printlog"];
-
-                       // Send the trace to the console.
-                       Trace.Listeners.Add (
-                               new TextWriterTraceListener (Console.Out));
-                       Console.WriteLine (
-                               Assembly.GetExecutingAssembly ().GetName 
().Name);
-                       
-                       
-                       // Create the socket.
-                       Socket socket;
-                       
-                       // Socket strings are in the format
-                       // "type[:ARG1[:ARG2[:...]]]".
-                       string socket_type = configmanager ["socket"] as string;
-                       if (socket_type == null)
-                               socket_type = "pipe";
-                       
-                       string [] socket_parts = socket_type.Split (
-                               new char [] {':'}, 3);
-                       
-                       switch (socket_parts [0].ToLower ()) {
-                       case "pipe":
-                               try {
-                                       socket = SocketFactory.CreatePipeSocket 
(
-                                               IntPtr.Zero);
-                               } catch (System.Net.Sockets.SocketException){
-                                       Console.WriteLine (
-                                               "Error: Pipe socket is not 
bound.");
-                                       return 1;
-                               }
-                               break;
-                       
-                       // The FILE sockets is of the format
-                       // "file[:PATH]".
-                       case "unix":
-                       case "file":
-                               if (socket_parts.Length == 2)
-                                       configmanager ["filename"] =
-                                               socket_parts [1];
-                               
-                               string path = (string) configmanager 
["filename"];
-                               
-                               try {
-                                       socket = SocketFactory.CreateUnixSocket 
(
-                                               path);
-                               } catch (System.Net.Sockets.SocketException e){
-                                       Console.WriteLine (
-                                               "Error creating the socket: 
{0}",
-                                               e.Message);
-                                       return 1;
-                               }
-                               
-                               Console.WriteLine ("Listening on file: {0}",
-                                       path);
-                               break;
-                       
-                       // The TCP socket is of the format
-                       // "tcp[[:ADDRESS]:PORT]".
-                       case "tcp":
-                               if (socket_parts.Length > 1)
-                                       configmanager ["port"] = socket_parts [
-                                               socket_parts.Length - 1];
-                               
-                               if (socket_parts.Length == 3)
-                                       configmanager ["address"] =
-                                               socket_parts [1];
-                               
-                               ushort port;
-                               try {
-                                       port = (ushort) configmanager ["port"];
-                               } catch (ApplicationException e) {
-                                       Console.WriteLine (e.Message);
-                                       return 1;
-                               }
-                               
-                               string address_str =
-                                       (string) configmanager ["address"];
-                               IPAddress address;
-                               
-                               try {
-                                       address = IPAddress.Parse (address_str);
-                               } catch {
-                                       Console.WriteLine (
-                                               "Error in argument \"address\". 
\"{0}\" cannot be converted to an IP address.",
-                                               address_str);
-                                       return 1;
-                               }
-                               
-                               try {
-                                       socket = SocketFactory.CreateTcpSocket (
-                                               address, port);
-                               } catch (System.Net.Sockets.SocketException e){
-                                       Console.WriteLine (
-                                               "Error creating the socket: 
{0}",
-                                               e.Message);
-                                       return 1;
-                               }
-                               
-                               Console.WriteLine ("Listening on port: {0}",
-                                       address_str);
-                               Console.WriteLine ("Listening on address: {0}",
-                                       port);
-                               break;
-                               
-                       default:
-                               Console.WriteLine (
-                                       "Error in argument \"socket\". \"{0}\" 
is not a supported type. Use \"pipe\", \"tcp\" or \"unix\".",
-                                       socket_parts [0]);
-                               return 1;
-                       }
-                       
-                       string root_dir = configmanager ["root"] as string;
-                       if (root_dir != null && root_dir.Length != 0) {
-                               try {
-                                       Environment.CurrentDirectory = root_dir;
-                               } catch (Exception e) {
-                                       Console.WriteLine ("Error: {0}",
-                                               e.Message);
-                                       return 1;
-                               }
-                       }
-                       
-                       root_dir = Environment.CurrentDirectory;
-                       bool auto_map = (bool) configmanager ["automappaths"];
-                       appmanager = new ApplicationManager (
-                               typeof (ApplicationHost), auto_map, false);
-                       appmanager.Verbose = (bool) configmanager ["verbose"];
-                       
-                       string applications = (string)
-                               configmanager ["applications"];
-                       string app_config_file;
-                       string app_config_dir;
-                       
-                       try {
-                               app_config_file = (string)
-                                       configmanager ["appconfigfile"];
-                               app_config_dir = (string)
-                                       configmanager ["appconfigdir"];
-                       } catch (ApplicationException e) {
-                               Console.WriteLine (e.Message);
-                               return 1;
-                       }
-                       
-                       if (applications != null)
-                               appmanager.AddApplicationsFromCommandLine (
-                                       applications);
-                       
-                       if (app_config_file != null)
-                               appmanager.AddApplicationsFromConfigFile (
-                                       app_config_file);
-                       
-                       if (app_config_dir != null)
-                               appmanager.AddApplicationsFromConfigDirectory (
-                                       app_config_dir);
-
-                       if (applications == null && app_config_dir == null &&
-                               app_config_file == null && !auto_map) {
-                               Console.WriteLine (
-                                       "There are no applications defined, and 
path mapping is disabled.");
-                               Console.WriteLine (
-                                       "Define an application using 
/applications, /appconfigfile, /appconfigdir");
-                               Console.WriteLine (
-                                       "or by enabling application mapping 
with /automappaths=True.");
-                               return 1;
-                       }
-                       
-                       Console.WriteLine ("Root directory: {0}", root_dir);
-                       Mono.FastCgi.Server server = new Mono.FastCgi.Server (
-                               socket);
-                       
-                       server.SetResponder (typeof (Responder));
-                       
-                       server.MaxConnections = (ushort)
-                               configmanager ["maxconns"];
-                       server.MaxRequests = (ushort)
-                               configmanager ["maxreqs"];
-                       server.MultiplexConnections = (bool)
-                               configmanager ["multiplex"];
-                       
-                       Console.WriteLine ("Max connections: {0}",
-                               server.MaxConnections);
-                       Console.WriteLine ("Max requests: {0}",
-                               server.MaxRequests);
-                       Console.WriteLine ("Multiplex connections: {0}",
-                               server.MultiplexConnections);
-                       
-                       bool stopable = (bool) configmanager ["stopable"];
-                       if (!stopable)
-                               Console.WriteLine (
-                                       "Use /stopable=True to enable stopping 
from the console.");
-                       
-                       server.Start (stopable);
-                       
-                       configmanager = null;
-                       
-                       if (stopable) {
-                               Console.WriteLine (
-                                       "Hit Return to stop the server.");
-                               Console.ReadLine ();
-                               server.Stop ();
-                       }
-                       
-                       return 0;
-               }
-       }
-}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to