Browse Source

Made md5 a static include, renamed source includes a .inl.

Thomas Davis 12 years ago
parent
commit
350b1fc75e

+ 1 - 1
Makefile

@@ -17,7 +17,7 @@ PREFIX = /usr/local
 
 BUILD_DIRS += $(BUILD_DIR)
 
-LIB_SOURCES = civetweb.c md5.c 
+LIB_SOURCES = civetweb.c
 APP_SOURCES = main.c
 SOURCE_DIRS =
 

+ 1 - 1
Makefile.deprecated

@@ -118,7 +118,7 @@ lua.lib: $(LUA_WINOBJS)
 linux_lua: $(ALL_OBJECTS)
 	$(CC) $(ALL_OBJECTS) -o $(PROG) -ldl
 
-civetweb.o: mod_lua.c
+civetweb.o: mod_lua.inl
 
 # Make sure that the compiler flags come last in the compilation string.
 # If not so, this can break some on some Linux distros which use

+ 1 - 1
ReleaseNotes.md

@@ -14,7 +14,7 @@ Changes
 - Created new documentation on Embeddeding, Building and yaSSL (see docs/).
 - Updated License file to include all licenses.
 - Replaced MD5 implementation due to questionable license.
-     + This requires two new source files md5.c, md5.h
+     + This requires new source file md5.c
 - Changed UNIX/OSX build to conform to common practices.
      + Supports build, install and clean rules.
      + Supports cross compiling

+ 4 - 3
VS2012/civetweb/civetweb.vcxproj

@@ -80,7 +80,6 @@
   <ItemGroup>
     <ClCompile Include="..\..\civetweb.c" />
     <ClCompile Include="..\..\main.c" />
-    <ClCompile Include="..\..\md5.c" />
   </ItemGroup>
   <ItemGroup>
     <Image Include="..\..\build\systray.ico" />
@@ -90,9 +89,11 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\civetweb.h" />
-    <ClInclude Include="..\..\md5.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\md5.inl" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 5 - 6
VS2012/civetweb/civetweb.vcxproj.filters

@@ -21,9 +21,6 @@
     <ClCompile Include="..\..\civetweb.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\md5.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="..\..\build\systray.ico">
@@ -39,8 +36,10 @@
     <ClInclude Include="..\..\civetweb.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\md5.h">
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\md5.inl">
       <Filter>Header Files</Filter>
-    </ClInclude>
+    </None>
   </ItemGroup>
-</Project>
+</Project>

+ 4 - 3
VS2012/civetweb_lua/civetweb_lua.vcxproj

@@ -84,13 +84,11 @@
     <ClInclude Include="..\..\civetweb.h" />
     <ClInclude Include="..\..\lua-5.2.1\src\lauxlib.h" />
     <ClInclude Include="..\..\lua-5.2.1\src\lua.h" />
-    <ClInclude Include="..\..\md5.h" />
     <ClInclude Include="Resource.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\civetweb.c" />
     <ClCompile Include="..\..\main.c" />
-    <ClCompile Include="..\..\md5.c" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\build\res.rc" />
@@ -103,7 +101,10 @@
       <Project>{8f5e5d77-d269-4665-9e27-1045da6cf0d8}</Project>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\md5.inl" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 6 - 7
VS2012/civetweb_lua/civetweb_lua.vcxproj.filters

@@ -24,9 +24,6 @@
     <ClInclude Include="..\..\civetweb.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\md5.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\lua-5.2.1\src\lua.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -41,9 +38,6 @@
     <ClCompile Include="..\..\main.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\md5.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\build\res.rc">
@@ -55,4 +49,9 @@
       <Filter>Resource Files</Filter>
     </Image>
   </ItemGroup>
-</Project>
+  <ItemGroup>
+    <None Include="..\..\md5.inl">
+      <Filter>Header Files</Filter>
+    </None>
+  </ItemGroup>
+</Project>

+ 3 - 2
VS2012/civetweb_yassl/civetweb_yassl/civetweb_yassl.vcxproj

