1
0
mirror of https://bitbucket.org/anguist/ntpa synced 2025-10-05 18:41:13 +00:00

Reference clean up

This commit is contained in:
2016-03-20 16:45:21 +01:00
parent 1a9c007d9a
commit 8a61a544c3
10 changed files with 63 additions and 103 deletions

View File

@ -56,7 +56,7 @@ For servers not registered on support.ntp.org just add 10000 and above.
See ntp.conf in examples on how to add time server IDs.
Configuration can be validate with the validation tool:
Configuration can be validated with the validation tool:
# mono ntpav.exe /etc/ntpa.conf
Use phpMyAdmin, MySQL Workbench or similar to adjust auto generated

View File

@ -4,7 +4,9 @@ all:
server:
xbuild Ntp.Analyzer.sln /property:Configuration=Server
release:
xbuild Ntp.Analyzer.sln /property:Configuration=Release
rm -R bin
clean:
xbuild Ntp.Analyzer.sln /t:clean

View File

@ -3,65 +3,13 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<!-- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> -->
<TargetFrameworkProfile />
<!--
<Framework Condition=" '$(Framework)' == '' and '$(VisualStudioVersion)' == '10.0'">4.0</Framework>
<Framework Condition=" '$(Framework)' == '' and '$(VisualStudioVersion)' == '11.0'">4.5</Framework>
<Framework Condition=" '$(Framework)' == '' and '$(VisualStudioVersion)' == '12.0'">4.5.1</Framework>
<Framework Condition=" '$(Framework)' == ''">2.0</Framework>
<TargetFrameworkVersion Condition="'$(Framework)'!=''">v$(Framework)</TargetFrameworkVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>-->
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ReleaseVersion>0.3</ReleaseVersion>
</PropertyGroup>
<Choose>
<When Condition=" '$(Platform)' != 'AnyCPU'">
<PropertyGroup>
<Platform>AnyCPU</Platform>
</PropertyGroup>
</When>
</Choose>
<Choose>
<When Condition=" '$(VisualStudioVersion)' == '12.0'">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<Framework>4.5.1</Framework>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<DefineConstants>NET_40_OR_GREATER;NET_45_OR_GREATER;NET_451_OR_GREATER;</DefineConstants>
</PropertyGroup>
</When>
<When Condition=" '$(VisualStudioVersion)' == '11.0'">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<Framework>4.5</Framework>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DefineConstants>NET_40_OR_GREATER;NET_45_OR_GREATER</DefineConstants>
</PropertyGroup>
</When>
<When Condition=" '$(VisualStudioVersion)' == '10.0'">
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<Framework>4.0</Framework>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<DefineConstants>NET_40_OR_GREATER</DefineConstants>
<ReleaseVersion>0.3</ReleaseVersion>
</PropertyGroup>
</When>
<Otherwise>
<!-- When Condition=" '$(VisualStudioVersion)' == ''" > -->
<PropertyGroup>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<Framework>3.5</Framework>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<ProjectGuid>{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}</ProjectGuid>
<OutputType>Library</OutputType>
@ -84,7 +32,6 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<!-- <DefineConstants Condition=" $(Framework) >= '4.0' ">NET_40_OR_GREATER</DefineConstants> -->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Runtime.InteropServices;
using System.Text;
using Ntp.Analyzer.Log;
using Ntp.Analyzer.Process;
@ -38,38 +37,6 @@ namespace Ntp.Analyzer.Cli
/// </summary>
public static class MainClass
{
#if __MonoCS__
[DllImport ("libc")]
private static extern int getpid ();
[DllImport ("libc")] // Linux
private static extern int prctl (int option, byte[] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
[DllImport ("libc")] // BSD
private static extern void setproctitle (byte[] fmt, byte[] str_arg);
/// <summary>
/// This is from http://abock.org/2006/02/09/changing-process-name-in-mono/
/// </summary>
/// <param name="name">Name.</param>
private static void SetPosixProcessName (string name)
{
try {
if (prctl (15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) {
throw new ApplicationException ("Error setting process name: " + Mono.Unix.Native.Stdlib.GetLastError ());
}
} catch (EntryPointNotFoundException) {
// Not every BSD has setproctitle
try {
setproctitle (Encoding.ASCII.GetBytes ("%s\0"), Encoding.ASCII.GetBytes (name + "\0"));
} catch (EntryPointNotFoundException) {
}
}
}
#else
private static int getpid () { return 0; }
#endif
/// <summary>
/// The entry point of the program, where the program control starts and ends.
/// </summary>
@ -97,7 +64,7 @@ namespace Ntp.Analyzer.Cli
}
string configFile = (args.Length > 0) ? args [0] : "/etc/ntpa.conf";
int pid = getpid ();
int pid = ProcessInfo.ProcessId;
Main main = new Main (configFile, pid, name);
main.Start ();

View File

@ -36,7 +36,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Mono.Posix" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />

View File

@ -39,9 +39,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="MySql.Data">
<HintPath>..\lib\v4.0\MySql.Data.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
@ -96,5 +93,9 @@
<Project>{A98DB601-2993-4181-A573-5FCCC5E954C1}</Project>
<Name>Ntp.System</Name>
</ProjectReference>
<ProjectReference Include="..\MySql\Source\MySql.Data\MySql.Data.csproj">
<Project>{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}</Project>
<Name>MySql.Data</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@ -124,7 +124,6 @@ Global
{74985534-474F-4191-971F-FCC791006FF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74985534-474F-4191-971F-FCC791006FF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74985534-474F-4191-971F-FCC791006FF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74985534-474F-4191-971F-FCC791006FF3}.Release|Any CPU.Build.0 = Release|Any CPU
{74985534-474F-4191-971F-FCC791006FF3}.Server|Any CPU.ActiveCfg = Debug|Any CPU
{8263BEAB-1610-4F82-9FC0-84421E5AB6B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8263BEAB-1610-4F82-9FC0-84421E5AB6B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
@ -163,8 +162,11 @@ Global
{CCF0EE0C-E3E4-4A75-AFEB-C709ED51E90F}.Server|Any CPU.ActiveCfg = Debug|Any CPU
{CCF0EE0C-E3E4-4A75-AFEB-C709ED51E90F}.Server|Any CPU.Build.0 = Debug|Any CPU
{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Release|Any CPU.Build.0 = Release|Any CPU
{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Server|Any CPU.ActiveCfg = Debug|Any CPU
{E9DF5ED1-4CBD-4226-B931-9A51610AC14D}.Server|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection

View File

@ -41,9 +41,6 @@
<Reference Include="System.Xml" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="MySql">
<HintPath>..\lib\MySql.Data.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Graph\HostGraph.cs" />

View File

@ -42,6 +42,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShellCommand.cs" />
<Compile Include="InterLock.cs" />
<Compile Include="ProcessInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

44
Ntp.System/ProcessInfo.cs Normal file
View File

@ -0,0 +1,44 @@
//
// ProcessInfo.cs
//
// Author:
// Carsten Sonne Larsen <cs@innolan.dk>
//
// Copyright (c) 2016 Carsten Sonne Larsen
//
// 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.Runtime.InteropServices;
namespace Ntp.System
{
public class ProcessInfo
{
public static int ProcessId {
get { return getpid (); }
}
#if __MonoCS__
[DllImport ("libc")]
private static extern int getpid ();
#else
private static int getpid () { return 0; }
#endif
}
}