瀏覽代碼

*** empty log message ***

David Rose 25 年之前
父節點
當前提交
887741751c

+ 6 - 0
dtool/Config.pp

@@ -156,6 +156,12 @@
 #define NSPR_LIBS nspr4
 #define NSPR_LIBS nspr4
 #defer HAVE_NSPR $[libtest $[NSPR_LPATH],$[NSPR_LIBS]]
 #defer HAVE_NSPR $[libtest $[NSPR_LPATH],$[NSPR_LIBS]]
 
 
+// Is Crypto++ installed, and where?
+#define CRYPTO_IPATH /usr/include/crypto++
+#define CRYPTO_LPATH /usr/lib
+#define CRYPTO_LIBS cryptlib
+#defer HAVE_CRYPTO $[libtest $[CRYPTO_LPATH],$[CRYPTO_LIBS]]
+
 // Is VRPN installed, and where?
 // Is VRPN installed, and where?
 #define VRPN_IPATH
 #define VRPN_IPATH
 #define VRPN_LPATH
 #define VRPN_LPATH

+ 3 - 0
dtool/LocalSetup.pp

@@ -31,6 +31,9 @@ $[cdefine HAVE_PYTHON]
 /* Define if we have NSPR installed.  */
 /* Define if we have NSPR installed.  */
 $[cdefine HAVE_NSPR]
 $[cdefine HAVE_NSPR]
 
 
+/* Define if we have crypto++ installed.  */
+$[cdefine HAVE_CRYPTO]
+
 /* Define if we have VRPN installed.  */
 /* Define if we have VRPN installed.  */
 $[cdefine HAVE_VRPN]
 $[cdefine HAVE_VRPN]
 
 

+ 21 - 0
dtool/pptempl/Global.pp

@@ -81,6 +81,12 @@
   #define nspr_libs $[NSPR_LIBS]
   #define nspr_libs $[NSPR_LIBS]
 #endif
 #endif
 
 
+#if $[HAVE_CRYPTO]
+  #define crypto_ipath $[wildcard $[CRYPTO_IPATH]]
+  #define crypto_lpath $[wildcard $[CRYPTO_LPATH]]
+  #define crypto_libs $[CRYPTO_LIBS]
+#endif
+
 #if $[HAVE_ZLIB]
 #if $[HAVE_ZLIB]
   #define zlib_ipath $[wildcard $[ZLIB_IPATH]]
   #define zlib_ipath $[wildcard $[ZLIB_IPATH]]
   #define zlib_lpath $[wildcard $[ZLIB_LPATH]]
   #define zlib_lpath $[wildcard $[ZLIB_LPATH]]