@@ -79,12 +79,10 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\civetweb.h" />
-    <ClInclude Include="..\..\..\md5.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\civetweb.c" />
     <ClCompile Include="..\..\..\main.c" />
-    <ClCompile Include="..\..\..\md5.c" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\..\build\res.rc" />
@@ -97,6 +95,9 @@
       <Project>{8c0c878b-bbd6-4241-bca6-61753ffcc7f1}</Project>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\..\md5.inl" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>

+ 5 - 6
VS2012/civetweb_yassl/civetweb_yassl/civetweb_yassl.vcxproj.filters

@@ -18,9 +18,6 @@
     <ClInclude Include="..\..\..\civetweb.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\md5.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\civetweb.c">
@@ -29,9 +26,6 @@
     <ClCompile Include="..\..\..\main.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\md5.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\..\build\res.rc">
@@ -43,4 +37,9 @@
       <Filter>Resource Files</Filter>
     </Image>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\..\md5.inl">
+      <Filter>Header Files</Filter>
+    </None>
+  </ItemGroup>
 </Project>

+ 4 - 3
VS2012/ex_embed_cpp/ex_embed_cpp.vcxproj

@@ -80,15 +80,16 @@
   <ItemGroup>
     <ClInclude Include="..\..\civetweb.h" />
     <ClInclude Include="..\..\cpp\CivetServer.h" />
-    <ClInclude Include="..\..\md5.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\civetweb.c" />
     <ClCompile Include="..\..\cpp\CivetServer.cpp" />
     <ClCompile Include="..\..\cpp\example.cpp" />
-    <ClCompile Include="..\..\md5.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\md5.inl" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 6 - 7
VS2012/ex_embed_cpp/ex_embed_cpp.vcxproj.filters

@@ -18,9 +18,6 @@
     <ClInclude Include="..\..\civetweb.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\md5.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\cpp\CivetServer.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -32,11 +29,13 @@
     <ClCompile Include="..\..\civetweb.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\md5.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\cpp\CivetServer.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
-</Project>
+  <ItemGroup>
+    <None Include="..\..\md5.inl">
+      <Filter>Header Files</Filter>
+    </None>
+  </ItemGroup>
+</Project>

+ 4 - 3
VS2012/ex_websocket/ex_websocket.vcxproj

@@ -79,14 +79,15 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClInclude Include="..\..\civetweb.h" />
-    <ClInclude Include="..\..\md5.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\civetweb.c" />
     <ClCompile Include="..\..\examples\websocket.c" />
-    <ClCompile Include="..\..\md5.c" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\..\md5.inl" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 6 - 7
VS2012/ex_websocket/ex_websocket.vcxproj.filters

@@ -18,9 +18,6 @@
     <ClInclude Include="..\..\civetweb.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\md5.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\examples\websocket.c">
@@ -29,8 +26,10 @@
     <ClCompile Include="..\..\civetweb.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\md5.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
-</Project>
+  <ItemGroup>
+    <None Include="..\..\md5.inl">
+      <Filter>Header Files</Filter>
+    </None>
+  </ItemGroup>
+</Project>

+ 1 - 4
VS2012/lua_lib/lua_lib.vcxproj

@@ -73,9 +73,6 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <Text Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
     <ClCompile Include="..\..\lua-5.2.1\src\lapi.c" />
     <ClCompile Include="..\..\lua-5.2.1\src\lauxlib.c" />
     <ClCompile Include="..\..\lua-5.2.1\src\lbaselib.c" />
@@ -117,4 +114,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 1 - 4
VS2012/lua_lib/lua_lib.vcxproj.filters

@@ -15,9 +15,6 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <Text Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
     <ClCompile Include="..\..\lua-5.2.1\src\lapi.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -126,4 +123,4 @@
       <Filter>Header Files</Filter>
     </ClInclude>
   </ItemGroup>
-</Project>
+</Project>

+ 4 - 3
civetweb.c

