summaryrefslogtreecommitdiffstats
path: root/src/libktorrent/util
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2025-03-10 20:36:49 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2025-03-21 19:05:50 +0900
commit73da215882d7f96b6010fa99361c7cc10ec18bfb (patch)
treecea1a5016a94a9dac26cab8227e2513224288be3 /src/libktorrent/util
parentbb099158e6c9fd0f1c2771cb9350d3b0a0b51a27 (diff)
downloadktorrent-73da2158.tar.gz
ktorrent-73da2158.zip
Conversion to cmake building system
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit bf204e931c605c73d761ec84943bb0cc94d7e7e4)
Diffstat (limited to 'src/libktorrent/util')
-rw-r--r--src/libktorrent/util/CMakeLists.txt24
-rw-r--r--src/libktorrent/util/bitset.h3
-rw-r--r--src/libktorrent/util/error.h3
-rw-r--r--src/libktorrent/util/file.h3
-rw-r--r--src/libktorrent/util/fileops.h38
-rw-r--r--src/libktorrent/util/functions.h42
-rw-r--r--src/libktorrent/util/httprequest.h2
-rw-r--r--src/libktorrent/util/log.cpp2
-rw-r--r--src/libktorrent/util/log.h7
-rw-r--r--src/libktorrent/util/mmapfile.h6
-rw-r--r--src/libktorrent/util/sha1hash.cpp2
-rw-r--r--src/libktorrent/util/sha1hash.h3
-rw-r--r--src/libktorrent/util/waitjob.h2
13 files changed, 85 insertions, 52 deletions
diff --git a/src/libktorrent/util/CMakeLists.txt b/src/libktorrent/util/CMakeLists.txt
new file mode 100644
index 0000000..fb8fa30
--- /dev/null
+++ b/src/libktorrent/util/CMakeLists.txt
@@ -0,0 +1,24 @@
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+
+##### check for profiling support
+
+if( WITH_PROFILING_SUPPORT )
+ add_definitions(-DKT_PROFILE )
+endif( )
+
+
+##### util library (static)
+
+tde_add_library( util STATIC_PIC AUTOMOC
+ SOURCES
+ array.cpp autorotatelogjob.cpp bitset.cpp error.cpp file.cpp fileops.cpp functions.cpp
+ httprequest.cpp log.cpp mmapfile.cpp profiler.cpp ptrmap.cpp sha1hash.cpp sha1hashgen.cpp
+ timer.cpp urlencoder.cpp waitjob.cpp
+ LINK
+ torrent-static
+)
diff --git a/src/libktorrent/util/bitset.h b/src/libktorrent/util/bitset.h
index 32e7e48..54910ec 100644
--- a/src/libktorrent/util/bitset.h
+++ b/src/libktorrent/util/bitset.h
@@ -21,6 +21,7 @@
#define BTBITSET_H
#include "constants.h"
+#include <libktorrent_export.h>
namespace bt
{
@@ -32,7 +33,7 @@ namespace bt
* Simple implementation of a BitSet, can only turn on and off bits.
* BitSet's are used to indicate which chunks we have or not.
*/
- class BitSet
+ class LIBKTORRENT_EXPORT BitSet
{
Uint32 num_bits,num_bytes;
Uint8* data;
diff --git a/src/libktorrent/util/error.h b/src/libktorrent/util/error.h
index 49aa95d..337c01a 100644
--- a/src/libktorrent/util/error.h
+++ b/src/libktorrent/util/error.h
@@ -21,6 +21,7 @@
#define BTERROR_H
#include <tqstring.h>
+#include <libktorrent_export.h>
namespace bt
{
@@ -28,7 +29,7 @@ namespace bt
/**
@author Joris Guisson
*/
- class Error
+ class LIBKTORRENT_EXPORT Error
{
TQString msg;
public:
diff --git a/src/libktorrent/util/file.h b/src/libktorrent/util/file.h
index c6567f8..40fd18b 100644
--- a/src/libktorrent/util/file.h
+++ b/src/libktorrent/util/file.h
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <tqstring.h>
#include "constants.h"
+#include <libktorrent_export.h>
namespace bt
{
@@ -33,7 +34,7 @@ namespace bt
*
* Wrapper class for stdio's FILE.
*/
- class File
+ class LIBKTORRENT_EXPORT File
{
FILE* fptr;
TQString file;
diff --git a/src/libktorrent/util/fileops.h b/src/libktorrent/util/fileops.h
index d1c3437..592ecd3 100644
--- a/src/libktorrent/util/fileops.h
+++ b/src/libktorrent/util/fileops.h
@@ -25,6 +25,8 @@
#endif
#include <util/constants.h>
+#include <libktorrent_export.h>
+
class TQString;
namespace bt
@@ -37,7 +39,7 @@ namespace bt
* @param nothrow wether or not we shouldn't throw an Error upon failure
* @throw Error upon error
*/
- void MakeDir(const TQString & dir,bool nothrow = false);
+ LIBKTORRENT_EXPORT void MakeDir(const TQString & dir,bool nothrow = false);
/**
* Create a symbolic link @a link_url which links to @a link_to
@@ -45,7 +47,7 @@ namespace bt
* @param link_url The link url
* @param nothrow wether or not we shouldn't throw an Error upon failure
*/
- void SymLink(const TQString & link_to,const TQString & link_url,bool nothrow = false);
+ LIBKTORRENT_EXPORT void SymLink(const TQString & link_to,const TQString & link_url,bool nothrow = false);
/**
* Move a file/dir from one location to another
@@ -53,7 +55,7 @@ namespace bt
* @param dst The destination file / directory
* @param nothrow wether or not we shouldn't throw an Error upon failure
*/
- void Move(const TQString & src,const TQString & dst,bool nothrow = false);
+ LIBKTORRENT_EXPORT void Move(const TQString & src,const TQString & dst,bool nothrow = false);
/**
* Copy a file.
@@ -61,7 +63,7 @@ namespace bt
* @param dst The destination dir/file
* @param nothrow wether or not we shouldn't throw an Error upon failure
*/
- void CopyFile(const TQString & src,const TQString & dst,bool nothrow = false);
+ LIBKTORRENT_EXPORT void CopyFile(const TQString & src,const TQString & dst,bool nothrow = false);
/**
* Copy a file or directory
@@ -69,21 +71,21 @@ namespace bt
* @param dst The destination dir/file
* @param nothrow wether or not we shouldn't throw an Error upon failure
*/
- void CopyDir(const TQString & src,const TQString & dst,bool nothrow = false);
+ LIBKTORRENT_EXPORT void CopyDir(const TQString & src,const TQString & dst,bool nothrow = false);
/**
* Check wether a file/dir exists
* @param url The file/dir
* @return true if it exits
*/
- bool Exists(const TQString & url);
+ LIBKTORRENT_EXPORT bool Exists(const TQString & url);
/**
* Delete a file or directory.
* @param url The url of the file/dir
* @param nothrow wether or not we shouldn't throw an Error upon failure
*/
- void Delete(const TQString & url,bool nothrow = false);
+ LIBKTORRENT_EXPORT void Delete(const TQString & url,bool nothrow = false);
/**
* Try to create a file. Doesn't do anything if the file
@@ -91,7 +93,7 @@ namespace bt
* @param url The url of the file
* @param nothrow wether or not we shouldn't throw an Error upon failure
*/
- void Touch(const TQString & url,bool nothrow = false);
+ LIBKTORRENT_EXPORT void Touch(const TQString & url,bool nothrow = false);
/**
* Calculates the size of a file
@@ -99,7 +101,7 @@ namespace bt
* @return The size of the file
* @throw Error if the file doesn't exist, or something else goes wrong
*/
- Uint64 FileSize(const TQString & url);
+ LIBKTORRENT_EXPORT Uint64 FileSize(const TQString & url);
/**
* Get the size of a file.
@@ -107,7 +109,7 @@ namespace bt
* @return The size
* @throw Error if the file doesn't exist, or something else goes wrong
*/
- Uint64 FileSize(int fd);
+ LIBKTORRENT_EXPORT Uint64 FileSize(int fd);
/**
* Truncate a file (wrapper around ftruncate)
@@ -115,7 +117,7 @@ namespace bt
* @param size The size to truncate to
* @throw Error if the file doesn't exist, or something else goes wrong
*/
- void TruncateFile(int fd,Uint64 size,bool quick);
+ LIBKTORRENT_EXPORT void TruncateFile(int fd,Uint64 size,bool quick);
/**
* Truncate a file (wrapper around ftruncate)
@@ -124,28 +126,28 @@ namespace bt
* @param quick Use the quick way (doesn't prevent fragmentationt)
* @throw Error if the file doesn't exist, or something else goes wrong
*/
- void TruncateFile(const TQString & path,Uint64 size);
+ LIBKTORRENT_EXPORT void TruncateFile(const TQString & path,Uint64 size);
/**
* Special truncate for FAT file systems.
*/
- bool FatPreallocate(int fd,Uint64 size);
+ LIBKTORRENT_EXPORT bool FatPreallocate(int fd,Uint64 size);
/**
* Special truncate for FAT file systems.
*/
- bool FatPreallocate(const TQString & path,Uint64 size);
+ LIBKTORRENT_EXPORT bool FatPreallocate(const TQString & path,Uint64 size);
#ifdef HAVE_XFS_XFS_H
/**
* Special truncate for XFS file systems.
*/
- bool XfsPreallocate(int fd,Uint64 size);
+ LIBKTORRENT_EXPORT bool XfsPreallocate(int fd,Uint64 size);
/**
* Special truncate for XFS file systems.
*/
- bool XfsPreallocate(const TQString & path,Uint64 size);
+ LIBKTORRENT_EXPORT bool XfsPreallocate(const TQString & path,Uint64 size);
#endif
@@ -156,10 +158,10 @@ namespace bt
* @param whence Position to seek from
* @throw Error if something else goes wrong
*/
- void SeekFile(int fd,Int64 off,int whence);
+ LIBKTORRENT_EXPORT void SeekFile(int fd,Int64 off,int whence);
/// Calculate the number of bytes free on the filesystem path is located
- bool FreeDiskSpace(const TQString & path,Uint64 & bytes_free);
+ LIBKTORRENT_EXPORT bool FreeDiskSpace(const TQString & path,Uint64 & bytes_free);
}
#endif
diff --git a/src/libktorrent/util/functions.h b/src/libktorrent/util/functions.h
index 9295b83..97bb3fe 100644
--- a/src/libktorrent/util/functions.h
+++ b/src/libktorrent/util/functions.h
@@ -21,6 +21,7 @@
#define BTFUNCTIONS_H
#include "constants.h"
+#include <libktorrent_export.h>
class TQString;
class TQHostAddress;
@@ -29,44 +30,43 @@ class KURL;
namespace bt
{
- void WriteUint64(Uint8* buf,Uint32 off,Uint64 val);
- Uint64 ReadUint64(const Uint8* buf,Uint64 off);
+ LIBKTORRENT_EXPORT void WriteUint64(Uint8* buf,Uint32 off,Uint64 val);
+ LIBKTORRENT_EXPORT Uint64 ReadUint64(const Uint8* buf,Uint64 off);
- void WriteUint32(Uint8* buf,Uint32 off,Uint32 val);
- Uint32 ReadUint32(const Uint8* buf,Uint32 off);
+ LIBKTORRENT_EXPORT void WriteUint32(Uint8* buf,Uint32 off,Uint32 val);
+ LIBKTORRENT_EXPORT Uint32 ReadUint32(const Uint8* buf,Uint32 off);
- void WriteUint16(Uint8* buf,Uint32 off,Uint16 val);
- Uint16 ReadUint16(const Uint8* buf,Uint32 off);
-
+ LIBKTORRENT_EXPORT void WriteUint16(Uint8* buf,Uint32 off,Uint16 val);
+ LIBKTORRENT_EXPORT Uint16 ReadUint16(const Uint8* buf,Uint32 off);
- void WriteInt64(Uint8* buf,Uint32 off,Int64 val);
- Int64 ReadInt64(const Uint8* buf,Uint32 off);
+ LIBKTORRENT_EXPORT void WriteInt64(Uint8* buf,Uint32 off,Int64 val);
+ LIBKTORRENT_EXPORT Int64 ReadInt64(const Uint8* buf,Uint32 off);
- void WriteInt32(Uint8* buf,Uint32 off,Int32 val);
- Int32 ReadInt32(const Uint8* buf,Uint32 off);
+ LIBKTORRENT_EXPORT void WriteInt32(Uint8* buf,Uint32 off,Int32 val);
+ LIBKTORRENT_EXPORT Int32 ReadInt32(const Uint8* buf,Uint32 off);
- void WriteInt16(Uint8* buf,Uint32 off,Int16 val);
- Int16 ReadInt16(const Uint8* buf,Uint32 off);
+ LIBKTORRENT_EXPORT void WriteInt16(Uint8* buf,Uint32 off,Int16 val);
+ LIBKTORRENT_EXPORT Int16 ReadInt16(const Uint8* buf,Uint32 off);
- void UpdateCurrentTime();
+ LIBKTORRENT_EXPORT void UpdateCurrentTime();
- extern TimeStamp global_time_stamp;
+ LIBKTORRENT_EXPORT extern TimeStamp global_time_stamp;
inline TimeStamp GetCurrentTime() {return global_time_stamp;}
- TimeStamp Now();
+ LIBKTORRENT_EXPORT TimeStamp Now();
- TQHostAddress LookUpHost(const TQString & host);
- TQString DirSeparator();
- bool IsMultimediaFile(const TQString & filename);
+ LIBKTORRENT_EXPORT TQHostAddress LookUpHost(const TQString & host);
+ LIBKTORRENT_EXPORT TQString DirSeparator();
+ LIBKTORRENT_EXPORT bool IsMultimediaFile(const TQString & filename);
/**
* Maximize the file and memory limits using setrlimit.
*/
- bool MaximizeLimits();
+ LIBKTORRENT_EXPORT bool MaximizeLimits();
/// Get the maximum number of open files
- Uint32 MaxOpenFiles();
+ LIBKTORRENT_EXPORT Uint32 MaxOpenFiles();
}
#endif
diff --git a/src/libktorrent/util/httprequest.h b/src/libktorrent/util/httprequest.h
index fd9e7b7..0116e79 100644
--- a/src/libktorrent/util/httprequest.h
+++ b/src/libktorrent/util/httprequest.h
@@ -38,7 +38,7 @@ namespace bt
* connect to the right signals and forget about it. After the reply has been received or
* an error occurred, the appropriate signal will be emitted.
*/
- class HTTPRequest : public kt::ExitOperation
+ class LIBKTORRENT_EXPORT HTTPRequest : public kt::ExitOperation
{
TQ_OBJECT
diff --git a/src/libktorrent/util/log.cpp b/src/libktorrent/util/log.cpp
index ff83f1d..281122b 100644
--- a/src/libktorrent/util/log.cpp
+++ b/src/libktorrent/util/log.cpp
@@ -119,7 +119,7 @@ namespace bt
*out << TQDateTime::currentDateTime().toString() << ": " << tmp << ::endl;
fptr.flush();
if (to_cout)
- std::cout << TQString(tmp.local8Bit()) << std::endl;
+ std::cout << tmp.local8Bit() << std::endl;
if (monitors.count() > 0)
{
diff --git a/src/libktorrent/util/log.h b/src/libktorrent/util/log.h
index 742b753..62260b7 100644
--- a/src/libktorrent/util/log.h
+++ b/src/libktorrent/util/log.h
@@ -23,6 +23,7 @@
#include "constants.h"
+#include <libktorrent_export.h>
#include <tqstring.h>
// LOG MESSAGES CONSTANTS
@@ -75,7 +76,7 @@ namespace bt
* There is also the possibility to monitor what is written to the log using
* the LogMonitorInterface class.
*/
- class Log
+ class LIBKTORRENT_EXPORT Log
{
class Private;
@@ -195,10 +196,10 @@ namespace bt
void logRotateDone();
};
- Log & endl(Log & lg);
+ LIBKTORRENT_EXPORT Log & endl(Log & lg);
- Log & Out(unsigned int arg = 0x00);
+ LIBKTORRENT_EXPORT Log & Out(unsigned int arg = 0x00);
inline Log & GenOut(unsigned int arg) {return Out(SYS_GEN|arg);}
inline Log & DHTOut(unsigned int arg) {return Out(SYS_DHT|arg);}
inline Log & ConOut(unsigned int arg) {return Out(SYS_CON|arg);}
diff --git a/src/libktorrent/util/mmapfile.h b/src/libktorrent/util/mmapfile.h
index 4d68fd2..78ccf4c 100644
--- a/src/libktorrent/util/mmapfile.h
+++ b/src/libktorrent/util/mmapfile.h
@@ -21,6 +21,7 @@
#define BTMMAPFILE_H
+#include <libktorrent_export.h>
#include <tqstring.h>
#include <util/constants.h>
@@ -35,11 +36,12 @@ namespace bt
* File.
* TODO: make sure large files work (not really needed for the blocklist)
*/
- class MMapFile
+ class LIBKTORRENT_EXPORT MMapFile
{
public:
MMapFile();
- virtual ~MMapFile();
+ //virtual
+ ~MMapFile();
enum Mode
{
diff --git a/src/libktorrent/util/sha1hash.cpp b/src/libktorrent/util/sha1hash.cpp
index 6cdbbc4..00a1bb2 100644
--- a/src/libktorrent/util/sha1hash.cpp
+++ b/src/libktorrent/util/sha1hash.cpp
@@ -115,7 +115,7 @@ namespace bt
return k;
}
- bool operator < (const SHA1Hash & a,const SHA1Hash & b)
+ LIBKTORRENT_EXPORT bool operator < (const SHA1Hash & a,const SHA1Hash & b)
{
for (int i = 0;i < 20;i++)
{
diff --git a/src/libktorrent/util/sha1hash.h b/src/libktorrent/util/sha1hash.h
index dba66c9..5363555 100644
--- a/src/libktorrent/util/sha1hash.h
+++ b/src/libktorrent/util/sha1hash.h
@@ -22,6 +22,7 @@
#include <tqcstring.h>
#include "constants.h"
+#include <libktorrent_export.h>
class TQString;
@@ -36,7 +37,7 @@ namespace bt
* This class keeps track of a SHA1 hash. A SHA1 hash is a 20 byte
* array of bytes.
*/
- class SHA1Hash
+ class LIBKTORRENT_EXPORT SHA1Hash
{
protected:
Uint8 hash[20];
diff --git a/src/libktorrent/util/waitjob.h b/src/libktorrent/util/waitjob.h
index 6f9bdd5..04508f4 100644
--- a/src/libktorrent/util/waitjob.h
+++ b/src/libktorrent/util/waitjob.h
@@ -35,7 +35,7 @@ namespace bt
* Job to wait for a certain amount of time or until one or more ExitOperation's have
* finished.
*/
- class WaitJob : public TDEIO::Job
+ class LIBKTORRENT_EXPORT WaitJob : public TDEIO::Job
{
TQ_OBJECT