Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*.swp
*.o
WebServer.exe

.exe
Debug

*.opendb
Binary file added .vs/cpp-webserver/v14/.suo
Binary file not shown.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# cpp-webserver
A simple webserver for Windows

## �˰汾����
����vs2015����

���������֧�����ģ�����utf-8����ת��

����config.ini�ļ����������˿ں�crsf��Խ�������������ļ�

����warning����

## Getting the sources from Github

git clone https://github.com/ReneNyffenegger/cpp-webserver webserver
Expand Down
1 change: 0 additions & 1 deletion base64
Submodule base64 deleted from 26a73f
Binary file added cpp-webserver.VC.db
Binary file not shown.
28 changes: 28 additions & 0 deletions cpp-webserver.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-webserver", "cpp-webserver\cpp-webserver.vcxproj", "{36A1603B-A705-4F3A-902A-3F354FD31564}"
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
{36A1603B-A705-4F3A-902A-3F354FD31564}.Debug|x64.ActiveCfg = Debug|x64
{36A1603B-A705-4F3A-902A-3F354FD31564}.Debug|x64.Build.0 = Debug|x64
{36A1603B-A705-4F3A-902A-3F354FD31564}.Debug|x86.ActiveCfg = Debug|Win32
{36A1603B-A705-4F3A-902A-3F354FD31564}.Debug|x86.Build.0 = Debug|Win32
{36A1603B-A705-4F3A-902A-3F354FD31564}.Release|x64.ActiveCfg = Release|x64
{36A1603B-A705-4F3A-902A-3F354FD31564}.Release|x64.Build.0 = Release|x64
{36A1603B-A705-4F3A-902A-3F354FD31564}.Release|x86.ActiveCfg = Release|Win32
{36A1603B-A705-4F3A-902A-3F354FD31564}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
242 changes: 242 additions & 0 deletions cpp-webserver/EncodingConverter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/**
* 源码感谢yaocoder
* 拷贝工程https://github.com/yaocoder/utility
*/
#pragma once
#include <string>
#include <stringapiset.h>

#ifdef tstring
#error "\"tstring\" Macro has been defined."
#else
#ifdef _UNICODE
#define tstring wstring
#else
#define tstring string
#endif
#endif