@@ -18,8 +18,6 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-#include "md5.h"
-
 #if defined(_WIN32)
 #if !defined(_CRT_SECURE_NO_WARNINGS)
 #define _CRT_SECURE_NO_WARNINGS // Disable deprecation warning in VS2005
@@ -266,6 +264,9 @@ static pthread_t pthread_self(void) {
 }
 #endif // _WIN32
 
+#define MD5_STATIC static
+#include "md5.inl"
+
 #ifdef DEBUG_TRACE
 #undef DEBUG_TRACE
 #define DEBUG_TRACE(x)
@@ -4100,7 +4101,7 @@ static uint32_t get_remote_ip(const struct mg_connection *conn) {
 }
 
 #ifdef USE_LUA
-#include "mod_lua.c"
+#include "mod_lua.inl"
 #endif // USE_LUA
 
 int mg_upload(struct mg_connection *conn, const char *destination_dir) {

+ 2 - 3
docs/Embedding.md

@@ -14,8 +14,7 @@ There is no library, it is just a small set of files to compile in to the applic
     - civetweb.c
     - civetweb.h
   2. MD5 API
-    - md5.h
-    - md5.c
+    - md5.inl
   3. C++ Wrapper (Optional)
     - cpp/CivetServer.cpp
     - cpp/CivetServer.h
@@ -58,7 +57,7 @@ LUA is a server side include functionality.  Files ending in .la will be process
 
 ##### Add the following sources
 
-  - mod_lua.c
+  - mod_lua.inl
   - lua-5.2.1/src
      + lapi.c
      + lauxlib.c

+ 1 - 1
examples/Makefile

@@ -1,5 +1,5 @@
 CFLAGS=	-W -Wall -I.. -pthread -g
-LIB_SOURCE =  ../civetweb.c  ../md5.c 
+LIB_SOURCE =  ../civetweb.c
 all:
 	OS=`uname`; \
 	  test "$$OS" = Linux && LIBS="-ldl" ; \

+ 0 - 69
md5.h

@@ -1,69 +0,0 @@
-
-/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
-/*
-  Independent implementation of MD5 (RFC 1321).
-
-  This code implements the MD5 Algorithm defined in RFC 1321, whose
-  text is available at
-	http://www.ietf.org/rfc/rfc1321.txt
-  The code is derived from the text of the RFC, including the test suite
-  (section A.5) but excluding the rest of Appendix A.  It does not include
-  any code or documentation that is identified in the RFC as being
-  copyrighted.
-
-  The original and principal author of md5.h is L. Peter Deutsch
-  <ghost@aladdin.com>.  Other authors are noted in the change history
-  that follows (in reverse chronological order):
-
-  2002-04-13 lpd Removed support for non-ANSI compilers; removed
-	references to Ghostscript; clarified derivation from RFC 1321;
-	now handles byte order either statically or dynamically.
-  1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
-  1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
-	added conditionalization for C++ compilation from Martin
-	Purschke <purschke@bnl.gov>.
-  1999-05-03 lpd Original version.
- */
-
-#ifndef md5_INCLUDED
-#  define md5_INCLUDED
-
-/*
- * This package supports both compile-time and run-time determination of CPU
- * byte order.  If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
- * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
- * defined as non-zero, the code will be compiled to run only on big-endian
- * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
- * run on either big- or little-endian CPUs, but will run slightly less
- * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
- */
-
-typedef unsigned char md5_byte_t; /* 8-bit byte */
-typedef unsigned int md5_word_t; /* 32-bit word */
-
-/* Define the state of the MD5 Algorithm. */
-typedef struct md5_state_s {
-    md5_word_t count[2];	/* message length in bits, lsw first */
-    md5_word_t abcd[4];		/* digest buffer */
-    md5_byte_t buf[64];		/* accumulate block */
-} md5_state_t;
-
-#ifdef __cplusplus
-extern "C" 
-{
-#endif
-
-/* Initialize the algorithm. */
-void md5_init(md5_state_t *pms);
-
-/* Append a string to the message. */
-void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
-
-/* Finish the message and return the digest. */
-void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
-
-#ifdef __cplusplus
-}  /* end extern "C" */
-#endif
-
-#endif /* md5_INCLUDED */

+ 84 - 4
md5.c → md5.inl

@@ -1,3 +1,82 @@
+/* 
+ * This an amalgamation of md5.c and md5.h into a single file
+ * with all static declaration to reduce linker conflicts
+ * in Civetweb.
+ *
+ * The MD5_STATIC declaration was added to facilitate static
+ * inclusion.
+ * No Face Press, LLC
+ */
+
+/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
+/*
+  Independent implementation of MD5 (RFC 1321).
+
+  This code implements the MD5 Algorithm defined in RFC 1321, whose
+  text is available at
+	http://www.ietf.org/rfc/rfc1321.txt
+  The code is derived from the text of the RFC, including the test suite
+  (section A.5) but excluding the rest of Appendix A.  It does not include
+  any code or documentation that is identified in the RFC as being
+  copyrighted.
+
+  The original and principal author of md5.h is L. Peter Deutsch
+  <ghost@aladdin.com>.  Other authors are noted in the change history
+  that follows (in reverse chronological order):
+
+  2002-04-13 lpd Removed support for non-ANSI compilers; removed
+	references to Ghostscript; clarified derivation from RFC 1321;
+	now handles byte order either statically or dynamically.
+  1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+  1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+	added conditionalization for C++ compilation from Martin
+	Purschke <purschke@bnl.gov>.
+  1999-05-03 lpd Original version.
+ */
+
+#ifndef md5_INCLUDED
+#  define md5_INCLUDED
+
+/*
+ * This package supports both compile-time and run-time determination of CPU
+ * byte order.  If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
+ * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
+ * defined as non-zero, the code will be compiled to run only on big-endian
+ * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
+ * run on either big- or little-endian CPUs, but will run slightly less
+ * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
+ */
+
+typedef unsigned char md5_byte_t; /* 8-bit byte */
+typedef unsigned int md5_word_t; /* 32-bit word */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+    md5_word_t count[2];	/* message length in bits, lsw first */
+    md5_word_t abcd[4];		/* digest buffer */
+    md5_byte_t buf[64];		/* accumulate block */
+} md5_state_t;
+
+#ifdef __cplusplus
+extern "C" 
+{
+#endif
+
+/* Initialize the algorithm. */
+MD5_STATIC void md5_init(md5_state_t *pms);
+
+/* Append a string to the message. */
+MD5_STATIC void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+
+/* Finish the message and return the digest. */
+MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+
+#ifdef __cplusplus
+}  /* end extern "C" */
+#endif
+
+#endif /* md5_INCLUDED */
+
 /*
   Copyright (C) 1999, 2000, 2002 Aladdin Enterprises.  All rights reserved.
 
@@ -51,8 +130,9 @@
   1999-05-03 lpd Original version.
  */
 
-#include "md5.h"
+#ifndef MD5_STATIC
 #include <string.h>
+#endif
 
 #undef BYTE_ORDER	/* 1 = big-endian, -1 = little-endian, 0 = unknown */
 #ifdef ARCH_IS_BIG_ENDIAN
@@ -309,7 +389,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
     pms->abcd[3] += d;
 }
 
-void
+MD5_STATIC void
 md5_init(md5_state_t *pms)
 {
     pms->count[0] = pms->count[1] = 0;
@@ -319,7 +399,7 @@ md5_init(md5_state_t *pms)
     pms->abcd[3] = 0x10325476;
 }
 
-void
+MD5_STATIC void
 md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
 {
     const md5_byte_t *p = data;
@@ -357,7 +437,7 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
 	memcpy(pms->buf, p, left);
 }
 
-void
+MD5_STATIC void
 md5_finish(md5_state_t *pms, md5_byte_t digest[16])
 {
     static const md5_byte_t pad[64] = {

+ 0 - 0
mod_lua.c → mod_lua.inl