瀏覽代碼

Add Qt build

bel2125 10 年之前
父節點
當前提交
fbaf61d6b8
共有 3 個文件被更改,包括 51 次插入16 次删除
  1. 22 0
      Qt/CivetWeb.pro
  2. 12 7
      src/civetweb.c
  3. 17 9
      src/main.c

+ 22 - 0
Qt/CivetWeb.pro

@@ -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

+ 12 - 7
src/civetweb.c

@@ -201,7 +201,9 @@ typedef long off_t;
 #define SSL_LIB   "ssleay32.dll"
 #define CRYPTO_LIB  "libeay32.dll"
 #define O_NONBLOCK  0
+#ifndef W_OK
 #define W_OK (2) /* http://msdn.microsoft.com/en-us/library/1w06ktdy.aspx */
+#endif
 #if !defined(EWOULDBLOCK)
 #define EWOULDBLOCK  WSAEWOULDBLOCK
 #endif /* !EWOULDBLOCK */
@@ -941,6 +943,8 @@ int mg_atomic_inc(volatile int * addr)
 {
     int ret;
 #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);
 #elif defined(__GNUC__)
     ret = __sync_add_and_fetch(addr, 1);
@@ -954,6 +958,8 @@ int mg_atomic_dec(volatile int * addr)
 {
     int ret;
 #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);
 #elif defined(__GNUC__)
     ret = __sync_sub_and_fetch(addr, 1);
@@ -2202,9 +2208,8 @@ static int mg_join_thread(pthread_t threadid)
     result = -1;
     dwevent = WaitForSingleObject(threadid, INFINITE);
     if (dwevent == WAIT_FAILED) {
-        int err;
-
-        err = GetLastError();
+        int err = GetLastError();
+        (void)err;
         DEBUG_TRACE("WaitForSingleObject() failed, error %d", err);
     } else {
         if (dwevent == WAIT_OBJECT_0) {
@@ -2690,7 +2695,7 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
                 char *end = 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);
                     if (i>0 && lenbuf[i] == '\r' && lenbuf[i-1] != '\r') continue;
                     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 ||
                    getsockname(so.sock, &(usa.sa), &len) != 0) {
             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) {
                 closesocket(so.sock);
                 so.sock = INVALID_SOCKET;
@@ -8260,7 +8265,7 @@ static void free_context(struct mg_context *ctx)
     /* Deallocate config parameters */
     for (i = 0; i < NUM_OPTIONS; i++) {
         if (ctx->config[i] != NULL)
-#ifdef WIN32
+#ifdef _MSC_VER
 #pragma warning(suppress: 6001)
 #endif
             mg_free(ctx->config[i]);
@@ -8334,7 +8339,7 @@ static void get_system_name(char **sysName)
     dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
     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);
 #else
     *sysName = mg_strdup("Symbian");

+ 17 - 9
src/main.c

@@ -48,6 +48,7 @@
 #ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501 /* Target Windows XP or higher */
 #endif
+#undef UNICODE
 #include <windows.h>
 #include <winsvc.h>
 #include <shlobj.h>
@@ -511,9 +512,10 @@ static void verify_existence(char **options, const char *option_name,
     if (path) {
         memset(wbuf, 0, sizeof(wbuf));
         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);
         path = mbbuf;
+        (void)len;
     }
 #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;
     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();
     char *file_options[MAX_OPTIONS*2+1] = {0};
     char *title;
+    (void)lParam;
 
     switch (msg) {
     case WM_CLOSE:
@@ -966,7 +969,6 @@ static int get_password(const char * user, const char * realm, char * passwd, un
 #define WIDTH 280
 #define LABEL_WIDTH 90
 
-    HWND hDlg = NULL;
     unsigned char mem[4096], *p;
     DLGTEMPLATE *dia = (DLGTEMPLATE *) mem;
     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,
         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);
 
@@ -1204,7 +1206,7 @@ static void show_settings_dialog()
                     (WORD) (x + LABEL_WIDTH), y, width, 12, "");
         nelems++;
 
-        assert((int)p - (int)mem < sizeof(mem));
+        assert(((int)p - (int)mem) < (int)sizeof(mem));
     }
 
     y = (WORD) (((nelems + 1) / 2 + 1) * HEIGHT + 5);
@@ -1227,7 +1229,7 @@ static void show_settings_dialog()
                 WS_CHILD | WS_VISIBLE | WS_DISABLED,
                 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;
     DialogBoxIndirectParam(NULL, dia, NULL, SettingsDlgProc, (LPARAM) NULL);
@@ -1329,7 +1331,7 @@ static void change_password_file()
                 140, y, 100, 12, u);
 
             nelems++;
-            assert((int)p - (int)mem < sizeof(mem));
+            assert(((int)p - (int)mem) < (int)sizeof(mem));
         }
         fclose(f);
 
@@ -1353,7 +1355,7 @@ static void change_password_file()
             WS_CHILD | WS_VISIBLE | WS_DISABLED,
             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;
     } 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,
                                    LPARAM lParam)
 {
-    static SERVICE_TABLE_ENTRY service_table[2] = {0};
+    static SERVICE_TABLE_ENTRY service_table[2];
     int service_installed;
     char buf[200], *service_argv[] = {__argv[0], NULL};
     POINT pt;
     HMENU hMenu;
     static UINT s_uTaskbarRestart; /* for taskbar creation */
 
+    memset(service_table, 0, sizeof(service_table));
     service_table[0].lpServiceName = server_name;
     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;
     MSG msg;
 
+    (void)hInst;
+    (void)hPrev;
+    (void)cmdline;
+    (void)show;
+
     init_server_name(__argc, __argv);
     memset(&cls, 0, sizeof(cls));
     cls.lpfnWndProc = (WNDPROC) WindowProc;