aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Framework.Console
diff options
context:
space:
mode:
Diffstat (limited to 'Common/OpenSim.Framework.Console')
-rw-r--r--Common/OpenSim.Framework.Console/AssemblyInfo.cs31
-rw-r--r--Common/OpenSim.Framework.Console/ConsoleBase.cs166
-rw-r--r--Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs12
-rw-r--r--Common/OpenSim.Framework.Console/MainConsole.cs48
-rw-r--r--Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj89
-rw-r--r--Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user12
-rw-r--r--Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build42
7 files changed, 400 insertions, 0 deletions
diff --git a/Common/OpenSim.Framework.Console/AssemblyInfo.cs b/Common/OpenSim.Framework.Console/AssemblyInfo.cs
new file mode 100644
index 0000000..00a9b7d
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("ServerConsole")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("ServerConsole")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/Common/OpenSim.Framework.Console/ConsoleBase.cs b/Common/OpenSim.Framework.Console/ConsoleBase.cs
new file mode 100644
index 0000000..6a1c53c
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/ConsoleBase.cs
@@ -0,0 +1,166 @@
1using System;
2using System.IO;
3
4namespace OpenSim.Framework.Console
5{
6 public enum LogPriority : int
7 {
8 CRITICAL,
9 HIGH,
10 MEDIUM,
11 NORMAL,
12 LOW,
13 VERBOSE,
14 EXTRAVERBOSE
15 }
16
17 public class ConsoleBase
18 {
19 StreamWriter Log;
20 public conscmd_callback cmdparser;
21 public string componentname;
22 private bool m_silent;
23
24 public ConsoleBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent )
25 {
26 this.componentname = componentname;
27 this.cmdparser = cmdparser;
28 this.m_silent = silent;
29 System.Console.WriteLine("ServerConsole.cs - creating new local console");
30 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
31 Log = File.AppendText(LogFile);
32 Log.WriteLine("========================================================================");
33 Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
34 }
35
36 public void Close()
37 {
38 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
39 Log.Close();
40 }
41
42 public void Write(string format, params object[] args)
43 {
44 WriteLine(LogPriority.NORMAL,format,args);
45 return;
46 }
47
48 [Obsolete("WriteLine(msg,args) has been depreciated, use WriteLine(priority,msg,args) instead.")]
49 public void WriteLine(string format, params object[] args)
50 {
51 Log.WriteLine(format, args);
52 Log.Flush();
53 if(!m_silent)
54 {
55 System.Console.WriteLine(format, args);
56 }
57 return;
58 }
59
60 public void WriteLine(LogPriority importance, string format, params object[] args)
61 {
62 Log.WriteLine(format, args);
63 Log.Flush();
64 if (!m_silent)
65 {
66 System.Console.WriteLine(format, args);
67 }
68 return;
69 }
70
71 public string ReadLine()
72 {
73 string TempStr = System.Console.ReadLine();
74 Log.WriteLine(TempStr);
75 return TempStr;
76 }
77
78 public int Read()
79 {
80 int TempInt = System.Console.Read();
81 Log.Write((char)TempInt);
82 return TempInt;
83 }
84
85 // Displays a prompt and waits for the user to enter a string, then returns that string
86 // Done with no echo and suitable for passwords
87 public string PasswdPrompt(string prompt)
88 {
89 // FIXME: Needs to be better abstracted
90 Log.WriteLine(prompt);
91 this.Write(prompt);
92 ConsoleColor oldfg = System.Console.ForegroundColor;
93 System.Console.ForegroundColor = System.Console.BackgroundColor;
94 string temp = System.Console.ReadLine();
95 System.Console.ForegroundColor = oldfg;
96 return temp;
97 }
98
99 // Displays a command prompt and waits for the user to enter a string, then returns that string
100 public string CmdPrompt(string prompt)
101 {
102 this.Write(String.Format("{0}: ", prompt));
103 return this.ReadLine();
104 }
105
106 // Displays a command prompt and returns a default value if the user simply presses enter
107 public string CmdPrompt(string prompt, string defaultresponse)
108 {
109 string temp = CmdPrompt(String.Format( "{0} [{1}]", prompt, defaultresponse ));
110 if (temp == "")
111 {
112 return defaultresponse;
113 }
114 else
115 {
116 return temp;
117 }
118 }
119
120 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
121 public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
122 {
123 bool itisdone = false;
124 string temp = CmdPrompt(prompt, defaultresponse);
125 while (itisdone == false)
126 {
127 if ((temp == OptionA) || (temp == OptionB))
128 {
129 itisdone = true;
130 }
131 else
132 {
133 this.WriteLine(LogPriority.MEDIUM,"Valid options are " + OptionA + " or " + OptionB);
134 temp = CmdPrompt(prompt, defaultresponse);
135 }
136 }
137 return temp;
138 }
139
140 // Runs a command with a number of parameters
141 public Object RunCmd(string Cmd, string[] cmdparams)
142 {
143 cmdparser.RunCmd(Cmd, cmdparams);
144 return null;
145 }
146
147 // Shows data about something
148 public void ShowCommands(string ShowWhat)
149 {
150 cmdparser.Show(ShowWhat);
151 }
152
153 public void MainConsolePrompt()
154 {
155 string[] tempstrarray;
156 string tempstr = this.CmdPrompt(this.componentname + "# ");
157 tempstrarray = tempstr.Split(' ');
158 string cmd = tempstrarray[0];
159 Array.Reverse(tempstrarray);
160 Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
161 Array.Reverse(tempstrarray);
162 string[] cmdparams = (string[])tempstrarray;
163 RunCmd(cmd, cmdparams);
164 }
165 }
166}
diff --git a/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs b/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs
new file mode 100644
index 0000000..bb589d2
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs
@@ -0,0 +1,12 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Console
6{
7 public interface conscmd_callback
8 {
9 void RunCmd(string cmd, string[] cmdparams);
10 void Show(string ShowWhat);
11 }
12}
diff --git a/Common/OpenSim.Framework.Console/MainConsole.cs b/Common/OpenSim.Framework.Console/MainConsole.cs
new file mode 100644
index 0000000..02c4ae8
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/MainConsole.cs
@@ -0,0 +1,48 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28
29namespace OpenSim.Framework.Console
30{
31 public class MainConsole {
32
33 private static ConsoleBase instance;
34
35 public static ConsoleBase Instance
36 {
37 get
38 {
39 return instance;
40 }
41 set
42 {
43 instance = value;
44 }
45 }
46 }
47
48}
diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj
new file mode 100644
index 0000000..7af0eca
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj
@@ -0,0 +1,89 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{A7CD0630-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Framework.Console</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Framework.Console</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 </ItemGroup>
66 <ItemGroup>
67 </ItemGroup>
68 <ItemGroup>
69 <Compile Include="AssemblyInfo.cs">
70 <SubType>Code</SubType>
71 </Compile>
72 <Compile Include="ConsoleBase.cs">
73 <SubType>Code</SubType>
74 </Compile>
75 <Compile Include="ConsoleCallbacksBase.cs">
76 <SubType>Code</SubType>
77 </Compile>
78 <Compile Include="MainConsole.cs">
79 <SubType>Code</SubType>
80 </Compile>
81 </ItemGroup>
82 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
83 <PropertyGroup>
84 <PreBuildEvent>
85 </PreBuildEvent>
86 <PostBuildEvent>
87 </PostBuildEvent>
88 </PropertyGroup>
89</Project>
diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build
new file mode 100644
index 0000000..9a03b54
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build
@@ -0,0 +1,42 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Framework.Console" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Framework.Console" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="ConsoleBase.cs" />
16 <include name="ConsoleCallbacksBase.cs" />
17 <include name="MainConsole.cs" />
18 </sources>
19 <references basedir="${project::get-base-directory()}">
20 <lib>
21 <include name="${project::get-base-directory()}" />
22 <include name="${project::get-base-directory()}/${build.dir}" />
23 </lib>
24 <include name="System.dll" />
25 </references>
26 </csc>
27 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
28 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
29 <copy todir="${project::get-base-directory()}/../../bin/">
30 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
31 <include name="*.dll"/>
32 <include name="*.exe"/>
33 </fileset>
34 </copy>
35 </target>
36 <target name="clean">
37 <delete dir="${bin.dir}" failonerror="false" />
38 <delete dir="${obj.dir}" failonerror="false" />
39 </target>
40 <target name="doc" description="Creates documentation.">
41 </target>
42</project>