diff --git a/Makefile b/Makefile
index 133a1efe..392fa505 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-#
+#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
@@ -24,6 +24,8 @@ DOCDIR = $(DATAROOTDIR)/doc/$(CPROG)
SYSCONFDIR = $(PREFIX)/etc
HTMLDIR = $(DOCDIR)
+UNAME := $(shell uname)
+
# desired configuration of the document root
# never assume that the document_root actually
# exists on the build machine. When building
@@ -92,7 +94,7 @@ LIB_OBJECTS = $(filter-out $(MAIN_OBJECTS), $(BUILD_OBJECTS))
LIBS = -lpthread -lm
-ifeq ($(TARGET_OS),LINUX)
+ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
@@ -100,6 +102,13 @@ ifeq ($(TARGET_OS),LINUX)
CAN_INSTALL = 1
endif
+ifneq (, $(findstring MINGW32, $(UNAME)))
+ LIBS += -lws2_32 -lcomdlg32
+ SHARED_LIB=dll
+else
+ SHARED_LIB=so
+endif
+
all: build
help:
@@ -174,7 +183,7 @@ endif
lib: lib$(CPROG).a
-slib: lib$(CPROG).so
+slib: lib$(CPROG).$(SHARED_LIB)
clean:
rm -rf $(BUILD_DIR)
@@ -182,16 +191,20 @@ clean:
distclean: clean
@rm -rf VS2012/Debug VS2012/*/Debug VS2012/*/*/Debug
@rm -rf VS2012/Release VS2012/*/Release VS2012/*/*/Release
- rm -f $(CPROG) lib$(CPROG).so lib$(CPROG).a *.dmg *.msi *.exe
+ rm -f $(CPROG) lib$(CPROG).so lib$(CPROG).a *.dmg *.msi *.exe lib$(CPROG).dll lib$(CPROG).dll.a
lib$(CPROG).a: $(LIB_OBJECTS)
- @rm -f $@
+ @rm -f $@
ar cq $@ $(LIB_OBJECTS)
lib$(CPROG).so: CFLAGS += -fPIC
lib$(CPROG).so: $(LIB_OBJECTS)
$(LCC) -shared -o $@ $(CFLAGS) $(LDFLAGS) $(LIB_OBJECTS)
+lib$(CPROG).dll: CFLAGS += -fPIC
+lib$(CPROG).dll: $(LIB_OBJECTS)
+ $(LCC) -shared -o $@ $(CFLAGS) $(LDFLAGS) $(LIB_OBJECTS) $(LIBS) -Wl,--out-implib,lib$(CPROG).dll.a
+
$(CPROG): $(BUILD_OBJECTS)
$(LCC) -o $@ $(CFLAGS) $(LDFLAGS) $(BUILD_OBJECTS) $(LIBS)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 97bb9cd9..51a03720 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,14 +1,24 @@
Release Notes v1.6 (Under Development)
===
-### Objectives: *???*
+### Objectives: *Enhance Lua support, bug fixes and updates"
Changes
-------
+- Allow to specify title and tray icon for the Windows standalone server (bel)
+- Fix minor memory leaks (bel)
+- Redirect all memory allocation/deallocation through mg functions which may be overwritten (bel)
+- Support Cross-Origin Resource Sharing (CORS) for static files and scripts (bel)
+- Win32: Replace dll.def file by export macros in civetweb.h (CSTAJ)
+- Base64 encode and decode functions for Lua (bel)
+- Support pre-loaded files for the Lua environment (bel)
+- Server should check the nonce for http digest access authentication (bel)
+- Hide read-only flag in file dialogs opened by the Edit Settings dialog for the Windows executable (bel)
+- Add all functions to dll.def, that are in the header (bel)
- Added Lua extensions: send_file, get_var, get_mime_type, get_cookie, url_decode, url_encode (bel)
- mg_set_request_handler() mod to use pattern (bel, Patch from Toni Wilk)
- Solved, tested and documented SSL support for Windows (bel)
-- Fixed: select for Linux needs the nfds parameter set correctly (bel)
+- Fixed: select for Linux needs the nfds parameter set correctly (bel)
- Add methods for returning the ports civetweb is listening on (keithel)
- Fixes for Lua Server Pages, as described within the google groups thread. (bel)
- Added support for plain Lua Scripts, and an example script. (bel)
@@ -30,7 +40,7 @@ Changes
- Corrected bad mask flag/opcode passing to websocket callback (William Greathouse)
- Moved CEVITWEB_VERSION define into civetweb.h
-- Added new simple zip deployment build for Windows.
+- Added new simple zip deployment build for Windows.
- Removed windows install package build.
- Fixes page violation in mod_lua.inl (apkbox)
- Use C style comments to enable compiling most of civetweb with -ansi. (F-Secure Corporation)
@@ -79,7 +89,7 @@ Changes
- Conformed source files to UNIX line endings for consistency.
- Unified the coding style to improve reability.
-Release Notes v1.3
+Release Notes v1.3
===
### Objectives: *Buildroot Integration*
@@ -91,7 +101,7 @@ Changes
- Updated documentation
- Updated Buildroot config example
-Release Notes v1.2
+Release Notes v1.2
===
### Objectives: *Installation Improvements, buildroot, cross compile support*
The objective of this release is to make installation seamless.
@@ -115,7 +125,7 @@ Known Issues
- The prebuilt Window's version requires [Visual C++ Redistributable for Visual Studio 2012](http://www.microsoft.com/en-us/download/details.aspx?id=30679)
-Release Notes v1.1
+Release Notes v1.1
===
### Objectives: *Build, Documentation, License Improvements*
The objective of this release is to establish a maintable code base, ensure MIT license rights and improve usability and documentation.
@@ -144,7 +154,7 @@ Changes
+ Removed yaSSL from the OSX build, not needed.
- Added new Visual Studio projects for Windows builds.
+ Removed Windows support from Makefiles
- + Provided additional, examples with Lua, and another with yaSSL.
+ + Provided additional, examples with Lua, and another with yaSSL.
- Changed Zombie Reaping policy to not ignore SIGCHLD.
+ The previous method caused trouble in applciations that spawn children.
@@ -154,7 +164,7 @@ Known Issues
- Build support for VS6 and some other has been deprecated.
+ This does not impact embedded programs, just the stand-alone build.
+ The old Makefile was renamed to Makefile.deprecated.
- + This is partcially do to lack fo testing.
+ + This is partcially do to lack fo testing.
+ Need to find out what is actually in demand.
- Build changes may impact current users.
+ As with any change of this type, changes may impact some users.
diff --git a/VS2012/civetweb_lua/civetweb_lua.vcxproj b/VS2012/civetweb_lua/civetweb_lua.vcxproj
index 35b0e22a..c8a1f6b4 100644
--- a/VS2012/civetweb_lua/civetweb_lua.vcxproj
+++ b/VS2012/civetweb_lua/civetweb_lua.vcxproj
@@ -88,7 +88,7 @@
Level3Disabled
- LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)
@@ -102,7 +102,7 @@
Level3Disabled
- LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)
@@ -118,7 +118,7 @@
MaxSpeedtruetrue
- LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)
@@ -136,7 +136,7 @@
MaxSpeedtruetrue
- LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)
diff --git a/docs/UserManual.md b/docs/UserManual.md
index 56543ecb..3e188e41 100644
--- a/docs/UserManual.md
+++ b/docs/UserManual.md
@@ -316,6 +316,13 @@ Timeout for network read and network write operations, in milliseconds.
If client intends to keep long-running connection, either increase this value
or use keep-alive messages.
+### lua_preload_file
+This configuration option can be used to specify a Lua script file, which
+is executed before the actual web page script (Lua script, Lua server page
+or Lua websocket). It can be used to modify the Lua environment of all web
+page scripts, e.g., by loading additional libraries required by all scripts
+or to achieve backward compatibility by defining obsolete functions.
+
### lua_script_pattern `"**.lua$`
A pattern for files that are interpreted as Lua scripts by the server.
In contrast to Lua server pages, Lua scripts use plain Lua syntax.
@@ -402,11 +409,13 @@ mg (table):
mg.document_root -- a string that holds the document root directory
mg.auth_domain -- a string that holds the HTTP authentication domain
mg.get_var(str, varname) -- extract variable from (query) string
- mg.get_cookie(str, cookie) -- extract cookie from a string
+ mg.get_cookie(str, cookie) -- extract cookie from a string
mg.get_mime_type(filename) -- get MIME type of a file
mg.send_file(filename) -- send a file, including MIME type
mg.url_encode(str) -- URL encode a string
mg.url_decode(str) -- URL decode a string
+ mg.base64_encode(str) -- BASE64 encode a string
+ mg.base64_decode(str) -- BASE64 decode a string
mg.md5(str) -- return the MD5 hash of a string
mg.keep_alive(bool) -- allow/forbid to use http keep-alive for this request
mg.request_info -- a table with the following request information
@@ -419,7 +428,7 @@ mg (table):
.query_string -- query string if present, nil otherwise
.script_name -- name of the Lua script
.https -- true if accessed by https://, false otherwise
- .remote_user -- user name if authenticated, nil otherwise
+ .remote_user -- user name if authenticated, nil otherwise
connect (function):
-- Connect to the remote TCP server. This function is an implementation
diff --git a/examples/websocket/WebSockCallbacks.c b/examples/websocket/WebSockCallbacks.c
index 36cf68f4..df547e43 100644
--- a/examples/websocket/WebSockCallbacks.c
+++ b/examples/websocket/WebSockCallbacks.c
@@ -3,6 +3,10 @@
#include
#include "WebSockCallbacks.h"
+#ifdef __APPLE__
+#include
+#endif
+
#ifdef _WIN32
#include
typedef HANDLE pthread_mutex_t;
@@ -73,7 +77,7 @@ void websocket_ready_handler(struct mg_connection *conn) {
break;
}
}
- printf("\nNew websocket attached: %08x:%u\n", rq->remote_ip, rq->remote_port);
+ printf("\nNew websocket attached: %08lx:%u\n", rq->remote_ip, rq->remote_port);
pthread_mutex_unlock(&sMutex);
}
@@ -88,7 +92,7 @@ static void websocket_done(tWebSockInfo * wsock) {
break;
}
}
- printf("\nClose websocket attached: %08x:%u\n", mg_get_request_info(wsock->conn)->remote_ip, mg_get_request_info(wsock->conn)->remote_port);
+ printf("\nClose websocket attached: %08lx:%u\n", mg_get_request_info(wsock->conn)->remote_ip, mg_get_request_info(wsock->conn)->remote_port);
free(wsock);
}
}
@@ -107,7 +111,7 @@ int websocket_data_handler(struct mg_connection *conn, int flags, char *data, si
pthread_mutex_unlock(&sMutex);
return 1;
}
- if ((data_len>=5) && (data_len<100) && (flags==129) || (flags==130)) {
+ if (((data_len>=5) && (data_len<100) && (flags==129)) || (flags==130)) {
// init command
if ((wsock->webSockState==1) && (!memcmp(data,"init ",5))) {
diff --git a/include/civetweb.h b/include/civetweb.h
index b8be9c41..a6ca3e72 100644
--- a/include/civetweb.h
+++ b/include/civetweb.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2004-2013 Sergey Lyubka
+/* Copyright (c) 2013-2014 the Civetweb developers
+ * Copyright (c) 2004-2013 Sergey Lyubka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,6 +27,20 @@
#define CIVETWEB_VERSION "1.6"
#endif
+#ifndef CIVETWEB_API
+ #if defined(_WIN32)
+ #if defined(CIVETWEB_DLL_EXPORTS)
+ #define CIVETWEB_API __declspec(dllexport)
+ #elif defined(CIVETWEB_DLL_IMPORTS)
+ #define CIVETWEB_API __declspec(dllimport)
+ #else
+ #define CIVETWEB_API
+ #endif
+ #else
+ #define CIVETWEB_API
+ #endif
+#endif
+
#include
#include
@@ -140,6 +155,7 @@ struct mg_callbacks {
int (*http_error)(struct mg_connection *, int status);
};
+
/* Start web server.
Parameters:
@@ -165,7 +181,7 @@ struct mg_callbacks {
Return:
web server context, or NULL on error. */
-struct mg_context *mg_start(const struct mg_callbacks *callbacks,
+CIVETWEB_API struct mg_context *mg_start(const struct mg_callbacks *callbacks,
void *user_data,
const char **configuration_options);
@@ -175,7 +191,8 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
Must be called last, when an application wants to stop the web server and
release all associated resources. This function blocks until all Civetweb
threads are stopped. Context pointer becomes invalid. */
-void mg_stop(struct mg_context *);
+CIVETWEB_API void mg_stop(struct mg_context *);
+
/* mg_request_handler
@@ -190,6 +207,7 @@ void mg_stop(struct mg_context *);
1: the handler processed the request. */
typedef int (* mg_request_handler)(struct mg_connection *conn, void *cbdata);
+
/* mg_set_request_handler
Sets or removes a URI mapping for a request handler.
@@ -206,7 +224,7 @@ typedef int (* mg_request_handler)(struct mg_connection *conn, void *cbdata);
handler: the callback handler to use when the URI is requested.
If NULL, the URI will be removed.
cbdata: the callback data to give to the handler when it s requested. */
-void mg_set_request_handler(struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata);
+CIVETWEB_API void mg_set_request_handler(struct mg_context *ctx, const char *uri, mg_request_handler handler, void *cbdata);
/* Get the value of particular configuration parameter.
@@ -215,14 +233,41 @@ void mg_set_request_handler(struct mg_context *ctx, const char *uri, mg_request_
If given parameter name is not valid, NULL is returned. For valid
names, return value is guaranteed to be non-NULL. If parameter is not
set, zero-length string is returned. */
-const char *mg_get_option(const struct mg_context *ctx, const char *name);
+CIVETWEB_API const char *mg_get_option(const struct mg_context *ctx, const char *name);
+#if defined(MG_LEGACY_INTERFACE)
/* Return array of strings that represent valid configuration options.
For each option, option name and default value is returned, i.e. the
number of entries in the array equals to number_of_options x 2.
Array is NULL terminated. */
-const char **mg_get_valid_option_names(void);
+/* Deprecated: Use mg_get_valid_options instead. */
+CIVETWEB_API const char **mg_get_valid_option_names(void);
+#endif
+
+
+struct mg_option {
+ const char * name;
+ int type;
+ const char * default_value;
+};
+
+enum {
+ CONFIG_TYPE_UNKNOWN = 0x0,
+ CONFIG_TYPE_NUMBER = 0x1,
+ CONFIG_TYPE_STRING = 0x2,
+ CONFIG_TYPE_FILE = 0x3,
+ CONFIG_TYPE_DIRECTORY = 0x4,
+ CONFIG_TYPE_BOOLEAN = 0x5,
+ CONFIG_TYPE_EXT_PATTERN = 0x6
+};
+
+
+/* Return array of struct mg_option, representing all valid configuration
+ options of civetweb.c.
+ The array is terminated by a NULL name option. */
+CIVETWEB_API const struct mg_option *mg_get_valid_options(void);
+
/* Get the list of ports that civetweb is listening on.
size is the size of the ports int array and ssl int array to fill.
@@ -231,7 +276,8 @@ const char **mg_get_valid_option_names(void);
Return value is the number of ports and ssl information filled in.
The value returned is read-only. Civetweb does not allow changing
configuration at run time. */
-size_t mg_get_ports(const struct mg_context *ctx, size_t size, int* ports, int* ssl);
+CIVETWEB_API size_t mg_get_ports(const struct mg_context *ctx, size_t size, int* ports, int* ssl);
+
/* Add, edit or delete the entry in the passwords file.
@@ -245,14 +291,14 @@ size_t mg_get_ports(const struct mg_context *ctx, size_t size, int* ports, int*
Return:
1 on success, 0 on error. */
-int mg_modify_passwords_file(const char *passwords_file_name,
- const char *domain,
- const char *user,
- const char *password);
+CIVETWEB_API int mg_modify_passwords_file(const char *passwords_file_name,
+ const char *domain,
+ const char *user,
+ const char *password);
/* Return information associated with the request. */
-struct mg_request_info *mg_get_request_info(struct mg_connection *);
+CIVETWEB_API struct mg_request_info *mg_get_request_info(struct mg_connection *);
/* Send data to the client.
@@ -260,7 +306,7 @@ struct mg_request_info *mg_get_request_info(struct mg_connection *);
0 when the connection has been closed
-1 on error
>0 number of bytes written on success */
-int mg_write(struct mg_connection *, const void *buf, size_t len);
+CIVETWEB_API int mg_write(struct mg_connection *, const void *buf, size_t len);
/* Send data to a websocket client wrapped in a websocket frame. Uses mg_lock
@@ -275,16 +321,18 @@ int mg_write(struct mg_connection *, const void *buf, size_t len);
0 when the connection has been closed
-1 on error
>0 number of bytes written on success */
-int mg_websocket_write(struct mg_connection* conn, int opcode,
- const char *data, size_t data_len);
+CIVETWEB_API int mg_websocket_write(struct mg_connection* conn, int opcode,
+ const char *data, size_t data_len);
+
/* Blocks until unique access is obtained to this connection. Intended for use
with websockets only.
Invoke this before mg_write or mg_printf when communicating with a
websocket if your code has server-initiated communication as well as
communication in direct response to a message. */
-void mg_lock(struct mg_connection* conn);
-void mg_unlock(struct mg_connection* conn);
+CIVETWEB_API void mg_lock(struct mg_connection* conn);
+CIVETWEB_API void mg_unlock(struct mg_connection* conn);
+
/* Opcodes, from http://tools.ietf.org/html/rfc6455 */
enum {
@@ -317,14 +365,13 @@ enum {
#endif
/* Send data to the client using printf() semantics.
-
Works exactly like mg_write(), but allows to do message formatting. */
-int mg_printf(struct mg_connection *,
- PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
+CIVETWEB_API int mg_printf(struct mg_connection *,
+ PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
/* Send contents of the entire file together with HTTP headers. */
-void mg_send_file(struct mg_connection *conn, const char *path);
+CIVETWEB_API void mg_send_file(struct mg_connection *conn, const char *path);
/* Read data from the remote end, return number of bytes read.
@@ -332,7 +379,7 @@ void mg_send_file(struct mg_connection *conn, const char *path);
0 connection has been closed by peer. No more data could be read.
< 0 read error. No more data could be read from the connection.
> 0 number of bytes read into the buffer. */
-int mg_read(struct mg_connection *, void *buf, size_t len);
+CIVETWEB_API int mg_read(struct mg_connection *, void *buf, size_t len);
/* Get the value of particular HTTP header.
@@ -340,7 +387,7 @@ int mg_read(struct mg_connection *, void *buf, size_t len);
This is a helper function. It traverses request_info->http_headers array,
and if the header is present in the array, returns its value. If it is
not present, NULL is returned. */
-const char *mg_get_header(const struct mg_connection *, const char *name);
+CIVETWEB_API const char *mg_get_header(const struct mg_connection *, const char *name);
/* Get a value of particular form variable.
@@ -362,8 +409,9 @@ const char *mg_get_header(const struct mg_connection *, const char *name);
Destination buffer is guaranteed to be '\0' - terminated if it is not
NULL or zero length. */
-int mg_get_var(const char *data, size_t data_len,
- const char *var_name, char *dst, size_t dst_len);
+CIVETWEB_API int mg_get_var(const char *data, size_t data_len,
+ const char *var_name, char *dst, size_t dst_len);
+
/* Get a value of particular form variable.
@@ -388,8 +436,9 @@ int mg_get_var(const char *data, size_t data_len,
Destination buffer is guaranteed to be '\0' - terminated if it is not
NULL or zero length. */
-int mg_get_var2(const char *data, size_t data_len,
- const char *var_name, char *dst, size_t dst_len, size_t occurrence);
+CIVETWEB_API int mg_get_var2(const char *data, size_t data_len,
+ const char *var_name, char *dst, size_t dst_len, size_t occurrence);
+
/* Fetch value of certain cookie variable into the destination buffer.
@@ -404,8 +453,8 @@ int mg_get_var2(const char *data, size_t data_len,
parameter is not found).
-2 (destination buffer is NULL, zero length or too small to hold the
value). */
-int mg_get_cookie(const char *cookie, const char *var_name,
- char *buf, size_t buf_len);
+CIVETWEB_API int mg_get_cookie(const char *cookie, const char *var_name,
+ char *buf, size_t buf_len);
/* Download data from the remote web server.
@@ -423,35 +472,36 @@ int mg_get_cookie(const char *cookie, const char *var_name,
conn = mg_download("google.com", 80, 0, ebuf, sizeof(ebuf),
"%s", "GET / HTTP/1.0\r\nHost: google.com\r\n\r\n");
*/
-struct mg_connection *mg_download(const char *host, int port, int use_ssl,
- char *error_buffer, size_t error_buffer_size,
- PRINTF_FORMAT_STRING(const char *request_fmt),
- ...) PRINTF_ARGS(6, 7);
+CIVETWEB_API struct mg_connection *mg_download(const char *host, int port, int use_ssl,
+ char *error_buffer, size_t error_buffer_size,
+ PRINTF_FORMAT_STRING(const char *request_fmt),
+ ...) PRINTF_ARGS(6, 7);
/* Close the connection opened by mg_download(). */
-void mg_close_connection(struct mg_connection *conn);
+CIVETWEB_API void mg_close_connection(struct mg_connection *conn);
/* File upload functionality. Each uploaded file gets saved into a temporary
file and MG_UPLOAD event is sent.
Return number of uploaded files. */
-int mg_upload(struct mg_connection *conn, const char *destination_dir);
+CIVETWEB_API int mg_upload(struct mg_connection *conn, const char *destination_dir);
/* Convenience function -- create detached thread.
Return: 0 on success, non-0 on error. */
typedef void * (*mg_thread_func_t)(void *);
-int mg_start_thread(mg_thread_func_t f, void *p);
+CIVETWEB_API int mg_start_thread(mg_thread_func_t f, void *p);
/* Return builtin mime type for the given file name.
For unrecognized extensions, "text/plain" is returned. */
-const char *mg_get_builtin_mime_type(const char *file_name);
+CIVETWEB_API const char *mg_get_builtin_mime_type(const char *file_name);
/* Return Civetweb version. */
-const char *mg_version(void);
+CIVETWEB_API const char *mg_version(void);
+
/* URL-decode input buffer into destination buffer.
0-terminate the destination buffer.
@@ -459,13 +509,15 @@ const char *mg_version(void);
uses '+' as character for space, see RFC 1866 section 8.2.1
http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt
Return: length of the decoded data, or -1 if dst buffer is too small. */
-int mg_url_decode(const char *src, int src_len, char *dst,
- int dst_len, int is_form_url_encoded);
+CIVETWEB_API int mg_url_decode(const char *src, int src_len, char *dst,
+ int dst_len, int is_form_url_encoded);
+
/* URL-encode input buffer into destination buffer.
returns the length of the resulting buffer or -1
is the buffer is too small. */
-int mg_url_encode(const char *src, char *dst, size_t dst_len);
+CIVETWEB_API int mg_url_encode(const char *src, char *dst, size_t dst_len);
+
/* MD5 hash given strings.
Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
@@ -473,7 +525,7 @@ int mg_url_encode(const char *src, char *dst, size_t dst_len);
MD5 hash. Example:
char buf[33];
mg_md5(buf, "aa", "bb", NULL); */
-char *mg_md5(char buf[33], ...);
+CIVETWEB_API char *mg_md5(char buf[33], ...);
/* Print error message to the opened error log stream.
@@ -483,11 +535,13 @@ char *mg_md5(char buf[33], ...);
...: variable argument list
Example:
mg_cry(conn,"i like %s", "logging"); */
-void mg_cry(struct mg_connection *conn,
- PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
+CIVETWEB_API void mg_cry(struct mg_connection *conn,
+ PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
+
/* utility method to compare two buffers, case incensitive. */
-int mg_strncasecmp(const char *s1, const char *s2, size_t len);
+CIVETWEB_API int mg_strncasecmp(const char *s1, const char *s2, size_t len);
+
#ifdef __cplusplus
}
diff --git a/resources/dll.def b/resources/dll.def
deleted file mode 100644
index afd53118..00000000
--- a/resources/dll.def
+++ /dev/null
@@ -1,15 +0,0 @@
-LIBRARY
-EXPORTS
- mg_start
- mg_stop
- mg_read
- mg_write
- mg_printf
- mg_get_header
- mg_get_var
- mg_get_cookie
- mg_get_option
- mg_get_valid_option_names
- mg_version
- mg_modify_passwords_file
- mg_md5
diff --git a/src/CivetServer.cpp b/src/CivetServer.cpp
index fc5a5700..70a414da 100644
--- a/src/CivetServer.cpp
+++ b/src/CivetServer.cpp
@@ -150,8 +150,19 @@ bool
CivetServer::getParam(struct mg_connection *conn, const char *name,
std::string &dst, size_t occurrence)
{
- const char *query = mg_get_request_info(conn)->query_string;
- return getParam(query, strlen(query), name, dst, occurrence);
+ const char *formParams = NULL;
+ mg_request_info * ri = mg_get_request_info(conn);
+
+ if (ri) {
+ // get requests do store html