@@ -170,6 +176,7 @@
  $[and \
  $[and \
      $[or $[not $[DIRECTORY_IF_PYTHON]],$[HAVE_PYTHON]], \
      $[or $[not $[DIRECTORY_IF_PYTHON]],$[HAVE_PYTHON]], \
      $[or $[not $[DIRECTORY_IF_NSPR]],$[HAVE_NSPR]], \
      $[or $[not $[DIRECTORY_IF_NSPR]],$[HAVE_NSPR]], \
+     $[or $[not $[DIRECTORY_IF_CRYPTO]],$[HAVE_CRYPTO]], \
      $[or $[not $[DIRECTORY_IF_ZLIB]],$[HAVE_ZLIB]], \
      $[or $[not $[DIRECTORY_IF_ZLIB]],$[HAVE_ZLIB]], \
      $[or $[not $[DIRECTORY_IF_SOXST]],$[HAVE_SOXST]], \
      $[or $[not $[DIRECTORY_IF_SOXST]],$[HAVE_SOXST]], \
      $[or $[not $[DIRECTORY_IF_GL]],$[HAVE_GL]], \
      $[or $[not $[DIRECTORY_IF_GL]],$[HAVE_GL]], \
@@ -195,6 +202,7 @@
  $[and \
  $[and \
      $[or $[not $[TARGET_IF_PYTHON]],$[HAVE_PYTHON]], \
      $[or $[not $[TARGET_IF_PYTHON]],$[HAVE_PYTHON]], \
      $[or $[not $[TARGET_IF_NSPR]],$[HAVE_NSPR]], \
      $[or $[not $[TARGET_IF_NSPR]],$[HAVE_NSPR]], \
+     $[or $[not $[TARGET_IF_CRYPTO]],$[HAVE_CRYPTO]], \
      $[or $[not $[TARGET_IF_ZLIB]],$[HAVE_ZLIB]], \
      $[or $[not $[TARGET_IF_ZLIB]],$[HAVE_ZLIB]], \
      $[or $[not $[TARGET_IF_SOXST]],$[HAVE_SOXST]], \
      $[or $[not $[TARGET_IF_SOXST]],$[HAVE_SOXST]], \
      $[or $[not $[TARGET_IF_GL]],$[HAVE_GL]], \
      $[or $[not $[TARGET_IF_GL]],$[HAVE_GL]], \
@@ -237,6 +245,7 @@
 // target.
 // target.
 #defer get_sources \
 #defer get_sources \
   $[SOURCES] \
   $[SOURCES] \
+  $[if $[HAVE_CRYPTO],$[IF_CRYPTO_SOURCES]] \
   $[if $[HAVE_ZLIB],$[IF_ZLIB_SOURCES]] \
   $[if $[HAVE_ZLIB],$[IF_ZLIB_SOURCES]] \
   $[if $[HAVE_IPC],$[IF_IPC_SOURCES]] \
   $[if $[HAVE_IPC],$[IF_IPC_SOURCES]] \
   $[if $[HAVE_NET],$[IF_NET_SOURCES]] \
   $[if $[HAVE_NET],$[IF_NET_SOURCES]] \
@@ -279,6 +288,9 @@
 #defun get_cflags
 #defun get_cflags
   #define alt_cflags $[nspr_cflags] $[python_cflags]
   #define alt_cflags $[nspr_cflags] $[python_cflags]
   
   
+  #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs]],]
+    #set alt_cflags $[alt_cflags] $[crypto_cflags]
+  #endif
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
     #set alt_cflags $[alt_cflags] $[zlib_cflags]
     #set alt_cflags $[alt_cflags] $[zlib_cflags]
   #endif
   #endif
@@ -326,6 +338,9 @@
 #defun get_ipath
 #defun get_ipath
   #define alt_ipath $[nspr_ipath] $[python_ipath]
   #define alt_ipath $[nspr_ipath] $[python_ipath]
   
   
+  #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs]],]
+    #set alt_ipath $[alt_ipath] $[crypto_ipath]
+  #endif
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
     #set alt_ipath $[alt_ipath] $[zlib_ipath]
     #set alt_ipath $[alt_ipath] $[zlib_ipath]
   #endif
   #endif
@@ -373,6 +388,9 @@
 #defun get_lpath
 #defun get_lpath
   #define alt_lpath $[nspr_lpath] $[python_lpath]
   #define alt_lpath $[nspr_lpath] $[python_lpath]
   
   
+  #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs]],]
+    #set alt_lpath $[alt_lpath] $[crypto_lpath]
+  #endif
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
     #set alt_lpath $[alt_lpath] $[zlib_lpath]
     #set alt_lpath $[alt_lpath] $[zlib_lpath]
   #endif
   #endif
@@ -421,6 +439,9 @@
 #defun get_libs
 #defun get_libs
   #define alt_libs $[nspr_libs] $[python_libs]
   #define alt_libs $[nspr_libs] $[python_libs]
   
   
+  #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs]],]
+    #set alt_libs $[alt_libs] $[crypto_libs]
+  #endif
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
   #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],]
     #set alt_libs $[alt_libs] $[zlib_libs]
     #set alt_libs $[alt_libs] $[zlib_libs]
   #endif
   #endif

+ 5 - 5
dtool/src/cppparser/cppPreprocessor.cxx

@@ -1322,15 +1322,15 @@ handle_include_directive(const string &args, int first_line,
     }
     }
     
     
     // Now look for it on the include path.
     // Now look for it on the include path.
-    if (!found_file && filename.resolve_filename(_include_path)) {
-      found_file = true;
-      source = CPPFile::S_alternate;
-    }
-    
     if (!found_file && filename.resolve_filename(_system_include_path)) {
     if (!found_file && filename.resolve_filename(_system_include_path)) {
       found_file = true;
       found_file = true;
       source = CPPFile::S_system;
       source = CPPFile::S_system;
     }
     }
+
+    if (!found_file && filename.resolve_filename(_include_path)) {
+      found_file = true;
+      source = CPPFile::S_alternate;
+    }
     
     
     if (!found_file) {
     if (!found_file) {
       warning("Cannot find " + filename.get_fullpath(),
       warning("Cannot find " + filename.get_fullpath(),

+ 1 - 1
dtool/src/parser-inc/Sources.pp

@@ -1,3 +1,3 @@
 #define INSTALL_PARSER_INC \
 #define INSTALL_PARSER_INC \
     deque iostream list map pair queue set stack stdtypedefs.h \
     deque iostream list map pair queue set stack stdtypedefs.h \
-    string vector windows.h zlib.h
+    string vector windows.h zlib.h md5.h files.h

+ 19 - 0
dtool/src/parser-inc/files.h

@@ -0,0 +1,19 @@
+// Filename: files.h
+// Created by:  drose (07Nov00)
+// 
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef FILES_H
+#define FILES_H
+
+namespace CryptoPP {
+  class FileSource;
+  class FileSink;
+};
+
+#endif

+ 19 - 0
dtool/src/parser-inc/md5.h

@@ -0,0 +1,19 @@
+// Filename: md5.h
+// Created by:  drose (07Nov00)
+// 
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef MD5_H
+#define MD5_H
+
+namespace CryptoPP {
+  class MD5;
+};
+
+#endif
+

+ 4 - 0
panda/src/downloader/Sources.pp

@@ -1,6 +1,7 @@
 #define LOCAL_LIBS event ipc express pandabase
 #define LOCAL_LIBS event ipc express pandabase
 #define OTHER_LIBS interrogatedb:c dconfig:c dtoolutil:c dtoolbase:c dtool:m
 #define OTHER_LIBS interrogatedb:c dconfig:c dtoolutil:c dtoolbase:c dtool:m
 #define USE_ZLIB yes
 #define USE_ZLIB yes
+#define USE_CRYPTO yes
 #define USE_IPC yes
 #define USE_IPC yes
 
 
 #begin lib_target
 #begin lib_target
@@ -19,6 +20,9 @@
     decompressor.cxx decompressor.h zcompressor.I zcompressor.cxx	\
     decompressor.cxx decompressor.h zcompressor.I zcompressor.cxx	\
     zcompressor.h download_utils.cxx download_utils.h
     zcompressor.h download_utils.cxx download_utils.h
 
 
+  #define IF_CRYPTO_SOURCES \
+    crypto_utils.cxx crypto_utils.h
+
   #define INSTALL_HEADERS					\
   #define INSTALL_HEADERS					\
     downloader.h downloader.I					\
     downloader.h downloader.I					\
     config_downloader.h zcompressor.I zcompressor.h		\
     config_downloader.h zcompressor.I zcompressor.h		\

+ 64 - 0
panda/src/downloader/crypto_utils.cxx

@@ -0,0 +1,64 @@
+// Filename: crypto_utils.cxx
+// Created by:  drose (07Nov00)
+//
+////////////////////////////////////////////////////////////////////
+
+// This file is compiled only if we have crypto++ installed.
+
+#include "crypto_utils.h"
+
+#include <md5.h>
+#include <files.h>
+
+#include <string>
+
+USING_NAMESPACE(CryptoPP);
+USING_NAMESPACE(std);
+
+uint 
+read32(istream& is) {
+  unsigned int ret = 0x0;
+  unsigned char b1, b2, b3, b4;
+  is >> b1;
+  is >> b2;
+  is >> b3;
+  is >> b4;
+  ret = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
+  return ret;
+}
+
+void 
+md5_a_file(const Filename &name, HashVal &ret) {
+  ostringstream os;
+  MD5 md5;
+
+  string fs = name.get_fullpath();
+  FileSource f(fs.c_str(), true, new HashFilter(md5, new FileSink(os)));
+
+  istringstream is(os.str());
+
+  ret[0] = read32(is);
+  ret[1] = read32(is);
+  ret[2] = read32(is);
+  ret[3] = read32(is);
+}
+
+void 
+md5_a_buffer(unsigned char* buf, unsigned long len, HashVal& ret) {
+  MD5 md5;
+
+  HashFilter hash(md5);
+  hash.Put((byte*)buf, len);
+  hash.Close();
+
+  unsigned char* outb;
+  unsigned long outl = hash.MaxRetrieveable();
+  outb = new uchar[outl];
+  hash.Get((byte*)outb, outl);
+  ret[0] = (outb[0] << 24) | (outb[1] << 16) | (outb[2] << 8) | outb[3];
+  ret[1] = (outb[4] << 24) | (outb[5] << 16) | (outb[6] << 8) | outb[7];
+  ret[2] = (outb[8] << 24) | (outb[9] << 16) | (outb[10] << 8) | outb[11];
+  ret[3] = (outb[12] << 24) | (outb[13] << 16) | (outb[14] << 8) | outb[15];
+  delete outb;
+}
+

+ 19 - 0
panda/src/downloader/crypto_utils.h

@@ -0,0 +1,19 @@
+// Filename: crypto_utils.h
+// Created by:  drose (07Nov00)
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef CRYPTO_UTILS_H
+#define CRYPTO_UTILS_H
+
+#include <pandabase.h>
+#include <filename.h>
+#include <typedef.h>
+
+typedef uint HashVal[4];
+
+EXPCL_PANDAEXPRESS void md5_a_file(const Filename &fname, HashVal &ret);
+EXPCL_PANDAEXPRESS void md5_a_buffer(uchar *buf, ulong len, HashVal &ret);
+
+#endif
+

+ 0 - 58
panda/src/downloader/download_utils.cxx

@@ -60,61 +60,3 @@ check_adler(Filename name) {
 
 
   return adler;
   return adler;
 }
 }
-
-#include <md5.h>
-#include <files.h>
-
-#include <iostream>
-#include <string>
-#include <strstream>
-
-USING_NAMESPACE(CryptoPP);
-USING_NAMESPACE(std);
-
-uint 
-read32(istream& is) {
-  unsigned int ret = 0x0;
-  unsigned char b1, b2, b3, b4;
-  is >> b1;
-  is >> b2;
-  is >> b3;
-  is >> b4;
-  ret = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
-  return ret;
-}
-
-void 
-md5_a_file(const Filename &name, HashVal &ret) {
-  ostrstream os;
-  MD5 md5;
-
-  string fs = name.get_fullpath();
-  FileSource f(fs.c_str(), true, new HashFilter(md5, new FileSink(os)));
-
-  istrstream is(os.str());
-
-  ret[0] = read32(is);
-  ret[1] = read32(is);
-  ret[2] = read32(is);
-  ret[3] = read32(is);
-}
-
-void 
-md5_a_buffer(unsigned char* buf, unsigned long len, HashVal& ret) {
-  MD5 md5;
-
-  HashFilter hash(md5);
-  hash.Put((byte*)buf, len);
-  hash.Close();
-
-  unsigned char* outb;
-  unsigned long outl = hash.MaxRetrieveable();
-  outb = new uchar[outl];
-  hash.Get((byte*)outb, outl);
-  ret[0] = (outb[0] << 24) | (outb[1] << 16) | (outb[2] << 8) | outb[3];
-  ret[1] = (outb[4] << 24) | (outb[5] << 16) | (outb[6] << 8) | outb[7];
-  ret[2] = (outb[8] << 24) | (outb[9] << 16) | (outb[10] << 8) | outb[11];
-  ret[3] = (outb[12] << 24) | (outb[13] << 16) | (outb[14] << 8) | outb[15];
-  delete outb;
-}
-

+ 1 - 5
panda/src/downloader/download_utils.h

@@ -7,15 +7,11 @@
 #define DOWNLOAD_UTILS_H
 #define DOWNLOAD_UTILS_H
 
 
 #include <pandabase.h>
 #include <pandabase.h>
-#include <typedef.h>
 #include <filename.h>
 #include <filename.h>
-
-typedef uint HashVal[4];
+#include <typedef.h>
 
 
 EXPCL_PANDAEXPRESS ulong check_crc(Filename name);
 EXPCL_PANDAEXPRESS ulong check_crc(Filename name);
 EXPCL_PANDAEXPRESS ulong check_adler(Filename name);
 EXPCL_PANDAEXPRESS ulong check_adler(Filename name);
-EXPCL_PANDAEXPRESS void md5_a_file(const Filename &fname, HashVal &ret);
-EXPCL_PANDAEXPRESS void md5_a_buffer(uchar *buf, ulong len, HashVal &ret);
 
 
 #endif
 #endif