mirror of
https://github.com/lammertb/libhttp.git
synced 2025-09-04 12:42:09 +03:00
Add Qt build
This commit is contained in:
22
Qt/CivetWeb.pro
Normal file
22
Qt/CivetWeb.pro
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
TEMPLATE = app
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG -= qt
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../src/md5.inl \
|
||||||
|
../src/mod_lua.inl \
|
||||||
|
../src/timer.inl \
|
||||||
|
../src/civetweb.c \
|
||||||
|
../src/main.c
|
||||||
|
|
||||||
|
include(deployment.pri)
|
||||||
|
qtcAddDeployment()
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../include/civetweb.h
|
||||||
|
|
||||||
|
INCLUDEPATH += \
|
||||||
|
../include/
|
||||||
|
|
||||||
|
LIBS += -lws2_32 -lComdlg32
|
@@ -201,7 +201,9 @@ typedef long off_t;
|
|||||||
#define SSL_LIB "ssleay32.dll"
|
#define SSL_LIB "ssleay32.dll"
|
||||||
#define CRYPTO_LIB "libeay32.dll"
|
#define CRYPTO_LIB "libeay32.dll"
|
||||||
#define O_NONBLOCK 0
|
#define O_NONBLOCK 0
|
||||||
|
#ifndef W_OK
|
||||||
#define W_OK (2) /* http://msdn.microsoft.com/en-us/library/1w06ktdy.aspx */
|
#define W_OK (2) /* http://msdn.microsoft.com/en-us/library/1w06ktdy.aspx */
|
||||||
|
#endif
|
||||||
#if !defined(EWOULDBLOCK)
|
#if !defined(EWOULDBLOCK)
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#endif /* !EWOULDBLOCK */
|
#endif /* !EWOULDBLOCK */
|
||||||
@@ -941,6 +943,8 @@ int mg_atomic_inc(volatile int * addr)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
#if defined(_WIN32) && !defined(__SYMBIAN32__)
|
#if defined(_WIN32) && !defined(__SYMBIAN32__)
|
||||||
|
/* Depending on the SDK, this is either (volatile unsigned int *) or (volatile LONG *),
|
||||||
|
whatever you use, the other SDK is likely to raise a warning. */
|
||||||
ret = InterlockedIncrement((volatile unsigned int *) addr);
|
ret = InterlockedIncrement((volatile unsigned int *) addr);
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
ret = __sync_add_and_fetch(addr, 1);
|
ret = __sync_add_and_fetch(addr, 1);
|
||||||
@@ -954,6 +958,8 @@ int mg_atomic_dec(volatile int * addr)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
#if defined(_WIN32) && !defined(__SYMBIAN32__)
|
#if defined(_WIN32) && !defined(__SYMBIAN32__)
|
||||||
|
/* Depending on the SDK, this is either (volatile unsigned int *) or (volatile LONG *),
|
||||||
|
whatever you use, the other SDK is likely to raise a warning. */
|
||||||
ret = InterlockedDecrement((volatile unsigned int *) addr);
|
ret = InterlockedDecrement((volatile unsigned int *) addr);
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
ret = __sync_sub_and_fetch(addr, 1);
|
ret = __sync_sub_and_fetch(addr, 1);
|
||||||
@@ -2202,9 +2208,8 @@ static int mg_join_thread(pthread_t threadid)
|
|||||||
result = -1;
|
result = -1;
|
||||||
dwevent = WaitForSingleObject(threadid, INFINITE);
|
dwevent = WaitForSingleObject(threadid, INFINITE);
|
||||||
if (dwevent == WAIT_FAILED) {
|
if (dwevent == WAIT_FAILED) {
|
||||||
int err;
|
int err = GetLastError();
|
||||||
|
(void)err;
|
||||||
err = GetLastError();
|
|
||||||
DEBUG_TRACE("WaitForSingleObject() failed, error %d", err);
|
DEBUG_TRACE("WaitForSingleObject() failed, error %d", err);
|
||||||
} else {
|
} else {
|
||||||
if (dwevent == WAIT_OBJECT_0) {
|
if (dwevent == WAIT_OBJECT_0) {
|
||||||
@@ -2690,7 +2695,7 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
|
|||||||
char *end = 0;
|
char *end = 0;
|
||||||
unsigned long chunkSize = 0;
|
unsigned long chunkSize = 0;
|
||||||
|
|
||||||
for (i=0; i<sizeof(lenbuf)-1; i++) {
|
for (i=0; i<((int)sizeof(lenbuf)-1); i++) {
|
||||||
lenbuf[i] = mg_getc(conn);
|
lenbuf[i] = mg_getc(conn);
|
||||||
if (i>0 && lenbuf[i] == '\r' && lenbuf[i-1] != '\r') continue;
|
if (i>0 && lenbuf[i] == '\r' && lenbuf[i-1] != '\r') continue;
|
||||||
if (i>1 && lenbuf[i] == '\n' && lenbuf[i-1] == '\r') {
|
if (i>1 && lenbuf[i] == '\n' && lenbuf[i-1] == '\r') {
|
||||||
@@ -7018,7 +7023,7 @@ static int set_ports_option(struct mg_context *ctx)
|
|||||||
listen(so.sock, SOMAXCONN) != 0 ||
|
listen(so.sock, SOMAXCONN) != 0 ||
|
||||||
getsockname(so.sock, &(usa.sa), &len) != 0) {
|
getsockname(so.sock, &(usa.sa), &len) != 0) {
|
||||||
mg_cry(fc(ctx), "%s: cannot bind to %.*s: %d (%s)", __func__,
|
mg_cry(fc(ctx), "%s: cannot bind to %.*s: %d (%s)", __func__,
|
||||||
(int) vec.len, vec.ptr, ERRNO, strerror(errno));
|
(int) vec.len, vec.ptr, (int)ERRNO, strerror(errno));
|
||||||
if (so.sock != INVALID_SOCKET) {
|
if (so.sock != INVALID_SOCKET) {
|
||||||
closesocket(so.sock);
|
closesocket(so.sock);
|
||||||
so.sock = INVALID_SOCKET;
|
so.sock = INVALID_SOCKET;
|
||||||
@@ -8260,7 +8265,7 @@ static void free_context(struct mg_context *ctx)
|
|||||||
/* Deallocate config parameters */
|
/* Deallocate config parameters */
|
||||||
for (i = 0; i < NUM_OPTIONS; i++) {
|
for (i = 0; i < NUM_OPTIONS; i++) {
|
||||||
if (ctx->config[i] != NULL)
|
if (ctx->config[i] != NULL)
|
||||||
#ifdef WIN32
|
#ifdef _MSC_VER
|
||||||
#pragma warning(suppress: 6001)
|
#pragma warning(suppress: 6001)
|
||||||
#endif
|
#endif
|
||||||
mg_free(ctx->config[i]);
|
mg_free(ctx->config[i]);
|
||||||
@@ -8334,7 +8339,7 @@ static void get_system_name(char **sysName)
|
|||||||
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
||||||
dwBuild = ((dwVersion < 0x80000000) ? (DWORD)(HIWORD(dwVersion)) : 0);
|
dwBuild = ((dwVersion < 0x80000000) ? (DWORD)(HIWORD(dwVersion)) : 0);
|
||||||
|
|
||||||
sprintf(name, "Windows %d.%d", dwMajorVersion, dwMinorVersion);
|
sprintf(name, "Windows %u.%u", (unsigned)dwMajorVersion, (unsigned)dwMinorVersion);
|
||||||
*sysName = mg_strdup(name);
|
*sysName = mg_strdup(name);
|
||||||
#else
|
#else
|
||||||
*sysName = mg_strdup("Symbian");
|
*sysName = mg_strdup("Symbian");
|
||||||
|
26
src/main.c
26
src/main.c
@@ -48,6 +48,7 @@
|
|||||||
#ifndef _WIN32_WINNT
|
#ifndef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0501 /* Target Windows XP or higher */
|
#define _WIN32_WINNT 0x0501 /* Target Windows XP or higher */
|
||||||
#endif
|
#endif
|
||||||
|
#undef UNICODE
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winsvc.h>
|
#include <winsvc.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
@@ -511,9 +512,10 @@ static void verify_existence(char **options, const char *option_name,
|
|||||||
if (path) {
|
if (path) {
|
||||||
memset(wbuf, 0, sizeof(wbuf));
|
memset(wbuf, 0, sizeof(wbuf));
|
||||||
memset(mbbuf, 0, sizeof(mbbuf));
|
memset(mbbuf, 0, sizeof(mbbuf));
|
||||||
len = MultiByteToWideChar(CP_UTF8, 0, path, -1, wbuf, (int) sizeof(wbuf)/sizeof(wbuf[0])-1);
|
len = MultiByteToWideChar(CP_UTF8, 0, path, -1, wbuf, (int) sizeof(wbuf)/sizeof(wbuf[0])-1);
|
||||||
wcstombs(mbbuf, wbuf, sizeof(mbbuf)-1);
|
wcstombs(mbbuf, wbuf, sizeof(mbbuf)-1);
|
||||||
path = mbbuf;
|
path = mbbuf;
|
||||||
|
(void)len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -747,7 +749,7 @@ static void save_config(HWND hDlg, FILE *fp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP)
|
static BOOL CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -755,6 +757,7 @@ static BOOL CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
|
|||||||
const struct mg_option *default_options = mg_get_valid_options();
|
const struct mg_option *default_options = mg_get_valid_options();
|
||||||
char *file_options[MAX_OPTIONS*2+1] = {0};
|
char *file_options[MAX_OPTIONS*2+1] = {0};
|
||||||
char *title;
|
char *title;
|
||||||
|
(void)lParam;
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
@@ -966,7 +969,6 @@ static int get_password(const char * user, const char * realm, char * passwd, un
|
|||||||
#define WIDTH 280
|
#define WIDTH 280
|
||||||
#define LABEL_WIDTH 90
|
#define LABEL_WIDTH 90
|
||||||
|
|
||||||
HWND hDlg = NULL;
|
|
||||||
unsigned char mem[4096], *p;
|
unsigned char mem[4096], *p;
|
||||||
DLGTEMPLATE *dia = (DLGTEMPLATE *) mem;
|
DLGTEMPLATE *dia = (DLGTEMPLATE *) mem;
|
||||||
int ok, y;
|
int ok, y;
|
||||||
@@ -1031,7 +1033,7 @@ static int get_password(const char * user, const char * realm, char * passwd, un
|
|||||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
|
||||||
140, y, 55, 12, "Cancel");
|
140, y, 55, 12, "Cancel");
|
||||||
|
|
||||||
assert((int)p - (int)mem < sizeof(mem));
|
assert((int)p - (int)mem < (int)sizeof(mem));
|
||||||
|
|
||||||
dia->cy = y + (WORD)(HEIGHT * 1.5);
|
dia->cy = y + (WORD)(HEIGHT * 1.5);
|
||||||
|
|
||||||
@@ -1204,7 +1206,7 @@ static void show_settings_dialog()
|
|||||||
(WORD) (x + LABEL_WIDTH), y, width, 12, "");
|
(WORD) (x + LABEL_WIDTH), y, width, 12, "");
|
||||||
nelems++;
|
nelems++;
|
||||||
|
|
||||||
assert((int)p - (int)mem < sizeof(mem));
|
assert(((int)p - (int)mem) < (int)sizeof(mem));
|
||||||
}
|
}
|
||||||
|
|
||||||
y = (WORD) (((nelems + 1) / 2 + 1) * HEIGHT + 5);
|
y = (WORD) (((nelems + 1) / 2 + 1) * HEIGHT + 5);
|
||||||
@@ -1227,7 +1229,7 @@ static void show_settings_dialog()
|
|||||||
WS_CHILD | WS_VISIBLE | WS_DISABLED,
|
WS_CHILD | WS_VISIBLE | WS_DISABLED,
|
||||||
5, y, 100, 12, server_base_name);
|
5, y, 100, 12, server_base_name);
|
||||||
|
|
||||||
assert((int)p - (int)mem < sizeof(mem));
|
assert(((int)p - (int)mem) < (int)sizeof(mem));
|
||||||
|
|
||||||
dia->cy = ((nelems + 1) / 2 + 1) * HEIGHT + 30;
|
dia->cy = ((nelems + 1) / 2 + 1) * HEIGHT + 30;
|
||||||
DialogBoxIndirectParam(NULL, dia, NULL, SettingsDlgProc, (LPARAM) NULL);
|
DialogBoxIndirectParam(NULL, dia, NULL, SettingsDlgProc, (LPARAM) NULL);
|
||||||
@@ -1329,7 +1331,7 @@ static void change_password_file()
|
|||||||
140, y, 100, 12, u);
|
140, y, 100, 12, u);
|
||||||
|
|
||||||
nelems++;
|
nelems++;
|
||||||
assert((int)p - (int)mem < sizeof(mem));
|
assert(((int)p - (int)mem) < (int)sizeof(mem));
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
@@ -1353,7 +1355,7 @@ static void change_password_file()
|
|||||||
WS_CHILD | WS_VISIBLE | WS_DISABLED,
|
WS_CHILD | WS_VISIBLE | WS_DISABLED,
|
||||||
5, y, 100, 12, server_base_name);
|
5, y, 100, 12, server_base_name);
|
||||||
|
|
||||||
assert((int)p - (int)mem < sizeof(mem));
|
assert(((int)p - (int)mem) < (int)sizeof(mem));
|
||||||
|
|
||||||
dia->cy = y + 20;
|
dia->cy = y + 20;
|
||||||
} while ((IDOK == DialogBoxIndirectParam(NULL, dia, NULL, PasswordDlgProc, (LPARAM) path)) && (!exit_flag));
|
} while ((IDOK == DialogBoxIndirectParam(NULL, dia, NULL, PasswordDlgProc, (LPARAM) path)) && (!exit_flag));
|
||||||
@@ -1412,13 +1414,14 @@ static int manage_service(int action)
|
|||||||
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
|
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
static SERVICE_TABLE_ENTRY service_table[2] = {0};
|
static SERVICE_TABLE_ENTRY service_table[2];
|
||||||
int service_installed;
|
int service_installed;
|
||||||
char buf[200], *service_argv[] = {__argv[0], NULL};
|
char buf[200], *service_argv[] = {__argv[0], NULL};
|
||||||
POINT pt;
|
POINT pt;
|
||||||
HMENU hMenu;
|
HMENU hMenu;
|
||||||
static UINT s_uTaskbarRestart; /* for taskbar creation */
|
static UINT s_uTaskbarRestart; /* for taskbar creation */
|
||||||
|
|
||||||
|
memset(service_table, 0, sizeof(service_table));
|
||||||
service_table[0].lpServiceName = server_name;
|
service_table[0].lpServiceName = server_name;
|
||||||
service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
|
service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
|
||||||
|
|
||||||
@@ -1540,6 +1543,11 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show)
|
|||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
|
(void)hInst;
|
||||||
|
(void)hPrev;
|
||||||
|
(void)cmdline;
|
||||||
|
(void)show;
|
||||||
|
|
||||||
init_server_name(__argc, __argv);
|
init_server_name(__argc, __argv);
|
||||||
memset(&cls, 0, sizeof(cls));
|
memset(&cls, 0, sizeof(cls));
|
||||||
cls.lpfnWndProc = (WNDPROC) WindowProc;
|
cls.lpfnWndProc = (WNDPROC) WindowProc;
|
||||||
|
Reference in New Issue
Block a user