增加图标
This commit is contained in:
commit
b93dbdf1e2
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Right_bash
|
||||
右键Bash(Bash on Debian on Windows)
|
||||
|
||||
|
||||
# Help
|
||||
Right_bash.exe -h,? print help
|
||||
Right_bash.exe -a add Registry
|
||||
Right_bash.exe -d delete Registry
|
||||
Right_bash.exe -b Start SSH on boot
|
||||
Right_bash.exe -p Turn off and start SSH
|
||||
|
||||
|
31
Right_bash.sln
Normal file
31
Right_bash.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.572
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Right_bash", "Right_bash\Right_bash.vcxproj", "{3DDDBF10-AC04-4536-B9A2-293663B8E993}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Debug|x64.Build.0 = Debug|x64
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Debug|x86.Build.0 = Debug|Win32
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Release|x64.ActiveCfg = Release|x64
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Release|x64.Build.0 = Release|x64
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Release|x86.ActiveCfg = Release|Win32
|
||||
{3DDDBF10-AC04-4536-B9A2-293663B8E993}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4F7FA8DF-1935-41F3-8AB6-B27801B8DE90}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
2
Right_bash/ClassDiagram.cd
Normal file
2
Right_bash/ClassDiagram.cd
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram />
|
15
Right_bash/Debug/Right_bash.Build.CppClean.log
Normal file
15
Right_bash/Debug/Right_bash.Build.CppClean.log
Normal file
@ -0,0 +1,15 @@
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\vc142.pdb
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\vc142.idb
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\getopt.obj
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\main.obj
|
||||
c:\users\niuyuling\source\repos\right_bash\debug\right_bash.exe
|
||||
c:\users\niuyuling\source\repos\right_bash\debug\right_bash.ilk
|
||||
c:\users\niuyuling\source\repos\right_bash\debug\right_bash.pdb
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\vc141.idb
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\vc141.pdb
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\right_bash.tlog\cl.command.1.tlog
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\right_bash.tlog\cl.read.1.tlog
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\right_bash.tlog\cl.write.1.tlog
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\right_bash.tlog\link.command.1.tlog
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\right_bash.tlog\link.read.1.tlog
|
||||
c:\users\niuyuling\source\repos\right_bash\right_bash\debug\right_bash.tlog\link.write.1.tlog
|
1
Right_bash/Debug/Right_bash.log
Normal file
1
Right_bash/Debug/Right_bash.log
Normal file
@ -0,0 +1 @@
|
||||
|
BIN
Right_bash/Debug/Right_bash.tlog/CL.command.1.tlog
Normal file
BIN
Right_bash/Debug/Right_bash.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/Debug/Right_bash.tlog/CL.read.1.tlog
Normal file
BIN
Right_bash/Debug/Right_bash.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/Debug/Right_bash.tlog/CL.write.1.tlog
Normal file
BIN
Right_bash/Debug/Right_bash.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
|
||||
Debug|Win32|C:\Users\niuyuling\source\repos\Right_bash\|
|
BIN
Right_bash/Debug/Right_bash.tlog/link.command.1.tlog
Normal file
BIN
Right_bash/Debug/Right_bash.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/Debug/Right_bash.tlog/link.read.1.tlog
Normal file
BIN
Right_bash/Debug/Right_bash.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/Debug/Right_bash.tlog/link.write.1.tlog
Normal file
BIN
Right_bash/Debug/Right_bash.tlog/link.write.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/Debug/main.obj
Normal file
BIN
Right_bash/Debug/main.obj
Normal file
Binary file not shown.
BIN
Right_bash/Debug/vc141.idb
Normal file
BIN
Right_bash/Debug/vc141.idb
Normal file
Binary file not shown.
BIN
Right_bash/Debug/vc141.pdb
Normal file
BIN
Right_bash/Debug/vc141.pdb
Normal file
Binary file not shown.
BIN
Right_bash/Debug/vc142.idb
Normal file
BIN
Right_bash/Debug/vc142.idb
Normal file
Binary file not shown.
BIN
Right_bash/Debug/vc142.pdb
Normal file
BIN
Right_bash/Debug/vc142.pdb
Normal file
Binary file not shown.
BIN
Right_bash/RCa23992
Normal file
BIN
Right_bash/RCa23992
Normal file
Binary file not shown.
BIN
Right_bash/Resource.aps
Normal file
BIN
Right_bash/Resource.aps
Normal file
Binary file not shown.
100
Right_bash/Resource.rc
Normal file
100
Right_bash/Resource.rc
Normal file
@ -0,0 +1,100 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 中文(简体,中国) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||
#pragma code_page(936)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource1.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,2,0,0
|
||||
PRODUCTVERSION 1,2,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080404b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "TODO: aixiao@aixiao.me"
|
||||
VALUE "FileDescription", "Right click bash"
|
||||
VALUE "FileVersion", "1.2.0.0"
|
||||
VALUE "InternalName", "Right_bash.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2021 aixiao@aixiao.me"
|
||||
VALUE "OriginalFilename", "Right_bash.exe"
|
||||
VALUE "ProductName", "Right_bash"
|
||||
VALUE "ProductVersion", "1.2.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x804, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // 中文(简体,中国) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
86
Right_bash/Right_bash.rc
Normal file
86
Right_bash/Right_bash.rc
Normal file
@ -0,0 +1,86 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 中文(简体,中国) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
||||
#pragma code_page(936)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_ICON1 ICON "icon.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_TOOLBAR1 BITMAP "toolbar1.bmp"
|
||||
|
||||
#endif // 中文(简体,中国) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
159
Right_bash/Right_bash.vcxproj
Normal file
159
Right_bash/Right_bash.vcxproj
Normal file
@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\getopt.c" />
|
||||
<ClCompile Include="..\src\main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\getopt.h" />
|
||||
<ClInclude Include="..\src\main.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="resource1.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Resource.rc" />
|
||||
<ResourceCompile Include="Right_bash.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="icon.ico">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
|
||||
<TreatOutputAsContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
</TreatOutputAsContent>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">C:\Users\niuyuling</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<Image Include="toolbar1.bmp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{3DDDBF10-AC04-4536-B9A2-293663B8E993}</ProjectGuid>
|
||||
<RootNamespace>Rightbash</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
60
Right_bash/Right_bash.vcxproj.filters
Normal file
60
Right_bash/Right_bash.vcxproj.filters
Normal file
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\main.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\getopt.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\getopt.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\main.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource1.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Right_bash.rc">
|
||||
<Filter>资源文件</Filter>
|
||||
</ResourceCompile>
|
||||
<ResourceCompile Include="Resource.rc">
|
||||
<Filter>资源文件</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="toolbar1.bmp">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="icon.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
</Project>
|
6
Right_bash/Right_bash.vcxproj.user
Normal file
6
Right_bash/Right_bash.vcxproj.user
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
BIN
Right_bash/icon.ico
Normal file
BIN
Right_bash/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
18
Right_bash/resource.h
Normal file
18
Right_bash/resource.h
Normal file
@ -0,0 +1,18 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 Right_bash.rc 使用
|
||||
//
|
||||
#define IDI_ICON1 101
|
||||
#define IDR_TOOLBAR1 103
|
||||
#define IDB_BITMAP1 104
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
BIN
Right_bash/toolbar1.bmp
Normal file
BIN
Right_bash/toolbar1.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 238 B |
BIN
Right_bash/x64/Debug/CodeAnalysisResultManifest.txt
Normal file
BIN
Right_bash/x64/Debug/CodeAnalysisResultManifest.txt
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Resource.res
Normal file
BIN
Right_bash/x64/Debug/Resource.res
Normal file
Binary file not shown.
27
Right_bash/x64/Debug/Right_bash.Build.CppClean.log
Normal file
27
Right_bash/x64/Debug/Right_bash.Build.CppClean.log
Normal file
@ -0,0 +1,27 @@
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\vc142.pdb
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\vc142.idb
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\getopt.obj
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\main.obj
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\right_bash.ilk
|
||||
c:\users\niuyuling\desktop\right_bash\x64\debug\right_bash.exe
|
||||
c:\users\niuyuling\desktop\right_bash\x64\debug\right_bash.pdb
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\resource.res
|
||||
c:\users\niuyuling\desktop\right_bash\right_bash\x64\debug\right_bash.res
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\getopt.obj
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\main.obj
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.ilk
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\resource.res
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.res
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\vc142.idb
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\vc142.pdb
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\x64\debug\right_bash.pdb
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\x64\debug\right_bash.exe
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\cl.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\cl.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\cl.write.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\link.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\link.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\link.write.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\rc.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\rc.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\debug\right_bash.tlog\rc.write.1.tlog
|
11
Right_bash/x64/Debug/Right_bash.exe.recipe
Normal file
11
Right_bash/x64/Debug/Right_bash.exe.recipe
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\niuyuling\Desktop\git.aixiao.me\Right_bash\x64\Debug\Right_bash.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
BIN
Right_bash/x64/Debug/Right_bash.ilk
Normal file
BIN
Right_bash/x64/Debug/Right_bash.ilk
Normal file
Binary file not shown.
3
Right_bash/x64/Debug/Right_bash.log
Normal file
3
Right_bash/x64/Debug/Right_bash.log
Normal file
@ -0,0 +1,3 @@
|
||||
getopt.c
|
||||
main.cpp
|
||||
Right_bash.vcxproj -> C:\Users\niuyuling\Desktop\git.aixiao.me\Right_bash\x64\Debug\Right_bash.exe
|
BIN
Right_bash/x64/Debug/Right_bash.res
Normal file
BIN
Right_bash/x64/Debug/Right_bash.res
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/CL.command.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/CL.read.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/CL.write.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.32.31326:TargetPlatformVersion=10.0.19041.0:
|
||||
Debug|x64|C:\Users\niuyuling\Desktop\git.aixiao.me\Right_bash\|
|
BIN
Right_bash/x64/Debug/Right_bash.tlog/link.command.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/link.read.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/link.write.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/link.write.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/rc.command.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/rc.command.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/rc.read.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/rc.read.1.tlog
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/Right_bash.tlog/rc.write.1.tlog
Normal file
BIN
Right_bash/x64/Debug/Right_bash.tlog/rc.write.1.tlog
Normal file
Binary file not shown.
2634
Right_bash/x64/Debug/getopt.nativecodeanalysis.sarif
Normal file
2634
Right_bash/x64/Debug/getopt.nativecodeanalysis.sarif
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Right_bash/x64/Debug/getopt.obj
Normal file
BIN
Right_bash/x64/Debug/getopt.obj
Normal file
Binary file not shown.
2634
Right_bash/x64/Debug/main.nativecodeanalysis.sarif
Normal file
2634
Right_bash/x64/Debug/main.nativecodeanalysis.sarif
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Right_bash/x64/Debug/main.obj
Normal file
BIN
Right_bash/x64/Debug/main.obj
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/vc143.idb
Normal file
BIN
Right_bash/x64/Debug/vc143.idb
Normal file
Binary file not shown.
BIN
Right_bash/x64/Debug/vc143.pdb
Normal file
BIN
Right_bash/x64/Debug/vc143.pdb
Normal file
Binary file not shown.
21
Right_bash/x64/Release/Right_bash.Build.CppClean.log
Normal file
21
Right_bash/x64/Release/Right_bash.Build.CppClean.log
Normal file
@ -0,0 +1,21 @@
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\vc143.pdb
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\getopt.obj
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\main.obj
|
||||
c:\users\niuyuling\icon.ico
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\x64\release\right_bash.exe
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\x64\release\right_bash.pdb
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.iobj
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\resource.res
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.res
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\cl.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\cl.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\cl.write.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\copyfile.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\copyfile.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\copyfile.write.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\link.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\link.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\link.write.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\rc.command.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\rc.read.1.tlog
|
||||
c:\users\niuyuling\desktop\git.aixiao.me\right_bash\right_bash\x64\release\right_bash.tlog\rc.write.1.tlog
|
11
Right_bash/x64/Release/Right_bash.exe.recipe
Normal file
11
Right_bash/x64/Release/Right_bash.exe.recipe
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\niuyuling\Desktop\git.aixiao.me\Right_bash\x64\Release\Right_bash.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
1
Right_bash/x64/Release/Right_bash.log
Normal file
1
Right_bash/x64/Release/Right_bash.log
Normal file
@ -0,0 +1 @@
|
||||
|
568
src/getopt.c
Normal file
568
src/getopt.c
Normal file
@ -0,0 +1,568 @@
|
||||
/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */
|
||||
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Sponsored in part by the Defense Advanced Research Projects
|
||||
* Agency (DARPA) and Air Force Research Laboratory, Air Force
|
||||
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||
*/
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Dieter Baron and Thomas Klausner.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "getopt.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
|
||||
|
||||
#ifdef REPLACE_GETOPT
|
||||
int opterr = 1; /* if error message should be printed */
|
||||
int optind = 1; /* index into parent argv vector */
|
||||
int optopt = '?'; /* character checked for validity */
|
||||
#undef optreset /* see getopt.h */
|
||||
#define optreset __mingw_optreset
|
||||
int optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
#endif
|
||||
|
||||
#define PRINT_ERROR ((opterr) && (*options != ':'))
|
||||
|
||||
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
|
||||
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
|
||||
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
|
||||
|
||||
/* return values */
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
|
||||
#define INORDER (int)1
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
#define __progname __argv[0]
|
||||
#else
|
||||
extern char __declspec(dllimport) *__progname;
|
||||
#endif
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
static char EMSG[] = "";
|
||||
#else
|
||||
#define EMSG ""
|
||||
#endif
|
||||
|
||||
static int getopt_internal(int, char * const *, const char *,
|
||||
const struct option *, int *, int);
|
||||
static int parse_long_options(char * const *, const char *,
|
||||
const struct option *, int *, int);
|
||||
static int gcd(int, int);
|
||||
static void permute_args(int, int, int, char * const *);
|
||||
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
|
||||
/* XXX: set optreset to 1 rather than these two */
|
||||
static int nonopt_start = -1; /* first non option argument (for permute) */
|
||||
static int nonopt_end = -1; /* first option after non options (for permute) */
|
||||
|
||||
/* Error messages */
|
||||
static const char recargchar[] = "option requires an argument -- %c";
|
||||
static const char recargstring[] = "option requires an argument -- %s";
|
||||
static const char ambig[] = "ambiguous option -- %.*s";
|
||||
static const char noarg[] = "option doesn't take an argument -- %.*s";
|
||||
static const char illoptchar[] = "unknown option -- %c";
|
||||
static const char illoptstring[] = "unknown option -- %s";
|
||||
|
||||
static void
|
||||
_vwarnx(const char *fmt,va_list ap)
|
||||
{
|
||||
(void)fprintf(stderr,"%s: ",__progname);
|
||||
if (fmt != NULL)
|
||||
(void)vfprintf(stderr,fmt,ap);
|
||||
(void)fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
static void
|
||||
warnx(const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
_vwarnx(fmt,ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the greatest common divisor of a and b.
|
||||
*/
|
||||
static int
|
||||
gcd(int a, int b)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = a % b;
|
||||
while (c != 0) {
|
||||
a = b;
|
||||
b = c;
|
||||
c = a % b;
|
||||
}
|
||||
|
||||
return (b);
|
||||
}
|
||||
|
||||
/*
|
||||
* Exchange the block from nonopt_start to nonopt_end with the block
|
||||
* from nonopt_end to opt_end (keeping the same order of arguments
|
||||
* in each block).
|
||||
*/
|
||||
static void
|
||||
permute_args(int panonopt_start, int panonopt_end, int opt_end,
|
||||
char * const *nargv)
|
||||
{
|
||||
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
|
||||
char *swap;
|
||||
|
||||
/*
|
||||
* compute lengths of blocks and number and size of cycles
|
||||
*/
|
||||
nnonopts = panonopt_end - panonopt_start;
|
||||
nopts = opt_end - panonopt_end;
|
||||
ncycle = gcd(nnonopts, nopts);
|
||||
cyclelen = (opt_end - panonopt_start) / ncycle;
|
||||
|
||||
for (i = 0; i < ncycle; i++) {
|
||||
cstart = panonopt_end+i;
|
||||
pos = cstart;
|
||||
for (j = 0; j < cyclelen; j++) {
|
||||
if (pos >= panonopt_end)
|
||||
pos -= nnonopts;
|
||||
else
|
||||
pos += nopts;
|
||||
swap = nargv[pos];
|
||||
/* LINTED const cast */
|
||||
((char **) nargv)[pos] = nargv[cstart];
|
||||
/* LINTED const cast */
|
||||
((char **)nargv)[cstart] = swap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* parse_long_options --
|
||||
* Parse long options in argc/argv argument vector.
|
||||
* Returns -1 if short_too is set and the option does not match long_options.
|
||||
*/
|
||||
static int
|
||||
parse_long_options(char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx, int short_too)
|
||||
{
|
||||
char *current_argv, *has_equal;
|
||||
size_t current_argv_len;
|
||||
int i, ambiguous, match;
|
||||
|
||||
#define IDENTICAL_INTERPRETATION(_x, _y) \
|
||||
(long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
|
||||
long_options[(_x)].flag == long_options[(_y)].flag && \
|
||||
long_options[(_x)].val == long_options[(_y)].val)
|
||||
|
||||
current_argv = place;
|
||||
match = -1;
|
||||
ambiguous = 0;
|
||||
|
||||
optind++;
|
||||
|
||||
if ((has_equal = strchr(current_argv, '=')) != NULL) {
|
||||
/* argument found (--option=arg) */
|
||||
current_argv_len = has_equal - current_argv;
|
||||
has_equal++;
|
||||
} else
|
||||
current_argv_len = strlen(current_argv);
|
||||
|
||||
for (i = 0; long_options[i].name; i++) {
|
||||
/* find matching long option */
|
||||
if (strncmp(current_argv, long_options[i].name,
|
||||
current_argv_len))
|
||||
continue;
|
||||
|
||||
if (strlen(long_options[i].name) == current_argv_len) {
|
||||
/* exact match */
|
||||
match = i;
|
||||
ambiguous = 0;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* If this is a known short option, don't allow
|
||||
* a partial match of a single character.
|
||||
*/
|
||||
if (short_too && current_argv_len == 1)
|
||||
continue;
|
||||
|
||||
if (match == -1) /* partial match */
|
||||
match = i;
|
||||
else if (!IDENTICAL_INTERPRETATION(i, match))
|
||||
ambiguous = 1;
|
||||
}
|
||||
if (ambiguous) {
|
||||
/* ambiguous abbreviation */
|
||||
if (PRINT_ERROR)
|
||||
warnx(ambig, (int)current_argv_len,
|
||||
current_argv);
|
||||
optopt = 0;
|
||||
return (BADCH);
|
||||
}
|
||||
if (match != -1) { /* option found */
|
||||
if (long_options[match].has_arg == no_argument
|
||||
&& has_equal) {
|
||||
if (PRINT_ERROR)
|
||||
warnx(noarg, (int)current_argv_len,
|
||||
current_argv);
|
||||
/*
|
||||
* XXX: GNU sets optopt to val regardless of flag
|
||||
*/
|
||||
if (long_options[match].flag == NULL)
|
||||
optopt = long_options[match].val;
|
||||
else
|
||||
optopt = 0;
|
||||
return (BADARG);
|
||||
}
|
||||
if (long_options[match].has_arg == required_argument ||
|
||||
long_options[match].has_arg == optional_argument) {
|
||||
if (has_equal)
|
||||
optarg = has_equal;
|
||||
else if (long_options[match].has_arg ==
|
||||
required_argument) {
|
||||
/*
|
||||
* optional argument doesn't use next nargv
|
||||
*/
|
||||
optarg = nargv[optind++];
|
||||
}
|
||||
}
|
||||
if ((long_options[match].has_arg == required_argument)
|
||||
&& (optarg == NULL)) {
|
||||
/*
|
||||
* Missing argument; leading ':' indicates no error
|
||||
* should be generated.
|
||||
*/
|
||||
if (PRINT_ERROR)
|
||||
warnx(recargstring,
|
||||
current_argv);
|
||||
/*
|
||||
* XXX: GNU sets optopt to val regardless of flag
|
||||
*/
|
||||
if (long_options[match].flag == NULL)
|
||||
optopt = long_options[match].val;
|
||||
else
|
||||
optopt = 0;
|
||||
--optind;
|
||||
return (BADARG);
|
||||
}
|
||||
} else { /* unknown option */
|
||||
if (short_too) {
|
||||
--optind;
|
||||
return (-1);
|
||||
}
|
||||
if (PRINT_ERROR)
|
||||
warnx(illoptstring, current_argv);
|
||||
optopt = 0;
|
||||
return (BADCH);
|
||||
}
|
||||
if (idx)
|
||||
*idx = match;
|
||||
if (long_options[match].flag) {
|
||||
*long_options[match].flag = long_options[match].val;
|
||||
return (0);
|
||||
} else
|
||||
return (long_options[match].val);
|
||||
#undef IDENTICAL_INTERPRETATION
|
||||
}
|
||||
|
||||
/*
|
||||
* getopt_internal --
|
||||
* Parse argc/argv argument vector. Called by user level routines.
|
||||
*/
|
||||
static int
|
||||
getopt_internal(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx, int flags)
|
||||
{
|
||||
const char *oli; /* option letter list index */
|
||||
int optchar, short_too;
|
||||
static int posixly_correct = -1;
|
||||
|
||||
if (options == NULL)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* XXX Some GNU programs (like cvs) set optind to 0 instead of
|
||||
* XXX using optreset. Work around this braindamage.
|
||||
*/
|
||||
if (optind == 0)
|
||||
optind = optreset = 1;
|
||||
|
||||
/*
|
||||
* Disable GNU extensions if POSIXLY_CORRECT is set or options
|
||||
* string begins with a '+'.
|
||||
*
|
||||
* CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or
|
||||
* optreset != 0 for GNU compatibility.
|
||||
*/
|
||||
|
||||
if (posixly_correct == -1 || optreset != 0) {
|
||||
//posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
|
||||
char* pValue;
|
||||
size_t len;
|
||||
posixly_correct = _dupenv_s(&pValue, &len, "pathext");
|
||||
free(pValue);
|
||||
}
|
||||
if (*options == '-')
|
||||
flags |= FLAG_ALLARGS;
|
||||
else if (posixly_correct || *options == '+')
|
||||
flags &= ~FLAG_PERMUTE;
|
||||
if (*options == '+' || *options == '-')
|
||||
options++;
|
||||
|
||||
optarg = NULL;
|
||||
if (optreset)
|
||||
nonopt_start = nonopt_end = -1;
|
||||
start:
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc) { /* end of argument vector */
|
||||
place = EMSG;
|
||||
if (nonopt_end != -1) {
|
||||
/* do permutation, if we have to */
|
||||
permute_args(nonopt_start, nonopt_end,
|
||||
optind, nargv);
|
||||
optind -= nonopt_end - nonopt_start;
|
||||
}
|
||||
else if (nonopt_start != -1) {
|
||||
/*
|
||||
* If we skipped non-options, set optind
|
||||
* to the first of them.
|
||||
*/
|
||||
optind = nonopt_start;
|
||||
}
|
||||
nonopt_start = nonopt_end = -1;
|
||||
return (-1);
|
||||
}
|
||||
if (*(place = nargv[optind]) != '-' ||
|
||||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
|
||||
place = EMSG; /* found non-option */
|
||||
if (flags & FLAG_ALLARGS) {
|
||||
/*
|
||||
* GNU extension:
|
||||
* return non-option as argument to option 1
|
||||
*/
|
||||
optarg = nargv[optind++];
|
||||
return (INORDER);
|
||||
}
|
||||
if (!(flags & FLAG_PERMUTE)) {
|
||||
/*
|
||||
* If no permutation wanted, stop parsing
|
||||
* at first non-option.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
/* do permutation */
|
||||
if (nonopt_start == -1)
|
||||
nonopt_start = optind;
|
||||
else if (nonopt_end != -1) {
|
||||
permute_args(nonopt_start, nonopt_end,
|
||||
optind, nargv);
|
||||
nonopt_start = optind -
|
||||
(nonopt_end - nonopt_start);
|
||||
nonopt_end = -1;
|
||||
}
|
||||
optind++;
|
||||
/* process next argument */
|
||||
goto start;
|
||||
}
|
||||
if (nonopt_start != -1 && nonopt_end == -1)
|
||||
nonopt_end = optind;
|
||||
|
||||
/*
|
||||
* If we have "-" do nothing, if "--" we are done.
|
||||
*/
|
||||
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
|
||||
optind++;
|
||||
place = EMSG;
|
||||
/*
|
||||
* We found an option (--), so if we skipped
|
||||
* non-options, we have to permute.
|
||||
*/
|
||||
if (nonopt_end != -1) {
|
||||
permute_args(nonopt_start, nonopt_end,
|
||||
optind, nargv);
|
||||
optind -= nonopt_end - nonopt_start;
|
||||
}
|
||||
nonopt_start = nonopt_end = -1;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check long options if:
|
||||
* 1) we were passed some
|
||||
* 2) the arg is not just "-"
|
||||
* 3) either the arg starts with -- we are getopt_long_only()
|
||||
*/
|
||||
if (long_options != NULL && place != nargv[optind] &&
|
||||
(*place == '-' || (flags & FLAG_LONGONLY))) {
|
||||
short_too = 0;
|
||||
if (*place == '-')
|
||||
place++; /* --foo long option */
|
||||
else if (*place != ':' && strchr(options, *place) != NULL)
|
||||
short_too = 1; /* could be short option too */
|
||||
|
||||
optchar = parse_long_options(nargv, options, long_options,
|
||||
idx, short_too);
|
||||
if (optchar != -1) {
|
||||
place = EMSG;
|
||||
return (optchar);
|
||||
}
|
||||
}
|
||||
|
||||
if ((optchar = (int)*place++) == (int)':' ||
|
||||
(optchar == (int)'-' && *place != '\0') ||
|
||||
(oli = strchr(options, optchar)) == NULL) {
|
||||
/*
|
||||
* If the user specified "-" and '-' isn't listed in
|
||||
* options, return -1 (non-option) as per POSIX.
|
||||
* Otherwise, it is an unknown option character (or ':').
|
||||
*/
|
||||
if (optchar == (int)'-' && *place == '\0')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (PRINT_ERROR)
|
||||
warnx(illoptchar, optchar);
|
||||
optopt = optchar;
|
||||
return (BADCH);
|
||||
}
|
||||
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
|
||||
/* -W long-option */
|
||||
if (*place) /* no space */
|
||||
/* NOTHING */;
|
||||
else if (++optind >= nargc) { /* no arg */
|
||||
place = EMSG;
|
||||
if (PRINT_ERROR)
|
||||
warnx(recargchar, optchar);
|
||||
optopt = optchar;
|
||||
return (BADARG);
|
||||
} else /* white space */
|
||||
place = nargv[optind];
|
||||
optchar = parse_long_options(nargv, options, long_options,
|
||||
idx, 0);
|
||||
place = EMSG;
|
||||
return (optchar);
|
||||
}
|
||||
if (*++oli != ':') { /* doesn't take argument */
|
||||
if (!*place)
|
||||
++optind;
|
||||
} else { /* takes (optional) argument */
|
||||
optarg = NULL;
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (oli[1] != ':') { /* arg not optional */
|
||||
if (++optind >= nargc) { /* no arg */
|
||||
place = EMSG;
|
||||
if (PRINT_ERROR)
|
||||
warnx(recargchar, optchar);
|
||||
optopt = optchar;
|
||||
return (BADARG);
|
||||
} else
|
||||
optarg = nargv[optind];
|
||||
}
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
/* dump back option letter */
|
||||
return (optchar);
|
||||
}
|
||||
|
||||
#ifdef REPLACE_GETOPT
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*
|
||||
* [eventually this will replace the BSD getopt]
|
||||
*/
|
||||
int
|
||||
getopt(int nargc, char * const *nargv, const char *options)
|
||||
{
|
||||
|
||||
/*
|
||||
* We don't pass FLAG_PERMUTE to getopt_internal() since
|
||||
* the BSD getopt(3) (unlike GNU) has never done this.
|
||||
*
|
||||
* Furthermore, since many privileged programs call getopt()
|
||||
* before dropping privileges it makes sense to keep things
|
||||
* as simple (and bug-free) as possible.
|
||||
*/
|
||||
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
|
||||
}
|
||||
#endif /* REPLACE_GETOPT */
|
||||
|
||||
/*
|
||||
* getopt_long --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt_long(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx)
|
||||
{
|
||||
|
||||
return (getopt_internal(nargc, nargv, options, long_options, idx,
|
||||
FLAG_PERMUTE));
|
||||
}
|
||||
|
||||
/*
|
||||
* getopt_long_only --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt_long_only(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx)
|
||||
{
|
||||
|
||||
return (getopt_internal(nargc, nargv, options, long_options, idx,
|
||||
FLAG_PERMUTE|FLAG_LONGONLY));
|
||||
}
|
105
src/getopt.h
Normal file
105
src/getopt.h
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef __GETOPT_H__
|
||||
/**
|
||||
* DISCLAIMER
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the w64 mingw-runtime package.
|
||||
*
|
||||
* The w64 mingw-runtime package and its code is distributed in the hope that it
|
||||
* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
|
||||
* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
|
||||
* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#define __GETOPT_H__
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <crtdefs.h>
|
||||
|
||||
#if defined( WINGETOPT_SHARED_LIB )
|
||||
# if defined( BUILDING_WINGETOPT_DLL )
|
||||
# define WINGETOPT_API __declspec(dllexport)
|
||||
# else
|
||||
# define WINGETOPT_API __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define WINGETOPT_API
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WINGETOPT_API extern int optind; /* index of first non-option in argv */
|
||||
WINGETOPT_API extern int optopt; /* single option character, as parsed */
|
||||
WINGETOPT_API extern int opterr; /* flag to enable built-in diagnostics... */
|
||||
/* (user may set to zero, to suppress) */
|
||||
|
||||
WINGETOPT_API extern char *optarg; /* pointer to argument of current option */
|
||||
|
||||
extern int getopt(int nargc, char * const *nargv, const char *options);
|
||||
|
||||
#ifdef _BSD_SOURCE
|
||||
/*
|
||||
* BSD adds the non-standard `optreset' feature, for reinitialisation
|
||||
* of `getopt' parsing. We support this feature, for applications which
|
||||
* proclaim their BSD heritage, before including this header; however,
|
||||
* to maintain portability, developers are advised to avoid it.
|
||||
*/
|
||||
# define optreset __mingw_optreset
|
||||
extern int optreset;
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* POSIX requires the `getopt' API to be specified in `unistd.h';
|
||||
* thus, `unistd.h' includes this header. However, we do not want
|
||||
* to expose the `getopt_long' or `getopt_long_only' APIs, when
|
||||
* included in this manner. Thus, close the standard __GETOPT_H__
|
||||
* declarations block, and open an additional __GETOPT_LONG_H__
|
||||
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
|
||||
* to declare the extended API.
|
||||
*/
|
||||
#endif /* !defined(__GETOPT_H__) */
|
||||
|
||||
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
|
||||
#define __GETOPT_LONG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct option /* specification for a long form option... */
|
||||
{
|
||||
const char *name; /* option name, without leading hyphens */
|
||||
int has_arg; /* does it take an argument? */
|
||||
int *flag; /* where to save its status, or NULL */
|
||||
int val; /* its associated status value */
|
||||
};
|
||||
|
||||
enum /* permitted values for its `has_arg' field... */
|
||||
{
|
||||
no_argument = 0, /* option never takes an argument */
|
||||
required_argument, /* option always requires an argument */
|
||||
optional_argument /* option may take an argument */
|
||||
};
|
||||
|
||||
extern int getopt_long(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx);
|
||||
extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
|
||||
const struct option *long_options, int *idx);
|
||||
/*
|
||||
* Previous MinGW implementation had...
|
||||
*/
|
||||
#ifndef HAVE_DECL_GETOPT
|
||||
/*
|
||||
* ...for the long form API only; keep this for compatibility.
|
||||
*/
|
||||
# define HAVE_DECL_GETOPT 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
|
235
src/main.cpp
Normal file
235
src/main.cpp
Normal file
@ -0,0 +1,235 @@
|
||||
#include "main.h"
|
||||
|
||||
// 打印帮助信息
|
||||
void help(char** argv)
|
||||
{
|
||||
static const char* help_s[] = {
|
||||
"",
|
||||
"Options:",
|
||||
" -h,? print help",
|
||||
" -a add Registry",
|
||||
" -d delete Registry",
|
||||
" -b Start SSH on boot",
|
||||
" -p Turn off and start SSH",
|
||||
"",
|
||||
0
|
||||
};
|
||||
static const char name[] = "Right_bash 1.2";
|
||||
static const char usage[] = "Usage: [-?hadbp]";
|
||||
static const char author[] = "Author: aixiao@aixiao.me";
|
||||
|
||||
printf("%s\n", name);
|
||||
printf("%s\n", author);
|
||||
printf("%s\n", usage);
|
||||
|
||||
for (int i = 0; help_s[i]; i++)
|
||||
fprintf(stderr, "%s\n", help_s[i]);
|
||||
}
|
||||
|
||||
// 根据错误码输出错误信息
|
||||
void showErrorText(DWORD error_num)
|
||||
{
|
||||
char* msg = NULL;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error_num, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // 使用默认语言
|
||||
(LPSTR)&msg, 0, NULL);
|
||||
|
||||
printf("Error code %d: ", error_num);
|
||||
if (msg == NULL)
|
||||
printf("%s\n", "Unknown error");
|
||||
else
|
||||
printf("%s", msg);
|
||||
}
|
||||
|
||||
void add_Right()
|
||||
{
|
||||
HKEY hKey;
|
||||
HKEY subKey;
|
||||
DWORD result;
|
||||
|
||||
char item1[] = "bash";
|
||||
char value1[] = "wsl.exe --cd \"%V\"";
|
||||
char item2[] = "command";
|
||||
char value2[] = "Open Bash in this location";
|
||||
|
||||
char icon_name[] = "Icon";
|
||||
char icon_data[] = "C:\\Users\\niuyuling\\icon.ico";
|
||||
|
||||
// 打开注册表, HKEY_CLASSES_ROOT\Directory\Background\shell
|
||||
result = RegOpenKeyEx(HKEY_CLASSES_ROOT, "Directory\\Background\\shell", 0, // 保留参数必须填 0
|
||||
KEY_WRITE, // 打开权限,写入
|
||||
&hKey // 打开之后的句柄
|
||||
);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
// 添加注册表项, 即 HKEY_CLASSES_ROOT\Directory\Background\shell\bash
|
||||
RegCreateKey(hKey, item1, &subKey);
|
||||
|
||||
|
||||
|
||||
// 修改注册表项,默认的数据
|
||||
result = RegSetValueA(subKey, NULL, REG_SZ, value2, (unsigned long)strlen(value2));
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
// 设置注册表项下指定值的数据和类型。(添加图标)
|
||||
RegSetValueExA(subKey, icon_name, 0, REG_SZ, (BYTE *)icon_data, strlen(icon_data));
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
// 打开注册表, HKEY_CLASSES_ROOT\Directory\Background\shell\bash
|
||||
result = RegOpenKeyEx(HKEY_CLASSES_ROOT, "Directory\\Background\\shell\\bash", 0, // 保留参数必须填 0
|
||||
KEY_WRITE, // 打开权限,写入
|
||||
&hKey // 打开之后的句柄
|
||||
);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
// 添加注册表项, 即 HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command
|
||||
RegCreateKey(hKey, item2, &subKey);
|
||||
|
||||
// 修改默认项的数据
|
||||
result = RegSetValueA(subKey, NULL, REG_SZ, value1, (unsigned long)strlen(value1));
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey); // 关闭注册表
|
||||
RegCloseKey(subKey); // 关闭注册表
|
||||
}
|
||||
|
||||
void del_Right()
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD result;
|
||||
|
||||
// 打开注册表, HKEY_CLASSES_ROOT\Directory\Background\shell
|
||||
result = RegOpenKeyEx(HKEY_CLASSES_ROOT, "Directory\\Background\\shell", 0, // 保留参数必须填 0
|
||||
KEY_WRITE, // 打开权限,写入
|
||||
&hKey // 打开之后的句柄
|
||||
);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表打开失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
// 删除 HKEY_CLASSES_ROOT\Directory\Background\shell\bash
|
||||
result = RegDeleteTreeA(hKey, "bash");
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey); //关闭注册表
|
||||
}
|
||||
|
||||
void add_boot_ssh(char* optarg)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD result;
|
||||
//char value[] = "C:\\WINDOWS\\system32\\wsl.exe -d debian -u root /usr/sbin/service ssh start";
|
||||
|
||||
char item[CACHE_SIZE];
|
||||
char value[CACHE_SIZE];
|
||||
memset(item, 0, CACHE_SIZE);
|
||||
memset(value, 0, CACHE_SIZE);
|
||||
strcpy_s(item, sizeof(item), optarg);
|
||||
sprintf_s(value, "%s", "C:\\WINDOWS\\system32\\wsl.exe -d ");
|
||||
strcat_s(value, strlen(value) + strlen(optarg) + 1, optarg);
|
||||
strcat_s(value, strlen(value) + 37, " -u root /usr/sbin/service ssh start");
|
||||
|
||||
// 计算机\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
|
||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, // 保留参数必须填 0
|
||||
KEY_WRITE, // 打开权限,写入
|
||||
&hKey // 打开之后的句柄
|
||||
);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表打开失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
result = RegSetValueEx(hKey, item, // 键名
|
||||
0, // 保留参数必须填 0
|
||||
REG_SZ, // 键值类型为字符串
|
||||
(const unsigned char*)value, // 字符串首地址
|
||||
sizeof(value) // 字符串长度
|
||||
);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey); // 关闭注册表
|
||||
}
|
||||
|
||||
void del_boot_ssh(char* optarg)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD result;
|
||||
|
||||
char item[CACHE_SIZE];
|
||||
char value[] = "C:\\WINDOWS\\system32\\wsl.exe -d debian -u root /usr/sbin/service ssh status";
|
||||
|
||||
memset(item, 0, CACHE_SIZE);
|
||||
strcpy_s(item, sizeof(item), optarg);
|
||||
|
||||
// 计算机\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
|
||||
result = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, // 保留参数必须填 0
|
||||
KEY_WRITE, // 打开权限,写入
|
||||
&hKey // 打开之后的句柄
|
||||
);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表打开失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
// 删除 计算机\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 下的 item
|
||||
result = RegDeleteValue(hKey, item);
|
||||
|
||||
if (result != ERROR_SUCCESS) {
|
||||
printf("注册表设置失败\n");
|
||||
showErrorText(result);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey); // 关闭注册表
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "adb:p:h?")) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
add_Right();
|
||||
break;
|
||||
case 'd':
|
||||
del_Right();
|
||||
break;
|
||||
case 'b':
|
||||
add_boot_ssh(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
del_boot_ssh(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
help(argv);
|
||||
break;
|
||||
case '?':
|
||||
help(argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
14
src/main.h
Normal file
14
src/main.h
Normal file
@ -0,0 +1,14 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <direct.h>
|
||||
#include "getopt.h"
|
||||
|
||||
#define CACHE_SIZE 270
|
||||
|
||||
void showErrorText(DWORD error_num);
|
||||
void add_Right();
|
||||
void del_Right();
|
||||
void add_boot_ssh(char* optarg);
|
||||
void del_boot_ssh(char* optarg);
|
||||
void help(char** argv);
|
||||
|
Loading…
Reference in New Issue
Block a user