Mailinglist Archive: zypp-commit (149 mails)

< Previous Next >
[zypp-commit] r5390 - in /trunk/libzypp/zypp: CMakeLists.txt base/Random.cc base/Random.h
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Mon, 16 Apr 2007 15:45:32 -0000
  • Message-id: <20070416154533.00D002367D@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Mon Apr 16 17:45:32 2007
New Revision: 5390

URL: http://svn.opensuse.org/viewcvs/zypp?rev=5390&view=rev
Log:

- Compile YUM downloader
- Introduce base:: Random.h


Added:
    trunk/libzypp/zypp/base/Random.cc
    trunk/libzypp/zypp/base/Random.h
Modified:
    trunk/libzypp/zypp/CMakeLists.txt

Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=5390&r1=5389&r2=5390&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Mon Apr 16 17:45:32 2007
@@ -183,6 +183,7 @@
 INSTALL(  FILES ${zypp_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/zypp" )
 
 SET( zypp_base_SRCS
+  base/Random.cc
   base/Measure.cc
   base/Fd.cc
   base/Gettext.cc
@@ -200,6 +201,7 @@
 )
 
 SET( zypp_base_HEADERS
+  base/Random.h
   base/Algorithm.h
   base/Counter.h
   base/Debug.h
@@ -751,6 +753,7 @@
 )
 
 SET( zypp_source_yum_SRCS
+  source/yum/YUMDownloader.cc
   source/yum/YUMAtomImpl.cc
   source/yum/YUMGroupImpl.cc
   source/yum/YUMMessageImpl.cc
@@ -763,6 +766,7 @@
 )
 
 SET( zypp_source_yum_HEADERS
+  source/yum/YUMDownloader.h
   source/yum/YUMAtomImpl.h
   source/yum/YUMGroupImpl.h
   source/yum/YUMMessageImpl.h

Added: trunk/libzypp/zypp/base/Random.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Random.cc?rev=5390&view=auto
==============================================================================
--- trunk/libzypp/zypp/base/Random.cc (added)
+++ trunk/libzypp/zypp/base/Random.cc Mon Apr 16 17:45:32 2007
@@ -0,0 +1,50 @@
+
+
+#include "zypp/base/Random.h"
+
+namespace zypp { namespace base {
+  
+
+ // Taken from KApplication
+int random_int()
+{
+  static bool init = false;
+  if (!init)
+  {
+      unsigned int seed;
+      init = true;
+      int fd = open("/dev/urandom", O_RDONLY);
+      if (fd < 0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed))
+      {
+            // No /dev/urandom... try something else.
+            srand(getpid());
+            seed = rand()+time(0);
+      }
+      if (fd >= 0) close(fd);
+      srand(seed);
+  }
+  return rand();
+}
+
+// Taken from KApplication
+std::string random_string(int length)
+{
+  if (length <=0 ) return std::string();
+
+  std::string str; str.resize( length );
+  int i = 0;
+  while (length--)
+  {
+      int r=random() % 62;
+      r+=48;
+      if (r>57) r+=7;
+      if (r>90) r+=6;
+      str[i++] =  char(r);
+      // so what if I work backwards?
+  }
+  return str;
+}
+  
+  
+} }
+

Added: trunk/libzypp/zypp/base/Random.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Random.h?rev=5390&view=auto
==============================================================================
--- trunk/libzypp/zypp/base/Random.h (added)
+++ trunk/libzypp/zypp/base/Random.h Mon Apr 16 17:45:32 2007
@@ -0,0 +1,30 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_BASE_Random_H
+#define ZYPP_BASE_Random_H
+
+#include <string>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace base
+  { ///////////////////////////
+    // Taken from KApplication
+    int random_int();
+    // Taken from KApplication
+    std::string random_string(int length);
+
+  } //ns base
+} // ns zypp
+
+#endif
+

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages