eliminate boost dependency, replace with C++11 features

git-svn-id: http://encfs.googlecode.com/svn/trunk@86 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
Valient Gough 2012-08-22 04:46:36 +00:00
parent 36946fdea7
commit 1680008df1
39 changed files with 149 additions and 835 deletions

View File

@ -1,3 +1,16 @@
Tue Aug 21 2012 Valient Gough <vgough@pobox.com>
* replace boost with C++11
Sun Aug 19 2012 Valient Gough <vgough@pobox.com>
* move encrypted key into separate config block
Sat Aug 18 2012 Valient Gough <vgough@pobox.com>
* add V to getopt for version
Sun May 13 2012 Valient Gough <vgough@pobox.com>
* allow "config" for top-level v6 xml config
* drop logging of useStdin state
Wed Apr 25 2012 Valient Gough <vgough@pobox.com>
* fix encfsctl cat when iv chaining is enabled. Fixes issue #132

View File

@ -46,9 +46,7 @@ AC_PROG_LIBTOOL
AX_PTHREAD
AX_BOOST_BASE([1.34])
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM
AC_CHECK_HEADERS([tr1/memory tr1/unordered_map tr1/unordered_set tr1/tuple])
dnl Need to include any user specified flags in the tests below, as they might
dnl specify required include directories..

View File

@ -31,7 +31,6 @@
#include "i18n.h"
using namespace rlog;
using namespace boost;
static RLogChannel * Info = DEF_CHANNEL( "info/nameio", Log_Info );

View File

@ -21,7 +21,7 @@
#include "NameIO.h"
#include "CipherKey.h"
#include <boost/shared_ptr.hpp>
#include <memory>
class Cipher;
@ -36,7 +36,7 @@ public:
static Interface CurrentInterface(bool caseSensitive = false);
BlockNameIO( const Interface &iface,
const boost::shared_ptr<Cipher> &cipher,
const shared_ptr<Cipher> &cipher,
const CipherKey &key, int blockSize,
bool caseSensitiveEncoding = false );
virtual ~BlockNameIO();
@ -57,11 +57,10 @@ protected:
private:
int _interface;
int _bs;
boost::shared_ptr<Cipher> _cipher;
shared_ptr<Cipher> _cipher;
CipherKey _key;
bool _caseSensitive;
};
#endif

View File

@ -34,7 +34,6 @@
#include "SSL_Cipher.h"
using namespace std;
using boost::shared_ptr;
#define REF_MODULE(TYPE) \
if( !TYPE::Enabled() ) \

View File