class EncodingConverter
{
public:
static int AnsiStrToWideStr(std::string& strSrc, std::wstring& strDest)
{
int nLen = strSrc.length() + 1;
int nRet = 0;

nLen *= sizeof(wchar_t);

wchar_t* pszW = new wchar_t[nLen];
memset(pszW, 0, nLen);

nRet = MultiByteToWideChar(CP_ACP, 0, strSrc.c_str(), -1, pszW, nLen);

strDest = pszW;
delete[] pszW;

return nRet;
};

static int WideStrToAnsiStr(std::wstring& strSrc, std::string& strDest)
{
int nLen = strSrc.length() + 1;
int nRet = 0;

nLen *= sizeof(wchar_t);

char* pszA = new char[nLen];
memset(pszA, 0, nLen);


nRet = WideCharToMultiByte(CP_ACP, 0, strSrc.c_str(), -1, pszA, nLen, NULL, NULL);

strDest = pszA;
delete[] pszA;

return nRet;
};

static int AnsiStrToTStr(std::string& strSrc, std::tstring& strDest)
{
int nRet = 0;

#ifdef _UNICODE
nRet = AnsiStrToWideStr(strSrc, strDest);
#else
strDest = strSrc;
nRet = strDest.length();
#endif

return nRet;
};

static int TStrToAnsiStr(std::tstring& strSrc, std::string& strDest)
{
int nRet = 0;

#ifdef _UNICODE
nRet = WideStrToAnsiStr(strSrc, strDest);
#else
strDest = strSrc;
nRet = strDest.length();
#endif

return nRet;
};

static int WideStrToTStr(std::wstring& strSrc, std::tstring& strDest)
{
int nRet = 0;

#ifdef _UNICODE
strDest = strSrc;
nRet = strDest.length();
#else
nRet = WideStrToAnsiStr(strSrc, strDest);
#endif

return nRet;
};

static int TStrToWideStr(std::tstring& strSrc, std::wstring& strDest)
{
int nRet = 0;

#ifdef _UNICODE
strDest = strSrc;
nRet = strDest.length();
#else
nRet = AnsiStrToWideStr(strSrc, strDest);
#endif

return nRet;
};

static std::string ToAnsiString(const wchar_t* lpStr)
{
std::wstring wide_string = lpStr;
std::string ansi_string;

WideStrToAnsiStr(wide_string, ansi_string);
return ansi_string;
};

static std::string ToAnsiString(const char* lpStr)
{
return std::string(lpStr);
};

static std::wstring ToWideString(const wchar_t* lpStr)
{
return std::wstring(lpStr);
};

static std::wstring ToWideString(const char* lpStr)
{
std::string ansi_string = lpStr;
std::wstring wide_string;

AnsiStrToWideStr(ansi_string, wide_string);
return wide_string;
};

static std::tstring ToTString(const char* lpStr)
{
#ifdef _UNICODE
return ToWideString(lpStr);
#else
return ToAnsiString(lpStr);
#endif
};

static std::tstring ToTString(const wchar_t* lpStr)
{
#ifdef _UNICODE
return ToWideString(lpStr);
#else
return ToAnsiString(lpStr);
#endif
};

static int WideStrToUtf8Str(std::wstring& strSrc, std::string& strDest)
{
int nRet = 0;
int nLen = 0;

nLen = WideCharToMultiByte(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0, NULL, NULL);

char * lpUtf8Str = new char[nLen + 1];
memset(lpUtf8Str, 0, nLen);
nRet = WideCharToMultiByte(CP_UTF8, 0, strSrc.c_str(), -1, lpUtf8Str, nLen, NULL, NULL);
strDest = lpUtf8Str;
delete[] lpUtf8Str;

return nRet;
};

static int AnsiStrToUtf8Str(std::string& strSrc, std::string& strDest)
{
int nRet = 0;
std::wstring wide_string;

nRet = AnsiStrToWideStr(strSrc, wide_string);
nRet = WideStrToUtf8Str(wide_string, strDest);

return nRet;
};

static int Utf8StrToWideStr(const std::string& strSrc, std::wstring& strDest)
{
int nRet = 0;
int nLen = 0;

nLen = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0);

wchar_t* lpWideStr = new wchar_t[nLen];
memset(lpWideStr, 0, nLen * sizeof(lpWideStr[0]));
nRet = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, lpWideStr, nLen);
strDest = lpWideStr;
delete[] lpWideStr;

return nRet;
};

static int Utf8StrToAnsiStr(const std::string& strSrc, std::string& strDest)
{
int nRet = 0;
std::wstring wide_string;

nRet = Utf8StrToWideStr(strSrc, wide_string);
nRet = WideStrToAnsiStr(wide_string, strDest);

return nRet;
};

static int Utf8StrToTStr(const std::string& strSrc, std::tstring& strDest)
{
#ifdef UNICODE
return Utf8StrToWideStr(strSrc, strDest);
#else
return Utf8StrToAnsiStr(strSrc, strDest);
#endif
};

static std::string ToUtf8String(const std::string& str)
{
std::string ansi_string = str;
std::string utf8_string;

AnsiStrToUtf8Str(ansi_string, utf8_string);
return utf8_string;
};

static std::string ToUtf8String(const std::wstring& str)
{
std::wstring wide_string = str;
std::string utf8_string;

WideStrToUtf8Str(wide_string, utf8_string);
return utf8_string;
};

};
40 changes: 40 additions & 0 deletions cpp-webserver/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
========================================================================
CONSOLE APPLICATION : cpp-webserver Project Overview
========================================================================

AppWizard has created this cpp-webserver application for you.

This file contains a summary of what you will find in each of the files that
make up your cpp-webserver application.


cpp-webserver.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

cpp-webserver.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).

cpp-webserver.cpp
This is the main application source file.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named cpp-webserver.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////
File renamed without changes.
2 changes: 1 addition & 1 deletion UrlHelper.cpp → cpp-webserver/UrlHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/


#include "stdafx.h"
#include "UrlHelper.h"
#include "Tracer.h"
#include "stdHelpers.h"
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions cpp-webserver/base64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.swp
test-base64
19 changes: 19 additions & 0 deletions cpp-webserver/base64/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright © 2004-2017 by René Nyffenegger

This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.

3. This notice may not be removed or altered from any source distribution.
2 changes: 2 additions & 0 deletions cpp-webserver/base64/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cpp-base64
base64 encoding and decoding with c++
Loading