@ -29,8 +29,6 @@
#include <list>
#include <inttypes.h>
using boost::shared_ptr;
/*
Mostly pure virtual interface defining operations on a cipher.
@ -42,7 +40,7 @@ class Cipher
public:
// if no key length was indicated when cipher was registered, then keyLen
// <= 0 will be used.
typedef boost::shared_ptr<Cipher> (*CipherConstructor)(
typedef shared_ptr<Cipher> (*CipherConstructor)(
const Interface &iface, int keyLenBits );
struct CipherAlgorithm
@ -59,9 +57,9 @@ public:
static AlgorithmList GetAlgorithmList( bool includeHidden = false );
static boost::shared_ptr<Cipher> New( const Interface &iface,
static shared_ptr<Cipher> New( const Interface &iface,
int keyLen = -1);
static boost::shared_ptr<Cipher> New( const std::string &cipherName,
static shared_ptr<Cipher> New( const std::string &cipherName,
int keyLen = -1 );

View File

@ -27,8 +27,6 @@
#include <fcntl.h>
#include <cerrno>
using boost::shared_ptr;
/*
- Version 2:0 adds support for a per-file initialization vector with a
fixed 8 byte header. The headers are enabled globally within a

View File

@ -34,7 +34,7 @@ class Cipher;
class CipherFileIO : public BlockFileIO
{
public:
CipherFileIO( const boost::shared_ptr<FileIO> &base,
CipherFileIO( const shared_ptr<FileIO> &base,
const FSConfigPtr &cfg);
virtual ~CipherFileIO();
@ -68,7 +68,7 @@ private:
bool streamWrite( unsigned char *buf, int size,
uint64_t iv64 ) const;
boost::shared_ptr<FileIO> base;
shared_ptr<FileIO> base;
FSConfigPtr fsConfig;
@ -80,7 +80,7 @@ private:
uint64_t fileIV;
int lastFlags;
boost::shared_ptr<Cipher> cipher;
shared_ptr<Cipher> cipher;
CipherKey key;
};

View File

@ -21,7 +21,7 @@
#ifndef _CipherKey_incl_
#define _CipherKey_incl_
#include <boost/shared_ptr.hpp>
#include "shared_ptr.h"
class AbstractCipherKey
{
@ -30,7 +30,7 @@ public:
virtual ~AbstractCipherKey();
};
typedef boost::shared_ptr<AbstractCipherKey> CipherKey;
typedef shared_ptr<AbstractCipherKey> CipherKey;
#endif

View File

@ -19,9 +19,7 @@
#define _ConfigVar_incl_
#include <string>
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
#include "shared_ptr.h"
class ConfigVar
{

View File

@ -140,7 +140,7 @@ shared_ptr<FileNode> EncFS_Context::getNode(void *pl)
}
void *EncFS_Context::putNode(const char *path,
const boost::shared_ptr<FileNode> &node)
const shared_ptr<FileNode> &node)
{
Lock lock( contextMutex );
Placeholder *pl = new Placeholder( node );

View File

@ -19,16 +19,17 @@
#define _Context_incl_
#include "encfs.h"
#include <boost/shared_ptr.hpp>
#include "shared_ptr.h"
#include <set>
#ifdef USE_HASHMAP
#include <ext/hash_map>
#if HAVE_TR1_UNORDERED_MAP
#include <tr1/unordered_map>
using std::tr1::unordered_map;
#else
#include <map>
#include <unordered_map>
using std::unordered_map;
#endif
using boost::shared_ptr;
struct EncFS_Args;
struct EncFS_Opts;
class FileNode;
@ -87,15 +88,9 @@ private:
};
// set of open files, indexed by path
#ifdef USE_HASHMAP
typedef __gnu_cxx::hash_map<std::string,
std::set<Placeholder*> > FileMap;
#else
typedef std::map< std::string,
std::set<Placeholder*> > FileMap;
#endif
typedef unordered_map<std::string, std::set<Placeholder*> > FileMap;
mutable pthread_mutex_t contextMutex;
FileMap openFiles;
int usageCount;

View File

@ -31,8 +31,7 @@
#include "NameIO.h"
#include "CipherKey.h"
#include "FSConfig.h"
using boost::shared_ptr;
#include "shared_ptr.h"
class Cipher;
class RenameOp;
@ -72,19 +71,6 @@ private:
};
inline bool DirTraverse::valid() const { return dir != 0; }
#ifdef USE_HASHMAP
namespace __gnu_cxx
{
template<> struct hash<std::string>
{
size_t operator() (const std::string &__s) const
{
return __stl_hash_string( __s.c_str() );
}
};
}
#endif
class DirNode
{
public:

View File

@ -24,9 +24,9 @@
#include "encfs.h"
#include "Interface.h"
#include "CipherKey.h"
#include "shared_ptr.h"
#include <vector>
#include <boost/shared_ptr.hpp>
enum ConfigType
{
@ -52,8 +52,8 @@ CipherKey getUserKey(const EncfsConfig &config,
CipherKey getNewUserKey(EncfsConfig &config, bool useStdin,
const std::string &program, const std::string &rootDir);
boost::shared_ptr<Cipher> getCipher(const EncfsConfig &cfg);
boost::shared_ptr<Cipher> getCipher(const Interface &iface, int keySize);
shared_ptr<Cipher> getCipher(const EncfsConfig &cfg);
shared_ptr<Cipher> getCipher(const Interface &iface, int keySize);
// helpers for serializing to/from a stream
std::ostream &operator << (std::ostream &os, const EncfsConfig &cfg);
@ -62,12 +62,12 @@ std::istream &operator >> (std::istream &os, EncfsConfig &cfg);
// Filesystem state
struct FSConfig
{
boost::shared_ptr<EncfsConfig> config;
boost::shared_ptr<EncFS_Opts> opts;
shared_ptr<EncfsConfig> config;
shared_ptr<EncFS_Opts> opts;
boost::shared_ptr<Cipher> cipher;
shared_ptr<Cipher> cipher;
CipherKey key;
boost::shared_ptr<NameIO> nameCoding;
shared_ptr<NameIO> nameCoding;
bool forceDecode; // force decode on MAC block failures
bool reverseEncryption; // reverse encryption operation
@ -75,7 +75,7 @@ struct FSConfig
bool idleTracking; // turn on idle monitoring of filesystem
};
typedef boost::shared_ptr<FSConfig> FSConfigPtr;
typedef shared_ptr<FSConfig> FSConfigPtr;
#endif

View File

@ -50,7 +50,6 @@
using namespace std;
using namespace rel;
using namespace rlog;
using boost::dynamic_pointer_cast;
/*
TODO: locking at the FileNode level is inefficient, since this precludes

View File

@ -29,7 +29,6 @@
class Cipher;
class FileIO;
class DirNode;
using boost::shared_ptr;
class FileNode
{

View File

@ -61,9 +61,6 @@
#include "i18n.h"
#include <boost/version.hpp>
#include <boost/filesystem/fstream.hpp>
#include <google/protobuf/text_format.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
@ -74,7 +71,6 @@
using namespace rlog;
using namespace std;
using namespace gnu;
namespace fs = boost::filesystem;
static const int DefaultBlockSize = 1024;
// The maximum length of text passwords. If longer are needed,
@ -90,17 +86,8 @@ static const char ENCFS_ENV_ROOTDIR[] = "encfs_root";
static const char ENCFS_ENV_STDOUT[] = "encfs_stdout";
static const char ENCFS_ENV_STDERR[] = "encfs_stderr";
//static int V5SubVersion = 20040518;
//static int V5SubVersion = 20040621; // add external IV chaining
static int V5SubVersion = 20040813; // fix MACFileIO block size issues
// 20080813 was really made on 20080413 -- typo on date..
//const int V6SubVersion = 20080813; // switch to v6/XML, add allowHoles option
//const int V6SubVersion = 20080816; // add salt and iteration count
const int V6SubVersion = 20100713; // add version field for boost 1.42+
const int ProtoSubVersion = 20120302;
const int V5Latest = 20040813; // fix MACFileIO block size issues
const int ProtoSubVersion = 20120819;
const char ConfigFileName[] = ".encfs.txt";
@ -116,7 +103,7 @@ struct ConfigInfo
{Config_V6, ".encfs6.xml", "ENCFS6_CONFIG", readV6Config },
// backward compatible support for older versions
{Config_V5, ".encfs5", "ENCFS5_CONFIG", readV5Config },
{Config_V3, ".encfs4", NULL, readV4Config },
{Config_V4, ".encfs4", NULL, readV4Config },
// prehistoric - no longer support
{Config_V3, ".encfs3", NULL, NULL },
{Config_Prehistoric, ".encfs2", NULL, NULL },
@ -310,7 +297,7 @@ bool readV6Config( const char *configFile,
{
rInfo("found 20080813");
cfg.set_revision(20080813);
} else if (version < V5SubVersion)
} else if (version < V5Latest)
{
rError("Invalid version %i - please fix config file", version);
} else
@ -393,16 +380,16 @@ bool readV5Config( const char *configFile,
try
{
config.set_revision(cfgRdr["subVersion"].readInt(0));
if(config.revision() > V5SubVersion)
if(config.revision() > V5Latest)
{
/* config file specifies a version outside our supported
range.. */
rWarning(_("Config subversion %i found, but this version of"
" encfs only supports up to version %i."),
config.revision(), V5SubVersion);
config.revision(), V5Latest);
return false;
}
if( config.revision() < 20040813 )
if( config.revision() < V5Latest )
{
rError(_("This version of EncFS doesn't support "
"filesystems created before 2004-08-13"));
@ -1053,7 +1040,7 @@ RootPtr createConfig( EncFS_Context *ctx,
config.set_block_size( blockSize );
config.mutable_naming()->MergeFrom( nameIOIface );
config.set_creator( "EncFS " VERSION );
config.set_revision( V6SubVersion );
config.set_revision( ProtoSubVersion );
config.set_block_mac_bytes( blockMACBytes );
config.set_block_mac_rand_bytes( blockMACRandBytes );
config.set_unique_iv( uniqueIV );
@ -1142,7 +1129,7 @@ RootPtr createConfig( EncFS_Context *ctx,
fsConfig->cipher = cipher;
fsConfig->key = volumeKey;
fsConfig->nameCoding = nameCoder;
fsConfig->config = boost::shared_ptr<EncfsConfig>(new EncfsConfig(config));
fsConfig->config = shared_ptr<EncfsConfig>(new EncfsConfig(config));
fsConfig->forceDecode = forceDecode;
fsConfig->reverseEncryption = reverseEncryption;
fsConfig->idleTracking = enableIdleTracking;
@ -1227,7 +1214,7 @@ void showFSInfo( const EncfsConfig &config )
}
if(config.block_mac_bytes() || config.block_mac_rand_bytes())
{
if(config.revision() < 20040813)
if(config.revision() < V5Latest)
{
cout << autosprintf(
// xgroup(diag)
@ -1636,7 +1623,7 @@ RootPtr initFS( EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts )
fsConfig->cipher = cipher;
fsConfig->key = volumeKey;
fsConfig->nameCoding = nameCoder;
fsConfig->config = boost::shared_ptr<EncfsConfig>(new EncfsConfig(config));
fsConfig->config = shared_ptr<EncfsConfig>(new EncfsConfig(config));
fsConfig->forceDecode = opts->forceDecode;
fsConfig->reverseEncryption = opts->reverseEncryption;
fsConfig->opts = opts;

View File

@ -44,15 +44,15 @@ class DirNode;
struct EncFS_Root
{
boost::shared_ptr<Cipher> cipher;
shared_ptr<Cipher> cipher;
CipherKey volumeKey;
boost::shared_ptr<DirNode> root;
shared_ptr<DirNode> root;
EncFS_Root();
~EncFS_Root();
};
typedef boost::shared_ptr<EncFS_Root> RootPtr;
typedef shared_ptr<EncFS_Root> RootPtr;
enum ConfigMode
{
@ -109,10 +109,10 @@ bool saveConfig( const std::string &rootdir, const EncfsConfig &config );
class EncFS_Context;
RootPtr initFS( EncFS_Context *ctx, const boost::shared_ptr<EncFS_Opts> &opts );
RootPtr initFS( EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts );
RootPtr createConfig( EncFS_Context *ctx,
const boost::shared_ptr<EncFS_Opts> &opts );
const shared_ptr<EncFS_Opts> &opts );
void showFSInfo( const EncfsConfig &config );

View File

@ -31,8 +31,6 @@
using namespace rlog;
using namespace std;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
static RLogChannel *Info = DEF_CHANNEL("info/MACFileIO", Log_Info);
//

View File

@ -21,8 +21,6 @@
#include "BlockFileIO.h"
#include "Cipher.h"
using boost::shared_ptr;
class MACFileIO : public BlockFileIO
{
public:

View File

@ -1,10 +1,9 @@
include $(top_srcdir)/Makefile.common
ALL_INCLUDES = @RLOG_CFLAGS@ @OPENSSL_CFLAGS@ @BOOST_CPPFLAGS@
ALL_INCLUDES = @RLOG_CFLAGS@ @OPENSSL_CFLAGS@
ALL_INCLUDES += @PROTOBUF_CFLAGS@
ALL_LDFLAGS = @RLOG_LIBS@ @OPENSSL_LIBS@ @BOOST_LDFLAGS@
ALL_LDFLAGS += @BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@
ALL_LDFLAGS = @RLOG_LIBS@ @OPENSSL_LIBS@
ALL_LDFLAGS += @PROTOBUF_LIBS@
INCLUDES = $(all_includes) -I../intl
@ -50,9 +49,7 @@ endif
# : +1 : => internal changes, nothing breaks
#
libencfs_la_LDFLAGS = -version-info 7:0:0
libencfs_la_LIBADD = @RLOG_LIBS@ \
@OPENSSL_LIBS@ \
@BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@
libencfs_la_LIBADD = @RLOG_LIBS@ @OPENSSL_LIBS@
EXTRASRC = ../intl/autosprintf.cpp
if BUILD_OPENSSL
@ -105,7 +102,6 @@ encfsctl_SOURCES = \
noinst_HEADERS = \
base64.h \
boost-versioning.h \
BlockFileIO.h \
BlockNameIO.h \
CipherFileIO.h \

View File

@ -26,7 +26,6 @@
#include "Interface.h"
#include "CipherKey.h"
using boost::shared_ptr;
class Cipher;
class NameIO

View File

@ -19,16 +19,14 @@
#include "Range.h"
#include "Interface.h"
#include "shared_ptr.h"
#include <boost/shared_ptr.hpp>
#include <rlog/rlog.h>
#include <cstring>
using namespace std;
using namespace rlog;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
static Interface NullInterface = makeInterface( "nullCipher", 1, 0, 0 );

View File

@ -22,8 +22,6 @@
#include <cstring>
using boost::shared_ptr;
static shared_ptr<NameIO> NewNNIO( const Interface &,
const shared_ptr<Cipher> &, const CipherKey & )
{

View File

@ -46,9 +46,6 @@ using namespace std;
using namespace rel;
using namespace rlog;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
const int MAX_KEYLENGTH = 32; // in bytes (256 bit)
const int MAX_IVLENGTH = 16;
const int KEY_CHECKSUM_BYTES = 4;

View File

@ -28,8 +28,6 @@ struct evp_cipher_st;
typedef struct evp_cipher_st EVP_CIPHER;
#endif
using boost::shared_ptr;
/*
Implements Cipher interface for OpenSSL's ciphers.

View File

@ -22,7 +22,6 @@
#include "CipherKey.h"
class Cipher;
using boost::shared_ptr;
class StreamNameIO : public NameIO
{

View File

@ -27,8 +27,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <map>
#include <tinyxml.h>
@ -151,7 +152,7 @@ public:
struct XmlReader::XmlReaderData
{
boost::shared_ptr<TiXmlDocument> doc;
shared_ptr<TiXmlDocument> doc;
};
XmlReader::XmlReader()

View File

@ -21,11 +21,11 @@
#ifndef _XmlReader_incl_
#define _XmlReader_incl_
#include <boost/shared_ptr.hpp>
#include <string>
#include "shared_ptr.h"
class XmlValue;
typedef boost::shared_ptr<XmlValue> XmlValuePtr;
typedef shared_ptr<XmlValue> XmlValuePtr;
class XmlValue
{
@ -72,7 +72,7 @@ public:
private:
struct XmlReaderData;
boost::shared_ptr<XmlReaderData> pd;
shared_ptr<XmlReaderData> pd;
};
#endif

View File

@ -1,96 +0,0 @@
#ifndef BOOST_VERSIONING_INCL
#define BOOST_VERSIONING_INCL
// This header stores workaround code for dealing with incompatible changes
// made to boost archive/serialization classes.
#if (BOOST_VERSION <= 104100)
// Easy case, boost archive serial numbers are sizeof(int)
BOOST_CLASS_VERSION(EncFSConfig, V6SubVersion)
#else
// starting with boost 1.42, serial numbers change to 8-bit. However to make
// things tricker, the internal comparison is more like 16bit, which makes
// writing backward compatible code very tricky.
// We make a partial specialization of the iserializer class to remove the
// version number checking which would otherwise cause boost::serialization to
// throw an exception if it came across a version that was greater then what
// we specify in BOOST_CLASS_VERSION below. Without this, manual editing
// of the file is needed before boost will allow us to read it.
// See bug http://code.google.com/p/encfs/issues/detail?id=60
BOOST_CLASS_VERSION(EncFSConfig, 20)
namespace boost {
namespace archive {
namespace detail {
// Specialize iserializer class in order to get rid of version check
template<class Archive>
class iserializer<Archive, EncFSConfig> : public basic_iserializer
{
private:
virtual void destroy(/*const*/ void *address) const {
boost::serialization::access::destroy(static_cast<EncFSConfig *>(address));
}
protected:
explicit iserializer() :
basic_iserializer(
boost::serialization::singleton<
BOOST_DEDUCED_TYPENAME
boost::serialization::type_info_implementation<EncFSConfig>::type
>::get_const_instance()
)
{}
public:
virtual BOOST_DLLEXPORT void load_object_data(
basic_iarchive & ar,
void *x,
const unsigned int file_version
) const BOOST_USED;
virtual bool class_info() const {
return boost::serialization::implementation_level<EncFSConfig>::value
>= boost::serialization::object_class_info;
}
virtual bool tracking(const unsigned int /* flags */) const {
return boost::serialization::tracking_level<EncFSConfig>::value
== boost::serialization::track_always
|| ( boost::serialization::tracking_level<EncFSConfig>::value
== boost::serialization::track_selectively
&& serialized_as_pointer());
}
virtual version_type version() const {
return version_type(::boost::serialization::version<EncFSConfig>::value);
}
virtual bool is_polymorphic() const {
return boost::is_polymorphic<EncFSConfig>::value;
}
virtual ~iserializer(){};
};
template<class Archive>
BOOST_DLLEXPORT void iserializer<Archive, EncFSConfig>::load_object_data(
basic_iarchive & ar,
void *x,
const unsigned int file_version
) const {
boost::serialization::serialize_adl(
boost::serialization::smart_cast_reference<Archive &>(ar),
* static_cast<EncFSConfig *>(x),
file_version
);
}
}
}
}
#endif
#endif // BOOST_VERSIONING_INCL

View File

@ -41,14 +41,21 @@
#include <string>
#include <map>
#include <boost/tuple/tuple.hpp>
#include <boost/scoped_array.hpp>
#if HAVE_TR1_TUPLE
#include <tr1/tuple>
using namespace std;
using namespace std::tr1;
#else
#include <tuple>
using namespace std;
#endif
#include "DirNode.h"
#include "MemoryPool.h"
#include "FileUtils.h"
#include "Mutex.h"
#include "Context.h"
#include "shared_ptr.h"
#include <rlog/rlog.h>
#include <rlog/Error.h>
@ -59,10 +66,8 @@
#define ESUCCESS 0
using namespace std;
using namespace rlog;
using rel::Lock;
using namespace boost;
#define GET_FN(ctx, finfo) ctx->getNode((void*)(uintptr_t)finfo->fh)
@ -165,16 +170,16 @@ int _do_getattr(FileNode *fnode, struct stat *stbuf)
if(FSRoot)
{
// determine plaintext link size.. Easiest to read and decrypt..
scoped_array<char> buf(new char[stbuf->st_size+1]);
vector<char> buf(stbuf->st_size+1, 0);
res = ::readlink( fnode->cipherName(), buf.get(), stbuf->st_size );
res = ::readlink( fnode->cipherName(), &buf[0], stbuf->st_size );
if(res >= 0)
{
// other functions expect c-strings to be null-terminated, which
// readlink doesn't provide
buf[res] = '\0';
stbuf->st_size = FSRoot->plainPath( buf.get() ).length();
stbuf->st_size = FSRoot->plainPath( &buf[0] ).length();
res = ESUCCESS;
} else
@ -363,8 +368,8 @@ int encfs_rmdir(const char *path)
int _do_readlink(EncFS_Context *ctx, const string &cyName,
tuple<char *, size_t> data )
{
char *buf = data.get<0>();
size_t size = data.get<1>();
char *buf = get<0>(data);
size_t size = get<1>(data);
int res = ESUCCESS;
shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
@ -500,7 +505,7 @@ int encfs_chmod(const char *path, mode_t mode)
int _do_chown(EncFS_Context *, const string &cyName,
tuple<uid_t, gid_t> data)
{
int res = lchown( cyName.c_str(), data.get<0>(), data.get<1>() );
int res = lchown( cyName.c_str(), get<0>(data), get<1>(data) );
return (res == -1) ? -errno : ESUCCESS;
}
@ -633,7 +638,7 @@ int encfs_release(const char *path, struct fuse_file_info *finfo)
int _do_read(FileNode *fnode, tuple<unsigned char *, size_t, off_t> data)
{
return fnode->read( data.get<2>(), data.get<0>(), data.get<1>());
return fnode->read( get<2>(data), get<0>(data), get<1>(data));
}
int encfs_read(const char *path, char *buf, size_t size, off_t offset,
@ -656,8 +661,8 @@ int encfs_fsync(const char *path, int dataSync,
int _do_write(FileNode *fnode, tuple<const char *, size_t, off_t> data)
{
size_t size = data.get<1>();
if(fnode->write( data.get<2>(), (unsigned char *)data.get<0>(), size ))
size_t size = get<1>(data);
if(fnode->write( get<2>(data), (unsigned char *)get<0>(data), size ))
return size;
else
return -EIO;
@ -707,8 +712,8 @@ int _do_setxattr(EncFS_Context *, const string &cyName,
tuple<const char *, const char *, size_t, uint32_t> data)
{
int options = 0;
return ::setxattr( cyName.c_str(), data.get<0>(), data.get<1>(),
data.get<2>(), data.get<3>(), options );
return ::setxattr( cyName.c_str(), get<0>(data), get<1>(data),
get<2>(data), get<3>(data), options );
}
int encfs_setxattr( const char *path, const char *name,
const char *value, size_t size, int flags, uint32_t position )
@ -721,8 +726,8 @@ int encfs_setxattr( const char *path, const char *name,
int _do_setxattr(EncFS_Context *, const string &cyName,
tuple<const char *, const char *, size_t, int> data)
{
return ::setxattr( cyName.c_str(), data.get<0>(), data.get<1>(),
data.get<2>(), data.get<3>() );
return ::setxattr( cyName.c_str(), get<0>(data), get<1>(data),
get<2>(data), get<3>(data) );
}
int encfs_setxattr( const char *path, const char *name,
const char *value, size_t size, int flags )
@ -738,8 +743,8 @@ int _do_getxattr(EncFS_Context *, const string &cyName,
tuple<const char *, void *, size_t, uint32_t> data)
{
int options = 0;
return ::getxattr( cyName.c_str(), data.get<0>(),
data.get<1>(), data.get<2>(), data.get<3>(), options );
return ::getxattr( cyName.c_str(), get<0>(data),
get<1>(data), get<2>(data), get<3>(data), options );
}
int encfs_getxattr( const char *path, const char *name,
char *value, size_t size, uint32_t position )
@ -751,8 +756,8 @@ int encfs_getxattr( const char *path, const char *name,
int _do_getxattr(EncFS_Context *, const string &cyName,
tuple<const char *, void *, size_t> data)
{
return ::getxattr( cyName.c_str(), data.get<0>(),
data.get<1>(), data.get<2>());
return ::getxattr( cyName.c_str(), get<0>(data),
get<1>(data), get<2>(data));
}
int encfs_getxattr( const char *path, const char *name,
char *value, size_t size )
@ -768,10 +773,10 @@ int _do_listxattr(EncFS_Context *, const string &cyName,
{
#ifdef XATTR_ADD_OPT
int options = 0;
int res = ::listxattr( cyName.c_str(), data.get<0>(), data.get<1>(),
int res = ::listxattr( cyName.c_str(), get<0>(data), get<1>(data),
options );
#else
int res = ::listxattr( cyName.c_str(), data.get<0>(), data.get<1>() );
int res = ::listxattr( cyName.c_str(), get<0>(data), get<1>(data) );
#endif
return (res == -1) ? -errno : res;
}

View File

@ -45,8 +45,6 @@
#include "i18n.h"
#include <boost/scoped_array.hpp>
#ifdef HAVE_SSL
#define NO_DES
#include <openssl/ssl.h>
@ -55,7 +53,6 @@
using namespace rlog;
using namespace std;
using namespace gnu;
using namespace boost;
static int showInfo( int argc, char **argv );
@ -472,8 +469,8 @@ static int copyLink(const struct stat &stBuf,
const shared_ptr<EncFS_Root> &rootInfo,
const string &cpath, const string &destName )
{
scoped_array<char> buf(new char[stBuf.st_size+1]);
int res = ::readlink( cpath.c_str(), buf.get(), stBuf.st_size );
vector<char> buf(stBuf.st_size+1, 0);
int res = ::readlink( cpath.c_str(), &buf[0], stBuf.st_size );
if(res == -1)
{
cerr << "unable to readlink of " << cpath << "\n";
@ -481,7 +478,7 @@ static int copyLink(const struct stat &stBuf,
}
buf[res] = '\0';
string decodedLink = rootInfo->root->plainPath(buf.get());
string decodedLink = rootInfo->root->plainPath(&buf[0]);
res = ::symlink( decodedLink.c_str(), destName.c_str() );
if(res == -1)

View File

@ -33,9 +33,6 @@
#include <getopt.h>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <rlog/rlog.h>
#include <rlog/Error.h>
#include <rlog/RLogChannel.h>
@ -70,8 +67,6 @@ inline static int MAX(int a, int b)
using namespace std;
using namespace rlog;
using namespace gnu;
using boost::shared_ptr;
using boost::scoped_ptr;
// Maximum number of arguments that we're going to pass on to fuse. Doesn't
// affect how many arguments we can handle, just how many we can pass on..
@ -501,8 +496,8 @@ int main(int argc, char *argv[])
#endif
// log to stderr by default..
scoped_ptr<StdioNode> slog( new StdioNode( STDERR_FILENO ) );
scoped_ptr<SyslogNode> logNode;
shared_ptr<StdioNode> slog( new StdioNode( STDERR_FILENO ) );
shared_ptr<SyslogNode> logNode;
// show error and warning output
slog->subscribeTo( GetGlobalChannel("error") );

38
encfs/shared_ptr.h Normal file
View File

@ -0,0 +1,38 @@
/*****************************************************************************
* Author: Valient Gough <vgough@pobox.com>
*
*****************************************************************************
* Copyright (c) 2012 Valient Gough
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SHARED_PTR_incl_
#define _SHARED_PTR_incl_
#include "config.h"
#ifdef HAVE_TR1_MEMORY
#include <tr1/memory>
using std::tr1::shared_ptr;
using std::tr1::dynamic_pointer_cast;
#else
#include <memory>
using std::shared_ptr;
using std::dynamic_pointer_cast;
#endif
#endif

View File

@ -20,8 +20,8 @@
#include "config.h"
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <sstream>
@ -49,14 +49,17 @@
#include <google/protobuf/text_format.h>
#if HAVE_TR1_UNORDERED_SET
#include <tr1/unordered_set>
using std::tr1::unordered_set;
#else
#include <unordered_set>
using std::unordered_set;
#endif
using namespace std;
using namespace rlog;
using boost::shared_ptr;
const int FSBlockSize = 256;
static
@ -171,7 +174,7 @@ bool testNameCoding( DirNode &dirNode, bool verbose,
cerr << "Checking for name collections, this will take a while..\n";
// check for collision rate
char buf[64];
tr1::unordered_set<string> encryptedNames;
unordered_set<string> encryptedNames;
for (long i=0; i < 10000000; i++)
{
snprintf(buf, sizeof(buf), "%li", i);

View File

@ -1,223 +0,0 @@
# ===========================================================================
# http://autoconf-archive.cryp.to/ax_boost_base.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_BASE([MINIMUM-VERSION])
#
# DESCRIPTION
#
# Test for the Boost C++ libraries of a particular version (or newer)
#
# If no path to the installed boost library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the
# $BOOST_ROOT environment variable. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
#
# And sets:
#
# HAVE_BOOST
#
# LAST MODIFICATION
#
# 2008-04-12
#
# COPYLEFT
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([AX_BOOST_BASE],
[
AC_ARG_WITH([boost],
AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ac_boost_path=""
else
want_boost="yes"
ac_boost_path="$withval"
fi
],
[want_boost="yes"])
AC_ARG_WITH([boost-libdir],
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
[Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
[
if test -d $withval
then
ac_boost_lib_path="$withval"
else
AC_MSG_ERROR(--with-boost-libdir expected directory name)
fi
],
[ac_boost_lib_path=""]
)
if test "x$want_boost" = "xyes"; then
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
boost_lib_version_req_sub_minor="0"
fi
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
succeeded=no
dnl first we check the system location for boost libraries
dnl this location ist chosen if boost libraries are installed with the --layout=system option
dnl or if you install boost with RPM
if test "$ac_boost_path" != ""; then
BOOST_LDFLAGS="-L$ac_boost_path/lib"
BOOST_CPPFLAGS="-I$ac_boost_path/include"
else
for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
break;
fi
done
fi
dnl overwrite ld flags if we have required special directory with
dnl --with-boost-libdir parameter
if test "$ac_boost_lib_path" != ""; then
BOOST_LDFLAGS="-L$ac_boost_lib_path"
fi
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= $WANT_BOOST_VERSION
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
dnl if we found no boost with system layout we search for boost libraries
dnl built and installed without the --layout=system option or for a staged(not installed) version
if test "x$succeeded" != "xyes"; then
_version=0
if test "$ac_boost_path" != ""; then
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "$V_CHECK" = "1" ; then
_version=$_version_tmp
fi
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
done
fi
else
for ac_boost_path in /usr /usr/local /opt /opt/local ; do
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "$V_CHECK" = "1" ; then
_version=$_version_tmp
best_path=$ac_boost_path
fi
done
fi
done
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
if test "$ac_boost_lib_path" = ""
then
BOOST_LDFLAGS="-L$best_path/lib"
fi
if test "x$BOOST_ROOT" != "x"; then
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
V_CHECK=`expr $stage_version_shorten \>\= $_version`
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
BOOST_CPPFLAGS="-I$BOOST_ROOT"
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
fi
fi
fi
fi
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= $WANT_BOOST_VERSION
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
fi
if test "$succeeded" != "yes" ; then
if test "$_version" = "0" ; then
AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
else
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
fi
else
AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS)
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])

View File

@ -1,118 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_FILESYSTEM
#
# DESCRIPTION
#
# Test for Filesystem library from the Boost C++ libraries. The macro
# requires a preceding call to AX_BOOST_BASE. Further documentation is
# available at <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_FILESYSTEM_LIB)
#
# And sets:
#
# HAVE_BOOST_FILESYSTEM
#
# LICENSE
#
# Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2009 Michael Tindal
# Copyright (c) 2009 Roman Rybalko <libtorrent@romanr.info>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 22
AC_DEFUN([AX_BOOST_FILESYSTEM],
[
AC_ARG_WITH([boost-filesystem],
AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@],
[use the Filesystem library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_filesystem_lib=""
else
want_boost="yes"
ax_boost_user_filesystem_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
LIBS_SAVED=$LIBS
LIBS="$LIBS $BOOST_SYSTEM_LIB"
export LIBS
AC_CACHE_CHECK(whether the Boost::Filesystem library is available,
ax_cv_boost_filesystem,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/filesystem/path.hpp>]],
[[using namespace boost::filesystem;
path my_path( "foo/bar/data.txt" );
return 0;]])],
ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no)
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_filesystem" = "xyes"; then
AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
if test "x$ax_boost_user_filesystem_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_filesystem*.so* $BOOSTLIBDIR/libboost_filesystem*.dylib* $BOOSTLIBDIR/libboost_filesystem*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_filesystem.*\)\.so.*$;\1;' -e 's;^lib\(boost_filesystem.*\)\.a*$;\1;' -e 's;^lib\(boost_filesystem.*\)\.dylib$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
[link_filesystem="no"])
done
if test "x$link_filesystem" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_filesystem*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_filesystem.*\)\.dll.*$;\1;' -e 's;^\(boost_filesystem.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
[link_filesystem="no"])
done
fi
else
for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do
AC_CHECK_LIB($ax_lib, exit,
[BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
[link_filesystem="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
fi
if test "x$link_filesystem" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
LIBS="$LIBS_SAVED"
fi
])

View File

@ -1,117 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_serialization.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_SERIALIZATION
#
# DESCRIPTION
#
# Test for Serialization library from the Boost C++ libraries. The macro
# requires a preceding call to AX_BOOST_BASE. Further documentation is
# available at <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_SERIALIZATION_LIB)
#
# And sets:
#
# HAVE_BOOST_SERIALIZATION
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 18
AC_DEFUN([AX_BOOST_SERIALIZATION],
[
AC_ARG_WITH([boost-serialization],
AS_HELP_STRING([--with-boost-serialization@<:@=special-lib@:>@],
[use the Serialization library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-serialization=boost_serialization-gcc-mt-d-1_33_1 ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_serialization_lib=""
else
want_boost="yes"
ax_boost_user_serialization_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_MSG_WARN(BOOST_CPPFLAGS $BOOST_CPPFLAGS)
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::Serialization library is available,
ax_cv_boost_serialization,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <fstream>
@%:@include <boost/archive/text_oarchive.hpp>
@%:@include <boost/archive/text_iarchive.hpp>
]],
[[std::ofstream ofs("filename");
boost::archive::text_oarchive oa(ofs);
return 0;
]])],
ax_cv_boost_serialization=yes, ax_cv_boost_serialization=no)
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_serialization" = "xyes"; then
AC_DEFINE(HAVE_BOOST_SERIALIZATION,,[define if the Boost::Serialization library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
if test "x$ax_boost_user_serialization_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_serialization*.so* $BOOSTLIBDIR/libboost_serialization*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_serialization.*\)\.so.*$;\1;' -e 's;^lib\(boost_serialization.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break],
[link_serialization="no"])
done
if test "x$link_serialization" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_serialization*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_serialization.*\)\.dll.*$;\1;' -e 's;^\(boost_serialization.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break],
[link_serialization="no"])
done
fi
else
for ax_lib in $ax_boost_user_serialization_lib boost_serialization-$ax_boost_user_serialization_lib; do
AC_CHECK_LIB($ax_lib, main,
[BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break],
[link_serialization="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
fi
if test "x$link_serialization" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])

View File

@ -1,120 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_SYSTEM
#
# DESCRIPTION
#
# Test for System library from the Boost C++ libraries. The macro requires
# a preceding call to AX_BOOST_BASE. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_SYSTEM_LIB)
#
# And sets:
#
# HAVE_BOOST_SYSTEM
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2008 Michael Tindal
# Copyright (c) 2008 Daniel Casimiro <dan.casimiro@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 14
AC_DEFUN([AX_BOOST_SYSTEM],
[
AC_ARG_WITH([boost-system],
AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@],
[use the System library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-system=boost_system-gcc-mt ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_system_lib=""
else
want_boost="yes"
ax_boost_user_system_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_BUILD])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::System library is available,
ax_cv_boost_system,
[AC_LANG_PUSH([C++])
CXXFLAGS_SAVE=$CXXFLAGS
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
[[boost::system::system_category]])],
ax_cv_boost_system=yes, ax_cv_boost_system=no)
CXXFLAGS=$CXXFLAGS_SAVE
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_system" = "xyes"; then
AC_SUBST(BOOST_CPPFLAGS)
AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
LDFLAGS_SAVE=$LDFLAGS
if test "x$ax_boost_user_system_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_system*.so* $BOOSTLIBDIR/libboost_system*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_system.*\)\.so.*$;\1;' -e 's;^lib\(boost_system.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
if test "x$link_system" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_system*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_system.*\)\.dll.*$;\1;' -e 's;^\(boost_system.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
fi
else
for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
fi
if test "x$link_system" = "xno"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])