text
stringlengths 9
39.2M
| dir
stringlengths 26
295
| lang
stringclasses 185
values | created_date
timestamp[us] | updated_date
timestamp[us] | repo_name
stringlengths 1
97
| repo_full_name
stringlengths 7
106
| star
int64 1k
183k
| len_tokens
int64 1
13.8M
|
|---|---|---|---|---|---|---|---|---|
```c++
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "jqnetwork_connectpool.h"
// Qt lib import
#include <QDebug>
#include <QTimer>
// JQNetwork lib import
#include <JQNetworkConnect>
using namespace std;
using namespace std::placeholders;
JQNetworkConnectPool::JQNetworkConnectPool(
JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings,
JQNetworkConnectSettingsSharedPointer connectSettings
):
connectPoolSettings_( connectPoolSettings ),
connectSettings_( connectSettings )
{
connectSettings_->connectToHostErrorCallback = bind( &JQNetworkConnectPool::onConnectToHostError, this, _1 );
connectSettings_->connectToHostTimeoutCallback = bind( &JQNetworkConnectPool::onConnectToHostTimeout, this, _1 );
connectSettings_->connectToHostSucceedCallback = bind( &JQNetworkConnectPool::onConnectToHostSucceed, this, _1 );
connectSettings_->remoteHostClosedCallback = bind( &JQNetworkConnectPool::onRemoteHostClosed, this, _1 );
connectSettings_->readyToDeleteCallback = bind( &JQNetworkConnectPool::onReadyToDelete, this, _1 );
connectSettings_->packageSendingCallback = bind( &JQNetworkConnectPool::onPackageSending, this, _1, _2, _3, _4, _5 );
connectSettings_->packageReceivingCallback = bind( &JQNetworkConnectPool::onPackageReceiving, this, _1, _2, _3, _4, _5 );
connectSettings_->packageReceivedCallback = bind( &JQNetworkConnectPool::onPackageReceived, this, _1, _2 );
connectSettings_->waitReplyPackageSucceedCallback = bind( &JQNetworkConnectPool::onWaitReplyPackageSucceed, this, _1, _2, _3 );
connectSettings_->waitReplyPackageFailCallback = bind( &JQNetworkConnectPool::onWaitReplyPackageFail, this, _1, _2 );
}
JQNetworkConnectPool::~JQNetworkConnectPool()
{
QVector< JQNetworkConnectSharedPointer > waitForCloseConnects;
for ( const auto &connect: connectForConnecting_ )
{
waitForCloseConnects.push_back( connect );
}
for ( const auto &connect: connectForConnected_ )
{
waitForCloseConnects.push_back( connect );
}
for ( const auto &connect: waitForCloseConnects )
{
connect->close();
}
}
void JQNetworkConnectPool::createConnect(
const std::function< void( std::function< void() > ) > runOnConnectThreadCallback,
const QString &hostName,
const quint16 &port
)
{
auto connectKey = QString( "%1:%2" ).arg( hostName ).arg( port );
mutex_.lock();
if ( bimapForHostAndPort1.contains( connectKey ) )
{
mutex_.unlock();
return;
}
mutex_.unlock();
JQNetworkConnect::createConnect(
[
this,
connectKey,
hostName
](const auto &connect)
{
this->mutex_.lock();
this->connectForConnecting_[ connect.data() ] = connect;
this->bimapForHostAndPort1[ connectKey ] = connect.data();
this->bimapForHostAndPort2[ connect.data() ] = connectKey;
this->mutex_.unlock();
},
runOnConnectThreadCallback,
connectSettings_,
hostName,
port
);
}
void JQNetworkConnectPool::createConnect(
const std::function< void( std::function< void() > ) > runOnConnectThreadCallback,
const qintptr &socketDescriptor
)
{
mutex_.lock();
if ( bimapForSocketDescriptor1.contains( socketDescriptor ) )
{
mutex_.unlock();
return;
}
mutex_.unlock();
JQNetworkConnect::createConnect(
[
this,
socketDescriptor
](const auto &connect)
{
this->mutex_.lock();
this->connectForConnecting_[ connect.data() ] = connect;
this->bimapForSocketDescriptor1[ socketDescriptor ] = connect.data();
this->bimapForSocketDescriptor2[ connect.data() ] = socketDescriptor;
this->mutex_.unlock();
},
runOnConnectThreadCallback,
connectSettings_,
socketDescriptor
);
}
QPair< QString, quint16 > JQNetworkConnectPool::getHostAndPortByConnect(const JQNetworkConnectPointer &connect)
{
QPair< QString, quint16 > reply;
mutex_.lock();
{
auto it = bimapForHostAndPort2.find( connect.data() );
if ( it != bimapForHostAndPort2.end() )
{
auto index = it.value().lastIndexOf( ":" );
if ( ( index > 0 ) && ( ( index + 1 ) < it.value().size() ) )
{
reply.first = it.value().mid( 0, index );
reply.second = it.value().mid( index + 1 ).toUShort();
}
}
}
mutex_.unlock();
return reply;
}
qintptr JQNetworkConnectPool::getSocketDescriptorByConnect(const JQNetworkConnectPointer &connect)
{
qintptr reply = { };
mutex_.lock();
{
auto it = bimapForSocketDescriptor2.find( connect.data() );
if ( it != bimapForSocketDescriptor2.end() )
{
reply = it.value();
}
}
mutex_.unlock();
return reply;
}
JQNetworkConnectPointer JQNetworkConnectPool::getConnectByHostAndPort(const QString &hostName, const quint16 &port)
{
JQNetworkConnectPointer reply;
mutex_.lock();
{
auto it = bimapForHostAndPort1.find( QString( "%1:%2" ).arg( hostName, QString::number( port ) ) );
if ( it != bimapForHostAndPort1.end() )
{
reply = it.value();
}
}
mutex_.unlock();
return reply;
}
JQNetworkConnectPointer JQNetworkConnectPool::getConnectBySocketDescriptor(const qintptr &socketDescriptor)
{
JQNetworkConnectPointer reply;
mutex_.lock();
{
auto it = bimapForSocketDescriptor1.find( socketDescriptor );
if ( it != bimapForSocketDescriptor1.end() )
{
reply = it.value();
}
}
mutex_.unlock();
return reply;
}
void JQNetworkConnectPool::onConnectToHostSucceed(const JQNetworkConnectPointer &connect)
{
// qDebug() << "JQNetworkConnectPool::onConnectToHostSucceed:" << connect.data();
mutex_.lock();
auto containsInConnecting = connectForConnecting_.contains( connect.data() );
if ( !containsInConnecting )
{
mutex_.unlock();
qDebug() << "JQNetworkConnectPool::onConnectToHostSucceed: error: connect not contains" << connect.data();
return;
}
connectForConnected_[ connect.data() ] = connectForConnecting_[ connect.data() ];
connectForConnecting_.remove( connect.data() );
mutex_.unlock();
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->connectToHostSucceedCallback );
connectPoolSettings_->connectToHostSucceedCallback( connect, this );
}
void JQNetworkConnectPool::onReadyToDelete(const JQNetworkConnectPointer &connect)
{
// qDebug() << "JQNetworkConnectPool::onReadyToDelete:" << connect.data();
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->readyToDeleteCallback );
connectPoolSettings_->readyToDeleteCallback( connect, this );
mutex_.lock();
auto containsInConnecting = connectForConnecting_.contains( connect.data() );
auto containsInConnected = connectForConnected_.contains( connect.data() );
auto containsInBimapForHostAndPort = bimapForHostAndPort2.contains( connect.data() );
auto containsInBimapForSocketDescriptor = bimapForSocketDescriptor2.contains( connect.data() );
if ( ( !containsInConnecting && !containsInConnected ) || ( !containsInBimapForHostAndPort && !containsInBimapForSocketDescriptor ) )
{
mutex_.unlock();
qDebug() << "JQNetworkConnectPool::onReadyToDelete: error: connect not contains" << connect.data();
return;
}
if ( containsInConnecting )
{
QTimer::singleShot( 0, [ connect = connectForConnecting_[ connect.data() ] ](){} );
connectForConnecting_.remove( connect.data() );
}
if ( containsInConnected )
{
QTimer::singleShot( 0, [ connect = connectForConnected_[ connect.data() ] ](){} );
connectForConnected_.remove( connect.data() );
}
if ( containsInBimapForHostAndPort )
{
bimapForHostAndPort1.remove( bimapForHostAndPort2[ connect.data() ] );
bimapForHostAndPort2.remove( connect.data() );
}
if ( containsInBimapForSocketDescriptor )
{
bimapForSocketDescriptor1.remove( bimapForSocketDescriptor2[ connect.data() ] );
bimapForSocketDescriptor2.remove( connect.data() );
}
mutex_.unlock();
}
```
|
/content/code_sandbox/library/JQNetwork/src/jqnetwork_connectpool.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,072
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CONNECTPOOL_H_
#define JQNETWORK_INCLUDE_JQNETWORK_CONNECTPOOL_H_
// JQNetwork lib import
#include <JQNetworkFoundation>
struct JQNetworkConnectPoolSettings
{
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer & ) > connectToHostErrorCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer & ) > connectToHostTimeoutCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer & ) > connectToHostSucceedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer & ) > remoteHostClosedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer & ) > readyToDeleteCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer &, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageSendingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer &, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageReceivingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer &, const JQNetworkPackageSharedPointer & ) > packageReceivedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer &, const JQNetworkPackageSharedPointer &, const JQNetworkConnectPointerAndPackageSharedPointerFunction & ) > waitReplyPackageSucceedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkConnectPoolPointer &, const JQNetworkConnectPointerFunction & ) > waitReplyPackageFailCallback = nullptr;
};
class JQNetworkConnectPool: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkConnectPool )
public:
JQNetworkConnectPool(
JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings,
JQNetworkConnectSettingsSharedPointer connectSettings
);
~JQNetworkConnectPool();
void createConnect(
const std::function< void( std::function< void() > ) > runOnConnectThreadCallback,
const QString &hostName,
const quint16 &port
);
void createConnect(
const std::function< void( std::function< void() > ) > runOnConnectThreadCallback,
const qintptr &socketDescriptor
);
inline bool containsConnect(const QString &hostName, const quint16 &port);
inline bool containsConnect(const qintptr &socketDescriptor);
QPair< QString, quint16 > getHostAndPortByConnect(const JQNetworkConnectPointer &connect);
qintptr getSocketDescriptorByConnect(const JQNetworkConnectPointer &connect);
JQNetworkConnectPointer getConnectByHostAndPort(const QString &hostName, const quint16 &port);
JQNetworkConnectPointer getConnectBySocketDescriptor(const qintptr &socketDescriptor);
private:
inline void onConnectToHostError(const JQNetworkConnectPointer &connectz);
inline void onConnectToHostTimeout(const JQNetworkConnectPointer &connect);
void onConnectToHostSucceed(const JQNetworkConnectPointer &connect);
inline void onRemoteHostClosed(const JQNetworkConnectPointer &connect);
void onReadyToDelete(const JQNetworkConnectPointer &connect);
inline void onPackageSending(
const JQNetworkConnectPointer &connect,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
);
inline void onPackageReceiving(
const JQNetworkConnectPointer &connect,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
);
inline void onPackageReceived(
const JQNetworkConnectPointer &connect,
const JQNetworkPackageSharedPointer &package
);
inline void onWaitReplyPackageSucceed(
const JQNetworkConnectPointer &connect,
const JQNetworkPackageSharedPointer &package,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback
);
inline void onWaitReplyPackageFail(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPointerFunction &failCallback
);
private:
// Settings
JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings_;
JQNetworkConnectSettingsSharedPointer connectSettings_;
// Connect
QMap< JQNetworkConnect *, JQNetworkConnectSharedPointer > connectForConnecting_;
QMap< JQNetworkConnect *, JQNetworkConnectSharedPointer > connectForConnected_;
QMap< QString, JQNetworkConnectPointer > bimapForHostAndPort1; // "127.0.0.1:34543" -> Connect
QMap< JQNetworkConnect *, QString > bimapForHostAndPort2; // Connect -> "127.0.0.1:34543"
QMap< qintptr, JQNetworkConnectPointer > bimapForSocketDescriptor1; // socketDescriptor -> Connect
QMap< JQNetworkConnect *, qintptr > bimapForSocketDescriptor2; // Connect -> socketDescriptor
// Other
QMutex mutex_;
};
// inc import
#include "jqnetwork_connectpool.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_CONNECTPOOL_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_connectpool.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,249
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CLIENGFORQML_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_CLIENGFORQML_INC_
// JQNetwork lib import
#include "jqnetwork_clientforqml.h"
inline void JQNetworkClientForQml::runOnClientThread(const std::function<void()> &callback)
{
callback();
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_CLIENGFORQML_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_clientforqml.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 128
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_PROCESSOR_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_PROCESSOR_INC_
// JQNetwork lib import
#include "jqnetwork_processor.h"
inline void JQNetworkProcessor::deleteByteArray(QByteArray *ptr)
{
delete ptr;
}
inline void JQNetworkProcessor::deleteVariantMap(QVariantMap *ptr)
{
delete ptr;
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_PROCESSOR_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_processor.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 131
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_LAN_H_
#define JQNETWORK_INCLUDE_JQNETWORK_LAN_H_
// JQNetwork lib import
#include <JQNetworkFoundation>
struct JQNetworkLanSettings
{
QString dutyMark;
QHostAddress multicastGroupAddress;
quint16 bindPort = 0;
int checkLoopInterval = 10 * 1000;
int lanNodeTimeoutInterval = 60 * 1000;
std::function< void( const JQNetworkLanNode & ) > lanNodeOnlineCallback;
std::function< void( const JQNetworkLanNode & ) > lanNodeActiveCallback;
std::function< void( const JQNetworkLanNode & ) > lanNodeOfflineCallback;
std::function< void() > lanNodeListChangedCallback;
int globalProcessorThreadCount = 1;
};
struct JQNetworkLanNode
{
QString nodeMarkSummary;
QString dutyMark;
int dataPackageIndex = 0;
qint64 lastActiveTime = 0;
QList< QHostAddress > ipList;
QVariant appendData;
QHostAddress matchAddress;
bool isSelf = false;
};
struct JQNetworkLanAddressEntries
{
QHostAddress ip;
QHostAddress netmask;
QHostAddress ipSegment;
bool isVmAddress;
};
class JQNetworkLan: public QObject
{
Q_OBJECT
public:
JQNetworkLan(const JQNetworkLanSettingsSharedPointer &lanSettings);
~JQNetworkLan();
JQNetworkLan(const JQNetworkLan &) = delete;
JQNetworkLan &operator =(const JQNetworkLan &) = delete;
static JQNetworkLanSharedPointer createLan(
const QHostAddress &multicastGroupAddress,
const quint16 &bindPort,
const QString &dutyMark = ""
);
static QList< JQNetworkLanAddressEntries > lanAddressEntries();
inline JQNetworkLanSettingsSharedPointer lanSettings();
inline QString nodeMarkSummary() const;
inline void setAppendData(const QVariant &appendData);
bool begin();
QHostAddress matchLanAddressEntries(const QList< QHostAddress > &ipList);
QList< JQNetworkLanNode > availableLanNodes();
void sendOnline();
void sendOffline();
private:
void refreshLanAddressEntries();
bool refreshUdp();
void checkLoop();
QByteArray makeData(const bool &requestOffline, const bool &requestFeedback);
void onUdpSocketReadyRead();
inline void onLanNodeStateOnline(const JQNetworkLanNode &lanNode);
inline void onLanNodeStateActive(const JQNetworkLanNode &lanNode);
inline void onLanNodeStateOffline(const JQNetworkLanNode &lanNode);
inline void onLanNodeListChanged();
private:
// Thread pool
static QWeakPointer< JQNetworkThreadPool > globalProcessorThreadPool_;
QSharedPointer< JQNetworkThreadPool > processorThreadPool_;
// Settings
JQNetworkLanSettingsSharedPointer lanSettings_;
// Socket
QSharedPointer< QUdpSocket > udpSocket_;
// Data
QList< JQNetworkLanAddressEntries > lanAddressEntries_;
QMap< QString, JQNetworkLanNode > availableLanNodes_;
// Other
QString nodeMarkSummary_;
QMutex mutex_;
QVariant appendData_;
QSharedPointer< QTimer > timerForCheckLoop_;
int checkLoopCounting_ = -1;
int nextDataPackageIndex_ = 0;
};
// inc import
#include "jqnetwork_lan.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_LAN_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_lan.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 844
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_PACKAGE_H_
#define JQNETWORK_INCLUDE_JQNETWORK_PACKAGE_H_
// Qt lib import
#include <QVariant>
// JQNetwork lib import
#include <JQNetworkFoundation>
class QFileInfo;
class QDateTime;
class JQNetworkPackage
{
private:
JQNetworkPackage() = default;
public:
~JQNetworkPackage() = default;
JQNetworkPackage(const JQNetworkPackage &) = delete;
JQNetworkPackage &operator =(const JQNetworkPackage &) = delete;
public:
static inline int headSize();
static qint32 checkDataIsReadyReceive(const QByteArray &rawData);
static JQNetworkPackageSharedPointer readPackage(QByteArray &rawData);
static QList< JQNetworkPackageSharedPointer > createPayloadTransportPackages(
const QString &targetActionFlag,
const QByteArray &payloadData,
const QVariantMap &appendData,
const qint32 &randomFlag,
const qint64 cutPackageSize = -1,
const bool &compressionData = false
);
static JQNetworkPackageSharedPointer createFileTransportPackage(
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const QByteArray &fileData,
const QVariantMap &appendData,
const qint32 &randomFlag,
const bool &compressionData = false
);
static JQNetworkPackageSharedPointer createPayloadDataRequestPackage(const qint32 &randomFlag);
static JQNetworkPackageSharedPointer createFileDataRequestPackage(const qint32 &randomFlag);
inline bool isCompletePackage() const;
inline bool isAbandonPackage() const;
inline qint8 bootFlag() const;
inline qint8 packageFlag() const;
inline qint32 randomFlag() const;
inline qint8 metaDataFlag() const;
inline qint32 metaDataTotalSize() const;
inline qint32 metaDataCurrentSize() const;
inline qint8 payloadDataFlag() const;
inline qint32 payloadDataTotalSize() const;
inline qint32 payloadDataCurrentSize() const;
inline QByteArray metaData() const;
inline int metaDataSize() const;
inline QByteArray payloadData() const;
inline int payloadDataSize() const;
inline qint32 metaDataOriginalIndex() const;
inline qint32 metaDataOriginalCurrentSize() const;
inline qint32 payloadDataOriginalIndex() const;
inline qint32 payloadDataOriginalCurrentSize() const;
inline QVariantMap metaDataInVariantMap() const;
inline QString targetActionFlag() const;
inline QVariantMap appendData() const;
inline QString fileName() const;
inline qint64 fileSize() const;
inline qint32 filePermissions() const;
QDateTime fileCreatedTime() const;
QDateTime fileLastReadTime() const;
QDateTime fileLastModifiedTime() const;
inline bool containsFile() const;
inline QString localFilePath() const;
inline void setLocalFilePath(const QString &localFilePath);
inline void clearMetaData();
inline void clearPayloadData();
inline QByteArray toByteArray() const;
bool mixPackage(const JQNetworkPackageSharedPointer &mixPackage);
void refreshPackage();
private:
bool isCompletePackage_ = false;
bool isAbandonPackage_ = false;
#pragma pack(push)
#pragma pack(1)
struct Head
{
qint8 bootFlag_ = 0;
qint8 packageFlag_ = 0;
qint32 randomFlag_ = 0;
qint8 metaDataFlag_ = 0;
qint32 metaDataTotalSize_ = -1;
qint32 metaDataCurrentSize_ = -1;
qint8 payloadDataFlag_ = 0;
qint32 payloadDataTotalSize_ = -1;
qint32 payloadDataCurrentSize_ = -1;
} head_;
#pragma pack(pop)
QByteArray metaData_;
QByteArray payloadData_;
QString localFilePath_;
qint32 metaDataOriginalIndex_ = -1;
qint32 metaDataOriginalCurrentSize_ = -1;
qint32 payloadDataOriginalIndex_ = -1;
qint32 payloadDataOriginalCurrentSize_ = -1;
QVariantMap metaDataInVariantMap_;
};
// inc import
#include "jqnetwork_package.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_PACKAGE_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_package.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 924
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_SERVER_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_SERVER_INC_
// JQNetwork lib import
#include "jqnetwork_server.h"
inline JQNetworkServerSettingsSharedPointer JQNetworkServer::serverSettings()
{
return serverSettings_;
}
inline JQNetworkConnectPoolSettingsSharedPointer JQNetworkServer::connectPoolSettings()
{
return connectPoolSettings_;
}
inline JQNetworkConnectSettingsSharedPointer JQNetworkServer::connectSettings()
{
return connectSettings_;
}
inline QString JQNetworkServer::nodeMarkSummary() const
{
return nodeMarkSummary_;
}
inline QSet< QString > JQNetworkServer::availableProcessorMethodNames() const
{
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) )
const auto keys = processorCallbacks_.keys();
return QSet< QString >( keys.begin(), keys.end() );
#else
return processorCallbacks_.keys().toSet();
#endif
}
inline void JQNetworkServer::onConnectToHostError(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &)
{
if ( !serverSettings_->connectToHostErrorCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->connectToHostErrorCallback
]()
{
callback( connect );
}
);
}
inline void JQNetworkServer::onConnectToHostTimeout(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &)
{
if ( !serverSettings_->connectToHostTimeoutCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->connectToHostTimeoutCallback
]()
{
callback( connect );
}
);
}
inline void JQNetworkServer::onConnectToHostSucceed(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &)
{
if ( !serverSettings_->connectToHostSucceedCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->connectToHostSucceedCallback
]()
{
callback( connect );
}
);
}
inline void JQNetworkServer::onRemoteHostClosed(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &)
{
if ( !serverSettings_->remoteHostClosedCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->remoteHostClosedCallback
]()
{
callback( connect );
}
);
}
inline void JQNetworkServer::onReadyToDelete(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &)
{
if ( !serverSettings_->readyToDeleteCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->readyToDeleteCallback
]()
{
callback( connect );
}
);
}
inline void JQNetworkServer::onPackageSending(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
)
{
if ( !serverSettings_->packageSendingCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->packageSendingCallback,
randomFlag,
payloadCurrentIndex,
payloadCurrentSize,
payloadTotalSize
]()
{
callback( connect, randomFlag, payloadCurrentIndex, payloadCurrentSize, payloadTotalSize );
}
);
}
inline void JQNetworkServer::onPackageReceiving(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
)
{
if ( !serverSettings_->packageReceivingCallback ) { return; }
callbackThreadPool_->run(
[
connect,
callback = serverSettings_->packageReceivingCallback,
randomFlag,
payloadCurrentIndex,
payloadCurrentSize,
payloadTotalSize
]()
{
callback( connect, randomFlag, payloadCurrentIndex, payloadCurrentSize, payloadTotalSize );
}
);
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_SERVER_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_server.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 988
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CLIENG_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_CLIENG_INC_
// JQNetwork lib import
#include "jqnetwork_client.h"
inline JQNetworkClientSettingsSharedPointer JQNetworkClient::clientSettings()
{
return clientSettings_;
}
inline JQNetworkConnectPoolSettingsSharedPointer JQNetworkClient::connectPoolSettings()
{
return connectPoolSettings_;
}
inline JQNetworkConnectSettingsSharedPointer JQNetworkClient::connectSettings()
{
return connectSettings_;
}
inline QString JQNetworkClient::nodeMarkSummary() const
{
return nodeMarkSummary_;
}
inline QSet< QString > JQNetworkClient::availableProcessorMethodNames() const
{
#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) )
const auto keys = processorCallbacks_.keys();
return QSet< QString >( keys.begin(), keys.end() );
#else
return processorCallbacks_.keys().toSet();
#endif
}
inline qint32 JQNetworkClient::sendPayloadData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendPayloadData(
hostName,
port,
targetActionFlag,
payloadData,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::sendPayloadData(
const QString &hostName,
const quint16 &port,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendPayloadData(
hostName,
port,
{ }, // empty targetActionFlag
payloadData,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::sendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendVariantMapData(
hostName,
port,
targetActionFlag,
variantMap,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::sendVariantMapData(
const QString &hostName,
const quint16 &port,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendVariantMapData(
hostName,
port,
{ }, // empty targetActionFlag
variantMap,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::sendFileData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendFileData(
hostName,
port,
targetActionFlag,
fileInfo,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::sendFileData(
const QString &hostName,
const quint16 &port,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendFileData(
hostName,
port,
{ }, // empty targetActionFlag
fileInfo,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::waitForSendPayloadData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->waitForSendPayloadData(
hostName,
port,
targetActionFlag,
payloadData,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::waitForSendPayloadData(
const QString &hostName,
const quint16 &port,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->waitForSendPayloadData(
hostName,
port,
{ }, // empty targetActionFlag
payloadData,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::waitForSendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->waitForSendVariantMapData(
hostName,
port,
targetActionFlag,
variantMap,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::waitForSendVariantMapData(
const QString &hostName,
const quint16 &port,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->waitForSendVariantMapData(
hostName,
port,
{ }, // empty targetActionFlag
variantMap,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::waitForSendFileData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->waitForSendFileData(
hostName,
port,
targetActionFlag,
fileInfo,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkClient::waitForSendFileData(
const QString &hostName,
const quint16 &port,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->waitForSendFileData(
hostName,
port,
{ }, // empty targetActionFlag
fileInfo,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_CLIENG_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_client.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,636
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_FOUNDATION_H_
#define JQNETWORK_INCLUDE_JQNETWORK_FOUNDATION_H_
// C++ lib import
#include <functional>
#include <vector>
#include <memory>
// Qt lib import
#include <QObject>
#include <QSharedPointer>
#include <QWeakPointer>
#include <QPointer>
#include <QMutex>
#include <QSet>
#include <QVariant>
#include <QHostAddress>
#define JQNETWORK_VERSIONNUMBER QVersionNumber::fromString( JQNETWORK_VERSIONSTRING )
#define JQNETWORKPACKAGE_BOOTFLAG qint8( 0x7d )
#define JQNETWORKPACKAGE_PAYLOADDATATRANSPORTPACKGEFLAG qint8( 0x1 )
#define JQNETWORKPACKAGE_PAYLOADDATAREQUESTPACKGEFLAG qint8( 0x2 )
#define JQNETWORKPACKAGE_FILEDATATRANSPORTPACKGEFLAG qint8( 0x3 )
#define JQNETWORKPACKAGE_FILEDATAREQUESTPACKGEFLAG qint8( 0x4 )
#define JQNETWORKPACKAGE_UNCOMPRESSEDFLAG qint8( 0x1 )
#define JQNETWORKPACKAGE_COMPRESSEDFLAG qint8( 0x2 )
#if ( defined Q_OS_IOS ) || ( defined Q_OS_ANDROID )
# define JQNETWORK_ADVISE_THREADCOUNT 1
# define JQNETWORKPACKAGE_ADVISE_CUTPACKAGESIZE qint64( 512 * 1024 )
#else
# define JQNETWORK_ADVISE_THREADCOUNT 2
# define JQNETWORKPACKAGE_ADVISE_CUTPACKAGESIZE qint64( 2 * 1024 * 1024 )
#endif
#define JQNETWORK_NULLPTR_CHECK( ptr, ... ) \
if ( !ptr ) { qDebug( "%s: %s is null", __func__, # ptr ); return __VA_ARGS__; }
#define JQNETWORK_THISNULL_CHECK( message, ... ) \
{ \
auto this_ = this; \
if ( !this_ ) \
{ \
qDebug( "%s: this is null", message ); \
return __VA_ARGS__; \
} \
}
class QSemaphore;
class QMutex;
class QTimer;
class QThreadPool;
class QEventLoop;
class QJsonObject;
class QJsonArray;
class QJsonValue;
class QJsonDocument;
class QFile;
class QDir;
class QFileInfo;
class QTcpSocket;
class QTcpServer;
class QUdpSocket;
template < typename T > class QVector;
template < typename T > class QSet;
class JQNetworkPackage;
class JQNetworkConnect;
class JQNetworkConnectPool;
class JQNetworkServer;
class JQNetworkProcessor;
class JQNetworkClient;
class JQNetworkLan;
struct JQNetworkConnectSettings;
struct JQNetworkConnectPoolSettings;
struct JQNetworkServerSettings;
struct JQNetworkClientSettings;
struct JQNetworkLanSettings;
struct JQNetworkLanNode;
typedef QPointer< JQNetworkPackage > JQNetworkPackagePointer;
typedef QPointer< JQNetworkConnect > JQNetworkConnectPointer;
typedef QPointer< JQNetworkConnectPool > JQNetworkConnectPoolPointer;
typedef QPointer< JQNetworkServer > JQNetworkServerPointer;
typedef QPointer< JQNetworkProcessor > JQNetworkProcessorPointer;
typedef QPointer< JQNetworkClient > JQNetworkClientPointer;
typedef QPointer< JQNetworkLan > JQNetworkLanPointer;
typedef std::shared_ptr< void > JQNetworkVoidSharedPointer;
typedef QSharedPointer< JQNetworkPackage > JQNetworkPackageSharedPointer;
typedef QSharedPointer< JQNetworkConnect > JQNetworkConnectSharedPointer;
typedef QSharedPointer< JQNetworkConnectPool > JQNetworkConnectPoolSharedPointer;
typedef QSharedPointer< JQNetworkServer > JQNetworkServerSharedPointer;
typedef QSharedPointer< JQNetworkProcessor > JQNetworkProcessorSharedPointer;
typedef QSharedPointer< JQNetworkClient > JQNetworkClientSharedPointer;
typedef QSharedPointer< JQNetworkLan > JQNetworkLanSharedPointer;
typedef QSharedPointer< JQNetworkConnectSettings > JQNetworkConnectSettingsSharedPointer;
typedef QSharedPointer< JQNetworkConnectPoolSettings > JQNetworkConnectPoolSettingsSharedPointer;
typedef QSharedPointer< JQNetworkServerSettings > JQNetworkServerSettingsSharedPointer;
typedef QSharedPointer< JQNetworkClientSettings > JQNetworkClientSettingsSharedPointer;
typedef QSharedPointer< JQNetworkLanSettings > JQNetworkLanSettingsSharedPointer;
typedef std::function< void(const JQNetworkConnectPointer &connect ) > JQNetworkConnectPointerFunction;
typedef std::function< void(const JQNetworkConnectPointer &connect, const JQNetworkPackageSharedPointer &package ) > JQNetworkConnectPointerAndPackageSharedPointerFunction;
struct JQNetworkOnReceivedCallbackPackage
{
std::function< void(const JQNetworkConnectPointer &connect, const JQNetworkPackageSharedPointer &) > succeedCallback = nullptr;
std::function< void(const JQNetworkConnectPointer &connect) > failCallback = nullptr;
};
class JQNetworkThreadPoolHelper: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkThreadPoolHelper )
public:
JQNetworkThreadPoolHelper();
~JQNetworkThreadPoolHelper() = default;
void run(const std::function< void() > &callback);
public Q_SLOTS:
void onRun();
private:
QMutex mutex_;
QSharedPointer< std::vector< std::function< void() > > > waitForRunCallbacks_;
bool alreadyCall_ = false;
qint64 lastRunTime_ = 0;
int lastRunCallbackCount_ = 0;
};
class JQNetworkThreadPool: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkThreadPool )
public:
JQNetworkThreadPool(const int &threadCount);
~JQNetworkThreadPool();
inline int nextRotaryIndex();
int run(const std::function< void() > &callback, const int &threadIndex = -1);
inline void runEach(const std::function< void() > &callback);
int waitRun(const std::function< void() > &callback, const int &threadIndex = -1);
inline void waitRunEach(const std::function< void() > &callback);
private:
QSharedPointer< QThreadPool > threadPool_;
QSharedPointer< QVector< QPointer< QEventLoop > > > eventLoops_;
QSharedPointer< QVector< QPointer< JQNetworkThreadPoolHelper > > > helpers_;
int rotaryIndex_ = -1;
};
class JQNetworkNodeMark
{
public:
JQNetworkNodeMark(const QString &dutyMark);
~JQNetworkNodeMark() = default;
static QString calculateNodeMarkSummary(const QString &dutyMark);
inline qint64 applicationStartTime() const;
inline QString applicationFilePath() const;
inline QString localHostName() const;
inline qint64 nodeMarkCreatedTime() const;
inline QString nodeMarkClassAddress() const;
inline QString dutyMark() const;
inline QString nodeMarkSummary() const;
private:
static qint64 applicationStartTime_;
static QString applicationFilePath_;
static QString localHostName_;
qint64 nodeMarkCreatedTime_;
QString nodeMarkClassAddress_;
QString dutyMark_;
QString nodeMarkSummary_;
};
namespace JQNetwork
{
void printVersionInformation(const char *jqNetworkCompileModeString = JQNETWORK_COMPILE_MODE_STRING);
}
// inc import
#include "jqnetwork_foundation.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_FOUNDATION_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_foundation.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,628
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_LAN_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_LAN_INC_
// JQNetwork lib import
#include "jqnetwork_lan.h"
inline JQNetworkLanSettingsSharedPointer JQNetworkLan::lanSettings()
{
return lanSettings_;
}
inline QString JQNetworkLan::nodeMarkSummary() const
{
return nodeMarkSummary_;
}
inline void JQNetworkLan::setAppendData(const QVariant &appendData)
{
appendData_ = appendData;
}
inline void JQNetworkLan::onLanNodeStateOnline(const JQNetworkLanNode &lanNode)
{
if ( !lanSettings_->lanNodeOnlineCallback ) { return; }
lanSettings_->lanNodeOnlineCallback( lanNode );
}
inline void JQNetworkLan::onLanNodeStateActive(const JQNetworkLanNode &lanNode)
{
if ( !lanSettings_->lanNodeActiveCallback ) { return; }
lanSettings_->lanNodeActiveCallback( lanNode );
}
inline void JQNetworkLan::onLanNodeStateOffline(const JQNetworkLanNode &lanNode)
{
if ( !lanSettings_->lanNodeOfflineCallback ) { return; }
lanSettings_->lanNodeOfflineCallback( lanNode );
}
inline void JQNetworkLan::onLanNodeListChanged()
{
if ( !lanSettings_->lanNodeListChangedCallback ) { return; }
lanSettings_->lanNodeListChangedCallback();
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_LAN_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_lan.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 372
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_SERVER_H_
#define JQNETWORK_INCLUDE_JQNETWORK_SERVER_H_
// JQNetwork lib import
#include <JQNetworkFoundation>
struct JQNetworkServerSettings
{
QString dutyMark;
QHostAddress listenAddress = QHostAddress::Any;
quint16 listenPort = 0;
std::function< void( const JQNetworkConnectPointer & ) > connectToHostErrorCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > connectToHostTimeoutCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > connectToHostSucceedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > remoteHostClosedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > readyToDeleteCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageSendingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageReceivingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer & ) > packageReceivedCallback = nullptr;
int globalServerThreadCount = 1;
int globalSocketThreadCount = JQNETWORK_ADVISE_THREADCOUNT;
int globalCallbackThreadCount = JQNETWORK_ADVISE_THREADCOUNT;
};
class JQNetworkServer: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkServer )
public:
JQNetworkServer(
const JQNetworkServerSettingsSharedPointer serverSettings,
const JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings,
const JQNetworkConnectSettingsSharedPointer connectSettings
);
~JQNetworkServer();
static JQNetworkServerSharedPointer createServer(
const quint16 &listenPort,
const QHostAddress &listenAddress = QHostAddress::Any,
const bool &fileTransferEnabled = false
);
inline JQNetworkServerSettingsSharedPointer serverSettings();
inline JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings();
inline JQNetworkConnectSettingsSharedPointer connectSettings();
inline QString nodeMarkSummary() const;
bool begin();
void registerProcessor(const JQNetworkProcessorPointer &processor);
inline QSet< QString > availableProcessorMethodNames() const;
private:
void incomingConnection(const qintptr &socketDescriptor);
inline void onConnectToHostError(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
inline void onConnectToHostTimeout(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
inline void onConnectToHostSucceed(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
inline void onRemoteHostClosed(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
inline void onReadyToDelete(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
inline void onPackageSending(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
);
inline void onPackageReceiving(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
);
void onPackageReceived(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const JQNetworkPackageSharedPointer &package
);
private:
// Thread pool
static QWeakPointer< JQNetworkThreadPool > globalServerThreadPool_;
QSharedPointer< JQNetworkThreadPool > serverThreadPool_;
static QWeakPointer< JQNetworkThreadPool > globalSocketThreadPool_;
QSharedPointer< JQNetworkThreadPool > socketThreadPool_;
static QWeakPointer< JQNetworkThreadPool > globalCallbackThreadPool_;
QSharedPointer< JQNetworkThreadPool > callbackThreadPool_;
// Settings
JQNetworkServerSettingsSharedPointer serverSettings_;
JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings_;
JQNetworkConnectSettingsSharedPointer connectSettings_;
// Server
QSharedPointer< QTcpServer > tcpServer_;
QMap< QThread *, JQNetworkConnectPoolSharedPointer > connectPools_;
// Processor
QSet< JQNetworkProcessor * > processors_;
QMap< QString, std::function< void( const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer & ) > > processorCallbacks_;
// Other
QString nodeMarkSummary_;
};
// inc import
#include "jqnetwork_server.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_SERVER_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_server.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,131
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CONNECTPOOL_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_CONNECTPOOL_INC_
// JQNetwork lib import
#include "jqnetwork_connectpool.h"
inline bool JQNetworkConnectPool::containsConnect(const QString &hostName, const quint16 &port)
{
mutex_.lock();
auto contains = bimapForHostAndPort1.contains( QString( "%1:%2" ).arg( hostName ).arg( port ) );
mutex_.unlock();
return contains;
}
inline bool JQNetworkConnectPool::containsConnect(const qintptr &socketDescriptor)
{
mutex_.lock();
auto contains = bimapForSocketDescriptor1.contains( socketDescriptor );
mutex_.unlock();
return contains;
}
inline void JQNetworkConnectPool::onConnectToHostError(const JQNetworkConnectPointer &connect)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->connectToHostErrorCallback );
connectPoolSettings_->connectToHostErrorCallback( connect, this );
}
inline void JQNetworkConnectPool::onConnectToHostTimeout(const JQNetworkConnectPointer &connect)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->connectToHostTimeoutCallback );
connectPoolSettings_->connectToHostTimeoutCallback( connect, this );
}
inline void JQNetworkConnectPool::onRemoteHostClosed(const JQNetworkConnectPointer &connect)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->remoteHostClosedCallback );
connectPoolSettings_->remoteHostClosedCallback( connect, this );
}
inline void JQNetworkConnectPool::onPackageSending(
const JQNetworkConnectPointer &connect,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->packageSendingCallback );
connectPoolSettings_->packageSendingCallback( connect, this, randomFlag, payloadCurrentIndex, payloadCurrentSize, payloadTotalSize );
}
inline void JQNetworkConnectPool::onPackageReceiving(
const JQNetworkConnectPointer &connect,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->packageReceivingCallback );
connectPoolSettings_->packageReceivingCallback( connect, this, randomFlag, payloadCurrentIndex, payloadCurrentSize, payloadTotalSize );
}
inline void JQNetworkConnectPool::onPackageReceived(
const JQNetworkConnectPointer &connect,
const JQNetworkPackageSharedPointer &package
)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->packageReceivedCallback );
connectPoolSettings_->packageReceivedCallback( connect, this, package );
}
inline void JQNetworkConnectPool::onWaitReplyPackageSucceed(
const JQNetworkConnectPointer &connect,
const JQNetworkPackageSharedPointer &package,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback
)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->waitReplyPackageSucceedCallback );
connectPoolSettings_->waitReplyPackageSucceedCallback( connect, this, package, succeedCallback );
}
inline void JQNetworkConnectPool::onWaitReplyPackageFail(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPointerFunction &failCallback
)
{
JQNETWORK_NULLPTR_CHECK( connectPoolSettings_->waitReplyPackageFailCallback );
connectPoolSettings_->waitReplyPackageFailCallback( connect, this, failCallback );
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_CONNECTPOOL_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_connectpool.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 826
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CONNECT_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_CONNECT_INC_
// JQNetwork lib import
#include "jqnetwork_connect.h"
inline QWeakPointer< QTcpSocket > JQNetworkConnect::tcpSocket()
{
return tcpSocket_.toWeakRef();
}
inline bool JQNetworkConnect::onceConnectSucceed() const
{
return onceConnectSucceed_;
}
inline bool JQNetworkConnect::isAbandonTcpSocket() const
{
return isAbandonTcpSocket_;
}
inline qint64 JQNetworkConnect::connectCreateTime() const
{
return connectCreateTime_;
}
inline qint64 JQNetworkConnect::connectSucceedTime() const
{
return connectSucceedTime_;
}
inline qint64 JQNetworkConnect::waitForSendBytes() const
{
return waitForSendBytes_;
}
inline qint64 JQNetworkConnect::alreadyWrittenBytes() const
{
return alreadyWrittenBytes_;
}
inline qint64 JQNetworkConnect::connectSucceedElapsed() const
{
if ( !connectSucceedTime_ ) { return -1; }
return connectSucceedTime_ - connectCreateTime_;
}
inline qint32 JQNetworkConnect::sendPayloadData(
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendPayloadData(
{ }, // empty targetActionFlag
payloadData,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkConnect::sendVariantMapData(
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendVariantMapData(
{ }, // empty targetActionFlag
variantMap,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline qint32 JQNetworkConnect::sendFileData(
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
)
{
return this->sendFileData(
{ }, // empty targetActionFlag
fileInfo,
{ }, // empty appendData
succeedCallback,
failCallback
);
}
inline bool JQNetworkConnect::putPayloadData(
const QByteArray &payloadData,
const QVariantMap &appendData
)
{
return this->putPayloadData(
{ }, // empty targetActionFlag,
payloadData,
appendData
);
}
inline bool JQNetworkConnect::putVariantMapData(
const QVariantMap &variantMap,
const QVariantMap &appendData
)
{
return this->putVariantMapData(
{ }, // empty targetActionFlag,
variantMap,
appendData
);
}
inline bool JQNetworkConnect::putFile(
const QFileInfo &fileInfo,
const QVariantMap &appendData
)
{
return this->putFile(
{ }, // empty targetActionFlag,
fileInfo,
appendData
);
}
inline bool JQNetworkConnect::needCompressionPayloadData(const int &dataSize)
{
bool compressionPayloadData = false;
if ( connectSettings_->packageCompressionThresholdForConnectSucceedElapsed != -1)
{
if ( this->connectSucceedElapsed() >= connectSettings_->packageCompressionThresholdForConnectSucceedElapsed )
{
compressionPayloadData = true;
}
if ( ( connectSettings_->packageCompressionMinimumBytes != -1 ) &&
( dataSize < connectSettings_->packageCompressionMinimumBytes ) )
{
compressionPayloadData = false;
}
}
return compressionPayloadData;
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_CONNECT_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_connect.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 868
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CLIENGFORQML_H_
#define JQNETWORK_INCLUDE_JQNETWORK_CLIENGFORQML_H_
// Qt lib import
#include <QJSValue>
#include <QJSValueList>
#include <QDateTime>
// JQNetwork lib import
#include <JQNetworkFoundation>
#ifndef QT_CORE_LIB
# error("Please add qml in pro file")
#endif
#define JQNETWORKCLIENTFORQML_REGISTERTYPE( engine ) \
qmlRegisterType< JQNetworkClientForQml >( "JQNetworkClientForQml", 1, 0, "JQNetworkClientForQml" ); \
engine.addImportPath( ":/JQNetwork/" );
class JQNetworkClientForQml: public QObject
{
Q_OBJECT
public:
JQNetworkClientForQml();
~JQNetworkClientForQml() = default;
public slots:
bool beginClient();
QVariantMap test() { return { { "key", QDateTime::currentDateTime() }, { "key2", QByteArray::fromHex( "00112233" ) } }; }
void print(const QVariant &d) { qDebug() << d; }
void createConnect(const QString &hostName, const quint16 &port);
void sendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &payloadData,
QJSValue succeedCallback,
QJSValue failCallback
);
private Q_SLOTS:
inline void runOnClientThread(const std::function<void()> &callback);
signals:
void connectToHostError(const QString &hostName, const quint16 &port);
void connectToHostTimeout(const QString &hostName, const quint16 &port);
void connectToHostSucceed(const QString &hostName, const quint16 &port);
void remoteHostClosed(const QString &hostName, const quint16 &port);
void readyToDelete(const QString &hostName, const quint16 &port);
private:
JQNetworkClientSharedPointer jqNetworkClient_;
};
// inc import
#include "jqnetwork_clientforqml.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_CLIENGFORQML_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_clientforqml.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 516
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_PACKAGE_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_PACKAGE_INC_
// JQNetwork lib import
#include "jqnetwork_package.h"
inline int JQNetworkPackage::headSize()
{
return sizeof( head_ );
}
inline bool JQNetworkPackage::isCompletePackage() const
{
return isCompletePackage_;
}
inline bool JQNetworkPackage::isAbandonPackage() const
{
return isAbandonPackage_;
}
inline qint8 JQNetworkPackage::bootFlag() const
{
return head_.bootFlag_;
}
inline qint8 JQNetworkPackage::packageFlag() const
{
return head_.packageFlag_;
}
inline qint32 JQNetworkPackage::randomFlag() const
{
return head_.randomFlag_;
}
inline qint8 JQNetworkPackage::metaDataFlag() const
{
return head_.metaDataFlag_;
}
inline qint32 JQNetworkPackage::metaDataTotalSize() const
{
return head_.metaDataTotalSize_;
}
inline qint32 JQNetworkPackage::metaDataCurrentSize() const
{
return head_.metaDataCurrentSize_;
}
inline qint8 JQNetworkPackage::payloadDataFlag() const
{
return head_.payloadDataFlag_;
}
inline qint32 JQNetworkPackage::payloadDataTotalSize() const
{
return head_.payloadDataTotalSize_;
}
inline qint32 JQNetworkPackage::payloadDataCurrentSize() const
{
return head_.payloadDataCurrentSize_;
}
inline QByteArray JQNetworkPackage::metaData() const
{
return metaData_;
}
inline int JQNetworkPackage::metaDataSize() const
{
return metaData_.size();
}
inline QByteArray JQNetworkPackage::payloadData() const
{
return payloadData_;
}
inline int JQNetworkPackage::payloadDataSize() const
{
return payloadData_.size();
}
inline qint32 JQNetworkPackage::metaDataOriginalIndex() const
{
return metaDataOriginalIndex_;
}
inline qint32 JQNetworkPackage::metaDataOriginalCurrentSize() const
{
return metaDataOriginalCurrentSize_;
}
inline qint32 JQNetworkPackage::payloadDataOriginalIndex() const
{
return payloadDataOriginalIndex_;
}
inline qint32 JQNetworkPackage::payloadDataOriginalCurrentSize() const
{
return payloadDataOriginalCurrentSize_;
}
inline QVariantMap JQNetworkPackage::metaDataInVariantMap() const
{
return metaDataInVariantMap_;
}
inline QString JQNetworkPackage::targetActionFlag() const
{
return ( metaDataInVariantMap_.contains( "targetActionFlag" ) ) ? ( metaDataInVariantMap_[ "targetActionFlag" ].toString() ) : ( QString() );
}
inline QVariantMap JQNetworkPackage::appendData() const
{
return ( metaDataInVariantMap_.contains( "appendData" ) ) ? ( metaDataInVariantMap_[ "appendData" ].toMap() ) : ( QVariantMap() );
}
inline QString JQNetworkPackage::fileName() const
{
return ( metaDataInVariantMap_.contains( "fileName" ) ) ? ( metaDataInVariantMap_[ "fileName" ].toString() ) : ( QString() );
}
inline qint64 JQNetworkPackage::fileSize() const
{
return ( metaDataInVariantMap_.contains( "fileSize" ) ) ? ( metaDataInVariantMap_[ "fileSize" ].toLongLong() ) : ( -1 );
}
inline qint32 JQNetworkPackage::filePermissions() const
{
return ( metaDataInVariantMap_.contains( "filePermissions" ) ) ? ( metaDataInVariantMap_[ "filePermissions" ].toInt() ) : ( 0 );
}
inline bool JQNetworkPackage::containsFile() const
{
return !localFilePath_.isEmpty();
}
inline QString JQNetworkPackage::localFilePath() const
{
return localFilePath_;
}
inline void JQNetworkPackage::setLocalFilePath(const QString &localFilePath)
{
localFilePath_ = localFilePath;
}
inline void JQNetworkPackage::clearMetaData()
{
metaData_.clear();
}
inline void JQNetworkPackage::clearPayloadData()
{
payloadData_.clear();
}
inline QByteArray JQNetworkPackage::toByteArray() const
{
QByteArray buffer;
buffer.append( reinterpret_cast< const char * >( &head_ ), JQNetworkPackage::headSize() );
if ( head_.metaDataCurrentSize_ > 0 )
{
buffer.append( metaData_ );
}
if ( head_.payloadDataCurrentSize_ > 0 )
{
buffer.append( payloadData_ );
}
return buffer;
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_PACKAGE_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_package.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,051
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CONNECT_H_
#define JQNETWORK_INCLUDE_JQNETWORK_CONNECT_H_
// JQNetwork lib import
#include <JQNetworkFoundation>
struct JQNetworkConnectSettings
{
bool longConnection = true;
bool autoMaintainLongConnection = false;
int streamFormat = -1;
qint64 cutPackageSize = JQNETWORKPACKAGE_ADVISE_CUTPACKAGESIZE;
qint64 packageCompressionMinimumBytes = 1024;
int packageCompressionThresholdForConnectSucceedElapsed = 500;
qint64 maximumSendForTotalByteCount = -1; // reserve
qint64 maximumSendPackageByteCount = -1; // reserve
int maximumSendSpeed = -1; // Byte/s reserve
qint64 maximumReceiveForTotalByteCount = -1; // reserve
qint64 maximumReceivePackageByteCount = -1;// reserve
int maximumReceiveSpeed = -1; // Byte/s reserve
bool fileTransferEnabled = false;
qint32 randomFlagRangeStart = -1;
qint32 randomFlagRangeEnd = -1;
int maximumConnectToHostWaitTime = 15 * 1000;
int maximumSendPackageWaitTime = 30 * 1000;
int maximumReceivePackageWaitTime = 30 * 1000;
int maximumFileWriteWaitTime = 30 * 1000;
int maximumConnectionTime = -1;
std::function< void( const JQNetworkConnectPointer & ) > connectToHostErrorCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > connectToHostTimeoutCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > connectToHostSucceedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > remoteHostClosedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer & ) > readyToDeleteCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageSendingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageReceivingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer & ) > packageReceivedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer &, const JQNetworkConnectPointerAndPackageSharedPointerFunction & ) > waitReplyPackageSucceedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const std::function< void(const JQNetworkConnectPointer &connect ) > & ) > waitReplyPackageFailCallback = nullptr;
std::function< QString( const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer &, const QString & ) > filePathProvider = nullptr;
void setFilePathProviderToDefaultDir();
void setFilePathProviderToDir(const QDir &dir);
};
class JQNetworkConnect: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkConnect )
private:
struct ReceivedCallbackPackage
{
qint64 sendTime;
JQNetworkConnectPointerAndPackageSharedPointerFunction succeedCallback;
JQNetworkConnectPointerFunction failCallback;
};
private:
JQNetworkConnect(const JQNetworkConnectSettingsSharedPointer &connectSettings);
public:
~JQNetworkConnect() = default;
static void createConnect(
const std::function< void(const JQNetworkConnectSharedPointer &) > &onConnectCreatedCallback,
const std::function< void( std::function< void() > ) > &runOnConnectThreadCallback,
const JQNetworkConnectSettingsSharedPointer &connectSettings,
const QString &hostName,
const quint16 &port
);
static void createConnect(
const std::function< void(const JQNetworkConnectSharedPointer &) > &onConnectCreatedCallback,
const std::function< void( std::function< void() > ) > &runOnConnectThreadCallback,
const JQNetworkConnectSettingsSharedPointer &connectSettings,
const qintptr &socketDescriptor
);
inline QWeakPointer< QTcpSocket > tcpSocket();
inline bool onceConnectSucceed() const;
inline bool isAbandonTcpSocket() const;
inline qint64 connectCreateTime() const;
inline qint64 connectSucceedTime() const;
inline qint64 waitForSendBytes() const;
inline qint64 alreadyWrittenBytes() const;
inline qint64 connectSucceedElapsed() const;
void close();
qint32 sendPayloadData(
const QString &targetActionFlag,
const QByteArray &payloadData,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendPayloadData(
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 sendVariantMapData(
const QString &targetActionFlag,
const QVariantMap &variantMap,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendVariantMapData(
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 sendFileData(
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendFileData(
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 replyPayloadData(
const qint32 &receivedPackageRandomFlag,
const QByteArray &payloadData,
const QVariantMap &appendData = QVariantMap()
);
qint32 replyVariantMapData(
const qint32 &receivedPackageRandomFlag,
const QVariantMap &variantMap,
const QVariantMap &appendData = QVariantMap()
);
qint32 replyFile(
const qint32 &receivedPackageRandomFlag,
const QFileInfo &fileInfo,
const QVariantMap &appendData = QVariantMap()
);
bool putPayloadData(
const QString &targetActionFlag,
const QByteArray &payloadData,
const QVariantMap &appendData = QVariantMap()
);
inline bool putPayloadData(
const QByteArray &payloadData,
const QVariantMap &appendData = QVariantMap()
);
bool putVariantMapData(
const QString &targetActionFlag,
const QVariantMap &variantMap,
const QVariantMap &appendData = QVariantMap()
);
inline bool putVariantMapData(
const QVariantMap &variantMap,
const QVariantMap &appendData = QVariantMap()
);
bool putFile(
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const QVariantMap &appendData = QVariantMap()
);
inline bool putFile(
const QFileInfo &fileInfo,
const QVariantMap &appendData = QVariantMap()
);
private Q_SLOTS:
void onTcpSocketStateChanged();
void onTcpSocketBytesWritten(const qint64 &bytes);
void onTcpSocketReadyRead();
void onTcpSocketConnectToHostTimeOut();
void onSendPackageCheck();
private:
void startTimerForConnectToHostTimeOut();
void startTimerForSendPackageCheck();
void onDataTransportPackageReceived(const JQNetworkPackageSharedPointer &package);
bool onFileDataTransportPackageReceived(
const JQNetworkPackageSharedPointer &package,
const bool &callbackOnFinish
);
void onReadyToDelete();
qint32 nextRandomFlag();
inline bool needCompressionPayloadData(const int &dataSize);
bool readySendPayloadData(
const qint32 &randomFlag,
const QString &targetActionFlag,
const QByteArray &payloadData,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
);
bool readySendFileData(
const qint32 &randomFlag,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
);
void readySendPackages(
const qint32 &randomFlag,
QList< JQNetworkPackageSharedPointer > &packages,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback,
const JQNetworkConnectPointerFunction &failCallback
);
void sendDataRequestToRemote(const JQNetworkPackageSharedPointer &package);
void sendPackageToRemote(const JQNetworkPackageSharedPointer &package);
private:
// Settings
JQNetworkConnectSettingsSharedPointer connectSettings_;
std::function< void( std::function< void() > ) > runOnConnectThreadCallback_;
// Socket
QSharedPointer< QTcpSocket > tcpSocket_;
bool onceConnectSucceed_ = false;
bool isAbandonTcpSocket_ = false;
QByteArray tcpSocketBuffer_;
// Timer
QSharedPointer< QTimer > timerForConnectToHostTimeOut_;
QSharedPointer< QTimer > timerForSendPackageCheck_;
// Package
QMutex mutexForSend_;
qint32 sendRandomFlagRotaryIndex_ = 0;
QMap< qint32, ReceivedCallbackPackage > onReceivedCallbacks_; // randomFlag -> package
// Payload
QMap< qint32, QList< JQNetworkPackageSharedPointer > > sendPayloadPackagePool_; // randomFlag -> package
QMap< qint32, JQNetworkPackageSharedPointer > receivePayloadPackagePool_; // randomFlag -> package
// File
QMap< qint32, QSharedPointer< QFile > > waitForSendFiles_; // randomFlag -> file
QMap< qint32, QPair< JQNetworkPackageSharedPointer, QSharedPointer< QFile > > > receivedFilePackagePool_; // randomFlag -> { package, file }
// Statistics
qint64 connectCreateTime_ = 0;
qint64 connectSucceedTime_ = 0;
qint64 waitForSendBytes_ = 0;
qint64 alreadyWrittenBytes_ = 0;
};
// inc import
#include "jqnetwork_connect.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_CONNECT_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_connect.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,391
|
```sourcepawn
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_FOUNDATION_INC_
#define JQNETWORK_INCLUDE_JQNETWORK_FOUNDATION_INC_
// JQNetwork lib import
#include "jqnetwork_foundation.h"
// JQNetworkThreadPool
inline int JQNetworkThreadPool::nextRotaryIndex()
{
rotaryIndex_ = ( rotaryIndex_ + 1 ) % helpers_->size();
return rotaryIndex_;
}
inline void JQNetworkThreadPool::runEach(const std::function<void ()> &callback)
{
for ( auto index = 0; index < helpers_->size(); ++index )
{
( *helpers_ )[ index ]->run( callback );
}
}
inline void JQNetworkThreadPool::waitRunEach(const std::function<void ()> &callback)
{
for ( auto index = 0; index < helpers_->size(); ++index )
{
this->waitRun( callback, index );
}
}
// JQNetworkNodeMark
inline qint64 JQNetworkNodeMark::applicationStartTime() const
{
return applicationStartTime_;
}
inline QString JQNetworkNodeMark::applicationFilePath() const
{
return applicationFilePath_;
}
inline QString JQNetworkNodeMark::localHostName() const
{
return localHostName_;
}
inline qint64 JQNetworkNodeMark::nodeMarkCreatedTime() const
{
return nodeMarkCreatedTime_;
}
inline QString JQNetworkNodeMark::nodeMarkClassAddress() const
{
return nodeMarkClassAddress_;
}
inline QString JQNetworkNodeMark::dutyMark() const
{
return dutyMark_;
}
inline QString JQNetworkNodeMark::nodeMarkSummary() const
{
return nodeMarkSummary_;
}
#endif//JQNETWORK_INCLUDE_JQNETWORK_FOUNDATION_INC_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_foundation.inc
|
sourcepawn
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 403
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_PROCESSOR_H_
#define JQNETWORK_INCLUDE_JQNETWORK_PROCESSOR_H_
// JQNetwork lib import
#include <JQNetworkFoundation>
#define JQNP_PRINTFUNCTION() \
{ \
const auto &&buffer = QString( Q_FUNC_INFO ); \
const auto &&indexForEnd = buffer.indexOf( '(' ); \
const auto functionName = buffer.mid( 0, indexForEnd ).remove( QStringLiteral( "bool " ) ); \
qDebug() << functionName.toLocal8Bit().data(); \
}
#define JQNP_PRINTRECEIVED() \
{ \
const auto &&buffer = QString( Q_FUNC_INFO ); \
const auto &&indexForEnd = buffer.indexOf( '(' ); \
const auto functionName = buffer.mid( 0, indexForEnd ).remove( QStringLiteral( "bool " ) ); \
qDebug() << ( functionName + ": received:" ).toLocal8Bit().data() << received; \
}
#define JQNP_SUCCEED() \
send[ QStringLiteral( "succeed" ) ] = true; \
send[ QStringLiteral( "message" ) ] = ""; \
return true;
#define JQNP_FAIL( errorMessage ) \
send[ QStringLiteral( "succeed" ) ] = false; \
send[ QStringLiteral( "message" ) ] = errorMessage; \
return false;
#define JQNP_SERVERFAIL( errorMessage ) \
const auto &&message = QStringLiteral( ": Server error: " ) + errorMessage; \
qWarning() << QString( Q_FUNC_INFO ).remove( "bool " ).toLocal8Bit().data() \
<< message.toLocal8Bit().data(); \
send[ QStringLiteral( "succeed" ) ] = false; \
send[ QStringLiteral( "message" ) ] = errorMessage; \
return false;
#define JQNP_CHECKRECEIVEDDATACONTAINS( ... ) \
if ( \
!JQNetworkProcessor::checkMapContains( \
{ __VA_ARGS__ }, \
received, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDDATACONTAINSANDNOT0( ... ) \
if ( \
!JQNetworkProcessor::checkMapContainsAndNot0( \
{ __VA_ARGS__ }, \
received, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDDATACONTAINSANDNOTEMPTY( ... ) \
if ( \
!JQNetworkProcessor::checkMapContainsAndNotEmpty( \
{ __VA_ARGS__ }, \
received, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDDATACONTAINSEXPECTEDCONTENT( key, ... ) \
if ( \
!JQNetworkProcessor::checkDataContasinsExpectedContent( \
key, \
__VA_ARGS__, \
received, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDAPPENDDATACONTAINS( ... ) \
if ( \
!JQNetworkProcessor::checkMapContains( \
{ __VA_ARGS__ }, \
receivedAppend, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDAPPENDDATACONTAINSANDNOT0( ... ) \
if ( \
!JQNetworkProcessor::checkMapContainsAndNot0( \
{ __VA_ARGS__ }, \
receivedAppend, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDAPPENDDATACONTAINSANDNOTEMPTY( ... ) \
if ( \
!JQNetworkProcessor::checkMapContainsAndNotEmpty( \
{ __VA_ARGS__ }, \
receivedAppend, \
send \
) \
) \
{ return false; }
#define JQNP_CHECKRECEIVEDAPPENDDATACONTAINSEXPECTEDCONTENT( key, ... ) \
if ( \
!JQNetworkProcessor::checkDataContasinsExpectedContent( \
key, \
__VA_ARGS__, \
receivedAppend, \
send \
) \
) \
{ return false; }
class JQNetworkProcessor: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkProcessor )
public:
JQNetworkProcessor(const bool &invokeMethodByProcessorThread = false);
~JQNetworkProcessor() = default;
QSet< QString > availableSlots();
bool handlePackage(const JQNetworkConnectPointer &connect, const JQNetworkPackageSharedPointer &package);
void setReceivedPossibleThreads(const QSet< QThread * > &threads);
static bool checkMapContains(const QStringList &keys, const QVariantMap &received, QVariantMap &send);
static bool checkMapContainsAndNot0(const QStringList &keys, const QVariantMap &received, QVariantMap &send);
static bool checkMapContainsAndNotEmpty(const QStringList &keys, const QVariantMap &received, QVariantMap &send);
static bool checkDataContasinsExpectedContent(const QString &key, const QVariantList &expectedContentList, const QVariantMap &received, QVariantMap &send);
protected:
JQNetworkConnectPointer currentThreadConnect();
private:
inline static void deleteByteArray(QByteArray *ptr);
inline static void deleteVariantMap(QVariantMap *ptr);
static void deleteFileInfo(QFileInfo *ptr);
private:
static QSet< QString > exceptionSlots_;
bool invokeMethodByProcessorThread_;
QSet< QString > availableSlots_;
QMap< QThread *, JQNetworkConnectPointer > connectMapByThread_;
QMap< QString, std::function<void(const JQNetworkConnectPointer &connect, const JQNetworkPackageSharedPointer &package)> > onpackageReceivedCallbacks_;
};
// inc import
#include "jqnetwork_processor.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_PROCESSOR_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_processor.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,412
|
```objective-c
/*
This file is part of JQNetwork
Library introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef JQNETWORK_INCLUDE_JQNETWORK_CLIENG_H_
#define JQNETWORK_INCLUDE_JQNETWORK_CLIENG_H_
// JQNetwork lib import
#include <JQNetworkFoundation>
struct JQNetworkClientSettings
{
QString dutyMark;
int maximumAutoConnectToHostWaitTime = 10 * 1000;
bool autoCreateConnect = true;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port ) > connectToHostErrorCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port ) > connectToHostTimeoutCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port ) > connectToHostSucceedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port ) > remoteHostClosedCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port ) > readyToDeleteCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageSendingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port, const qint32 &, const qint64 &, const qint64 &, const qint64 & ) > packageReceivingCallback = nullptr;
std::function< void( const JQNetworkConnectPointer &, const QString &hostName, const quint16 &port, const JQNetworkPackageSharedPointer & ) > packageReceivedCallback = nullptr;
int globalSocketThreadCount = 1;
int globalCallbackThreadCount = JQNETWORK_ADVISE_THREADCOUNT;
};
class JQNetworkClient: public QObject
{
Q_OBJECT
Q_DISABLE_COPY( JQNetworkClient )
public:
JQNetworkClient(
const JQNetworkClientSettingsSharedPointer &clientSettings,
const JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings,
const JQNetworkConnectSettingsSharedPointer connectSettings
);
~JQNetworkClient();
static JQNetworkClientSharedPointer createClient(
const bool &fileTransferEnabled = false
);
inline JQNetworkClientSettingsSharedPointer clientSettings();
inline JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings();
inline JQNetworkConnectSettingsSharedPointer connectSettings();
inline QString nodeMarkSummary() const;
bool begin();
void registerProcessor(const JQNetworkProcessorPointer &processor);
inline QSet< QString > availableProcessorMethodNames() const;
void createConnect(const QString &hostName, const quint16 &port);
bool waitForCreateConnect(
const QString &hostName,
const quint16 &port,
const int &maximumConnectToHostWaitTime = -1
);
qint32 sendPayloadData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QByteArray &payloadData,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendPayloadData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendPayloadData(
const QString &hostName,
const quint16 &port,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 sendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &variantMap,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendVariantMapData(
const QString &hostName,
const quint16 &port,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 sendFileData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendFileData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 sendFileData(
const QString &hostName,
const quint16 &port,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 waitForSendPayloadData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QByteArray &payloadData,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 waitForSendPayloadData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 waitForSendPayloadData(
const QString &hostName,
const quint16 &port,
const QByteArray &payloadData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 waitForSendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &variantMap,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 waitForSendVariantMapData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 waitForSendVariantMapData(
const QString &hostName,
const quint16 &port,
const QVariantMap &variantMap,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
qint32 waitForSendFileData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const QVariantMap &appendData,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 waitForSendFileData(
const QString &hostName,
const quint16 &port,
const QString &targetActionFlag,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
inline qint32 waitForSendFileData(
const QString &hostName,
const quint16 &port,
const QFileInfo &fileInfo,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback = nullptr,
const JQNetworkConnectPointerFunction &failCallback = nullptr
);
JQNetworkConnectPointer getConnect(const QString &hostName, const quint16 &port);
bool containsConnect(const QString &hostName, const quint16 &port);
private:
void onConnectToHostError(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
void onConnectToHostTimeout(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
void onConnectToHostSucceed(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
void onRemoteHostClosed(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
void onReadyToDelete(const JQNetworkConnectPointer &connect, const JQNetworkConnectPoolPointer &connectPool);
void onPackageSending(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
);
void onPackageReceiving(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const qint32 &randomFlag,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
);
void onPackageReceived(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const JQNetworkPackageSharedPointer &package
);
void onWaitReplySucceedPackage(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const JQNetworkPackageSharedPointer &package,
const JQNetworkConnectPointerAndPackageSharedPointerFunction &succeedCallback
);
void onWaitReplyPackageFail(
const JQNetworkConnectPointer &connect,
const JQNetworkConnectPoolPointer &connectPool,
const JQNetworkConnectPointerFunction &failCallback
);
void releaseWaitConnectSucceedSemaphore(const QString &hostName, const quint16 &port, const bool &succeed);
private:
// Thread pool
static QWeakPointer< JQNetworkThreadPool > globalSocketThreadPool_;
QSharedPointer< JQNetworkThreadPool > socketThreadPool_;
static QWeakPointer< JQNetworkThreadPool > globalCallbackThreadPool_;
QSharedPointer< JQNetworkThreadPool > callbackThreadPool_;
// Settings
JQNetworkClientSettingsSharedPointer clientSettings_;
JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings_;
JQNetworkConnectSettingsSharedPointer connectSettings_;
// Client
QMap< QThread *, JQNetworkConnectPoolSharedPointer > connectPools_;
// Processor
QSet< JQNetworkProcessor * > processors_;
QMap< QString, std::function< void( const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer & ) > > processorCallbacks_;
// Other
QString nodeMarkSummary_;
QMutex mutex_;
QMap< QString, QWeakPointer< QSemaphore > > waitConnectSucceedSemaphore_; // "127.0.0.1:34543" -> SemaphoreForConnect
};
// inc import
#include "jqnetwork_client.inc"
#endif//JQNETWORK_INCLUDE_JQNETWORK_CLIENG_H_
```
|
/content/code_sandbox/library/JQNetwork/include/jqnetwork_client.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,693
|
```qmake
#
# This file is part of JQLibrary
#
#
# Contact email: 188080501@qq.com
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
CONFIG *= c++11
CONFIG *= c++14
INCLUDEPATH *= \
$$PWD/include/JQZopfli/ \
$$PWD/include/JQZopfli/zopfli/ \
$$PWD/include/JQZopfli/zopflipng/ \
$$PWD/include/JQZopfli/zopflipng/lodepng/
HEADERS *= \
$$PWD/include/JQZopfli/JQZopfli.h
SOURCES *= \
$$PWD/src/JQZopfli/JQZopfli.cpp \
$$PWD/src/JQZopfli/zopflipng/lodepng/lodepng.cpp \
$$PWD/src/JQZopfli/zopflipng/lodepng/lodepng_util.cpp \
$$PWD/src/JQZopfli/zopfli/blocksplitter.c \
$$PWD/src/JQZopfli/zopfli/cache.c \
$$PWD/src/JQZopfli/zopfli/deflate.c \
$$PWD/src/JQZopfli/zopfli/gzip_container.c \
$$PWD/src/JQZopfli/zopfli/hash.c \
$$PWD/src/JQZopfli/zopfli/katajainen.c \
$$PWD/src/JQZopfli/zopfli/lz77.c \
$$PWD/src/JQZopfli/zopfli/squeeze.c \
$$PWD/src/JQZopfli/zopfli/symbols.c \
$$PWD/src/JQZopfli/zopfli/tree.c \
$$PWD/src/JQZopfli/zopfli/util.c \
$$PWD/src/JQZopfli/zopfli/zlib_container.c
```
|
/content/code_sandbox/library/JQLibrary/JQZopfli.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 653
|
```qmake
#
# This file is part of JQLibrary
#
# Library introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/include/JQQRCodeWriter/
# JQQRCodeWriter
JQQRCODEWRITER_VERSIONSTRING = 1.6
# Qt5.6
lessThan( QT_MAJOR_VERSION, 5 ) | lessThan( QT_MINOR_VERSION, 7 ) {
error( JQQRCodeWriter request minimum Qt version is 5.7.0 )
}
# bin
JQQRCODEWRITER_BIN_NO1_DIR = JQQRCodeWriter$$JQQRCODEWRITER_VERSIONSTRING/Qt$$[QT_VERSION]
JQQRCODEWRITER_BIN_NO2_DIR = $$QT_ARCH
JQQRCODEWRITER_BIN_NO3_DIR = $$[QMAKE_XSPEC]
JQQRCODEWRITER_BIN_NO3_DIR ~= s/g\+\+/gcc
# static
contains( CONFIG, static ) {
JQQRCODEWRITER_BIN_NO3_DIR = $$JQQRCODEWRITER_BIN_NO3_DIR-static
}
JQQRCODEWRITER_BIN_DIR = $$PWD/bin/$$JQQRCODEWRITER_BIN_NO1_DIR/$$JQQRCODEWRITER_BIN_NO2_DIR/$$JQQRCODEWRITER_BIN_NO3_DIR
#message($$JQQRCODEWRITER_BIN_DIR)
# bin
!exists( $$JQQRCODEWRITER_BIN_DIR ) {
mkpath( $$JQQRCODEWRITER_BIN_DIR )
}
#
unix | linux | mingw {
CONFIG( debug, debug | release ) {
JQQRCODEWRITER_LIB_FILENAME = libJQQRCodeWriterd.a
}
CONFIG( release, debug | release ) {
JQQRCODEWRITER_LIB_FILENAME = libJQQRCodeWriter.a
}
}
else: msvc {
CONFIG( debug, debug | release ) {
JQQRCODEWRITER_LIB_FILENAME = JQQRCodeWriterd.lib
}
CONFIG( release, debug | release ) {
JQQRCODEWRITER_LIB_FILENAME = JQQRCodeWriter.lib
}
}
else {
error( unknow platfrom )
}
# bin
JQQRCODEWRITER_LIB_FILEPATH = $$JQQRCODEWRITER_BIN_DIR/$$JQQRCODEWRITER_LIB_FILENAME
# binbin
!equals(JQQRCODEWRITER_COMPILE_MODE, SRC) {
exists($$JQQRCODEWRITER_LIB_FILEPATH) {
JQQRCODEWRITER_COMPILE_MODE = LIB
}
else {
JQQRCODEWRITER_COMPILE_MODE = SRC
}
}
equals(JQQRCODEWRITER_COMPILE_MODE,SRC) {
HEADERS *= \
$$PWD/src/JQQRCodeWriter/qrencode/qrencode.h \
$$PWD/src/JQQRCodeWriter/qrencode/bitstream.h \
$$PWD/src/JQQRCodeWriter/qrencode/mask.h \
$$PWD/src/JQQRCodeWriter/qrencode/mmask.h \
$$PWD/src/JQQRCodeWriter/qrencode/mqrspec.h \
$$PWD/src/JQQRCodeWriter/qrencode/qrencode_inner.h \
$$PWD/src/JQQRCodeWriter/qrencode/qrinput.h \
$$PWD/src/JQQRCodeWriter/qrencode/qrspec.h \
$$PWD/src/JQQRCodeWriter/qrencode/rscode.h \
$$PWD/src/JQQRCodeWriter/qrencode/split.h \
$$PWD/src/JQQRCodeWriter/qrencode/config.h \
$$PWD/include/JQQRCodeWriter/JQQRCodeWriter.h
SOURCES *= \
$$PWD/src/JQQRCodeWriter/qrencode/qrencode.c \
$$PWD/src/JQQRCodeWriter/qrencode/bitstream.c \
$$PWD/src/JQQRCodeWriter/qrencode/mask.c \
$$PWD/src/JQQRCodeWriter/qrencode/mmask.c \
$$PWD/src/JQQRCodeWriter/qrencode/mqrspec.c \
$$PWD/src/JQQRCodeWriter/qrencode/qrinput.c \
$$PWD/src/JQQRCodeWriter/qrencode/qrspec.c \
$$PWD/src/JQQRCodeWriter/qrencode/rscode.c \
$$PWD/src/JQQRCodeWriter/qrencode/split.c \
$$PWD/src/JQQRCodeWriter/JQQRCodeWriter.cpp
}
else : equals(JQQRCODEWRITER_COMPILE_MODE,LIB) {
LIBS *= $$JQQRCODEWRITER_LIB_FILEPATH
}
else {
error(unknow JQQRCODEWRITER_COMPILE_MODE: $$JQQRCODEWRITER_COMPILE_MODE)
}
DEFINES *= JQQRCODEWRITER_COMPILE_MODE_STRING=\\\"$$JQQRCODEWRITER_COMPILE_MODE\\\"
DEFINES *= JQQRCODEWRITER_VERSIONSTRING=\\\"$$JQQRCODEWRITER_VERSIONSTRING\\\"
```
|
/content/code_sandbox/library/JQLibrary/JQQRCodeWriter.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,086
|
```qmake
#
# This file is part of JQLibrary
#
# Library introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/include/JQQRCodeReader/
# JQQRCodeReader
JQQRCODEREADER_VERSIONSTRING = 1.6
# Qt5.6
lessThan( QT_MAJOR_VERSION, 5 ) | lessThan( QT_MINOR_VERSION, 7 ) {
error( JQQRCodeReader request minimum Qt version is 5.7.0 )
}
# bin
JQQRCODEREADER_BIN_NO1_DIR = JQQRCodeReader$$JQQRCODEREADER_VERSIONSTRING/Qt$$[QT_VERSION]
JQQRCODEREADER_BIN_NO2_DIR = $$QT_ARCH
JQQRCODEREADER_BIN_NO3_DIR = $$[QMAKE_XSPEC]
JQQRCODEREADER_BIN_NO3_DIR ~= s/g\+\+/gcc
# static
contains( CONFIG, static ) {
JQQRCODEREADER_BIN_NO3_DIR = $$JQQRCODEREADER_BIN_NO3_DIR-static
}
JQQRCODEREADER_BIN_DIR = $$PWD/bin/$$JQQRCODEREADER_BIN_NO1_DIR/$$JQQRCODEREADER_BIN_NO2_DIR/$$JQQRCODEREADER_BIN_NO3_DIR
#message($$JQQRCODEREADER_BIN_DIR)
# bin
!exists( $$JQQRCODEREADER_BIN_DIR ) {
mkpath( $$JQQRCODEREADER_BIN_DIR )
}
#
unix | linux | mingw {
CONFIG( debug, debug | release ) {
JQQRCODEREADER_LIB_FILENAME = libJQQRCodeReaderd.a
}
CONFIG( release, debug | release ) {
JQQRCODEREADER_LIB_FILENAME = libJQQRCodeReader.a
}
}
else: msvc {
CONFIG( debug, debug | release ) {
JQQRCODEREADER_LIB_FILENAME = JQQRCodeReaderd.lib
}
CONFIG( release, debug | release ) {
JQQRCODEREADER_LIB_FILENAME = JQQRCodeReader.lib
}
}
else {
error( unknow platfrom )
}
# bin
JQQRCODEREADER_LIB_FILEPATH = $$JQQRCODEREADER_BIN_DIR/$$JQQRCODEREADER_LIB_FILENAME
# binbin
!equals(JQQRCODEREADER_COMPILE_MODE, SRC) {
exists($$JQQRCODEREADER_LIB_FILEPATH) {
JQQRCODEREADER_COMPILE_MODE = LIB
}
else {
JQQRCODEREADER_COMPILE_MODE = SRC
}
}
equals(JQQRCODEREADER_COMPILE_MODE,SRC) {
DEFINES *= \
ZXING_ICONV_CONST \
DISABLE_LIBRARY_FEATURES \
NO_ICONV
INCLUDEPATH *= \
$$PWD/src/JQQRCodeReader/zxing
HEADERS *= \
$$PWD/include/JQQRCodeReader/JQQRCodeReader.h
SOURCES *= \
$$PWD/src/JQQRCodeReader/JQQRCodeReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/bigint/BigInteger.cc \
$$PWD/src/JQQRCodeReader/zxing/bigint/BigIntegerAlgorithms.cc \
$$PWD/src/JQQRCodeReader/zxing/bigint/BigIntegerUtils.cc \
$$PWD/src/JQQRCodeReader/zxing/bigint/BigUnsigned.cc \
$$PWD/src/JQQRCodeReader/zxing/bigint/BigUnsignedInABase.cc \
$$PWD/src/JQQRCodeReader/zxing/zxing/aztec/decoder/Decoder1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/aztec/detector/Detector1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/aztec/AztecDetectorResult.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/aztec/AztecReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/detector/MonochromeRectangleDetector.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/detector/WhiteRectangleDetector.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/reedsolomon/GenericGF.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/reedsolomon/GenericGFPoly.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/BitArray.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/BitArrayIO.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/BitMatrix.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/BitSource.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/CharacterSetECI.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/DecoderResult.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/DetectorResult.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/GlobalHistogramBinarizer.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/GreyscaleLuminanceSource.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/GridSampler.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/HybridBinarizer.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/IllegalArgumentException.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/PerspectiveTransform.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/Str.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/common/StringUtils.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/decoder/BitMatrixParser1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/decoder/DataBlock1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/decoder/Decoder2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/detector/CornerPoint.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/detector/Detector2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/detector/DetectorException.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/DataMatrixReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/datamatrix/Version1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/multi/qrcode/detector/MultiDetector.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder1.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/multi/qrcode/QRCodeMultiReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/multi/ByQuadrantReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/multi/MultipleBarcodeReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/CodaBarReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/Code128Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/Code39Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/Code93Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/EAN13Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/EAN8Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/ITFReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/MultiFormatOneDReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/MultiFormatUPCEANReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/OneDReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/OneDResultPoint.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/UPCAReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/UPCEANReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/oned/UPCEReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/BitMatrixParser2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/DecodedBitStreamParser2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/decoder/Decoder3.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/detector/Detector3.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/detector/LinesSampler.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/pdf417/PDF417Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/decoder/BitMatrixParser3.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/decoder/DataBlock2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/decoder/DataMask.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/decoder/DecodedBitStreamParser3.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/decoder/Decoder4.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/decoder/Mode.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/detector/AlignmentPattern.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/detector/AlignmentPatternFinder.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/detector/Detector4.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/detector/FinderPattern.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/detector/FinderPatternFinder2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/detector/FinderPatternInfo.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/ErrorCorrectionLevel.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/FormatInformation.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/QRCodeReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/qrcode/Version2.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/BarcodeFormat.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/Binarizer.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/BinaryBitmap.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/ChecksumException.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/DecodeHints.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/Exception.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/FormatException.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/InvertedLuminanceSource.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/LuminanceSource.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/MultiFormatReader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/Reader.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/Result.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/ResultIO.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/ResultPoint.cpp \
$$PWD/src/JQQRCodeReader/zxing/zxing/ResultPointCallback.cpp
win32-msvc* {
INCLUDEPATH *= \
$$PWD/src/JQQRCodeReader/zxing/win32/zxing \
$$PWD/src/JQQRCodeReader/zxing/win32/zxing/msvc
SOURCES *= \
$$PWD/src/JQQRCodeReader/zxing/win32/zxing/win_iconv.c
}
}
else : equals(JQQRCODEREADER_COMPILE_MODE,LIB) {
LIBS *= $$JQQRCODEREADER_LIB_FILEPATH
}
else {
error(unknow JQQRCODEREADER_COMPILE_MODE: $$JQQRCODEREADER_COMPILE_MODE)
}
# JQQRCodeReaderqml
contains( QT, qml ) {
contains(QT, concurrent) {
contains(QT, multimedia) {
HEADERS *= \
$$PWD/include/JQQRCodeReader/JQQRCodeReaderForQml.h
SOURCES *= \
$$PWD/src/JQQRCodeReader/JQQRCodeReaderForQml.cpp
RESOURCES *= \
$$PWD/qml/JQQRCodeReaderQml.qrc
QML_IMPORT_PATH *= \
$$PWD/qml/
PLUGINS *= \
declarative_multimedia
}
}
}
DEFINES *= JQQRCODEREADER_COMPILE_MODE_STRING=\\\"$$JQQRCODEREADER_COMPILE_MODE\\\"
DEFINES *= JQQRCODEREADER_VERSIONSTRING=\\\"$$JQQRCODEREADER_VERSIONSTRING\\\"
```
|
/content/code_sandbox/library/JQLibrary/JQQRCodeReader.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 3,151
|
```qmake
#
# This file is part of JQLibrary
#
#
# Contact email: 188080501@qq.com
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
CONFIG *= c++11
CONFIG *= c++14
INCLUDEPATH *= \
$$PWD/include/JQGuetzli/
HEADERS *= \
$$PWD/include/JQGuetzli/*.h
SOURCES *= \
$$PWD/src/JQGuetzli/*.cpp \
$$PWD/src/JQGuetzli/guetzli/*.cc \
$$PWD/src/JQGuetzli/butteraugli/*.cc
LIBS *= \
$$PWD/bin/JQGuetzli/x86_64/macx-clang/gflags/libgflags.2.2.0.dylib \
$$PWD/bin/JQGuetzli/x86_64/macx-clang/png/libpng16.16.dylib
```
|
/content/code_sandbox/library/JQLibrary/JQGuetzli.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 423
|
```qmake
#
# This file is part of JQLibrary
#
#
# Contact email: 188080501@qq.com
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
QT *= core gui
CONFIG *= c++11
INCLUDEPATH *= \
$$PWD/include/
exists( $$PWD/src/JQBarcode.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQBarcode.h
SOURCES *= $$PWD/src/JQBarcode.cpp
}
}
contains( QT, bluetooth ) : exists( $$PWD/src/JQBluetooth.cpp ) {
mac | ios {
DEFINES += JQBLUETOOTH_UUIDMODE
}
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQBluetooth.h
SOURCES *= $$PWD/src/JQBluetooth.cpp
}
}
exists( $$PWD/include/jqchecksum.hpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/jqchecksum.hpp
}
}
exists( $$PWD/include/jqdeclare.hpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/jqdeclare.hpp
}
}
exists( $$PWD/src/JQExcel.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQExcel.h
SOURCES *= $$PWD/src/JQExcel.cpp
}
}
exists( $$PWD/src/JQFile.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQFile.h
SOURCES *= $$PWD/src/JQFile.cpp
}
}
unix | linux | mingw {
exists( $$PWD/src/JQFilePack.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQFilePack.h
SOURCES *= $$PWD/src/JQFilePack.cpp
}
}
}
exists( $$PWD/src/JQFoundation.cpp ) {
DEFINES += JQFOUNDATION_LIB
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQFoundation.h
HEADERS *= $$PWD/include/jqdeclare.hpp
SOURCES *= $$PWD/src/JQFoundation.cpp
}
}
exists( $$PWD/src/jqgpio.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/jqgpio.h
SOURCES *= $$PWD/src/jqgpio.cpp
}
}
contains( QT, network ) : contains( QT, concurrent ) : exists( $$PWD/src/jqhttpserver.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/jqhttpserver.h
SOURCES *= $$PWD/src/jqhttpserver.cpp
}
}
ios : exists( $$PWD/src/JQiOS.cpp ) {
LIBS *= -framework Foundation -framework UIKit
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQiOS.h
OBJECTIVE_SOURCES *= $$PWD/src/JQiOS.mm
}
}
exists( $$PWD/src/JQLanguage.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQLanguage.h
SOURCES *= $$PWD/src/JQLanguage.cpp
}
}
contains( QT, network ) : exists( $$PWD/src/jqnet.cpp ) : !wasm {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/jqnet.h
SOURCES *= $$PWD/src/jqnet.cpp
}
}
contains( QT, serialport ) : exists( $$PWD/src/JQSerialPort.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQSerialPort.h
SOURCES *= $$PWD/src/JQSerialPort.cpp
}
}
exists( $$PWD/src/JQSettings.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQSettings.h
SOURCES *= $$PWD/src/JQSettings.cpp
}
}
exists( $$PWD/src/JQSms.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQSms.h
SOURCES *= $$PWD/src/JQSms.cpp
}
}
contains( QT, network ) : exists( $$PWD/src/JQSystemFlag.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQSystemFlag.h
SOURCES *= $$PWD/src/JQSystemFlag.cpp
}
}
exists( $$PWD/src/jqthread.cpp ) : !wasm {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/jqthread.h
SOURCES *= $$PWD/src/jqthread.cpp
}
}
contains( QT, webenginewidgets ) : exists( $$PWD/src/JQWebEngine.cpp ) {
!contains( DEFINES, JQLIBRARY_EXPORT_ENABLE ) | contains( DEFINES, JQLIBRARY_EXPORT_MODE ) {
HEADERS *= $$PWD/include/JQWebEngine.h
SOURCES *= $$PWD/src/JQWebEngine.cpp
}
}
```
|
/content/code_sandbox/library/JQLibrary/JQLibrary.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,660
|
```c++
/*
This file is part of JQLibrary
Contact email: 188080501@qq.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "JQFile.h"
// C lib import
#if ( defined Q_OS_MAC ) || ( defined __MINGW32__ ) || ( defined Q_OS_LINUX )
# include <utime.h>
#endif
// Qt lib import
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QCryptographicHash>
#include <QStandardPaths>
#include <QCoreApplication>
// JQLibrary lib import
#include "JQFoundation.h"
void JQFile::foreachFileFromDirectory(const QDir &directory, const std::function<void(const QFileInfo &)> &each, const bool &recursion)
{
for ( const auto &fileInfo: JQCONST( directory.entryInfoList( QDir::Files ) ) )
{
each( fileInfo );
}
if ( recursion )
{
for ( const auto &fileInfo: JQCONST( directory.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot ) ) )
{
JQFile::foreachFileFromDirectory( fileInfo.filePath(), each, recursion );
}
}
}
bool JQFile::foreachFileFromDirectory(const QDir &directory, const std::function<void(const QFileInfo &, bool &)> &each, const bool &recursion)
{
bool continueFlag = true;
for ( const auto &fileInfo: JQCONST( directory.entryInfoList( QDir::Files ) ) )
{
each( fileInfo, continueFlag );
if ( !continueFlag ) { return false; }
}
if ( recursion )
{
for ( const auto &fileInfo: JQCONST( directory.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot ) ) )
{
continueFlag = JQFile::foreachFileFromDirectory( fileInfo.filePath(), each, recursion );
if ( !continueFlag ) { return false; }
}
}
return true;
}
void JQFile::foreachDirectoryFromDirectory(const QDir &directory, const std::function<void (const QDir &)> &each, const bool &recursion)
{
for ( const auto &fileInfo: JQCONST( directory.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot ) ) )
{
each( fileInfo.filePath() );
}
if ( recursion )
{
for ( const auto &fileInfo: JQCONST( directory.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot ) ) )
{
JQFile::foreachDirectoryFromDirectory( fileInfo.filePath(), each, recursion );
}
}
}
QString JQFile::tempFilePath(const QString &fileName)
{
if ( qApp->applicationName().isEmpty() )
{
return QString( "%1/%2" ).arg( QStandardPaths::writableLocation( QStandardPaths::TempLocation ), fileName );
}
else
{
return QString( "%1/%2/%3" ).arg( QStandardPaths::writableLocation( QStandardPaths::TempLocation ), qApp->applicationName(), fileName );
}
}
bool JQFile::writeFile(const QFileInfo &targetFilePath, const QByteArray &data, const bool &cover)
{
if ( !targetFilePath.dir().isReadable() )
{
if ( !QDir().mkpath( targetFilePath.path() ))
{
return false;
}
}
if ( targetFilePath.isFile() && !cover )
{
return true;
}
QFile file( targetFilePath.filePath() );
if ( !file.open( QIODevice::WriteOnly ) )
{
return false;
}
file.write( data );
file.waitForBytesWritten( 15 * 1000 );
return true;
}
bool JQFile::writeFileToDesktop(const QString &fileName, const QByteArray &data, const bool &cover)
{
return writeFile(
{ QString( "%1/%2" ).arg( QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ), fileName ) },
data,
cover
);
}
bool JQFile::writeFileToTemp(const QString &fileName, const QByteArray &data, const bool &cover)
{
const QFileInfo fileInfo( tempFilePath( fileName ) );
if ( !QDir().exists( fileInfo.path() ) && !QDir().mkpath( fileInfo.path() ) )
{
return false;
}
return writeFile( fileInfo, data, cover );
}
bool JQFile::appendFile(const QFileInfo &targetFilePath, const QByteArray &data)
{
if ( !targetFilePath.dir().isReadable() )
{
if ( !QDir().mkpath( targetFilePath.path() ))
{
return false;
}
}
QFile file( targetFilePath.filePath() );
if ( !file.open( QIODevice::Append ) )
{
return false;
}
file.write( data );
file.waitForBytesWritten( 15 * 1000 );
return true;
}
QPair< bool, QByteArray > JQFile::readFile(const QFileInfo &filePath)
{
QFile file( filePath.filePath() );
if ( !file.open( QIODevice::ReadOnly ) ) { return { false, { } }; }
return { true, file.readAll() };
}
QPair< bool, QByteArray > JQFile::readFileFromDesktop(const QString &fileName)
{
return readFile(
{ QString( "%1/%2" ).arg( QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ), fileName ) }
);
}
QPair< bool, QByteArray > JQFile::readFileFromTemp(const QString &fileName)
{
return readFile( tempFilePath( fileName ) );
}
bool JQFile::copyFile(const QFileInfo &sourceFileInfo, const QFileInfo &targetFileInfo, const bool &cover)
{
const auto &&sourceFilePath = sourceFileInfo.filePath();
const auto &&targetFilePath = targetFileInfo.filePath();
if ( sourceFilePath.isEmpty() || ( sourceFilePath[ sourceFileInfo.filePath().size() - 1 ] == '/' ) )
{
return false;
}
if ( targetFilePath.isEmpty() || ( targetFilePath[ targetFileInfo.filePath().size() - 1 ] == '/' ) )
{
return false;
}
if ( !targetFileInfo.dir().isReadable() )
{
if ( !QDir().mkpath( targetFileInfo.path() ) )
{
return false;
}
}
if ( targetFileInfo.isFile() )
{
if ( !cover )
{
return false;
}
else
{
if ( !QFile( targetFilePath ).remove() )
{
return false;
}
}
}
return QFile::copy( sourceFilePath, targetFilePath );
}
bool JQFile::copyFileToTemp(const QFileInfo &sourceFileInfo, const QString &fileName)
{
if ( !sourceFileInfo.exists() ) { return false; }
const QFileInfo tempFileInfo( tempFilePath( fileName ) );
if ( !QDir().exists( tempFileInfo.path() ) && !QDir().mkpath( tempFileInfo.path() ) )
{
return false;
}
return QFile::copy( sourceFileInfo.filePath(), tempFileInfo.filePath() );
}
QPair< bool, QString > JQFile::copyFileToTemp(const QFileInfo &sourceFileInfo, const QCryptographicHash::Algorithm &fileNameHashAlgorithm, const QString &salt)
{
if ( !sourceFileInfo.exists() ) { return { false, { } }; }
const QFileInfo tempFileInfo( tempFilePath( JQFoundation::hashString( ( sourceFileInfo.filePath() + salt ).toUtf8(), fileNameHashAlgorithm ) ) );
if ( !QDir().exists( tempFileInfo.path() ) && !QDir().mkpath( tempFileInfo.path() ) )
{
return { false, { } };
}
return { QFile::copy( sourceFileInfo.filePath(), tempFileInfo.filePath() ), tempFileInfo.filePath() };
}
bool JQFile::copyDirectory(const QDir &sourceDirectory, const QDir &targetDirectory, const bool &cover)
{
bool(*fun)(const QDir &directory, const std::function<void(const QFileInfo &, bool &)> &each, const bool &recursion) = foreachFileFromDirectory;
return fun( sourceDirectory, [ & ](const QFileInfo &info, bool &continueFlag)
{
const auto &&path = info.path().mid( sourceDirectory.path().size() );
if ( !JQFile::copyFile( info, targetDirectory.path() + "/" + ( ( path.isEmpty() ) ? ( "" ) : ( path + "/" ) ) + info.fileName(), cover ) )
{
continueFlag = false;
}
}, true );
}
bool JQFile::copy(const QFileInfo &source, const QFileInfo &target, const bool &cover)
{
if ( source.isFile() )
{
return JQFile::copyFile( source, target, cover );
}
else if ( source.isDir() )
{
return JQFile::copyDirectory( QDir( source.filePath() ), QDir( target.filePath() ), cover );
}
return false;
}
QString JQFile::md5(const QFileInfo &fileInfo)
{
QFile file( fileInfo.filePath() );
if ( !file.open( QIODevice::ReadOnly ) ) { return "00000000000000000000000000000000"; }
return QCryptographicHash::hash( file.readAll(), QCryptographicHash::Md5 ).toHex();
}
#if ( defined Q_OS_MAC ) || ( defined __MINGW32__ ) || ( defined Q_OS_LINUX )
bool JQFile::setFileLastReadAndLastModifiedTime(const char *fileName, const quint32 &lastRead, const quint32 &lastModified)
{
utimbuf buf( { static_cast< time_t >( lastRead ), static_cast< time_t >( lastModified ) } );
return !utime(fileName, &buf);
}
#endif
```
|
/content/code_sandbox/library/JQLibrary/src/JQFile.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,348
|
```c++
/*
This file is part of JQLibrary
Contact email: 188080501@qq.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "JQBarcode.h"
// Qt lib import
#include <QDebug>
#include <QPainter>
qint64 JQBarcode::makeNumber(const qint64 &rawNumebr)
{
const auto &n1 = rawNumebr / 100000000000 % 10;
const auto &n2 = rawNumebr / 10000000000 % 10;
const auto &n3 = rawNumebr / 1000000000 % 10;
const auto &n4 = rawNumebr / 100000000 % 10;
const auto &n5 = rawNumebr / 10000000 % 10;
const auto &n6 = rawNumebr / 1000000 % 10;
const auto &n7 = rawNumebr / 100000 % 10;
const auto &n8 = rawNumebr / 10000 % 10;
const auto &n9 = rawNumebr / 1000 % 10;
const auto &n10 = rawNumebr / 100 % 10;
const auto &n11 = rawNumebr / 10 % 10;
const auto &n12 = rawNumebr / 1 % 10;
const auto &&c1 = n1 + n3 + n5 + n7 + n9 + n11;
const auto &&c2 = ( n2 + n4 + n6 + n8 + n10 + n12 ) * 3;
const auto &&cc = c1 + c2;
const auto &&c = qAbs( 10 - ( cc % 10 ) );
// qDebug() << n1 << n2 << n3 << n4 << n5 << n6 << n7 << n8 << n9 << n10 << n11 << n12;
// qDebug() << cc;
return rawNumebr * 10 + c;
}
QImage JQBarcode::makeBarcode(const qint64 &number)
{
QImage image( QSize( 190, 120 ), QImage::Format_ARGB32 );
image.fill( qRgba( 0, 0, 0, 0 ) );
auto pos = 0;
JQBarcode::paintLine( image, true, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, false, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, true, pos, 120 ); pos += 1;
JQBarcode::paintByteA( image, number / 100000000000 % 10, pos ); pos += 7;
JQBarcode::paintByteB( image, number / 10000000000 % 10, pos ); pos += 7;
JQBarcode::paintByteB( image, number / 1000000000 % 10, pos ); pos += 7;
JQBarcode::paintByteB( image, number / 100000000 % 10, pos ); pos += 7;
JQBarcode::paintByteA( image, number / 10000000 % 10, pos ); pos += 7;
JQBarcode::paintByteA( image, number / 1000000 % 10, pos ); pos += 7;
JQBarcode::paintLine( image, false, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, true, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, false, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, true, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, false, pos, 120 ); pos += 1;
JQBarcode::paintByteC( image, number / 100000 % 10, pos ); pos += 7;
JQBarcode::paintByteC( image, number / 10000 % 10, pos ); pos += 7;
JQBarcode::paintByteC( image, number / 1000 % 10, pos ); pos += 7;
JQBarcode::paintByteC( image, number / 100 % 10, pos ); pos += 7;
JQBarcode::paintByteC( image, number / 10 % 10, pos ); pos += 7;
JQBarcode::paintByteC( image, number % 10, pos ); pos += 7;
JQBarcode::paintLine( image, true, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, false, pos, 120 ); pos += 1;
JQBarcode::paintLine( image, true, pos, 120 );
return image;
}
void JQBarcode::paintByteA(QImage &image, const int &number, const int &pos)
{
switch( number )
{
case 0: JQBarcode::paintLines( image, "0001101", pos ); break;
case 1: JQBarcode::paintLines( image, "0011001", pos ); break;
case 2: JQBarcode::paintLines( image, "0010011", pos ); break;
case 3: JQBarcode::paintLines( image, "0111101", pos ); break;
case 4: JQBarcode::paintLines( image, "0100011", pos ); break;
case 5: JQBarcode::paintLines( image, "0110001", pos ); break;
case 6: JQBarcode::paintLines( image, "0101111", pos ); break;
case 7: JQBarcode::paintLines( image, "0111011", pos ); break;
case 8: JQBarcode::paintLines( image, "0110111", pos ); break;
case 9: JQBarcode::paintLines( image, "0001011", pos ); break;
default: qDebug() << "JQBarcode::paintByteA: unexpected number:" << number; break;
}
}
void JQBarcode::paintByteB(QImage &image, const int &number, const int &pos)
{
switch( number )
{
case 0: JQBarcode::paintLines( image, "0100111", pos ); break;
case 1: JQBarcode::paintLines( image, "0110011", pos ); break;
case 2: JQBarcode::paintLines( image, "0011011", pos ); break;
case 3: JQBarcode::paintLines( image, "0100001", pos ); break;
case 4: JQBarcode::paintLines( image, "0011101", pos ); break;
case 5: JQBarcode::paintLines( image, "0111001", pos ); break;
case 6: JQBarcode::paintLines( image, "0000101", pos ); break;
case 7: JQBarcode::paintLines( image, "0010001", pos ); break;
case 8: JQBarcode::paintLines( image, "0001001", pos ); break;
case 9: JQBarcode::paintLines( image, "0010111", pos ); break;
default: qDebug() << "JQBarcode::paintByteB: unexpected number:" << number; break;
}
}
void JQBarcode::paintByteC(QImage &image, const int &number, const int &pos)
{
switch( number )
{
case 0: JQBarcode::paintLines( image, "1110010", pos ); break;
case 1: JQBarcode::paintLines( image, "1100110", pos ); break;
case 2: JQBarcode::paintLines( image, "1101100", pos ); break;
case 3: JQBarcode::paintLines( image, "1000010", pos ); break;
case 4: JQBarcode::paintLines( image, "1011100", pos ); break;
case 5: JQBarcode::paintLines( image, "1001110", pos ); break;
case 6: JQBarcode::paintLines( image, "1010000", pos ); break;
case 7: JQBarcode::paintLines( image, "1000100", pos ); break;
case 8: JQBarcode::paintLines( image, "1001000", pos ); break;
case 9: JQBarcode::paintLines( image, "1110100", pos ); break;
default: qDebug() << "JQBarcode::paintByteC: unexpected number:" << number; break;
}
}
void JQBarcode::paintLines(QImage &image, const QString &key, const int &pos, const int &len)
{
for ( auto index = 0; index < 7; ++index )
{
JQBarcode::paintLine( image, key[ index ] == '1', pos + index, len);
}
}
void JQBarcode::paintLine(QImage &image, const bool &black, const int &pos, const int &len)
{
for ( auto index = 0; index < len; ++index )
{
image.setPixel( pos * 2, index, ( black ) ? ( qRgba( 0, 0, 0, 255 ) ) : ( qRgba( 0, 0, 0, 0 ) ) );
image.setPixel( pos * 2 + 1, index, ( black ) ? ( qRgba( 0, 0, 0, 255 ) ) : ( qRgba( 0, 0, 0, 0 ) ) );
}
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQBarcode.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,396
|
```c++
/*
This file is part of JQLibrary
Contact email: 188080501@qq.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "JQQRCodeWriter.h"
// Qt lib import
#include <QDebug>
#include <QPainter>
// qrencode lib import
#include "./qrencode/qrencode.h"
using namespace JQQRCodeWriter;
QImage JQQRCodeWriter::makeQRcode(
const QString &data,
const QSize &size,
const QColor &colorForPoint
)
{
QImage image( size, QImage::Format_RGB32 );
image.fill( QColor( "#000000" ) );
QPainter painter( &image );
if ( !painter.isActive() )
{
qDebug() << "JQQRCodeWriter::makeQRcode: error";
return image;
}
QRcode *qrCode = QRcode_encodeString( data.toUtf8().data(), 1, QR_ECLEVEL_H, QR_MODE_8, true );
if ( !qrCode )
{
qDebug() << "JQQRCodeWriter::makeQRcode: empty qrcode";
QColor error( "#ffffff" );
painter.setBrush( error );
painter.setPen( Qt::NoPen );
painter.drawRect( 0, 0, image.width(), image.height() );
painter.end();
return image;
}
QColor colorForBackground( "#ffffff" );
painter.setBrush( colorForBackground );
painter.setPen( Qt::NoPen );
painter.drawRect( 0, 0, image.width(), image.height() );
painter.setBrush( colorForPoint );
const double &&s = ( qrCode->width > 0 ) ? ( qrCode->width ) : ( 1 );
const double &&aspect = image.width() / image.height();
const double &&scale = ( ( aspect > 1.0 ) ? image.height() : image.width() ) / s;
for ( int y = 0; y < s; ++y )
{
const int &&yy = static_cast< int >( y * s );
for( int x = 0; x < s; ++x )
{
const int &&xx = yy + x;
const unsigned char &b = qrCode->data[xx];
if( b & 0x01 )
{
const double rx1 = x * scale, ry1 = y * scale;
QRectF r( rx1, ry1, scale, scale );
painter.drawRects( &r,1 );
}
}
}
QRcode_free( qrCode );
painter.end();
return image;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/JQQRCodeWriter.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 780
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Masking.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __MASK_H__
#define __MASK_H__
extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level);
extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level);
#ifdef WITH_TESTS
extern int Mask_calcN2(int width, unsigned char *frame);
extern int Mask_calcN1N3(int length, int *runLength);
extern int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength);
extern int Mask_evaluateSymbol(int width, unsigned char *frame);
extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level);
extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask);
#endif
#endif /* __MASK_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/mask.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 298
|
```objective-c
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if using pthread is enabled. */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Major version number */
#define MAJOR_VERSION 3
/* Micro version number */
#define MICRO_VERSION 4
/* Minor version number */
#define MINOR_VERSION 4
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#define VERSION "3.4.4"
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to 'static' if no test programs will be compiled. */
#define __STATIC static
#undef WITH_TESTS
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/config.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 607
|
```shell
#!/bin/sh
set -e
if [ `uname -s` = Darwin ]; then
LIBTOOLIZE=glibtoolize
else
LIBTOOLIZE=libtoolize
fi
ACLOCAL_OPT=""
if [ -d /usr/local/share/aclocal ]; then
ACLOCAL_OPT="-I /usr/local/share/aclocal"
elif [ -d /opt/local/share/aclocal ]; then
ACLOCAL_OPT="-I /opt/local/share/aclocal"
elif [ -d /usr/share/aclocal ]; then
ACLOCAL_OPT="-I /usr/share/aclocal"
fi
if [ ! -d use ]; then
mkdir use
fi
autoheader
aclocal $ACLOCAL_OPT
$LIBTOOLIZE --automake --copy
automake --add-missing --copy
autoconf
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/autogen.sh
|
shell
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 175
|
```c++
/*
This file is part of JQLibrary
Contact email: 188080501@qq.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// JQFoundation header include
#include "JQFoundation.h"
// C++ lib import
#include <iostream>
// Qt lib import
#include <QDebug>
#include <QSharedMemory>
#include <QHash>
#include <QBuffer>
#include <QMetaMethod>
#include <QImage>
#include <QTextCursor>
#include <QPalette>
#include <QFileInfo>
#include <QDir>
#include <QProcess>
#include <QUuid>
#include <QTimer>
#include <QTime>
#include <QDateTime>
#include <QTextStream>
#include <QMutex>
#ifdef QT_CONCURRENT_LIB
# include <QtConcurrent>
#endif
// Windows lib import
#ifdef Q_OS_WIN
# include <Windows.h>
#endif
QDebug operator<<(QDebug dbg, const QPair< QDateTime, QDateTime > &data)
{
return ( dbg <<
"(" <<
data.first.toString( "yyyy-MM-dd hh:mm:ss.zzz" ).toLatin1().data() <<
"~" <<
data.second.toString( "yyyy-MM-dd hh:mm:ss.zzz" ).toLatin1().data() ) <<
")";
}
QDebug operator<<(QDebug dbg, const JQDebugEnum &debugConfig)
{
#ifdef Q_OS_WIN
static bool runOnWindowsConsole = QProcess::systemEnvironment().contains( "SESSIONNAME=Console" );
if ( debugConfig == JQDebugForceConsoleMode )
{
runOnWindowsConsole = true;
}
if ( runOnWindowsConsole )
{
switch ( debugConfig )
{
case JQDebugReset: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 7 ); break; }
case JQDebugBlue: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_BLUE ); break; }
case JQDebugGreen: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN ); break; }
case JQDebugRed: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_RED ); break; }
case JQDebugYellow: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 14 ); break; }
case JQDebugPurple: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 5 ); break; }
case JQDebugCyan: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 3 ); break; }
case JQDebugBlack: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0 ); break; }
case JQDebugWhite: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 15 ); break; }
default: { break; }
}
return dbg;
}
else
#endif
{
switch ( debugConfig )
{
case JQDebugReset: { return dbg << "\033[0m"; }
case JQDebugBlue: { return dbg << "\033[34m"; }
case JQDebugGreen: { return dbg << "\033[32m"; }
case JQDebugRed: { return dbg << "\033[31m"; }
case JQDebugYellow: { return dbg << "\033[33m"; }
case JQDebugPurple: { return dbg << "\033[35m"; }
case JQDebugCyan: { return dbg << "\033[36m"; }
case JQDebugBlack: { return dbg << "\033[30m"; }
case JQDebugWhite: { return dbg << "\033[37m"; }
default: { return dbg; }
}
}
}
std::ostream &operator<<(std::ostream &dbg, const JQDebugEnum &debugConfig)
{
#ifdef Q_OS_WIN
static bool runOnWindowsConsole = QProcess::systemEnvironment().contains( "SESSIONNAME=Console" );
if ( debugConfig == JQDebugForceConsoleMode )
{
runOnWindowsConsole = true;
}
if ( runOnWindowsConsole )
{
switch ( debugConfig )
{
case JQDebugReset: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 7 ); break; }
case JQDebugBlue: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_BLUE ); break; }
case JQDebugGreen: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN ); break; }
case JQDebugRed: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_RED ); break; }
case JQDebugYellow: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 14 ); break; }
case JQDebugPurple: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 5 ); break; }
case JQDebugCyan: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 3 ); break; }
case JQDebugBlack: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0 ); break; }
case JQDebugWhite: { SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 15 ); break; }
default: { break; }
}
return dbg;
}
else
#endif
{
switch ( debugConfig )
{
case JQDebugReset: { return dbg << "\033[0m"; }
case JQDebugBlue: { return dbg << "\033[34m"; }
case JQDebugGreen: { return dbg << "\033[32m"; }
case JQDebugRed: { return dbg << "\033[31m"; }
case JQDebugYellow: { return dbg << "\033[33m"; }
case JQDebugPurple: { return dbg << "\033[35m"; }
case JQDebugCyan: { return dbg << "\033[36m"; }
case JQDebugBlack: { return dbg << "\033[30m"; }
case JQDebugWhite: { return dbg << "\033[37m"; }
default: { return dbg; }
}
}
}
QString JQFoundation::hashString(const QByteArray &key, const QCryptographicHash::Algorithm &algorithm)
{
return QCryptographicHash::hash( key, algorithm ).toHex();
}
QString JQFoundation::variantToString(const QVariant &value)
{
QString result;
if ( ( value.type() == 31 ) || ( value.type() == 51 ) || ( value.type() == QVariant::Invalid ) ) { return "NULL"; }
switch ( value.type() )
{
case QVariant::Bool:
{
result = ( ( value.toBool() ) ? ( "1" ) : ( "0" ) );
break;
}
case QVariant::ByteArray:
{
result = QString( "\\x" );
result += value.toByteArray().toHex();
break;
}
case QVariant::String:
{
result = value.toString();
break;
}
case QVariant::Int:
case QVariant::Double:
{
result = QString::number( value.toDouble(), 'f', 8 );
while ( result.endsWith( '0' ) )
{
result = result.mid( 0, result.size() - 1 );
}
if ( result.endsWith( '.' ) )
{
result = result.mid( 0, result.size() - 1 );
}
if ( result == "" )
{
result = "0";
}
break;
}
default:
{
if ( value.type() == QVariant::nameToType( "QJsonValue" ) )
{
const auto &&jsonValue = value.toJsonValue();
switch ( jsonValue.type() )
{
case QJsonValue::Null:
{
result = "NULL";
break;
}
case QJsonValue::Bool:
{
result = ( ( jsonValue.toBool() ) ? ( "1" ) : ( "0" ) );
break;
}
case QJsonValue::String:
{
result = jsonValue.toString();
break;
}
case QJsonValue::Double:
{
result = QString::number( jsonValue.toDouble(), 'f', 8 );
while ( result.endsWith( '0' ) )
{
result = result.mid( 0, result.size() - 1 );
}
if ( result.endsWith( '.' ) )
{
result = result.mid( 0, result.size() - 1 );
}
if ( result == "" )
{
result = "0";
}
break;
}
default:
{
qDebug() << "JQFoundation::variantToString: unexpected json type:" << jsonValue;
result = jsonValue.toString();
break;
}
}
}
else
{
qDebug() << "JQFoundation::variantToString: unexpected type:" << value;
result = value.toString();
}
break;
}
}
return result;
}
QString JQFoundation::createUuidString()
{
return QUuid::createUuid().toString().mid( 1, 36 );
}
QJsonObject JQFoundation::jsonFilter(const QJsonObject &source, const QStringList &leftKey, const QJsonObject &mix)
{
QJsonObject result;
for ( const auto &key: leftKey )
{
auto buf = source.find( key );
if ( buf != source.end() )
{
result[ buf.key() ] = buf.value();
}
}
if ( !mix.isEmpty() )
{
for ( auto it = mix.begin(); it != mix.end(); ++it )
{
result.insert( it.key(), it.value() );
}
}
return result;
}
QJsonObject JQFoundation::jsonFilter(const QJsonObject &source, const char *leftKey, const QJsonObject &mix)
{
return JQFoundation::jsonFilter( source, QStringList( { leftKey } ), mix );
}
QVariantList JQFoundation::listVariantMapToVariantList(const QList< QVariantMap > &source)
{
QVariantList result;
for ( const auto &data: source )
{
result.push_back( data );
}
return result;
}
QList< QVariantMap > JQFoundation::variantListToListVariantMap(const QVariantList &source)
{
QList< QVariantMap > result;
for ( const auto &item: source )
{
result.push_back( item.toMap() );
}
return result;
}
QVariantMap JQFoundation::mapKeyTranslate(const QVariantMap &source, const QMap< QString, QString > &keyMap)
{
QVariantMap result;
for ( auto sourceIt = source.begin(); sourceIt != source.end(); ++sourceIt )
{
const auto &&keyMapIt = keyMap.find( sourceIt.key() );
if ( keyMapIt == keyMap.end() ) { continue; }
result[ keyMapIt.value() ] = sourceIt.value();
}
return result;
}
QVariantList JQFoundation::listKeyTranslate(const QVariantList &source, const QMap< QString, QString > &keyMap)
{
QVariantList result;
for ( const auto &data: source )
{
result.push_back( mapKeyTranslate( data.toMap(), keyMap ) );
}
return result;
}
QList< QVariantMap > JQFoundation::listKeyTranslate(const QList< QVariantMap > &source, const QMap<QString, QString> &keyMap)
{
QList< QVariantMap > result;
for ( const auto &data: source )
{
result.push_back( mapKeyTranslate( data, keyMap ) );
}
return result;
}
QSharedPointer< QTimer > JQFoundation::setTimerCallback(
const int &interval,
const std::function<void (bool &continueFlag)> &callback,
const bool &callbackOnStart
)
{
QSharedPointer< QTimer > timer( new QTimer );
QObject::connect( timer.data(), &QTimer::timeout, [ timer, callback ]()
{
bool continueFlag = true;
callback( continueFlag );
if ( continueFlag )
{
timer->start();
}
} );
timer->setInterval( interval );
timer->setSingleShot( true );
if ( callbackOnStart )
{
bool continueFlag = true;
callback( continueFlag );
if ( continueFlag )
{
timer->start();
}
}
else
{
timer->start();
}
return timer;
}
#if ( defined QT_CONCURRENT_LIB ) && ( QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) )
void JQFoundation::setTimerCallback(
const QDateTime &dateTime,
const std::function<void ()> &callback,
const QSharedPointer< QThreadPool > &threadPool
)
{
const auto &¤tDateTime = QDateTime::currentDateTime();
auto workThread = [ = ]()
{
QSharedPointer< QThreadPool > targetThreadPool;
if ( threadPool )
{
targetThreadPool = threadPool;
}
else
{
targetThreadPool.reset( new QThreadPool );
}
QtConcurrent::run( targetThreadPool.data(), [ = ]()
{
const auto &&timeDiff = QDateTime::currentDateTime().msecsTo( dateTime );
if ( timeDiff > 0 )
{
QThread::msleep( static_cast< unsigned long >( timeDiff ) );
}
while ( QDateTime::currentDateTime() < dateTime )
{
QThread::msleep( 10 );
}
callback();
} );
};
if ( currentDateTime.secsTo( dateTime ) < 3 )
{
workThread();
}
else
{
QMetaObject::invokeMethod( qApp, [ = ]()
{
QTimer::singleShot( ( currentDateTime.secsTo( dateTime ) - 3 ) * 1000, workThread );
} );
}
}
void JQFoundation::setTimerCallback(
const std::function< QDateTime() > &nextTime,
const std::function<void ()> &callback,
const QSharedPointer< QThreadPool > &threadPool
)
{
setTimerCallback( nextTime(), [ = ]()
{
callback();
setTimerCallback( nextTime, callback, threadPool );
}, threadPool );
}
#endif
void JQFoundation::setDebugOutput(const QString &rawTargetFilePath_, const bool &argDateFlag_)
{
static QString rawTargetFilePath;
static bool argDateFlag;
static const QtMessageHandler QT_DEFAULT_MESSAGE_HANDLER = qInstallMessageHandler( nullptr );
rawTargetFilePath = rawTargetFilePath_;
argDateFlag = argDateFlag_;
class HelperClass
{
public:
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &rawMessage)
{
QString message;
switch ( type )
{
case QtDebugMsg:
{
message = rawMessage;
break;
}
case QtWarningMsg:
{
message.append( "Warning: " );
message.append( rawMessage );
break;
}
case QtCriticalMsg:
{
message.append( "Critical: " );
message.append( rawMessage );
break;
}
case QtFatalMsg:
{
message.append( "Fatal: " );
message.append( rawMessage );
break;
}
default: { break; }
}
QString currentTargetFilePath;
if ( argDateFlag )
{
currentTargetFilePath = rawTargetFilePath.arg( ( ( argDateFlag ) ? ( QDateTime::currentDateTime().toString("yyyy_MM_dd") ) : ( "" ) ) );
}
else
{
currentTargetFilePath = rawTargetFilePath;
}
if ( !QFileInfo::exists( currentTargetFilePath ) )
{
QDir().mkpath( QFileInfo( currentTargetFilePath ).path() );
}
( *QT_DEFAULT_MESSAGE_HANDLER )( type, context, rawMessage );
QFile file( currentTargetFilePath );
file.open( QIODevice::WriteOnly | QIODevice::Append );
QTextStream textStream( &file );
textStream << QDateTime::currentDateTime().toString( "yyyy-MM-dd hh:mm:ss" ) << ": " << message << endl;
}
};
qInstallMessageHandler( HelperClass::messageHandler );
}
void JQFoundation::openDebugConsole()
{
#ifdef Q_OS_WIN
class HelperClass
{
public:
static void messageHandler(QtMsgType type, const QMessageLogContext &, const QString &message_)
{
QString message;
switch ( type )
{
case QtDebugMsg:
{
message = message_;
break;
}
case QtWarningMsg:
{
message.append( "Warning: " );
message.append( message_ );
break;
}
case QtCriticalMsg:
{
message.append( "Critical: " );
message.append( message_ );
break;
}
case QtFatalMsg:
{
message.append( "Fatal: " );
message.append( message_ );
break;
}
default: { break; }
}
std::cout << QDateTime::currentDateTime().toString( "yyyy-MM-dd hh:mm:ss" ).toUtf8().data()
<< ": " << message.toUtf8().data() << std::endl;
}
};
qInstallMessageHandler( HelperClass::messageHandler );
AllocConsole();
#endif
}
#if !(defined Q_OS_IOS) && !(defined Q_OS_ANDROID) && !(defined Q_OS_WINPHONE) && !(defined Q_OS_WASM)
bool JQFoundation::singleApplication(const QString &flag)
{
static QMap< QString, QSharedMemory * > shareMemSet;
auto &shareMem = shareMemSet[ flag ];
if ( shareMem ) { return true; }
shareMem = new QSharedMemory( flag );
for ( auto count = 0; count < 2; ++count )
{
if ( shareMem->attach( QSharedMemory::ReadOnly ) )
{
shareMem->detach();
}
}
if ( shareMem->create( 1 ) )
{
return true;
}
delete shareMem;
shareMem = nullptr;
return false;
}
bool JQFoundation::singleApplicationExist(const QString &flag)
{
QSharedMemory shareMem( flag );
for ( auto count = 0; count < 2; ++count )
{
if (shareMem.attach( QSharedMemory::ReadOnly ))
{
shareMem.detach();
}
}
if ( shareMem.create( 1 ) )
{
return false;
}
return true;
}
#else
bool JQFoundation::singleApplication(const QString &)
{
return true;
}
bool JQFoundation::singleApplicationExist(const QString &)
{
return false;
}
#endif
QString JQFoundation::snakeCaseToCamelCase(const QString &source, const bool &firstCharUpper)
{
const auto &&splitList = source.split( '_', QString::SkipEmptyParts );
QString result;
for ( const auto &splitTag: splitList )
{
if ( splitTag.size() == 1 )
{
if ( result.isEmpty() )
{
if ( firstCharUpper )
{
result += splitTag[ 0 ].toUpper();
}
else
{
result += splitTag;
}
}
else
{
result += splitTag[ 0 ].toUpper();
}
}
else
{
if ( result.isEmpty() )
{
if ( firstCharUpper )
{
result += splitTag[ 0 ].toUpper();
result += splitTag.midRef( 1 );
}
else
{
result += splitTag;
}
}
else
{
result += splitTag[ 0 ].toUpper();
result += splitTag.midRef( 1 );
}
}
}
return result;
}
int JQFoundation::rectOverflow(const QSize &frameSize, const QRect &rect, const int &redundancy)
{
if ( redundancy != 0 )
{
return rectOverflow(
{
frameSize.width() + redundancy,
frameSize.height() + redundancy
},
{
rect.x() + redundancy,
rect.y() + redundancy,
rect.width(),
rect.height()
},
0
);
}
const auto &&unitedRect = QRect( QPoint( 0, 0 ), frameSize ).united( rect );
return qMax( unitedRect.width() - frameSize.width(), unitedRect.height() - frameSize.height() );
}
QRect JQFoundation::scaleRect(const QRect &rect, const qreal &scale)
{
return scaleRect( rect, scale, scale );
}
QRect JQFoundation::scaleRect(const QRect &rect, const qreal &horizontalScale, const qreal &verticalScale)
{
return {
static_cast< int >( rect.x() * horizontalScale ),
static_cast< int >( rect.y() * verticalScale ),
static_cast< int >( rect.width() * horizontalScale ),
static_cast< int >( rect.height() * verticalScale )
};
}
QPoint JQFoundation::scalePoint(const QPoint &point, const qreal &horizontalScale, const qreal &verticalScale)
{
return {
static_cast< int >( point.x() * horizontalScale ),
static_cast< int >( point.y() * verticalScale )
};
}
QPointF JQFoundation::scalePoint(const QPointF &point, const qreal &horizontalScale, const qreal &verticalScale)
{
return {
static_cast< qreal >( point.x() * horizontalScale ),
static_cast< qreal >( point.y() * verticalScale )
};
}
QPoint JQFoundation::pointFToPoint(const QPointF &point, const QSize &size)
{
return {
static_cast< int >( point.x() * size.width() ),
static_cast< int >( point.y() * size.height() )
};
}
QPointF JQFoundation::pointToPointF(const QPoint &point, const QSize &size)
{
return {
static_cast< qreal >( point.x() ) / size.width(),
static_cast< qreal >( point.y() ) / size.height()
};
}
QLine JQFoundation::pointFToLine(const QPointF &point1, const QPointF &point2, const QSize &size)
{
return {
JQFoundation::pointFToPoint( point1, size ),
JQFoundation::pointFToPoint( point2, size )
};
}
QRect JQFoundation::rectFToRect(const QRectF &rect, const QSize &size)
{
return {
static_cast< int >( rect.x() * size.width() ),
static_cast< int >( rect.y() * size.height() ),
static_cast< int >( rect.width() * size.width() ),
static_cast< int >( rect.height() * size.height() )
};
}
QRectF JQFoundation::rectToRectF(const QRect &rect, const QSize &size)
{
return {
static_cast< qreal >( rect.x() ) / size.width(),
static_cast< qreal >( rect.y() ) / size.height(),
static_cast< qreal >( rect.width() ) / size.width(),
static_cast< qreal >( rect.height() ) / size.height()
};
}
QLine JQFoundation::lineFToLine(const QLineF &line, const QSize &size)
{
return {
static_cast< int >( line.x1() * size.width() ),
static_cast< int >( line.y1() * size.height() ),
static_cast< int >( line.x2() * size.width() ),
static_cast< int >( line.y2() * size.height() )
};
}
QRect JQFoundation::cropRect(const QRect &rect, const QRect &bigRect)
{
return {
QPoint(
( ( rect.x() < bigRect.x() ) ? ( bigRect.x() ) : ( rect.x() ) ),
( ( rect.y() < bigRect.y() ) ? ( bigRect.y() ) : ( rect.y() ) )
),
QPoint(
( ( rect.bottomRight().x() > bigRect.bottomRight().x() ) ? ( bigRect.bottomRight().x() ) : ( rect.bottomRight().x() ) ),
( ( rect.bottomRight().y() > bigRect.bottomRight().y() ) ? ( bigRect.bottomRight().y() ) : ( rect.bottomRight().y() ) )
)
};
}
#ifdef QT_CONCURRENT_LIB
QByteArray JQFoundation::pixmapToByteArray(const QPixmap &pixmap, const QString &format, int quality)
{
QByteArray bytes;
QBuffer buffer( &bytes );
buffer.open( QIODevice::WriteOnly );
pixmap.save( &buffer, format.toLatin1().data(), quality );
return bytes;
}
QByteArray JQFoundation::imageToByteArray(const QImage &image, const QString &format, int quality)
{
static QMap< QThread *, QByteArray * > cacheMap; // thread -> QByteArray
static QMutex cacheMutex;
QByteArray *bytes = nullptr;
cacheMutex.lock();
{
auto it = cacheMap.find( QThread::currentThread() );
if ( ( it == cacheMap.end() ) || !*it )
{
bytes = new QByteArray;
cacheMap[ QThread::currentThread() ] = bytes;
}
else
{
bytes = *it;
}
}
cacheMutex.unlock();
if ( bytes->capacity() <= 0 )
{
bytes->reserve( 512 * 1024 );
}
// qDebug() << reinterpret_cast< const void * >( bytes->constData() ) << bytes->size() << bytes->capacity();
QBuffer buffer( bytes );
buffer.open( QIODevice::WriteOnly );
image.save( &buffer, format.toLatin1().data(), quality );
// qDebug() << reinterpret_cast< const void * >( bytes->constData() ) << bytes->size() << bytes->capacity();
return *bytes;
}
QImage JQFoundation::imageCopy(const QImage &image, const QRect &rect)
{
const auto &&unitedRect = QRect( 0, 0, image.width(), image.height() ).united( rect );
if ( ( unitedRect.width() > image.width() ) || ( unitedRect.height() > image.height() ) )
{
qDebug() << "JQFoundation::imageCopy: error: input:" << image.size() << ", rect:" << rect << ", unitedRect:" << unitedRect;
return { };
}
if ( image.format() != QImage::Format_RGB888 )
{
qDebug() << "JQFoundation::format: error:" <<image.format();
return { };
}
auto rgbData = JQMemoryPool::requestMemory( static_cast< size_t >( rect.width() * rect.height() * 3 ) );
QImage result(
reinterpret_cast< unsigned char * >( rgbData ),
rect.width(),
rect.height(),
rect.width() * 3,
QImage::Format_RGB888,
JQMemoryPool::recoverMemory,
rgbData
);
for ( auto y = rect.y(); y < ( rect.y() + rect.height() ); ++y )
{
auto source = image.bits() + image.bytesPerLine() * y + rect.x() * 3 - 1;
auto target = result.bits() + result.bytesPerLine() * ( y - rect.y() ) - 1;
auto sourceEnd = source + rect.width() * 3 + 1;
while ( source < sourceEnd )
{
*( ++target ) = *( ++source );
}
}
return result;
}
QImage JQFoundation::removeImageColor(const QImage &image, const QColor &color)
{
if ( image.format() != QImage::Format_RGB888 )
{
qDebug() << "JQFoundation::removeImageColor: not support formath:" << image;
return { };
}
auto rgbData = JQMemoryPool::requestMemory( static_cast< size_t >( image.width() * image.height() * 4 ) );
QImage result(
reinterpret_cast< unsigned char * >( rgbData ),
image.width(),
image.height(),
image.width() * 4,
QImage::Format_ARGB32,
JQMemoryPool::recoverMemory,
rgbData
);
auto current = reinterpret_cast< const quint8 * >( image.bits() );
auto end = reinterpret_cast< const quint8 * >( current + image.width() * image.height() * 3 );
auto target = reinterpret_cast< quint8 * >( rgbData );
const auto alphaKey = static_cast< quint32 >( color.red() << 16 | color.green() << 8 | color.blue() );
for ( ; current < end; current += 3, target += 4 )
{
if ( ( *reinterpret_cast< const quint32 * >( current ) & 0xffffff ) == alphaKey )
{
*( target + 0 ) = 0x00;
*( target + 1 ) = 0x00;
*( target + 2 ) = 0x00;
*( target + 3 ) = 0x00;
}
else
{
*( target + 3 ) = 0xff;
*( target + 2 ) = *( current + 0 );
*( target + 1 ) = *( current + 1 );
*( target + 0 ) = *( current + 2 );
}
}
return result;
}
void JQFoundation::waitFor(const std::function< bool() > &predicate, const int &timeout)
{
for ( auto current = 0; current < timeout; current += 25 )
{
if ( !predicate() ) { break; }
QThread::msleep( 25 );
}
}
#endif
QList< QPair< QDateTime, QDateTime > > JQFoundation::extractTimeRange(const QDateTime &startTime, const QDateTime &endTime, const qint64 &interval)
{
if ( interval <= 0 )
{
return { { startTime, endTime } };
}
const auto &&dayStartTime = QDateTime( startTime.date(), QTime( 0, 0, 0 ) );
auto currentTime = startTime.addMSecs( -1 * ( ( startTime.toMSecsSinceEpoch() - dayStartTime.toMSecsSinceEpoch() ) % interval ) );
QList< QPair< QDateTime, QDateTime > > result;
while ( currentTime < endTime )
{
result.push_back( { currentTime, currentTime.addMSecs( interval ) } );
currentTime = currentTime.addMSecs( interval );
if ( result.size() >= 1000 )
{
qDebug() << "extractTimeRange: result size limit: 1000";
break;
}
}
return result;
}
#if ( ( defined Q_OS_MAC ) && !( defined Q_OS_IOS ) ) || ( defined Q_OS_WIN ) || ( defined Q_OS_LINUX )
QPair< int, QByteArray > JQFoundation::startProcessAndReadOutput(const QString &program, const QStringList &arguments, const int &maximumTime)
{
QPair< int, QByteArray > reply;
QProcess process;
process.setProgram( program );
process.setArguments( arguments );
process.start();
QObject::connect( &process, static_cast< void(QProcess::*)(int, QProcess::ExitStatus exitStatus) >( &QProcess::finished ), [ &reply ](const int &exitCode)
{
reply.first = exitCode;
} );
QObject::connect( &process, &QIODevice::readyRead, [ &process, &reply ]()
{
reply.second.append( process.readAll() );
} );
process.waitForFinished( maximumTime );
return reply;
}
#endif
JQTickCounter::JQTickCounter(const qint64 &timeRange):
timeRange_( timeRange ),
mutex_( new QMutex )
{ }
void JQTickCounter::tick(const int &count)
{
mutex_->lock();
const auto &¤tMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
while ( ( !tickRecord_.isEmpty() ) && ( qAbs( currentMSecsSinceEpoch - tickRecord_.first() ) > timeRange_ ) )
{
tickRecord_.pop_front();
}
for ( auto index = 0; index < count; ++index )
{
tickRecord_.push_back( currentMSecsSinceEpoch );
}
mutex_->unlock();
}
qreal JQTickCounter::tickPerSecond()
{
qreal result = 0;
mutex_->lock();
const auto &¤tMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
while ( ( !tickRecord_.isEmpty() ) && ( qAbs( currentMSecsSinceEpoch - tickRecord_.first() ) > timeRange_ ) )
{
tickRecord_.pop_front();
}
if ( !tickRecord_.isEmpty() )
{
result = static_cast< qreal >( tickRecord_.size() ) / ( timeRange_ / 1000.0 );
}
mutex_->unlock();
return result;
}
QString JQTickCounter::tickPerSecondDisplayString()
{
return QString::number( tickPerSecond(), 'f', 1 );
}
// AtcityFpsControl
#ifdef QT_CONCURRENT_LIB
JQFpsControl::JQFpsControl(const qreal &fps):
fps_( fps )
{ }
void JQFpsControl::setFps(const qreal &fps)
{
fps_ = fps;
}
void JQFpsControl::waitNextFrame()
{
const auto &¤tMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
const int timeInterval = qMax( 1, static_cast< int >( 1000.0 / fps_ ) );
qint64 nextFrameTime = 0;
if ( currentMSecsSinceEpoch % timeInterval )
{
nextFrameTime = ( currentMSecsSinceEpoch / timeInterval + 1 ) * timeInterval;
}
else
{
nextFrameTime = currentMSecsSinceEpoch;
}
if ( nextFrameTime == lastTriggeredTime_ )
{
nextFrameTime += timeInterval;
}
const auto readyToMSleep = qBound( 0, static_cast< int >( nextFrameTime - currentMSecsSinceEpoch ), 1000 );
if ( readyToMSleep > 0 )
{
QThread::msleep( static_cast< unsigned long >( readyToMSleep ) );
}
lastTriggeredTime_ = QDateTime::currentMSecsSinceEpoch();
}
bool JQFpsControl::readyNextFrame()
{
const auto &¤tMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
const int timeInterval = qMax( 1, static_cast< int >( 1000.0 / fps_ ) );
if ( ( currentMSecsSinceEpoch - lastTriggeredTime_ ) >= timeInterval )
{
lastTriggeredTime_ = ( currentMSecsSinceEpoch / timeInterval ) * timeInterval;
return true;
}
else
{
return false;
}
}
// JQMemoryPool
QMutex JQMemoryPool::mutex_;
QMap< size_t, QVector< JQMemoryPool::JQMemoryPoolNodeHead > > JQMemoryPool::nodeMap_;
QAtomicInteger< qint64 > JQMemoryPool::realTotalMallocSize_ = 0;
QAtomicInteger< qint64 > JQMemoryPool::totalMallocSize_ = 0;
QAtomicInteger< qint64 > JQMemoryPool::totalMallocCount_ = 0;
qint64 JQMemoryPool::releaseThreshold_ = -1;
void JQMemoryPool::initReleaseThreshold(const qreal &percentage)
{
#ifdef Q_OS_WIN
MEMORYSTATUSEX statex;
statex.dwLength = sizeof( statex );
GlobalMemoryStatusEx( &statex );
releaseThreshold_ = static_cast< qint64 >( statex.ullTotalPhys * percentage );
#else
Q_UNUSED( percentage )
releaseThreshold_ = static_cast< qint64 >( 8 ) * 1024 * 1024 * 1024;
#endif
qDebug() << "JQMemoryPool: Release threshold set to:" << ( releaseThreshold_ / 1024 / 1024 ) << "MB";
}
qint64 JQMemoryPool::realTotalMallocSize()
{
return realTotalMallocSize_;
}
qint64 JQMemoryPool::totalMallocSize()
{
return totalMallocSize_;
}
qint64 JQMemoryPool::totalMallocCount()
{
return totalMallocCount_;
}
void *JQMemoryPool::requestMemory(const size_t &requestSize)
{
totalMallocSize_ += static_cast< qint64 >( requestSize );
++totalMallocCount_;
mutex_.lock();
if ( releaseThreshold_ <= 0 )
{
initReleaseThreshold();
}
auto it = nodeMap_.find( requestSize );
if ( ( it == nodeMap_.end() ) || it->isEmpty() )
{
mutex_.unlock();
return makeNode( requestSize ).memory;
}
else
{
auto node = it->takeLast();
it = { };
mutex_.unlock();
return node.memory;
}
}
void JQMemoryPool::recoverMemory(void *memory)
{
auto node = reinterpret_cast< JQMemoryPoolNodeHead * >( reinterpret_cast< qint8 * >( memory ) - sizeof( JQMemoryPoolNodeHead ) );
if ( node->flag != 0x3519 )
{
qDebug() << "JQMemoryPool::recoverMemory: error: flag not match:" << memory << node->flag;
return;
}
if ( ( realTotalMallocSize_ > releaseThreshold_ ) ||
( node->requestSize < 128 ) )
{
realTotalMallocSize_ -= static_cast< long long >( node->requestSize );
if ( realTotalMallocSize_ < 0 )
{
qDebug() << "JQMemoryPool::recoverMemory: error:" << realTotalMallocSize_ << node->requestSize;
}
free( reinterpret_cast< qint8 * >( memory ) - sizeof( JQMemoryPoolNodeHead ) );
}
else
{
mutex_.lock();
nodeMap_[ node->requestSize ].push_back( *node );
mutex_.unlock();
}
}
JQMemoryPool::JQMemoryPoolNodeHead JQMemoryPool::makeNode(const size_t &requestSize)
{
static qint64 lastPrintSize = 0;
realTotalMallocSize_ += static_cast< qint64 >( requestSize );
if ( ( realTotalMallocSize_ - lastPrintSize ) > ( 256 * 1024 * 1024 ) )
{
lastPrintSize = realTotalMallocSize_;
qDebug() << "JQMemoryPool::makeNode: totalMallocSize:" << ( realTotalMallocSize_ / 1024 / 1024 ) << "MB";
}
auto buffer = malloc( sizeof( JQMemoryPoolNodeHead ) + requestSize + 100 );
auto node = reinterpret_cast< JQMemoryPoolNodeHead * >( buffer );
node->flag = 0x3519;
node->mallocThread = QThread::currentThread();
node->mallocTime = QDateTime::currentMSecsSinceEpoch();
node->requestSize = requestSize;
node->memory = reinterpret_cast< qint8 * >( buffer ) + sizeof( JQMemoryPoolNodeHead );
return *node;
}
#endif
```
|
/content/code_sandbox/library/JQLibrary/src/JQFoundation.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 8,729
|
```c
/*
* qrencode - QR Code encoder
*
* Input data chunk class
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "qrencode.h"
#include "qrspec.h"
#include "mqrspec.h"
#include "bitstream.h"
#include "qrinput.h"
/******************************************************************************
* Utilities
*****************************************************************************/
int QRinput_isSplittableMode(QRencodeMode mode)
{
return (mode >= QR_MODE_NUM && mode <= QR_MODE_KANJI);
}
/******************************************************************************
* Entry of input data
*****************************************************************************/
static QRinput_List *QRinput_List_newEntry(QRencodeMode mode, int size, const unsigned char *data)
{
QRinput_List *entry;
if(QRinput_check(mode, size, data)) {
errno = EINVAL;
return NULL;
}
entry = (QRinput_List *)malloc(sizeof(QRinput_List));
if(entry == NULL) return NULL;
entry->mode = mode;
entry->size = size;
if(size > 0) {
entry->data = (unsigned char *)malloc(size);
if(entry->data == NULL) {
free(entry);
return NULL;
}
memcpy(entry->data, data, size);
}
entry->bstream = NULL;
entry->next = NULL;
return entry;
}
static void QRinput_List_freeEntry(QRinput_List *entry)
{
if(entry != NULL) {
free(entry->data);
BitStream_free(entry->bstream);
free(entry);
}
}
static QRinput_List *QRinput_List_dup(QRinput_List *entry)
{
QRinput_List *n;
n = (QRinput_List *)malloc(sizeof(QRinput_List));
if(n == NULL) return NULL;
n->mode = entry->mode;
n->size = entry->size;
n->data = (unsigned char *)malloc(n->size);
if(n->data == NULL) {
free(n);
return NULL;
}
memcpy(n->data, entry->data, entry->size);
n->bstream = NULL;
n->next = NULL;
return n;
}
/******************************************************************************
* Input Data
*****************************************************************************/
QRinput *QRinput_new(void)
{
return QRinput_new2(0, QR_ECLEVEL_L);
}
QRinput *QRinput_new2(int version, QRecLevel level)
{
QRinput *input;
if(version < 0 || version > QRSPEC_VERSION_MAX || level > QR_ECLEVEL_H) {
errno = EINVAL;
return NULL;
}
input = (QRinput *)malloc(sizeof(QRinput));
if(input == NULL) return NULL;
input->head = NULL;
input->tail = NULL;
input->version = version;
input->level = level;
input->mqr = 0;
input->fnc1 = 0;
return input;
}
QRinput *QRinput_newMQR(int version, QRecLevel level)
{
QRinput *input;
if(version <= 0 || version > MQRSPEC_VERSION_MAX) goto INVALID;
if((MQRspec_getECCLength(version, level) == 0)) goto INVALID;
input = QRinput_new2(version, level);
if(input == NULL) return NULL;
input->mqr = 1;
return input;
INVALID:
errno = EINVAL;
return NULL;
}
int QRinput_getVersion(QRinput *input)
{
return input->version;
}
int QRinput_setVersion(QRinput *input, int version)
{
if(input->mqr || version < 0 || version > QRSPEC_VERSION_MAX) {
errno = EINVAL;
return -1;
}
input->version = version;
return 0;
}
QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input)
{
return input->level;
}
int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level)
{
if(input->mqr || level > QR_ECLEVEL_H) {
errno = EINVAL;
return -1;
}
input->level = level;
return 0;
}
int QRinput_setVersionAndErrorCorrectionLevel(QRinput *input, int version, QRecLevel level)
{
if(input->mqr) {
if(version <= 0 || version > MQRSPEC_VERSION_MAX) goto INVALID;
if((MQRspec_getECCLength(version, level) == 0)) goto INVALID;
} else {
if(version < 0 || version > QRSPEC_VERSION_MAX) goto INVALID;
if(level > QR_ECLEVEL_H) goto INVALID;
}
input->version = version;
input->level = level;
return 0;
INVALID:
errno = EINVAL;
return -1;
}
static void QRinput_appendEntry(QRinput *input, QRinput_List *entry)
{
if(input->tail == NULL) {
input->head = entry;
input->tail = entry;
} else {
input->tail->next = entry;
input->tail = entry;
}
entry->next = NULL;
}
int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data)
{
QRinput_List *entry;
entry = QRinput_List_newEntry(mode, size, data);
if(entry == NULL) {
return -1;
}
QRinput_appendEntry(input, entry);
return 0;
}
/**
* Insert a structured-append header to the head of the input data.
* @param input input data.
* @param size number of structured symbols.
* @param number index number of the symbol. (1 <= number <= size)
* @param parity parity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data)
* @retval 0 success.
* @retval -1 error occurred and errno is set to indeicate the error. See Execptions for the details.
* @throw EINVAL invalid parameter.
* @throw ENOMEM unable to allocate memory.
*/
int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int number, unsigned char parity)
{
QRinput_List *entry;
unsigned char buf[3];
if(size > MAX_STRUCTURED_SYMBOLS) {
errno = EINVAL;
return -1;
}
if(number <= 0 || number > size) {
errno = EINVAL;
return -1;
}
buf[0] = (unsigned char)size;
buf[1] = (unsigned char)number;
buf[2] = parity;
entry = QRinput_List_newEntry(QR_MODE_STRUCTURE, 3, buf);
if(entry == NULL) {
return -1;
}
entry->next = input->head;
input->head = entry;
return 0;
}
int QRinput_appendECIheader(QRinput *input, unsigned int ecinum)
{
unsigned char data[4];
if(ecinum > 999999) {
errno = EINVAL;
return -1;
}
/* We manually create byte array of ecinum because
(unsigned char *)&ecinum may cause bus error on some architectures, */
data[0] = ecinum & 0xff;
data[1] = (ecinum >> 8) & 0xff;
data[2] = (ecinum >> 16) & 0xff;
data[3] = (ecinum >> 24) & 0xff;
return QRinput_append(input, QR_MODE_ECI, 4, data);
}
void QRinput_free(QRinput *input)
{
QRinput_List *list, *next;
if(input != NULL) {
list = input->head;
while(list != NULL) {
next = list->next;
QRinput_List_freeEntry(list);
list = next;
}
free(input);
}
}
static unsigned char QRinput_calcParity(QRinput *input)
{
unsigned char parity = 0;
QRinput_List *list;
int i;
list = input->head;
while(list != NULL) {
if(list->mode != QR_MODE_STRUCTURE) {
for(i=list->size-1; i>=0; i--) {
parity ^= list->data[i];
}
}
list = list->next;
}
return parity;
}
QRinput *QRinput_dup(QRinput *input)
{
QRinput *n;
QRinput_List *list, *e;
if(input->mqr) {
n = QRinput_newMQR(input->version, input->level);
} else {
n = QRinput_new2(input->version, input->level);
}
if(n == NULL) return NULL;
list = input->head;
while(list != NULL) {
e = QRinput_List_dup(list);
if(e == NULL) {
QRinput_free(n);
return NULL;
}
QRinput_appendEntry(n, e);
list = list->next;
}
return n;
}
/******************************************************************************
* Numeric data
*****************************************************************************/
/**
* Check the input data.
* @param size
* @param data
* @return result
*/
static int QRinput_checkModeNum(int size, const char *data)
{
int i;
for(i=0; i<size; i++) {
if(data[i] < '0' || data[i] > '9')
return -1;
}
return 0;
}
/**
* Estimates the length of the encoded bit stream of numeric data.
* @param size
* @return number of bits
*/
int QRinput_estimateBitsModeNum(int size)
{
int w;
int bits;
w = size / 3;
bits = w * 10;
switch(size - w * 3) {
case 1:
bits += 4;
break;
case 2:
bits += 7;
break;
default:
break;
}
return bits;
}
/**
* Convert the number data to a bit stream.
* @param entry
* @param mqr
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
*/
static int QRinput_encodeModeNum(QRinput_List *entry, int version, int mqr)
{
int words, i, ret;
unsigned int val;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
if(mqr) {
if(version > 1) {
ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_NUM);
if(ret < 0) goto ABORT;
}
ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_NUM, version), entry->size);
if(ret < 0) goto ABORT;
} else {
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_NUM);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_NUM, version), entry->size);
if(ret < 0) goto ABORT;
}
words = entry->size / 3;
for(i=0; i<words; i++) {
val = (entry->data[i*3 ] - '0') * 100;
val += (entry->data[i*3+1] - '0') * 10;
val += (entry->data[i*3+2] - '0');
ret = BitStream_appendNum(entry->bstream, 10, val);
if(ret < 0) goto ABORT;
}
if(entry->size - words * 3 == 1) {
val = entry->data[words*3] - '0';
ret = BitStream_appendNum(entry->bstream, 4, val);
if(ret < 0) goto ABORT;
} else if(entry->size - words * 3 == 2) {
val = (entry->data[words*3 ] - '0') * 10;
val += (entry->data[words*3+1] - '0');
BitStream_appendNum(entry->bstream, 7, val);
if(ret < 0) goto ABORT;
}
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* Alphabet-numeric data
*****************************************************************************/
const signed char QRinput_anTable[128] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
/**
* Check the input data.
* @param size
* @param data
* @return result
*/
static int QRinput_checkModeAn(int size, const char *data)
{
int i;
for(i=0; i<size; i++) {
if(QRinput_lookAnTable(data[i]) < 0)
return -1;
}
return 0;
}
/**
* Estimates the length of the encoded bit stream of alphabet-numeric data.
* @param size
* @return number of bits
*/
int QRinput_estimateBitsModeAn(int size)
{
int w;
int bits;
w = size / 2;
bits = w * 11;
if(size & 1) {
bits += 6;
}
return bits;
}
/**
* Convert the alphabet-numeric data to a bit stream.
* @param entry
* @param mqr
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw EINVAL invalid version.
*/
static int QRinput_encodeModeAn(QRinput_List *entry, int version, int mqr)
{
int words, i, ret;
unsigned int val;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
if(mqr) {
if(version < 2) {
errno = EINVAL;
goto ABORT;
}
ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_AN);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_AN, version), entry->size);
if(ret < 0) goto ABORT;
} else {
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_AN);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_AN, version), entry->size);
if(ret < 0) goto ABORT;
}
words = entry->size / 2;
for(i=0; i<words; i++) {
val = (unsigned int)QRinput_lookAnTable(entry->data[i*2 ]) * 45;
val += (unsigned int)QRinput_lookAnTable(entry->data[i*2+1]);
ret = BitStream_appendNum(entry->bstream, 11, val);
if(ret < 0) goto ABORT;
}
if(entry->size & 1) {
val = (unsigned int)QRinput_lookAnTable(entry->data[words * 2]);
ret = BitStream_appendNum(entry->bstream, 6, val);
if(ret < 0) goto ABORT;
}
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* 8 bit data
*****************************************************************************/
/**
* Estimates the length of the encoded bit stream of 8 bit data.
* @param size
* @return number of bits
*/
int QRinput_estimateBitsMode8(int size)
{
return size * 8;
}
/**
* Convert the 8bits data to a bit stream.
* @param entry
* @param mqr
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
*/
static int QRinput_encodeMode8(QRinput_List *entry, int version, int mqr)
{
int ret;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
if(mqr) {
if(version < 3) {
errno = EINVAL;
goto ABORT;
}
ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_8);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_8, version), entry->size);
if(ret < 0) goto ABORT;
} else {
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_8);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_8, version), entry->size);
if(ret < 0) goto ABORT;
}
ret = BitStream_appendBytes(entry->bstream, entry->size, entry->data);
if(ret < 0) goto ABORT;
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* Kanji data
*****************************************************************************/
/**
* Estimates the length of the encoded bit stream of kanji data.
* @param size
* @return number of bits
*/
int QRinput_estimateBitsModeKanji(int size)
{
return (size / 2) * 13;
}
/**
* Check the input data.
* @param size
* @param data
* @return result
*/
static int QRinput_checkModeKanji(int size, const unsigned char *data)
{
int i;
unsigned int val;
if(size & 1)
return -1;
for(i=0; i<size; i+=2) {
val = ((unsigned int)data[i] << 8) | data[i+1];
if(val < 0x8140 || (val > 0x9ffc && val < 0xe040) || val > 0xebbf) {
return -1;
}
}
return 0;
}
/**
* Convert the kanji data to a bit stream.
* @param entry
* @param mqr
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw EINVAL invalid version.
*/
static int QRinput_encodeModeKanji(QRinput_List *entry, int version, int mqr)
{
int ret, i;
unsigned int val, h;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
if(mqr) {
if(version < 2) {
errno = EINVAL;
goto ABORT;
}
ret = BitStream_appendNum(entry->bstream, version - 1, MQRSPEC_MODEID_KANJI);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, MQRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2);
if(ret < 0) goto ABORT;
} else {
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_KANJI);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, QRspec_lengthIndicator(QR_MODE_KANJI, version), entry->size/2);
if(ret < 0) goto ABORT;
}
for(i=0; i<entry->size; i+=2) {
val = ((unsigned int)entry->data[i] << 8) | entry->data[i+1];
if(val <= 0x9ffc) {
val -= 0x8140;
} else {
val -= 0xc140;
}
h = (val >> 8) * 0xc0;
val = (val & 0xff) + h;
ret = BitStream_appendNum(entry->bstream, 13, val);
if(ret < 0) goto ABORT;
}
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* Structured Symbol
*****************************************************************************/
/**
* Convert a structure symbol code to a bit stream.
* @param entry
* @param mqr
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw EINVAL invalid entry.
*/
static int QRinput_encodeModeStructure(QRinput_List *entry, int mqr)
{
int ret;
if(mqr) {
errno = EINVAL;
return -1;
}
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_STRUCTURE);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, 4, entry->data[1] - 1);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, 4, entry->data[0] - 1);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, 8, entry->data[2]);
if(ret < 0) goto ABORT;
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* FNC1
*****************************************************************************/
static int QRinput_checkModeFNC1Second(int size)
{
if(size != 1) return -1;
return 0;
}
static int QRinput_encodeModeFNC1Second(QRinput_List *entry)
{
int ret;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_FNC1SECOND);
if(ret < 0) goto ABORT;
ret = BitStream_appendBytes(entry->bstream, 1, entry->data);
if(ret < 0) goto ABORT;
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* ECI header
*****************************************************************************/
static unsigned int QRinput_decodeECIfromByteArray(unsigned char *data)
{
int i;
unsigned int ecinum;
ecinum = 0;
for(i=0; i<4; i++) {
ecinum = ecinum << 8;
ecinum |= data[3-i];
}
return ecinum;
}
int QRinput_estimateBitsModeECI(unsigned char *data)
{
unsigned int ecinum;
ecinum = QRinput_decodeECIfromByteArray(data);;
/* See Table 4 of JISX 0510:2004 pp.17. */
if(ecinum < 128) {
return MODE_INDICATOR_SIZE + 8;
} else if(ecinum < 16384) {
return MODE_INDICATOR_SIZE + 16;
} else {
return MODE_INDICATOR_SIZE + 24;
}
}
static int QRinput_encodeModeECI(QRinput_List *entry)
{
int ret, words;
unsigned int ecinum, code;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) return -1;
ecinum = QRinput_decodeECIfromByteArray(entry->data);;
/* See Table 4 of JISX 0510:2004 pp.17. */
if(ecinum < 128) {
words = 1;
code = ecinum;
} else if(ecinum < 16384) {
words = 2;
code = 0x8000 + ecinum;
} else {
words = 3;
code = 0xc0000 + ecinum;
}
ret = BitStream_appendNum(entry->bstream, 4, QRSPEC_MODEID_ECI);
if(ret < 0) goto ABORT;
ret = BitStream_appendNum(entry->bstream, words * 8, code);
if(ret < 0) goto ABORT;
return 0;
ABORT:
BitStream_free(entry->bstream);
entry->bstream = NULL;
return -1;
}
/******************************************************************************
* Validation
*****************************************************************************/
int QRinput_check(QRencodeMode mode, int size, const unsigned char *data)
{
if((mode == QR_MODE_FNC1FIRST && size < 0) || size <= 0) return -1;
switch(mode) {
case QR_MODE_NUM:
return QRinput_checkModeNum(size, (const char *)data);
case QR_MODE_AN:
return QRinput_checkModeAn(size, (const char *)data);
case QR_MODE_KANJI:
return QRinput_checkModeKanji(size, data);
case QR_MODE_8:
return 0;
case QR_MODE_STRUCTURE:
return 0;
case QR_MODE_ECI:
return 0;
case QR_MODE_FNC1FIRST:
return 0;
case QR_MODE_FNC1SECOND:
return QRinput_checkModeFNC1Second(size);
case QR_MODE_NUL:
break;
}
return -1;
}
/******************************************************************************
* Estimation of the bit length
*****************************************************************************/
/**
* Estimates the length of the encoded bit stream on the current version.
* @param entry
* @param version version of the symbol
* @param mqr
* @return number of bits
*/
static int QRinput_estimateBitStreamSizeOfEntry(QRinput_List *entry, int version, int mqr)
{
int bits = 0;
int l, m;
int num;
if(version == 0) version = 1;
switch(entry->mode) {
case QR_MODE_NUM:
bits = QRinput_estimateBitsModeNum(entry->size);
break;
case QR_MODE_AN:
bits = QRinput_estimateBitsModeAn(entry->size);
break;
case QR_MODE_8:
bits = QRinput_estimateBitsMode8(entry->size);
break;
case QR_MODE_KANJI:
bits = QRinput_estimateBitsModeKanji(entry->size);
break;
case QR_MODE_STRUCTURE:
return STRUCTURE_HEADER_SIZE;
case QR_MODE_ECI:
bits = QRinput_estimateBitsModeECI(entry->data);
break;
case QR_MODE_FNC1FIRST:
return MODE_INDICATOR_SIZE;
case QR_MODE_FNC1SECOND:
return MODE_INDICATOR_SIZE + 8;
default:
return 0;
}
if(mqr) {
l = QRspec_lengthIndicator(entry->mode, version);
m = version - 1;
bits += l + m;
} else {
l = QRspec_lengthIndicator(entry->mode, version);
m = 1 << l;
num = (entry->size + m - 1) / m;
bits += num * (MODE_INDICATOR_SIZE + l);
}
return bits;
}
/**
* Estimates the length of the encoded bit stream of the data.
* @param input input data
* @param version version of the symbol
* @return number of bits
*/
int QRinput_estimateBitStreamSize(QRinput *input, int version)
{
QRinput_List *list;
int bits = 0;
list = input->head;
while(list != NULL) {
bits += QRinput_estimateBitStreamSizeOfEntry(list, version, input->mqr);
list = list->next;
}
return bits;
}
/**
* Estimates the required version number of the symbol.
* @param input input data
* @return required version number
*/
static int QRinput_estimateVersion(QRinput *input)
{
int bits;
int version, prev;
version = 0;
do {
prev = version;
bits = QRinput_estimateBitStreamSize(input, prev);
version = QRspec_getMinimumVersion((bits + 7) / 8, input->level);
if (version < 0) {
return -1;
}
} while (version > prev);
return version;
}
/**
* Returns required length in bytes for specified mode, version and bits.
* @param mode
* @param version
* @param bits
* @return required length of code words in bytes.
*/
int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits)
{
int payload, size, chunks, remain, maxsize;
payload = bits - 4 - QRspec_lengthIndicator(mode, version);
switch(mode) {
case QR_MODE_NUM:
chunks = payload / 10;
remain = payload - chunks * 10;
size = chunks * 3;
if(remain >= 7) {
size += 2;
} else if(remain >= 4) {
size += 1;
}
break;
case QR_MODE_AN:
chunks = payload / 11;
remain = payload - chunks * 11;
size = chunks * 2;
if(remain >= 6) size++;
break;
case QR_MODE_8:
size = payload / 8;
break;
case QR_MODE_KANJI:
size = (payload / 13) * 2;
break;
case QR_MODE_STRUCTURE:
size = payload / 8;
break;
default:
size = 0;
break;
}
maxsize = QRspec_maximumWords(mode, version);
if(size < 0) size = 0;
if(maxsize > 0 && size > maxsize) size = maxsize;
return size;
}
/******************************************************************************
* Data conversion
*****************************************************************************/
/**
* Convert the input data in the data chunk to a bit stream.
* @param entry
* @return number of bits (>0) or -1 for failure.
*/
static int QRinput_encodeBitStream(QRinput_List *entry, int version, int mqr)
{
int words, ret;
QRinput_List *st1 = NULL, *st2 = NULL;
if(entry->bstream != NULL) {
BitStream_free(entry->bstream);
entry->bstream = NULL;
}
words = QRspec_maximumWords(entry->mode, version);
if(words != 0 && entry->size > words) {
st1 = QRinput_List_newEntry(entry->mode, words, entry->data);
if(st1 == NULL) goto ABORT;
st2 = QRinput_List_newEntry(entry->mode, entry->size - words, &entry->data[words]);
if(st2 == NULL) goto ABORT;
ret = QRinput_encodeBitStream(st1, version, mqr);
if(ret < 0) goto ABORT;
ret = QRinput_encodeBitStream(st2, version, mqr);
if(ret < 0) goto ABORT;
entry->bstream = BitStream_new();
if(entry->bstream == NULL) goto ABORT;
ret = BitStream_append(entry->bstream, st1->bstream);
if(ret < 0) goto ABORT;
ret = BitStream_append(entry->bstream, st2->bstream);
if(ret < 0) goto ABORT;
QRinput_List_freeEntry(st1);
QRinput_List_freeEntry(st2);
} else {
ret = 0;
switch(entry->mode) {
case QR_MODE_NUM:
ret = QRinput_encodeModeNum(entry, version, mqr);
break;
case QR_MODE_AN:
ret = QRinput_encodeModeAn(entry, version, mqr);
break;
case QR_MODE_8:
ret = QRinput_encodeMode8(entry, version, mqr);
break;
case QR_MODE_KANJI:
ret = QRinput_encodeModeKanji(entry, version, mqr);
break;
case QR_MODE_STRUCTURE:
ret = QRinput_encodeModeStructure(entry, mqr);
break;
case QR_MODE_ECI:
ret = QRinput_encodeModeECI(entry);
break;
case QR_MODE_FNC1SECOND:
ret = QRinput_encodeModeFNC1Second(entry);
break;
default:
break;
}
if(ret < 0) return -1;
}
return BitStream_size(entry->bstream);
ABORT:
QRinput_List_freeEntry(st1);
QRinput_List_freeEntry(st2);
return -1;
}
/**
* Convert the input data to a bit stream.
* @param input input data.
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
*/
static int QRinput_createBitStream(QRinput *input)
{
QRinput_List *list;
int bits, total = 0;
list = input->head;
while(list != NULL) {
bits = QRinput_encodeBitStream(list, input->version, input->mqr);
if(bits < 0) return -1;
total += bits;
list = list->next;
}
return total;
}
/**
* Convert the input data to a bit stream.
* When the version number is given and that is not sufficient, it is increased
* automatically.
* @param input input data.
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw ERANGE input is too large.
*/
static int QRinput_convertData(QRinput *input)
{
int bits;
int ver;
ver = QRinput_estimateVersion(input);
if(ver > QRinput_getVersion(input)) {
QRinput_setVersion(input, ver);
}
for(;;) {
bits = QRinput_createBitStream(input);
if(bits < 0) return -1;
ver = QRspec_getMinimumVersion((bits + 7) / 8, input->level);
if(ver < 0) {
errno = ERANGE;
return -1;
} else if(ver > QRinput_getVersion(input)) {
QRinput_setVersion(input, ver);
} else {
break;
}
}
return 0;
}
/**
* Append padding bits for the input data.
* @param bstream Bitstream to be appended.
* @param input input data.
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ERANGE input data is too large.
* @throw ENOMEM unable to allocate memory.
*/
static int QRinput_appendPaddingBit(BitStream *bstream, QRinput *input)
{
int bits, maxbits, words, maxwords, i, ret;
BitStream *padding = NULL;
unsigned char *padbuf;
int padlen;
bits = BitStream_size(bstream);
maxwords = QRspec_getDataLength(input->version, input->level);
maxbits = maxwords * 8;
if(maxbits < bits) {
errno = ERANGE;
return -1;
}
if(maxbits == bits) {
return 0;
}
if(maxbits - bits <= 4) {
ret = BitStream_appendNum(bstream, maxbits - bits, 0);
goto DONE;
}
words = (bits + 4 + 7) / 8;
padding = BitStream_new();
if(padding == NULL) return -1;
ret = BitStream_appendNum(padding, words * 8 - bits, 0);
if(ret < 0) goto DONE;
padlen = maxwords - words;
if(padlen > 0) {
padbuf = (unsigned char *)malloc(padlen);
if(padbuf == NULL) {
ret = -1;
goto DONE;
}
for(i=0; i<padlen; i++) {
padbuf[i] = (i&1)?0x11:0xec;
}
ret = BitStream_appendBytes(padding, padlen, padbuf);
free(padbuf);
if(ret < 0) {
goto DONE;
}
}
ret = BitStream_append(bstream, padding);
DONE:
BitStream_free(padding);
return ret;
}
/**
* Append padding bits for the input data - Micro QR Code version.
* @param bstream Bitstream to be appended.
* @param input input data.
* @retval 0 success
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ERANGE input data is too large.
* @throw ENOMEM unable to allocate memory.
*/
static int QRinput_appendPaddingBitMQR(BitStream *bstream, QRinput *input)
{
int bits, maxbits, words, maxwords, i, ret, termbits;
BitStream *padding = NULL;
unsigned char *padbuf;
int padlen;
bits = BitStream_size(bstream);
maxbits = MQRspec_getDataLengthBit(input->version, input->level);
maxwords = maxbits / 8;
if(maxbits < bits) {
errno = ERANGE;
return -1;
}
if(maxbits == bits) {
return 0;
}
termbits = input->version * 2 + 1;
if(maxbits - bits <= termbits) {
ret = BitStream_appendNum(bstream, maxbits - bits, 0);
goto DONE;
}
bits += termbits;
words = (bits + 7) / 8;
if(maxbits - words * 8 > 0) {
termbits += words * 8 - bits;
if(words == maxwords) termbits += maxbits - words * 8;
} else {
termbits += words * 8 - bits;
}
padding = BitStream_new();
if(padding == NULL) return -1;
ret = BitStream_appendNum(padding, termbits, 0);
if(ret < 0) goto DONE;
padlen = maxwords - words;
if(padlen > 0) {
padbuf = (unsigned char *)malloc(padlen);
if(padbuf == NULL) {
ret = -1;
goto DONE;
}
for(i=0; i<padlen; i++) {
padbuf[i] = (i&1)?0x11:0xec;
}
ret = BitStream_appendBytes(padding, padlen, padbuf);
free(padbuf);
if(ret < 0) {
goto DONE;
}
termbits = maxbits - maxwords * 8;
if(termbits > 0) {
ret = BitStream_appendNum(padding, termbits, 0);
if(ret < 0) goto DONE;
}
}
ret = BitStream_append(bstream, padding);
DONE:
BitStream_free(padding);
return ret;
}
static int QRinput_insertFNC1Header(QRinput *input)
{
QRinput_List *entry = NULL;
if(input->fnc1 == 1) {
entry = QRinput_List_newEntry(QR_MODE_FNC1FIRST, 0, NULL);
} else if(input->fnc1 == 2) {
entry = QRinput_List_newEntry(QR_MODE_FNC1SECOND, 1, &(input->appid));
}
if(entry == NULL) {
return -1;
}
if(input->head->mode != QR_MODE_STRUCTURE || input->head->mode != QR_MODE_ECI) {
entry->next = input->head;
input->head = entry;
} else {
entry->next = input->head->next;
input->head->next = entry;
}
return 0;
}
/**
* Merge all bit streams in the input data.
* @param input input data.
* @return merged bit stream
*/
BitStream *QRinput_mergeBitStream(QRinput *input)
{
BitStream *bstream;
QRinput_List *list;
int ret;
if(input->mqr) {
if(QRinput_createBitStream(input) < 0) {
return NULL;
}
} else {
if(input->fnc1) {
if(QRinput_insertFNC1Header(input) < 0) {
return NULL;
}
}
if(QRinput_convertData(input) < 0) {
return NULL;
}
}
bstream = BitStream_new();
if(bstream == NULL) return NULL;
list = input->head;
while(list != NULL) {
ret = BitStream_append(bstream, list->bstream);
if(ret < 0) {
BitStream_free(bstream);
return NULL;
}
list = list->next;
}
return bstream;
}
/**
* Merge all bit streams in the input data and append padding bits
* @param input input data.
* @return padded merged bit stream
*/
BitStream *QRinput_getBitStream(QRinput *input)
{
BitStream *bstream;
int ret;
bstream = QRinput_mergeBitStream(input);
if(bstream == NULL) {
return NULL;
}
if(input->mqr) {
ret = QRinput_appendPaddingBitMQR(bstream, input);
} else {
ret = QRinput_appendPaddingBit(bstream, input);
}
if(ret < 0) {
BitStream_free(bstream);
return NULL;
}
return bstream;
}
/**
* Pack all bit streams padding bits into a byte array.
* @param input input data.
* @return padded merged byte stream
*/
unsigned char *QRinput_getByteStream(QRinput *input)
{
BitStream *bstream;
unsigned char *array;
bstream = QRinput_getBitStream(input);
if(bstream == NULL) {
return NULL;
}
array = BitStream_toByte(bstream);
BitStream_free(bstream);
return array;
}
/******************************************************************************
* Structured input data
*****************************************************************************/
static QRinput_InputList *QRinput_InputList_newEntry(QRinput *input)
{
QRinput_InputList *entry;
entry = (QRinput_InputList *)malloc(sizeof(QRinput_InputList));
if(entry == NULL) return NULL;
entry->input = input;
entry->next = NULL;
return entry;
}
static void QRinput_InputList_freeEntry(QRinput_InputList *entry)
{
if(entry != NULL) {
QRinput_free(entry->input);
free(entry);
}
}
QRinput_Struct *QRinput_Struct_new(void)
{
QRinput_Struct *s;
s = (QRinput_Struct *)malloc(sizeof(QRinput_Struct));
if(s == NULL) return NULL;
s->size = 0;
s->parity = -1;
s->head = NULL;
s->tail = NULL;
return s;
}
void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity)
{
s->parity = (int)parity;
}
int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input)
{
QRinput_InputList *e;
if(input->mqr) {
errno = EINVAL;
return -1;
}
e = QRinput_InputList_newEntry(input);
if(e == NULL) return -1;
s->size++;
if(s->tail == NULL) {
s->head = e;
s->tail = e;
} else {
s->tail->next = e;
s->tail = e;
}
return s->size;
}
void QRinput_Struct_free(QRinput_Struct *s)
{
QRinput_InputList *list, *next;
if(s != NULL) {
list = s->head;
while(list != NULL) {
next = list->next;
QRinput_InputList_freeEntry(list);
list = next;
}
free(s);
}
}
static unsigned char QRinput_Struct_calcParity(QRinput_Struct *s)
{
QRinput_InputList *list;
unsigned char parity = 0;
list = s->head;
while(list != NULL) {
parity ^= QRinput_calcParity(list->input);
list = list->next;
}
QRinput_Struct_setParity(s, parity);
return parity;
}
static int QRinput_List_shrinkEntry(QRinput_List *entry, int bytes)
{
unsigned char *data;
data = (unsigned char *)malloc(bytes);
if(data == NULL) return -1;
memcpy(data, entry->data, bytes);
free(entry->data);
entry->data = data;
entry->size = bytes;
return 0;
}
int QRinput_splitEntry(QRinput_List *entry, int bytes)
{
QRinput_List *e;
int ret;
e = QRinput_List_newEntry(entry->mode, entry->size - bytes, entry->data + bytes);
if(e == NULL) {
return -1;
}
ret = QRinput_List_shrinkEntry(entry, bytes);
if(ret < 0) {
QRinput_List_freeEntry(e);
return -1;
}
e->next = entry->next;
entry->next = e;
return 0;
}
QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input)
{
QRinput *p;
QRinput_Struct *s;
int bits, maxbits, nextbits, bytes, ret;
QRinput_List *list, *next, *prev;
if(input->mqr) {
errno = EINVAL;
return NULL;
}
s = QRinput_Struct_new();
if(s == NULL) return NULL;
input = QRinput_dup(input);
if(input == NULL) {
QRinput_Struct_free(s);
return NULL;
}
QRinput_Struct_setParity(s, QRinput_calcParity(input));
maxbits = QRspec_getDataLength(input->version, input->level) * 8 - STRUCTURE_HEADER_SIZE;
if(maxbits <= 0) {
QRinput_Struct_free(s);
QRinput_free(input);
return NULL;
}
bits = 0;
list = input->head;
prev = NULL;
while(list != NULL) {
nextbits = QRinput_estimateBitStreamSizeOfEntry(list, input->version, input->mqr);
if(bits + nextbits <= maxbits) {
ret = QRinput_encodeBitStream(list, input->version, input->mqr);
if(ret < 0) goto ABORT;
bits += ret;
prev = list;
list = list->next;
} else {
bytes = QRinput_lengthOfCode(list->mode, input->version, maxbits - bits);
p = QRinput_new2(input->version, input->level);
if(p == NULL) goto ABORT;
if(bytes > 0) {
/* Splits this entry into 2 entries. */
ret = QRinput_splitEntry(list, bytes);
if(ret < 0) {
QRinput_free(p);
goto ABORT;
}
/* First half is the tail of the current input. */
next = list->next;
list->next = NULL;
/* Second half is the head of the next input, p.*/
p->head = next;
/* Renew QRinput.tail. */
p->tail = input->tail;
input->tail = list;
/* Point to the next entry. */
prev = list;
list = next;
} else {
/* Current entry will go to the next input. */
prev->next = NULL;
p->head = list;
p->tail = input->tail;
input->tail = prev;
}
ret = QRinput_Struct_appendInput(s, input);
if(ret < 0) {
QRinput_free(p);
goto ABORT;
}
input = p;
bits = 0;
}
}
ret = QRinput_Struct_appendInput(s, input);
if(ret < 0) goto ABORT;
if(s->size > MAX_STRUCTURED_SYMBOLS) {
QRinput_Struct_free(s);
errno = ERANGE;
return NULL;
}
ret = QRinput_Struct_insertStructuredAppendHeaders(s);
if(ret < 0) {
QRinput_Struct_free(s);
return NULL;
}
return s;
ABORT:
QRinput_free(input);
QRinput_Struct_free(s);
return NULL;
}
int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s)
{
int i;
QRinput_InputList *list;
if(s->size == 1) {
return 0;
}
if(s->parity < 0) {
QRinput_Struct_calcParity(s);
}
i = 1;
list = s->head;
while(list != NULL) {
if(QRinput_insertStructuredAppendHeader(list->input, s->size, i, s->parity))
return -1;
i++;
list = list->next;
}
return 0;
}
/******************************************************************************
* Extended encoding mode (FNC1 and ECI)
*****************************************************************************/
int QRinput_setFNC1First(QRinput *input)
{
if(input->mqr) {
errno = EINVAL;
return -1;
}
input->fnc1 = 1;
return 0;
}
int QRinput_setFNC1Second(QRinput *input, unsigned char appid)
{
if(input->mqr) {
errno = EINVAL;
return -1;
}
input->fnc1 = 2;
input->appid = appid;
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrinput.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 11,385
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Input data chunk class
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __QRINPUT_H__
#define __QRINPUT_H__
#include "qrencode.h"
#include "bitstream.h"
int QRinput_isSplittableMode(QRencodeMode mode);
/******************************************************************************
* Entry of input data
*****************************************************************************/
typedef struct _QRinput_List QRinput_List;
struct _QRinput_List {
QRencodeMode mode;
int size; ///< Size of data chunk (byte).
unsigned char *data; ///< Data chunk.
BitStream *bstream;
QRinput_List *next;
};
/******************************************************************************
* Input Data
*****************************************************************************/
struct _QRinput {
int version;
QRecLevel level;
QRinput_List *head;
QRinput_List *tail;
int mqr;
int fnc1;
unsigned char appid;
};
/******************************************************************************
* Structured append input data
*****************************************************************************/
typedef struct _QRinput_InputList QRinput_InputList;
struct _QRinput_InputList {
QRinput *input;
QRinput_InputList *next;
};
struct _QRinput_Struct {
int size; ///< number of structured symbols
int parity;
QRinput_InputList *head;
QRinput_InputList *tail;
};
/**
* Pack all bit streams padding bits into a byte array.
* @param input input data.
* @return padded merged byte stream
*/
extern unsigned char *QRinput_getByteStream(QRinput *input);
extern int QRinput_estimateBitsModeNum(int size);
extern int QRinput_estimateBitsModeAn(int size);
extern int QRinput_estimateBitsMode8(int size);
extern int QRinput_estimateBitsModeKanji(int size);
extern QRinput *QRinput_dup(QRinput *input);
extern const signed char QRinput_anTable[128];
/**
* Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19).
* @param __c__ character
* @return value
*/
#define QRinput_lookAnTable(__c__) \
((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__])
/**
* Length of a standard mode indicator in bits.
*/
#define MODE_INDICATOR_SIZE 4
/**
* Length of a segment of structured-append header.
*/
#define STRUCTURE_HEADER_SIZE 20
/**
* Maximum number of symbols in a set of structured-appended symbols.
*/
#define MAX_STRUCTURED_SYMBOLS 16
#ifdef WITH_TESTS
extern BitStream *QRinput_mergeBitStream(QRinput *input);
extern BitStream *QRinput_getBitStream(QRinput *input);
extern int QRinput_estimateBitStreamSize(QRinput *input, int version);
extern int QRinput_splitEntry(QRinput_List *entry, int bytes);
extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits);
extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity);
#endif
#endif /* __QRINPUT_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrinput.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 739
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Input data splitter.
*
* The following data / specifications are taken from
* "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
* or
* "Automatic identification and data capture techniques --
* QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __SPLIT_H__
#define __SPLIT_H__
#include "qrencode.h"
/**
* Split the input string (null terminated) into QRinput.
* @param string input string
* @param hint give QR_MODE_KANJI if the input string contains Kanji character encoded in Shift-JIS. If not, give QR_MODE_8.
* @param casesensitive 0 for case-insensitive encoding (all alphabet characters are replaced to UPPER-CASE CHARACTERS.
* @retval 0 success.
* @retval -1 an error occurred. errno is set to indicate the error. See
* Exceptions for the details.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory for input objects.
*/
extern int Split_splitStringToQRinput(const char *string, QRinput *input,
QRencodeMode hint, int casesensitive);
#endif /* __SPLIT_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/split.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 388
|
```c
/*
* qrencode - QR Code encoder
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "qrencode.h"
#include "qrspec.h"
#include "mqrspec.h"
#include "bitstream.h"
#include "qrinput.h"
#include "rscode.h"
#include "split.h"
#include "mask.h"
#include "mmask.h"
/******************************************************************************
* Raw code
*****************************************************************************/
typedef struct {
int dataLength;
unsigned char *data;
int eccLength;
unsigned char *ecc;
} RSblock;
typedef struct {
int version;
int dataLength;
int eccLength;
unsigned char *datacode;
unsigned char *ecccode;
int b1;
int blocks;
RSblock *rsblock;
int count;
} QRRawCode;
static void RSblock_initBlock(RSblock *block, int dl, unsigned char *data, int el, unsigned char *ecc, RS *rs)
{
block->dataLength = dl;
block->data = data;
block->eccLength = el;
block->ecc = ecc;
encode_rs_char(rs, data, ecc);
}
static int RSblock_init(RSblock *blocks, int spec[5], unsigned char *data, unsigned char *ecc)
{
int i;
RSblock *block;
unsigned char *dp, *ep;
RS *rs;
int el, dl;
dl = QRspec_rsDataCodes1(spec);
el = QRspec_rsEccCodes1(spec);
rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el);
if(rs == NULL) return -1;
block = blocks;
dp = data;
ep = ecc;
for(i=0; i<QRspec_rsBlockNum1(spec); i++) {
RSblock_initBlock(block, dl, dp, el, ep, rs);
dp += dl;
ep += el;
block++;
}
if(QRspec_rsBlockNum2(spec) == 0) return 0;
dl = QRspec_rsDataCodes2(spec);
el = QRspec_rsEccCodes2(spec);
rs = init_rs(8, 0x11d, 0, 1, el, 255 - dl - el);
if(rs == NULL) return -1;
for(i=0; i<QRspec_rsBlockNum2(spec); i++) {
RSblock_initBlock(block, dl, dp, el, ep, rs);
dp += dl;
ep += el;
block++;
}
return 0;
}
void QRraw_free(QRRawCode *raw);
QRRawCode *QRraw_new(QRinput *input)
{
QRRawCode *raw;
int spec[5], ret;
raw = (QRRawCode *)malloc(sizeof(QRRawCode));
if(raw == NULL) return NULL;
raw->datacode = QRinput_getByteStream(input);
if(raw->datacode == NULL) {
free(raw);
return NULL;
}
QRspec_getEccSpec(input->version, input->level, spec);
raw->version = input->version;
raw->b1 = QRspec_rsBlockNum1(spec);
raw->dataLength = QRspec_rsDataLength(spec);
raw->eccLength = QRspec_rsEccLength(spec);
raw->ecccode = (unsigned char *)malloc(raw->eccLength);
if(raw->ecccode == NULL) {
free(raw->datacode);
free(raw);
return NULL;
}
raw->blocks = QRspec_rsBlockNum(spec);
raw->rsblock = (RSblock *)calloc(raw->blocks, sizeof(RSblock));
if(raw->rsblock == NULL) {
QRraw_free(raw);
return NULL;
}
ret = RSblock_init(raw->rsblock, spec, raw->datacode, raw->ecccode);
if(ret < 0) {
QRraw_free(raw);
return NULL;
}
raw->count = 0;
return raw;
}
/**
* Return a code (byte).
* This function can be called iteratively.
* @param raw raw code.
* @return code
*/
unsigned char QRraw_getCode(QRRawCode *raw)
{
int col, row;
unsigned char ret;
if(raw->count < raw->dataLength) {
row = raw->count % raw->blocks;
col = raw->count / raw->blocks;
if(col >= raw->rsblock[0].dataLength) {
row += raw->b1;
}
ret = raw->rsblock[row].data[col];
} else if(raw->count < raw->dataLength + raw->eccLength) {
row = (raw->count - raw->dataLength) % raw->blocks;
col = (raw->count - raw->dataLength) / raw->blocks;
ret = raw->rsblock[row].ecc[col];
} else {
return 0;
}
raw->count++;
return ret;
}
void QRraw_free(QRRawCode *raw)
{
if(raw != NULL) {
free(raw->datacode);
free(raw->ecccode);
free(raw->rsblock);
free(raw);
}
}
/******************************************************************************
* Raw code for Micro QR Code
*****************************************************************************/
typedef struct {
int version;
int dataLength;
int eccLength;
unsigned char *datacode;
unsigned char *ecccode;
RSblock *rsblock;
int oddbits;
int count;
} MQRRawCode;
void MQRraw_free(MQRRawCode *raw);
MQRRawCode *MQRraw_new(QRinput *input)
{
MQRRawCode *raw;
RS *rs;
raw = (MQRRawCode *)malloc(sizeof(MQRRawCode));
if(raw == NULL) return NULL;
raw->version = input->version;
raw->dataLength = MQRspec_getDataLength(input->version, input->level);
raw->eccLength = MQRspec_getECCLength(input->version, input->level);
raw->oddbits = raw->dataLength * 8 - MQRspec_getDataLengthBit(input->version, input->level);
raw->datacode = QRinput_getByteStream(input);
if(raw->datacode == NULL) {
free(raw);
return NULL;
}
raw->ecccode = (unsigned char *)malloc(raw->eccLength);
if(raw->ecccode == NULL) {
free(raw->datacode);
free(raw);
return NULL;
}
raw->rsblock = (RSblock *)calloc(1, sizeof(RSblock));
if(raw->rsblock == NULL) {
MQRraw_free(raw);
return NULL;
}
rs = init_rs(8, 0x11d, 0, 1, raw->eccLength, 255 - raw->dataLength - raw->eccLength);
if(rs == NULL) {
MQRraw_free(raw);
return NULL;
}
RSblock_initBlock(raw->rsblock, raw->dataLength, raw->datacode, raw->eccLength, raw->ecccode, rs);
raw->count = 0;
return raw;
}
/**
* Return a code (byte).
* This function can be called iteratively.
* @param raw raw code.
* @return code
*/
unsigned char MQRraw_getCode(MQRRawCode *raw)
{
unsigned char ret;
if(raw->count < raw->dataLength) {
ret = raw->datacode[raw->count];
} else if(raw->count < raw->dataLength + raw->eccLength) {
ret = raw->ecccode[raw->count - raw->dataLength];
} else {
return 0;
}
raw->count++;
return ret;
}
void MQRraw_free(MQRRawCode *raw)
{
if(raw != NULL) {
free(raw->datacode);
free(raw->ecccode);
free(raw->rsblock);
free(raw);
}
}
/******************************************************************************
* Frame filling
*****************************************************************************/
typedef struct {
int width;
unsigned char *frame;
int x, y;
int dir;
int bit;
int mqr;
} FrameFiller;
static FrameFiller *FrameFiller_new(int width, unsigned char *frame, int mqr)
{
FrameFiller *filler;
filler = (FrameFiller *)malloc(sizeof(FrameFiller));
if(filler == NULL) return NULL;
filler->width = width;
filler->frame = frame;
filler->x = width - 1;
filler->y = width - 1;
filler->dir = -1;
filler->bit = -1;
filler->mqr = mqr;
return filler;
}
static unsigned char *FrameFiller_next(FrameFiller *filler)
{
unsigned char *p;
int x, y, w;
if(filler->bit == -1) {
filler->bit = 0;
return filler->frame + filler->y * filler->width + filler->x;
}
x = filler->x;
y = filler->y;
p = filler->frame;
w = filler->width;
if(filler->bit == 0) {
x--;
filler->bit++;
} else {
x++;
y += filler->dir;
filler->bit--;
}
if(filler->dir < 0) {
if(y < 0) {
y = 0;
x -= 2;
filler->dir = 1;
if(!filler->mqr && x == 6) {
x--;
y = 9;
}
}
} else {
if(y == w) {
y = w - 1;
x -= 2;
filler->dir = -1;
if(!filler->mqr && x == 6) {
x--;
y -= 8;
}
}
}
if(x < 0 || y < 0) return NULL;
filler->x = x;
filler->y = y;
if(p[y * w + x] & 0x80) {
// This tail recursion could be optimized.
return FrameFiller_next(filler);
}
return &p[y * w + x];
}
#ifdef WITH_TESTS
extern unsigned char *FrameFiller_test(int version)
{
int width;
unsigned char *frame, *p;
FrameFiller *filler;
int i, length;
width = QRspec_getWidth(version);
frame = QRspec_newFrame(version);
if(frame == NULL) return NULL;
filler = FrameFiller_new(width, frame, 0);
if(filler == NULL) {
free(frame);
return NULL;
}
length = QRspec_getDataLength(version, QR_ECLEVEL_L) * 8
+ QRspec_getECCLength(version, QR_ECLEVEL_L) * 8
+ QRspec_getRemainder(version);
for(i=0; i<length; i++) {
p = FrameFiller_next(filler);
if(p == NULL) {
free(filler);
free(frame);
return NULL;
}
*p = (unsigned char)(i & 0x7f) | 0x80;
}
free(filler);
return frame;
}
extern unsigned char *FrameFiller_testMQR(int version)
{
int width;
unsigned char *frame, *p;
FrameFiller *filler;
int i, length;
width = MQRspec_getWidth(version);
frame = MQRspec_newFrame(version);
if(frame == NULL) return NULL;
filler = FrameFiller_new(width, frame, 1);
if(filler == NULL) {
free(frame);
return NULL;
}
length = MQRspec_getDataLengthBit(version, QR_ECLEVEL_L)
+ MQRspec_getECCLength(version, QR_ECLEVEL_L) * 8;
for(i=0; i<length; i++) {
p = FrameFiller_next(filler);
if(p == NULL) {
fprintf(stderr, "Frame filler run over the frame!\n");
free(filler);
return frame;
}
*p = (unsigned char)(i & 0x7f) | 0x80;
}
free(filler);
return frame;
}
#endif
/******************************************************************************
* QR-code encoding
*****************************************************************************/
QRcode *QRcode_new(int version, int width, unsigned char *data)
{
QRcode *qrcode;
qrcode = (QRcode *)malloc(sizeof(QRcode));
if(qrcode == NULL) return NULL;
qrcode->version = version;
qrcode->width = width;
qrcode->data = data;
return qrcode;
}
void QRcode_free(QRcode *qrcode)
{
if(qrcode != NULL) {
free(qrcode->data);
free(qrcode);
}
}
QRcode *QRcode_encodeMask(QRinput *input, int mask)
{
int width, version;
QRRawCode *raw;
unsigned char *frame, *masked, *p, code, bit;
FrameFiller *filler;
int i, j;
QRcode *qrcode = NULL;
if(input->mqr) {
errno = EINVAL;
return NULL;
}
if(input->version < 0 || input->version > QRSPEC_VERSION_MAX) {
errno = EINVAL;
return NULL;
}
if(input->level > QR_ECLEVEL_H) {
errno = EINVAL;
return NULL;
}
raw = QRraw_new(input);
if(raw == NULL) return NULL;
version = raw->version;
width = QRspec_getWidth(version);
frame = QRspec_newFrame(version);
if(frame == NULL) {
QRraw_free(raw);
return NULL;
}
filler = FrameFiller_new(width, frame, 0);
if(filler == NULL) {
QRraw_free(raw);
free(frame);
return NULL;
}
/* inteleaved data and ecc codes */
for(i=0; i<raw->dataLength + raw->eccLength; i++) {
code = QRraw_getCode(raw);
bit = 0x80;
for(j=0; j<8; j++) {
p = FrameFiller_next(filler);
if(p == NULL) goto EXIT;
*p = 0x02 | ((bit & code) != 0);
bit = bit >> 1;
}
}
QRraw_free(raw);
raw = NULL;
/* remainder bits */
j = QRspec_getRemainder(version);
for(i=0; i<j; i++) {
p = FrameFiller_next(filler);
if(p == NULL) goto EXIT;
*p = 0x02;
}
/* masking */
if(mask == -2) { // just for debug purpose
masked = (unsigned char *)malloc(width * width);
memcpy(masked, frame, width * width);
} else if(mask < 0) {
masked = Mask_mask(width, frame, input->level);
} else {
masked = Mask_makeMask(width, frame, mask, input->level);
}
if(masked == NULL) {
goto EXIT;
}
qrcode = QRcode_new(version, width, masked);
if(qrcode == NULL) {
free(masked);
}
EXIT:
QRraw_free(raw);
free(filler);
free(frame);
return qrcode;
}
QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask)
{
int width, version;
MQRRawCode *raw;
unsigned char *frame, *masked, *p, code, bit;
FrameFiller *filler;
int i, j;
QRcode *qrcode = NULL;
if(!input->mqr) {
errno = EINVAL;
return NULL;
}
if(input->version <= 0 || input->version > MQRSPEC_VERSION_MAX) {
errno = EINVAL;
return NULL;
}
if(input->level > QR_ECLEVEL_Q) {
errno = EINVAL;
return NULL;
}
raw = MQRraw_new(input);
if(raw == NULL) return NULL;
version = raw->version;
width = MQRspec_getWidth(version);
frame = MQRspec_newFrame(version);
if(frame == NULL) {
MQRraw_free(raw);
return NULL;
}
filler = FrameFiller_new(width, frame, 1);
if(filler == NULL) {
MQRraw_free(raw);
free(frame);
return NULL;
}
/* inteleaved data and ecc codes */
for(i=0; i<raw->dataLength + raw->eccLength; i++) {
code = MQRraw_getCode(raw);
if(raw->oddbits && i == raw->dataLength - 1) {
bit = 1 << (raw->oddbits - 1);
for(j=0; j<raw->oddbits; j++) {
p = FrameFiller_next(filler);
if(p == NULL) goto EXIT;
*p = 0x02 | ((bit & code) != 0);
bit = bit >> 1;
}
} else {
bit = 0x80;
for(j=0; j<8; j++) {
p = FrameFiller_next(filler);
if(p == NULL) goto EXIT;
*p = 0x02 | ((bit & code) != 0);
bit = bit >> 1;
}
}
}
MQRraw_free(raw);
raw = NULL;
/* masking */
if(mask < 0) {
masked = MMask_mask(version, frame, input->level);
} else {
masked = MMask_makeMask(version, frame, mask, input->level);
}
if(masked == NULL) {
goto EXIT;
}
qrcode = QRcode_new(version, width, masked);
EXIT:
MQRraw_free(raw);
free(filler);
free(frame);
return qrcode;
}
QRcode *QRcode_encodeInput(QRinput *input)
{
if(input->mqr) {
return QRcode_encodeMaskMQR(input, -1);
} else {
return QRcode_encodeMask(input, -1);
}
}
static QRcode *QRcode_encodeStringReal(const char *string, int version, QRecLevel level, int mqr, QRencodeMode hint, int casesensitive)
{
QRinput *input;
QRcode *code;
int ret;
if(string == NULL) {
errno = EINVAL;
return NULL;
}
if(hint != QR_MODE_8 && hint != QR_MODE_KANJI) {
errno = EINVAL;
return NULL;
}
if(mqr) {
input = QRinput_newMQR(version, level);
} else {
input = QRinput_new2(version, level);
}
if(input == NULL) return NULL;
ret = Split_splitStringToQRinput(string, input, hint, casesensitive);
if(ret < 0) {
QRinput_free(input);
return NULL;
}
code = QRcode_encodeInput(input);
QRinput_free(input);
return code;
}
QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
{
return QRcode_encodeStringReal(string, version, level, 0, hint, casesensitive);
}
QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
{
return QRcode_encodeStringReal(string, version, level, 1, hint, casesensitive);
}
static QRcode *QRcode_encodeDataReal(const unsigned char *data, int length, int version, QRecLevel level, int mqr)
{
QRinput *input;
QRcode *code;
int ret;
if(data == NULL || length == 0) {
errno = EINVAL;
return NULL;
}
if(mqr) {
input = QRinput_newMQR(version, level);
} else {
input = QRinput_new2(version, level);
}
if(input == NULL) return NULL;
ret = QRinput_append(input, QR_MODE_8, length, data);
if(ret < 0) {
QRinput_free(input);
return NULL;
}
code = QRcode_encodeInput(input);
QRinput_free(input);
return code;
}
QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level)
{
return QRcode_encodeDataReal(data, size, version, level, 0);
}
QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level)
{
if(string == NULL) {
errno = EINVAL;
return NULL;
}
return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 0);
}
QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level)
{
return QRcode_encodeDataReal(data, size, version, level, 1);
}
QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level)
{
if(string == NULL) {
errno = EINVAL;
return NULL;
}
return QRcode_encodeDataReal((unsigned char *)string, (int)strlen(string), version, level, 1);
}
/******************************************************************************
* Structured QR-code encoding
*****************************************************************************/
static QRcode_List *QRcode_List_newEntry(void)
{
QRcode_List *entry;
entry = (QRcode_List *)malloc(sizeof(QRcode_List));
if(entry == NULL) return NULL;
entry->next = NULL;
entry->code = NULL;
return entry;
}
static void QRcode_List_freeEntry(QRcode_List *entry)
{
if(entry != NULL) {
QRcode_free(entry->code);
free(entry);
}
}
void QRcode_List_free(QRcode_List *qrlist)
{
QRcode_List *list = qrlist, *next;
while(list != NULL) {
next = list->next;
QRcode_List_freeEntry(list);
list = next;
}
}
int QRcode_List_size(QRcode_List *qrlist)
{
QRcode_List *list = qrlist;
int size = 0;
while(list != NULL) {
size++;
list = list->next;
}
return size;
}
#if 0
static unsigned char QRcode_parity(const char *str, int size)
{
unsigned char parity = 0;
int i;
for(i=0; i<size; i++) {
parity ^= str[i];
}
return parity;
}
#endif
QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s)
{
QRcode_List *head = NULL;
QRcode_List *tail = NULL;
QRcode_List *entry;
QRinput_InputList *list = s->head;
while(list != NULL) {
if(head == NULL) {
entry = QRcode_List_newEntry();
if(entry == NULL) goto ABORT;
head = entry;
tail = head;
} else {
entry = QRcode_List_newEntry();
if(entry == NULL) goto ABORT;
tail->next = entry;
tail = tail->next;
}
tail->code = QRcode_encodeInput(list->input);
if(tail->code == NULL) {
goto ABORT;
}
list = list->next;
}
return head;
ABORT:
QRcode_List_free(head);
return NULL;
}
static QRcode_List *QRcode_encodeInputToStructured(QRinput *input)
{
QRinput_Struct *s;
QRcode_List *codes;
s = QRinput_splitQRinputToStruct(input);
if(s == NULL) return NULL;
codes = QRcode_encodeInputStructured(s);
QRinput_Struct_free(s);
return codes;
}
static QRcode_List *QRcode_encodeDataStructuredReal(
int size, const unsigned char *data,
int version, QRecLevel level,
int eightbit, QRencodeMode hint, int casesensitive)
{
QRinput *input;
QRcode_List *codes;
int ret;
if(version <= 0) {
errno = EINVAL;
return NULL;
}
if(!eightbit && (hint != QR_MODE_8 && hint != QR_MODE_KANJI)) {
errno = EINVAL;
return NULL;
}
input = QRinput_new2(version, level);
if(input == NULL) return NULL;
if(eightbit) {
ret = QRinput_append(input, QR_MODE_8, size, data);
} else {
ret = Split_splitStringToQRinput((char *)data, input, hint, casesensitive);
}
if(ret < 0) {
QRinput_free(input);
return NULL;
}
codes = QRcode_encodeInputToStructured(input);
QRinput_free(input);
return codes;
}
QRcode_List *QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level) {
return QRcode_encodeDataStructuredReal(size, data, version, level, 1, QR_MODE_NUL, 0);
}
QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level) {
if(string == NULL) {
errno = EINVAL;
return NULL;
}
return QRcode_encodeDataStructured((int)strlen(string), (unsigned char *)string, version, level);
}
QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
{
if(string == NULL) {
errno = EINVAL;
return NULL;
}
return QRcode_encodeDataStructuredReal((int)strlen(string), (unsigned char *)string, version, level, 0, hint, casesensitive);
}
/******************************************************************************
* System utilities
*****************************************************************************/
void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version)
{
if(major_version != NULL) {
*major_version = 3;
}
if(minor_version != NULL) {
*minor_version = 4;
}
if(micro_version != NULL) {
*micro_version = 4;
}
}
char *QRcode_APIVersionString(void)
{
return "3.4.4";
}
void QRcode_clearCache(void)
{
QRspec_clearCache();
MQRspec_clearCache();
free_rs_cache();
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrencode.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 5,828
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Micro QR Code specification in convenient format.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __MQRSPEC_H__
#define __MQRSPEC_H__
#include "qrencode.h"
/******************************************************************************
* Version and capacity
*****************************************************************************/
/**
* Maximum width of a symbol
*/
#define MQRSPEC_WIDTH_MAX 17
/**
* Return maximum data code length (bits) for the version.
* @param version
* @param level
* @return maximum size (bits)
*/
extern int MQRspec_getDataLengthBit(int version, QRecLevel level);
/**
* Return maximum data code length (bytes) for the version.
* @param version
* @param level
* @return maximum size (bytes)
*/
extern int MQRspec_getDataLength(int version, QRecLevel level);
/**
* Return maximum error correction code length (bytes) for the version.
* @param version
* @param level
* @return ECC size (bytes)
*/
extern int MQRspec_getECCLength(int version, QRecLevel level);
/**
* Return a version number that satisfies the input code length.
* @param size input code length (byte)
* @param level
* @return version number
*/
extern int MQRspec_getMinimumVersion(int size, QRecLevel level);
/**
* Return the width of the symbol for the version.
* @param version
* @return width
*/
extern int MQRspec_getWidth(int version);
/**
* Return the numer of remainder bits.
* @param version
* @return number of remainder bits
*/
extern int MQRspec_getRemainder(int version);
/******************************************************************************
* Length indicator
*****************************************************************************/
/**
* Return the size of lenght indicator for the mode and version.
* @param mode
* @param version
* @return the size of the appropriate length indicator (bits).
*/
extern int MQRspec_lengthIndicator(QRencodeMode mode, int version);
/**
* Return the maximum length for the mode and version.
* @param mode
* @param version
* @return the maximum length (bytes)
*/
extern int MQRspec_maximumWords(QRencodeMode mode, int version);
/******************************************************************************
* Version information pattern
*****************************************************************************/
/**
* Return BCH encoded version information pattern that is used for the symbol
* of version 7 or greater. Use lower 18 bits.
* @param version
* @return BCH encoded version information pattern
*/
extern unsigned int MQRspec_getVersionPattern(int version);
/******************************************************************************
* Format information
*****************************************************************************/
/**
* Return BCH encoded format information pattern.
* @param mask
* @param version
* @param level
* @return BCH encoded format information pattern
*/
extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level);
/******************************************************************************
* Frame
*****************************************************************************/
/**
* Return a copy of initialized frame.
* When the same version is requested twice or more, a copy of cached frame
* is returned.
* @param version
* @return Array of unsigned char. You can free it by free().
*/
extern unsigned char *MQRspec_newFrame(int version);
/**
* Clear the frame cache. Typically for debug.
*/
extern void MQRspec_clearCache(void);
/******************************************************************************
* Mode indicator
*****************************************************************************/
/**
* Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107.
*/
#define MQRSPEC_MODEID_NUM 0
#define MQRSPEC_MODEID_AN 1
#define MQRSPEC_MODEID_8 2
#define MQRSPEC_MODEID_KANJI 3
#endif /* __MQRSPEC_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/mqrspec.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 861
|
```m4sugar
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/acinclude.m4
|
m4sugar
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1
|
```m4sugar
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is '.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ([2.52])dnl
m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
[$1], [CXX], [depcc="$CXX" am_compiler_list=],
[$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
[$1], [UPC], [depcc="$UPC" am_compiler_list=],
[$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named 'D' -- because '-MD' means "put the output
# in D".
rm -rf conftest.dir
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
# Solaris 10 /bin/sh.
echo '/* dummy */' > sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with '-c' and '-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle '-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs.
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
nosideeffect)
# After this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested.
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
msvc7 | msvc7msys | msvisualcpp | msvcmsys)
# This compiler won't grok '-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
if depmode=$depmode \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE([dependency-tracking], [dnl
AS_HELP_STRING(
[--enable-dependency-tracking],
[do not reject slow dependency extractors])
AS_HELP_STRING(
[--disable-dependency-tracking],
[speeds up one-time build])])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
am__nodep='_no'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
AC_SUBST([am__nodep])dnl
_AM_SUBST_NOTMAKE([am__nodep])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[{
# Older Autoconf quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named 'Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running 'make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "$am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each '.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Do all the work for Automake. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])
[_AM_PROG_CC_C_O
])
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.65])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I."
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
# test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[AC_DIAGNOSE([obsolete],
[$0: two- and three-arguments forms are deprecated.])
m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
[ok:ok],,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
AM_MISSING_PROG([AUTOCONF], [autoconf])
AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
AM_MISSING_PROG([AUTOHEADER], [autoheader])
AM_MISSING_PROG([MAKEINFO], [makeinfo])
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
# <path_to_url
# <path_to_url
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES([CC])],
[m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES([CXX])],
[m4_define([AC_PROG_CXX],
m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES([OBJC])],
[m4_define([AC_PROG_OBJC],
m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[_AM_DEPENDENCIES([OBJCXX])],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
])
AC_REQUIRE([AM_SILENT_RULES])dnl
dnl The testsuite driver may need to know about EXEEXT, so add the
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes. So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
cat >&2 <<'END'
Oops!
Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present. This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard: <path_to_url
Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message. This
can help us improve future automake versions.
END
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
echo 'Configuration will proceed anyway, since you have set the' >&2
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
echo >&2
else
cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: <path_to_url
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.
END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$_am_arg | $_am_arg:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
*)
install_sh="\${SHELL} $am_aux_dir/install-sh"
esac
fi
AC_SUBST([install_sh])])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it is modern enough.
# If it is, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --is-lightweight"; then
am_missing_run="$MISSING "
else
am_missing_run=
AC_MSG_WARN(['missing' script is too old or missing])
fi
])
# Helper functions for option handling. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# --------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
# _AM_SET_OPTIONS(OPTIONS)
# ------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_CC_C_O
# ---------------
# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
# to automatically call this.
AC_DEFUN([_AM_PROG_CC_C_O],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([compile])dnl
AC_LANG_PUSH([C])dnl
AC_CACHE_CHECK(
[whether $CC understands -c and -o together],
[am_cv_prog_cc_c_o],
[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
# Make sure it works both with $CC and with simple cc.
# Following AC_PROG_CC_C_O, we do the test twice because some
# compilers refuse to overwrite an existing .o file with -o,
# though they will create one.
am_cv_prog_cc_c_o=yes
for am_i in 1 2; do
if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
&& test -f conftest2.$ac_objext; then
: OK
else
am_cv_prog_cc_c_o=no
break
fi
done
rm -f core conftest*
unset am_i])
if test "$am_cv_prog_cc_c_o" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_RUN_LOG(COMMAND)
# -------------------
# Run COMMAND, save the exit status in ac_status, and log it.
# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
AC_DEFUN([AM_RUN_LOG],
[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
(exit $ac_status); }])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
*[[\\\"\#\$\&\'\`$am_lf]]*)
AC_MSG_ERROR([unsafe absolute working directory name]);;
esac
case $srcdir in
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
esac
# Do 'set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
am_has_slept=no
for am_try in 1 2; do
echo "timestamp, slept: $am_has_slept" > conftest.file
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t "$srcdir/configure" conftest.file`
fi
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
if test "$[2]" = conftest.file || test $am_try -eq 2; then
break
fi
# Just in case.
sleep 1
am_has_slept=yes
done
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT([yes])
# If we didn't sleep, we still need to ensure time stamps of config.status and
# generated files are strictly newer.
am_sleep_pid=
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
( sleep 1 ) &
am_sleep_pid=$!
fi
AC_CONFIG_COMMANDS_PRE(
[AC_MSG_CHECKING([that generated files are newer than configure])
if test -n "$am_sleep_pid"; then
# Hide warnings about reused PIDs.
wait $am_sleep_pid 2>/dev/null
fi
AC_MSG_RESULT([done])])
rm -f conftest.file
])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_SILENT_RULES([DEFAULT])
# --------------------------
# Enable less verbose build rules; with the default set to DEFAULT
# ("yes" being less verbose, "no" or empty being verbose).
AC_DEFUN([AM_SILENT_RULES],
[AC_ARG_ENABLE([silent-rules], [dnl
AS_HELP_STRING(
[--enable-silent-rules],
[less verbose build output (undo: "make V=1")])
AS_HELP_STRING(
[--disable-silent-rules],
[verbose build output (undo: "make V=0")])dnl
])
case $enable_silent_rules in @%:@ (((
yes) AM_DEFAULT_VERBOSITY=0;;
no) AM_DEFAULT_VERBOSITY=1;;
*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
esac
dnl
dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
dnl do not support nested variable expansions.
dnl See automake bug#9928 and bug#10237.
am_make=${MAKE-make}
AC_CACHE_CHECK([whether $am_make supports nested variables],
[am_cv_make_support_nested_variables],
[if AS_ECHO([['TRUE=$(BAR$(V))
BAR0=false
BAR1=true
V=1
am__doit:
@$(TRUE)
.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
am_cv_make_support_nested_variables=yes
else
am_cv_make_support_nested_variables=no
fi])
if test $am_cv_make_support_nested_variables = yes; then
dnl Using '$V' instead of '$(V)' breaks IRIX make.
AM_V='$(V)'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
else
AM_V=$AM_DEFAULT_VERBOSITY
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
fi
AC_SUBST([AM_V])dnl
AM_SUBST_NOTMAKE([AM_V])dnl
AC_SUBST([AM_DEFAULT_V])dnl
AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
AM_BACKSLASH='\'
AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor 'install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in "make install-strip", and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using 'strip' when the user
# run "make install-strip". However 'strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the 'STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# --------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of 'v7', 'ustar', or 'pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
#
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AC_SUBST([AMTAR], ['$${TAR-tar}'])
# We'll loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
m4_if([$1], [v7],
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
[m4_case([$1],
[ustar],
[# The POSIX 1988 'ustar' format is defined with fixed-size fields.
# There is notably a 21 bits limit for the UID and the GID. In fact,
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
# and bug#13588).
am_max_uid=2097151 # 2^21 - 1
am_max_gid=$am_max_uid
# The $UID and $GID variables are not portable, so we need to resort
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
# below are definitely unexpected, so allow the users to see them
# (that is, avoid stderr redirection).
am_uid=`id -u || echo unknown`
am_gid=`id -g || echo unknown`
AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
if test $am_uid -le $am_max_uid; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
_am_tools=none
fi
AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
if test $am_gid -le $am_max_gid; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
_am_tools=none
fi],
[pax],
[],
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Go ahead even if we have the value already cached. We do so because we
# need to set the values for the 'am__tar' and 'am__untar' variables.
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
for _am_tool in $_am_tools; do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar; do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works.
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
AM_RUN_LOG([cat conftest.dir/file])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
# iconv.m4 serial 18 (gettext-0.18.2)
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([iconv])
])
AC_DEFUN([AM_ICONV_LINK],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first
dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdlib.h>
#include <iconv.h>
]],
[[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);]])],
[am_cv_func_iconv=yes])
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS $LIBICONV"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdlib.h>
#include <iconv.h>
]],
[[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);]])],
[am_cv_lib_iconv=yes]
[am_cv_func_iconv=yes])
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
dnl Solaris 10.
am_save_LIBS="$LIBS"
if test $am_cv_lib_iconv = yes; then
LIBS="$LIBS $LIBICONV"
fi
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <iconv.h>
#include <string.h>
int main ()
{
int result = 0;
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
returns. */
{
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
if (cd_utf8_to_88591 != (iconv_t)(-1))
{
static const char input[] = "\342\202\254"; /* EURO SIGN */
char buf[10];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
result |= 1;
iconv_close (cd_utf8_to_88591);
}
}
/* Test against Solaris 10 bug: Failures are not distinguishable from
successful returns. */
{
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
if (cd_ascii_to_88591 != (iconv_t)(-1))
{
static const char input[] = "\263";
char buf[10];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_ascii_to_88591,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res == 0)
result |= 2;
iconv_close (cd_ascii_to_88591);
}
}
/* Test against AIX 6.1..7.1 bug: Buffer overrun. */
{
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
static const char input[] = "\304";
static char buf[2] = { (char)0xDE, (char)0xAD };
const char *inptr = input;
size_t inbytesleft = 1;
char *outptr = buf;
size_t outbytesleft = 1;
size_t res = iconv (cd_88591_to_utf8,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
result |= 4;
iconv_close (cd_88591_to_utf8);
}
}
#if 0 /* This bug could be worked around by the caller. */
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
{
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
if (cd_88591_to_utf8 != (iconv_t)(-1))
{
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
char buf[50];
const char *inptr = input;
size_t inbytesleft = strlen (input);
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_88591_to_utf8,
(char **) &inptr, &inbytesleft,
&outptr, &outbytesleft);
if ((int)res > 0)
result |= 8;
iconv_close (cd_88591_to_utf8);
}
}
#endif
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
if (/* Try standardized names. */
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
/* Try IRIX, OSF/1 names. */
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
/* Try AIX names. */
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
/* Try HP-UX names. */
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
result |= 16;
return result;
}]])],
[am_cv_func_iconv_works=yes],
[am_cv_func_iconv_works=no],
[
changequote(,)dnl
case "$host_os" in
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
*) am_cv_func_iconv_works="guessing yes" ;;
esac
changequote([,])dnl
])
LIBS="$am_save_LIBS"
])
case "$am_cv_func_iconv_works" in
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
*) am_func_iconv=yes ;;
esac
else
am_func_iconv=no am_cv_lib_iconv=no
fi
if test "$am_func_iconv" = yes; then
AC_DEFINE([HAVE_ICONV], [1],
[Define if you have the iconv() function and it works.])
fi
if test "$am_cv_lib_iconv" = yes; then
AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV])
else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV=
LTLIBICONV=
fi
AC_SUBST([LIBICONV])
AC_SUBST([LTLIBICONV])
])
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
dnl avoid warnings like
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
dnl This is tricky because of the way 'aclocal' is implemented:
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
dnl warnings.
m4_define([gl_iconv_AC_DEFUN],
m4_version_prereq([2.64],
[[AC_DEFUN_ONCE(
[$1], [$2])]],
[m4_ifdef([gl_00GNULIB],
[[AC_DEFUN_ONCE(
[$1], [$2])]],
[[AC_DEFUN(
[$1], [$2])]])]))
gl_iconv_AC_DEFUN([AM_ICONV],
[
AM_ICONV_LINK
if test "$am_cv_func_iconv" = yes; then
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL([am_cv_proto_iconv], [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
]],
[[]])],
[am_cv_proto_iconv_arg1=""],
[am_cv_proto_iconv_arg1="const"])
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([
$am_cv_proto_iconv])
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
[Define as const if the declaration of iconv() needs const.])
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
m4_ifdef([gl_ICONV_H_DEFAULTS],
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
if test -n "$am_cv_proto_iconv_arg1"; then
ICONV_CONST="const"
fi
])
fi
])
# lib-ld.m4 serial 6
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Subroutines of libtool.m4,
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
dnl collision with libtool.m4.
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
AC_DEFUN([AC_LIB_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
case `$LD -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
acl_cv_prog_gnu_ld=yes
;;
*)
acl_cv_prog_gnu_ld=no
;;
esac])
with_gnu_ld=$acl_cv_prog_gnu_ld
])
dnl From libtool-2.4. Sets the variable LD.
AC_DEFUN([AC_LIB_PROG_LD],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_ARG_WITH([gnu-ld],
[AS_HELP_STRING([--with-gnu-ld],
[assume the C compiler uses GNU ld [default=no]])],
[test "$withval" = no || with_gnu_ld=yes],
[with_gnu_ld=no])dnl
# Prepare PATH_SEPARATOR.
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
# Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
# contains only /bin. Note that ksh looks also at the FPATH variable,
# so we have to set that as well for the test.
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
&& { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|| PATH_SEPARATOR=';'
}
fi
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by $CC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]]* | ?:[[\\/]]*)
re_direlt='/[[^/]][[^/]]*/\.\./'
# Canonicalize the pathname of ld
ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL([acl_cv_path_LD],
[if test -z "$LD"; then
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
for ac_dir in $PATH; do
IFS="$acl_save_ifs"
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
acl_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some variants of GNU ld only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break
;;
*)
test "$with_gnu_ld" != yes && break
;;
esac
fi
done
IFS="$acl_save_ifs"
else
acl_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$acl_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT([$LD])
else
AC_MSG_RESULT([no])
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_LIB_PROG_LD_GNU
])
# lib-link.m4 serial 26 (gettext-0.18.2)
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_PREREQ([2.54])
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
dnl augments the CPPFLAGS variable.
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
pushdef([Name],[m4_translit([$1],[./+-], [____])])
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
AC_LIB_LINKFLAGS_BODY([$1], [$2])
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
])
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
AC_SUBST([LIB]NAME[_PREFIX])
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
dnl results of this search when this library appears as a dependency.
HAVE_LIB[]NAME=yes
popdef([NAME])
popdef([Name])
])
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
dnl searches for libname and the libraries corresponding to explicit and
dnl implicit dependencies, together with the specified include files and
dnl the ability to compile and link the specified testcode. The missing-message
dnl defaults to 'no' and may contain additional hints for the user.
dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
pushdef([Name],[m4_translit([$1],[./+-], [____])])
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([$1], [$2])
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
dnl because if the user has installed lib[]Name and not disabled its use
dnl via --without-lib[]Name-prefix, he wants to use it.
ac_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
dnl because these -l options might require -L options that are present in
dnl LIBS. -l options benefit only from the -L options listed before it.
dnl Otherwise, add it to the front of LIBS, because it may be a static
dnl library that depends on another static library that is present in LIBS.
dnl Static libraries benefit only from the static libraries listed after
dnl it.
case " $LIB[]NAME" in
*" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
*) LIBS="$LIB[]NAME $LIBS" ;;
esac
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[$3]], [[$4]])],
[ac_cv_lib[]Name=yes],
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
LIBS="$ac_save_LIBS"
])
if test "$ac_cv_lib[]Name" = yes; then
HAVE_LIB[]NAME=yes
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
AC_MSG_CHECKING([how to link with lib[]$1])
AC_MSG_RESULT([$LIB[]NAME])
else
HAVE_LIB[]NAME=no
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
dnl $INC[]NAME either.
CPPFLAGS="$ac_save_CPPFLAGS"
LIB[]NAME=
LTLIB[]NAME=
LIB[]NAME[]_PREFIX=
fi
AC_SUBST([HAVE_LIB]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
AC_SUBST([LIB]NAME[_PREFIX])
popdef([NAME])
popdef([Name])
])
dnl Determine the platform dependent parameters needed to use rpath:
dnl acl_libext,
dnl acl_shlibext,
dnl acl_libname_spec,
dnl acl_library_names_spec,
dnl acl_hardcode_libdir_flag_spec,
dnl acl_hardcode_libdir_separator,
dnl acl_hardcode_direct,
dnl acl_hardcode_minus_L.
AC_DEFUN([AC_LIB_RPATH],
[
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
. ./conftest.sh
rm -f ./conftest.sh
acl_cv_rpath=done
])
wl="$acl_cv_wl"
acl_libext="$acl_cv_libext"
acl_shlibext="$acl_cv_shlibext"
acl_libname_spec="$acl_cv_libname_spec"
acl_library_names_spec="$acl_cv_library_names_spec"
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
acl_hardcode_direct="$acl_cv_hardcode_direct"
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
dnl Determine whether the user wants rpath handling at all.
AC_ARG_ENABLE([rpath],
[ --disable-rpath do not hardcode runtime library paths],
:, enable_rpath=yes)
])
dnl AC_LIB_FROMPACKAGE(name, package)
dnl declares that libname comes from the given package. The configure file
dnl will then not have a --with-libname-prefix option but a
dnl --with-package-prefix option. Several libraries can come from the same
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
dnl macro call that searches for libname.
AC_DEFUN([AC_LIB_FROMPACKAGE],
[
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
define([acl_frompackage_]NAME, [$2])
popdef([NAME])
pushdef([PACK],[$2])
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
define([acl_libsinpackage_]PACKUP,
m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
popdef([PACKUP])
popdef([PACK])
])
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
[
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
dnl Autoconf >= 2.61 supports dots in --with options.
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH(P_A_C_K[-prefix],
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
if test "$acl_libdirstem2" != "$acl_libdirstem" \
&& ! test -d "$withval/$acl_libdirstem"; then
additional_libdir="$withval/$acl_libdirstem2"
fi
fi
fi
])
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
LTLIB[]NAME=
INC[]NAME=
LIB[]NAME[]_PREFIX=
dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
dnl computed. So it has to be reset here.
HAVE_LIB[]NAME=
rpathdirs=
ltrpathdirs=
names_already_handled=
names_next_round='$1 $2'
while test -n "$names_next_round"; do
names_this_round="$names_next_round"
names_next_round=
for name in $names_this_round; do
already_handled=
for n in $names_already_handled; do
if test "$n" = "$name"; then
already_handled=yes
break
fi
done
if test -z "$already_handled"; then
names_already_handled="$names_already_handled $name"
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
dnl or AC_LIB_HAVE_LINKFLAGS call.
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
eval value=\"\$HAVE_LIB$uppername\"
if test -n "$value"; then
if test "$value" = yes; then
eval value=\"\$LIB$uppername\"
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
eval value=\"\$LTLIB$uppername\"
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
else
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
dnl that this library doesn't exist. So just drop it.
:
fi
else
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
dnl and the already constructed $LIBNAME/$LTLIBNAME.
found_dir=
found_la=
found_so=
found_a=
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
if test -n "$acl_shlibext"; then
shrext=".$acl_shlibext" # typically: shrext=.so
else
shrext=
fi
if test $use_additional = yes; then
dir="$additional_libdir"
dnl The same code as in the loop below:
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
if test -f "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
ver=`(cd "$dir" && \
for f in "$libname$shrext".*; do echo "$f"; done \
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
if test -f "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
fi
done
fi
fi
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
if test -f "$dir/$libname.$acl_libext"; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
fi
if test "X$found_dir" != "X"; then
if test -f "$dir/$libname.la"; then
found_la="$dir/$libname.la"
fi
fi
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
if test -f "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
ver=`(cd "$dir" && \
for f in "$libname$shrext".*; do echo "$f"; done \
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
if test -f "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
fi
done
fi
fi
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
if test -f "$dir/$libname.$acl_libext"; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
fi
if test "X$found_dir" != "X"; then
if test -f "$dir/$libname.la"; then
found_la="$dir/$libname.la"
fi
fi
;;
esac
if test "X$found_dir" != "X"; then
break
fi
done
fi
if test "X$found_dir" != "X"; then
dnl Found the library.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
if test "X$found_so" != "X"; then
dnl Linking with a shared library. We attempt to hardcode its
dnl directory into the executable's runpath, unless it's the
dnl standard /usr/lib.
if test "$enable_rpath" = no \
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $found_dir"
fi
dnl The hardcoding into $LIBNAME is system dependent.
if test "$acl_hardcode_direct" = yes; then
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
dnl resulting binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $found_dir"
fi
else
dnl Rely on "-L$found_dir".
dnl But don't add it if it's already contained in the LDFLAGS
dnl or the already constructed $LIBNAME
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
fi
if test "$acl_hardcode_minus_L" != no; then
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
dnl here, because this doesn't fit in flags passed to the
dnl compiler. So give up. No hardcoding. This affects only
dnl very old systems.
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
fi
fi
fi
fi
else
if test "X$found_a" != "X"; then
dnl Linking with a static library.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
else
dnl We shouldn't come here, but anyway it's good to have a
dnl fallback.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
fi
fi
dnl Assume the include files are nearby.
additional_includedir=
case "$found_dir" in
*/$acl_libdirstem | */$acl_libdirstem/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
if test "$name" = '$1'; then
LIB[]NAME[]_PREFIX="$basedir"
fi
additional_includedir="$basedir/include"
;;
*/$acl_libdirstem2 | */$acl_libdirstem2/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
if test "$name" = '$1'; then
LIB[]NAME[]_PREFIX="$basedir"
fi
additional_includedir="$basedir/include"
;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
dnl 3. if it's already present in $CPPFLAGS or the already
dnl constructed $INCNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
for x in $CPPFLAGS $INC[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $INCNAME.
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
fi
fi
fi
fi
fi
dnl Look for dependencies.
if test -n "$found_la"; then
dnl Read the .la file. It defines the variables
dnl dlname, library_names, old_library, dependency_libs, current,
dnl age, revision, installed, dlopen, dlpreopen, libdir.
save_libdir="$libdir"
case "$found_la" in
*/* | *\\*) . "$found_la" ;;
*) . "./$found_la" ;;
esac
libdir="$save_libdir"
dnl We use only dependency_libs.
for dep in $dependency_libs; do
case "$dep" in
-L*)
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
haveit=
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LIBNAME.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LTLIBNAME.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
fi
fi
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
if test "$enable_rpath" != no; then
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
dnl directory; it is already contained in a preceding -L
dnl option.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
;;
*)
dnl Most likely an immediate library name.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
;;
esac
done
fi
else
dnl Didn't find the library; assume it is in the system directories
dnl known to the linker and runtime loader. (All the system
dnl directories known to the linker should also be known to the
dnl runtime loader, otherwise the system is severely misconfigured.)
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
fi
fi
fi
done
done
if test "X$rpathdirs" != "X"; then
if test -n "$acl_hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user must
dnl pass all path elements in one option. We can arrange that for a
dnl single library, but not when more than one $LIBNAMEs are used.
alldirs=
for found_dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
done
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
else
dnl The -rpath options are cumulative.
for found_dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$found_dir"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
done
fi
fi
if test "X$ltrpathdirs" != "X"; then
dnl When using libtool, the option that works for both libraries and
dnl executables is -R. The -R options are cumulative.
for found_dir in $ltrpathdirs; do
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
done
fi
popdef([P_A_C_K])
popdef([PACKLIBS])
popdef([PACKUP])
popdef([PACK])
popdef([NAME])
])
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
dnl unless already present in VAR.
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
dnl contains two or three consecutive elements that belong together.
AC_DEFUN([AC_LIB_APPENDTOVAR],
[
for element in [$2]; do
haveit=
for x in $[$1]; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X$element"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
[$1]="${[$1]}${[$1]:+ }$element"
fi
done
])
dnl For those cases where a variable contains several -L and -l options
dnl referring to unknown libraries and directories, this macro determines the
dnl necessary additional linker options for the runtime path.
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
dnl otherwise linking without libtool is assumed.
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
[
AC_REQUIRE([AC_LIB_RPATH])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
$1=
if test "$enable_rpath" != no; then
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode directories into the resulting
dnl binary.
rpathdirs=
next=
for opt in $2; do
if test -n "$next"; then
dir="$next"
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem" \
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
rpathdirs="$rpathdirs $dir"
fi
next=
else
case $opt in
-L) next=yes ;;
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem" \
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
rpathdirs="$rpathdirs $dir"
fi
next= ;;
*) next= ;;
esac
fi
done
if test "X$rpathdirs" != "X"; then
if test -n ""$3""; then
dnl libtool is used for linking. Use -R options.
for dir in $rpathdirs; do
$1="${$1}${$1:+ }-R$dir"
done
else
dnl The linker is used for linking directly.
if test -n "$acl_hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user
dnl must pass all path elements in one option.
alldirs=
for dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
done
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
$1="$flag"
else
dnl The -rpath options are cumulative.
for dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$dir"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
$1="${$1}${$1:+ }$flag"
done
fi
fi
fi
fi
fi
AC_SUBST([$1])
])
# lib-prefix.m4 serial 7 (gettext-0.18)
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
dnl require excessive bracketing.
ifdef([AC_HELP_STRING],
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_LIB_ARG_WITH([lib-prefix],
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_save_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
acl_save_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
])
dnl AC_LIB_PREPARE_MULTILIB creates
dnl - a variable acl_libdirstem, containing the basename of the libdir, either
dnl "lib" or "lib64" or "lib/64",
dnl - a variable acl_libdirstem2, as a secondary possible value for
dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
dnl "lib/amd64".
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
[
dnl There is no formal standard regarding lib and lib64.
dnl On glibc systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
dnl the compiler's default mode by looking at the compiler's library search
dnl path. If at least one of its elements ends in /lib64 or points to a
dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
dnl Otherwise we use the default, namely "lib".
dnl On Solaris systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
AC_REQUIRE([AC_CANONICAL_HOST])
acl_libdirstem=lib
acl_libdirstem2=
case "$host_os" in
solaris*)
dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
dnl <path_to_url
dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
dnl symlink is missing, so we set acl_libdirstem2 too.
AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
[AC_EGREP_CPP([sixtyfour bits], [
#ifdef _LP64
sixtyfour bits
#endif
], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
])
if test $gl_cv_solaris_64bit = yes; then
acl_libdirstem=lib/64
case "$host_cpu" in
sparc*) acl_libdirstem2=lib/sparcv9 ;;
i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
esac
fi
;;
*)
searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
if test -n "$searchpath"; then
acl_save_IFS="${IFS= }"; IFS=":"
for searchdir in $searchpath; do
if test -d "$searchdir"; then
case "$searchdir" in
*/lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
*/../ | */.. )
# Better ignore directories of this form. They are misleading.
;;
*) searchdir=`cd "$searchdir" && pwd`
case "$searchdir" in
*/lib64 ) acl_libdirstem=lib64 ;;
esac ;;
esac
fi
done
IFS="$acl_save_IFS"
fi
;;
esac
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
])
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
#
# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# Written by Gordon Matzigkeit, 1996
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
m4_define([_LT_COPYING], [dnl
# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# Written by Gordon Matzigkeit, 1996
#
# This file is part of GNU Libtool.
#
# GNU Libtool is free software; you can redistribute it and/or
# published by the Free Software Foundation; either version 2 of
#
# if you distribute this file as part of a program or library that
# is built using GNU Libtool, you may include this file under the
# same distribution terms that you use for the rest of that program.
#
# GNU Libtool 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
#
# along with GNU Libtool; see the file COPYING. If not, a copy
# can be downloaded from path_to_url or
# obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
])
# serial 57 LT_INIT
# LT_PREREQ(VERSION)
# ------------------
# Complain and exit if this libtool version is less that VERSION.
m4_defun([LT_PREREQ],
[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
[m4_default([$3],
[m4_fatal([Libtool version $1 or higher is required],
63)])],
[$2])])
# _LT_CHECK_BUILDDIR
# ------------------
# Complain if the absolute build directory name contains unusual characters
m4_defun([_LT_CHECK_BUILDDIR],
[case `pwd` in
*\ * | *\ *)
AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
esac
])
# LT_INIT([OPTIONS])
# ------------------
AC_DEFUN([LT_INIT],
[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
AC_BEFORE([$0], [LT_LANG])dnl
AC_BEFORE([$0], [LT_OUTPUT])dnl
AC_BEFORE([$0], [LTDL_INIT])dnl
m4_require([_LT_CHECK_BUILDDIR])dnl
dnl Autoconf doesn't catch unexpanded LT_ macros by default:
m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
dnl unless we require an AC_DEFUNed macro:
AC_REQUIRE([LTOPTIONS_VERSION])dnl
AC_REQUIRE([LTSUGAR_VERSION])dnl
AC_REQUIRE([LTVERSION_VERSION])dnl
AC_REQUIRE([LTOBSOLETE_VERSION])dnl
m4_require([_LT_PROG_LTMAIN])dnl
_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
dnl Parse OPTIONS
_LT_SET_OPTIONS([$0], [$1])
# This can be used to rebuild libtool when needed
LIBTOOL_DEPS="$ltmain"
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
AC_SUBST(LIBTOOL)dnl
_LT_SETUP
# Only expand once:
m4_define([LT_INIT])
])# LT_INIT
# Old names:
AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
# _LT_CC_BASENAME(CC)
# -------------------
# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
m4_defun([_LT_CC_BASENAME],
[for cc_temp in $1""; do
case $cc_temp in
compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
])
# _LT_FILEUTILS_DEFAULTS
# ----------------------
# It is okay to use these file commands and assume they have been set
# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
m4_defun([_LT_FILEUTILS_DEFAULTS],
[: ${CP="cp -f"}
: ${MV="mv -f"}
: ${RM="rm -f"}
])# _LT_FILEUTILS_DEFAULTS
# _LT_SETUP
# ---------
m4_defun([_LT_SETUP],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
dnl
_LT_DECL([], [host_alias], [0], [The host system])dnl
_LT_DECL([], [host], [0])dnl
_LT_DECL([], [host_os], [0])dnl
dnl
_LT_DECL([], [build_alias], [0], [The build system])dnl
_LT_DECL([], [build], [0])dnl
_LT_DECL([], [build_os], [0])dnl
dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([LT_PATH_LD])dnl
AC_REQUIRE([LT_PATH_NM])dnl
dnl
AC_REQUIRE([AC_PROG_LN_S])dnl
test -z "$LN_S" && LN_S="ln -s"
_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
dnl
AC_REQUIRE([LT_CMD_MAX_LEN])dnl
_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_CHECK_SHELL_FEATURES])dnl
m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
m4_require([_LT_CMD_RELOAD])dnl
m4_require([_LT_CHECK_MAGIC_METHOD])dnl
m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
m4_require([_LT_CMD_OLD_ARCHIVE])dnl
m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
m4_require([_LT_WITH_SYSROOT])dnl
_LT_CONFIG_LIBTOOL_INIT([
# See if we are running on zsh, and set the options which allow our
# commands through without removal of \ escapes INIT.
if test -n "\${ZSH_VERSION+set}" ; then
setopt NO_GLOB_SUBST
fi
])
if test -n "${ZSH_VERSION+set}" ; then
setopt NO_GLOB_SUBST
fi
_LT_CHECK_OBJDIR
m4_require([_LT_TAG_COMPILER])dnl
case $host_os in
aix3*)
# AIX sometimes has problems with the GCC collect2 program. For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
if test "X${COLLECT_NAMES+set}" != Xset; then
COLLECT_NAMES=
export COLLECT_NAMES
fi
;;
esac
# Global variables:
ofile=libtool
can_build_shared=yes
# All known linkers require a `.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
with_gnu_ld="$lt_cv_prog_gnu_ld"
old_CC="$CC"
old_CFLAGS="$CFLAGS"
# Set sane defaults for various variables
test -z "$CC" && CC=cc
test -z "$LTCC" && LTCC=$CC
test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
test -z "$LD" && LD=ld
test -z "$ac_objext" && ac_objext=o
_LT_CC_BASENAME([$compiler])
# Only perform the check for file, if the check method requires it
test -z "$MAGIC_CMD" && MAGIC_CMD=file
case $deplibs_check_method in
file_magic*)
if test "$file_magic_cmd" = '$MAGIC_CMD'; then
_LT_PATH_MAGIC
fi
;;
esac
# Use C for the default configuration in the libtool script
LT_SUPPORTED_TAG([CC])
_LT_LANG_C_CONFIG
_LT_LANG_DEFAULT_CONFIG
_LT_CONFIG_COMMANDS
])# _LT_SETUP
# _LT_PREPARE_SED_QUOTE_VARS
# --------------------------
# Define a few sed substitution that help us do robust quoting.
m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
[# Backslashify metacharacters that are still active within
# double-quoted strings.
sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
# Same as above, but do not quote variable references.
double_quote_subst='s/\([["`\\]]\)/\\\1/g'
# Sed substitution to delay expansion of an escaped shell variable in a
# double_quote_subst'ed string.
delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
# Sed substitution to delay expansion of an escaped single quote.
delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
# Sed substitution to avoid accidental globbing in evaled expressions
no_glob_subst='s/\*/\\\*/g'
])
# _LT_PROG_LTMAIN
# ---------------
# Note that this code is called both from `configure', and `config.status'
# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
# `config.status' has no value for ac_aux_dir unless we are using Automake,
# so we pass a copy along to make sure it has a sensible value anyway.
m4_defun([_LT_PROG_LTMAIN],
[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
ltmain="$ac_aux_dir/ltmain.sh"
])# _LT_PROG_LTMAIN
# So that we can recreate a full libtool script including additional
# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
# in macros and then make a single call at the end using the `libtool'
# label.
# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
# ----------------------------------------
# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
m4_define([_LT_CONFIG_LIBTOOL_INIT],
[m4_ifval([$1],
[m4_append([_LT_OUTPUT_LIBTOOL_INIT],
[$1
])])])
# Initialize.
m4_define([_LT_OUTPUT_LIBTOOL_INIT])
# _LT_CONFIG_LIBTOOL([COMMANDS])
# ------------------------------
# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
m4_define([_LT_CONFIG_LIBTOOL],
[m4_ifval([$1],
[m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
[$1
])])])
# Initialize.
m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
# -----------------------------------------------------
m4_defun([_LT_CONFIG_SAVE_COMMANDS],
[_LT_CONFIG_LIBTOOL([$1])
_LT_CONFIG_LIBTOOL_INIT([$2])
])
# _LT_FORMAT_COMMENT([COMMENT])
# -----------------------------
# Add leading comment marks to the start of each line, and a trailing
# full-stop to the whole comment if one is not present already.
m4_define([_LT_FORMAT_COMMENT],
[m4_ifval([$1], [
m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
[['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
)])
# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
# your_sha256_hash---
# CONFIGNAME is the name given to the value in the libtool script.
# VARNAME is the (base) name used in the configure script.
# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
# VARNAME. Any other value will be used directly.
m4_define([_LT_DECL],
[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
[lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
[m4_ifval([$1], [$1], [$2])])
lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
m4_ifval([$4],
[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
lt_dict_add_subkey([lt_decl_dict], [$2],
[tagged?], [m4_ifval([$5], [yes], [no])])])
])
# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
# --------------------------------------------------------
m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
# ------------------------------------------------
m4_define([lt_decl_tag_varnames],
[_lt_decl_filter([tagged?], [yes], $@)])
# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
# ---------------------------------------------------------
m4_define([_lt_decl_filter],
[m4_case([$#],
[0], [m4_fatal([$0: too few arguments: $#])],
[1], [m4_fatal([$0: too few arguments: $#: $1])],
[2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
[3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
[lt_dict_filter([lt_decl_dict], $@)])[]dnl
])
# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
# --------------------------------------------------
m4_define([lt_decl_quote_varnames],
[_lt_decl_filter([value], [1], $@)])
# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
# ---------------------------------------------------
m4_define([lt_decl_dquote_varnames],
[_lt_decl_filter([value], [2], $@)])
# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
# ---------------------------------------------------
m4_define([lt_decl_varnames_tagged],
[m4_assert([$# <= 2])dnl
_$0(m4_quote(m4_default([$1], [[, ]])),
m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
m4_define([_lt_decl_varnames_tagged],
[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
# ------------------------------------------------
m4_define([lt_decl_all_varnames],
[_$0(m4_quote(m4_default([$1], [[, ]])),
m4_if([$2], [],
m4_quote(lt_decl_varnames),
m4_quote(m4_shift($@))))[]dnl
])
m4_define([_lt_decl_all_varnames],
[lt_join($@, lt_decl_varnames_tagged([$1],
lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
])
# _LT_CONFIG_STATUS_DECLARE([VARNAME])
# ------------------------------------
# Quote a variable value, and forward it to `config.status' so that its
# declaration there will have the same value as in `configure'. VARNAME
# must have a single quote delimited value for this to work.
m4_define([_LT_CONFIG_STATUS_DECLARE],
[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
# _LT_CONFIG_STATUS_DECLARATIONS
# ------------------------------
# We delimit libtool config variables with single quotes, so when
# we write them to config.status, we have to be sure to quote all
# embedded single quotes properly. In configure, this macro expands
# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
#
# <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
[m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
# _LT_LIBTOOL_TAGS
# ----------------
# Output comment and list of tags supported by the script
m4_defun([_LT_LIBTOOL_TAGS],
[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
available_tags="_LT_TAGS"dnl
])
# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
# -----------------------------------
# Extract the dictionary values for VARNAME (optionally with TAG) and
# expand to a commented shell variable setting:
#
# # Some comment about what VAR is for.
# visible_name=$lt_internal_name
m4_define([_LT_LIBTOOL_DECLARE],
[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
[description])))[]dnl
m4_pushdef([_libtool_name],
m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
[0], [_libtool_name=[$]$1],
[1], [_libtool_name=$lt_[]$1],
[2], [_libtool_name=$lt_[]$1],
[_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
])
# _LT_LIBTOOL_CONFIG_VARS
# -----------------------
# Produce commented declarations of non-tagged libtool config variables
# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
# section) are produced by _LT_LIBTOOL_TAG_VARS.
m4_defun([_LT_LIBTOOL_CONFIG_VARS],
[m4_foreach([_lt_var],
m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
[m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
# _LT_LIBTOOL_TAG_VARS(TAG)
# -------------------------
m4_define([_LT_LIBTOOL_TAG_VARS],
[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
[m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
# _LT_TAGVAR(VARNAME, [TAGNAME])
# ------------------------------
m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
# _LT_CONFIG_COMMANDS
# -------------------
# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
# variables for single and double quote escaping we saved from calls
# to _LT_DECL, we can put quote escaped variables declarations
# into `config.status', and then the shell code to quote escape them in
# for loops in `config.status'. Finally, any additional code accumulated
# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
m4_defun([_LT_CONFIG_COMMANDS],
[AC_PROVIDE_IFELSE([LT_OUTPUT],
dnl If the libtool generation code has been placed in $CONFIG_LT,
dnl instead of duplicating it all over again into config.status,
dnl then we will have config.status run $CONFIG_LT later, so it
dnl needs to know what name is stored there:
[AC_CONFIG_COMMANDS([libtool],
[$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
dnl If the libtool generation code is destined for config.status,
dnl expand the accumulated commands and init code now:
[AC_CONFIG_COMMANDS([libtool],
[_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
])#_LT_CONFIG_COMMANDS
# Initialize.
m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
[
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
sed_quote_subst='$sed_quote_subst'
double_quote_subst='$double_quote_subst'
delay_variable_subst='$delay_variable_subst'
_LT_CONFIG_STATUS_DECLARATIONS
LTCC='$LTCC'
LTCFLAGS='$LTCFLAGS'
compiler='$compiler_DEFAULT'
# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
eval 'cat <<_LTECHO_EOF
\$[]1
_LTECHO_EOF'
}
# Quote evaled strings.
for var in lt_decl_all_varnames([[ \
]], lt_decl_quote_varnames); do
case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
*[[\\\\\\\`\\"\\\$]]*)
eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
;;
*)
eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
;;
esac
done
# Double-quote double-evaled strings.
for var in lt_decl_all_varnames([[ \
]], lt_decl_dquote_varnames); do
case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
*[[\\\\\\\`\\"\\\$]]*)
eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
;;
*)
eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
;;
esac
done
_LT_OUTPUT_LIBTOOL_INIT
])
# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
# ------------------------------------
# Generate a child script FILE with all initialization necessary to
# reuse the environment learned by the parent script, and make the
# file executable. If COMMENT is supplied, it is inserted after the
# `#!' sequence but before initialization text begins. After this
# macro, additional text can be appended to FILE to form the body of
# the child script. The macro ends with non-zero status if the
# file could not be fully written (such as if the disk is full).
m4_ifdef([AS_INIT_GENERATED],
[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
[m4_defun([_LT_GENERATED_FILE_INIT],
[m4_require([AS_PREPARE])]dnl
[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
[lt_write_fail=0
cat >$1 <<_ASEOF || lt_write_fail=1
#! $SHELL
# Generated by $as_me.
$2
SHELL=\${CONFIG_SHELL-$SHELL}
export SHELL
_ASEOF
cat >>$1 <<\_ASEOF || lt_write_fail=1
AS_SHELL_SANITIZE
_AS_PREPARE
exec AS_MESSAGE_FD>&1
_ASEOF
test $lt_write_fail = 0 && chmod +x $1[]dnl
m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
# LT_OUTPUT
# ---------
# This macro allows early generation of the libtool script (before
# AC_OUTPUT is called), incase it is used in configure for compilation
# tests.
AC_DEFUN([LT_OUTPUT],
[: ${CONFIG_LT=./config.lt}
AC_MSG_NOTICE([creating $CONFIG_LT])
_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
[# Run this file to recreate a libtool stub with the current configuration.])
cat >>"$CONFIG_LT" <<\_LTEOF
lt_cl_silent=false
exec AS_MESSAGE_LOG_FD>>config.log
{
echo
AS_BOX([Running $as_me.])
} >&AS_MESSAGE_LOG_FD
lt_cl_help="\
\`$as_me' creates a local libtool stub from the current configuration,
for use in further configure time tests before the real libtool is
generated.
Usage: $[0] [[OPTIONS]]
-h, --help print this help, then exit
-V, --version print version number, then exit
-q, --quiet do not print progress messages
-d, --debug don't remove temporary files
Report bugs to <bug-libtool@gnu.org>."
lt_cl_version="\
m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
configured by $[0], generated by m4_PACKAGE_STRING.
This config.lt script is free software; the Free Software Foundation
gives unlimited permision to copy, distribute and modify it."
while test $[#] != 0
do
case $[1] in
--version | --v* | -V )
echo "$lt_cl_version"; exit 0 ;;
--help | --h* | -h )
echo "$lt_cl_help"; exit 0 ;;
--debug | --d* | -d )
debug=: ;;
--quiet | --q* | --silent | --s* | -q )
lt_cl_silent=: ;;
-*) AC_MSG_ERROR([unrecognized option: $[1]
Try \`$[0] --help' for more information.]) ;;
*) AC_MSG_ERROR([unrecognized argument: $[1]
Try \`$[0] --help' for more information.]) ;;
esac
shift
done
if $lt_cl_silent; then
exec AS_MESSAGE_FD>/dev/null
fi
_LTEOF
cat >>"$CONFIG_LT" <<_LTEOF
_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
_LTEOF
cat >>"$CONFIG_LT" <<\_LTEOF
AC_MSG_NOTICE([creating $ofile])
_LT_OUTPUT_LIBTOOL_COMMANDS
AS_EXIT(0)
_LTEOF
chmod +x "$CONFIG_LT"
# configure is writing to config.log, but config.lt does its own redirection,
# appending to config.log, which fails on DOS, as config.log is still kept
# open by configure. Here we exec the FD to /dev/null, effectively closing
# config.log, so it can be properly (re)opened and appended to by config.lt.
lt_cl_success=:
test "$silent" = yes &&
lt_config_lt_args="$lt_config_lt_args --quiet"
exec AS_MESSAGE_LOG_FD>/dev/null
$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
exec AS_MESSAGE_LOG_FD>>config.log
$lt_cl_success || AS_EXIT(1)
])# LT_OUTPUT
# _LT_CONFIG(TAG)
# ---------------
# If TAG is the built-in tag, create an initial libtool script with a
# default configuration from the untagged config vars. Otherwise add code
# to config.status for appending the configuration named by TAG from the
# matching tagged config vars.
m4_defun([_LT_CONFIG],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
_LT_CONFIG_SAVE_COMMANDS([
m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
m4_if(_LT_TAG, [C], [
# See if we are running on zsh, and set the options which allow our
# commands through without removal of \ escapes.
if test -n "${ZSH_VERSION+set}" ; then
setopt NO_GLOB_SUBST
fi
cfgfile="${ofile}T"
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
$RM "$cfgfile"
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
#
_LT_COPYING
_LT_LIBTOOL_TAGS
# ### BEGIN LIBTOOL CONFIG
_LT_LIBTOOL_CONFIG_VARS
_LT_LIBTOOL_TAG_VARS
# ### END LIBTOOL CONFIG
_LT_EOF
case $host_os in
aix3*)
cat <<\_LT_EOF >> "$cfgfile"
# AIX sometimes has problems with the GCC collect2 program. For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
if test "X${COLLECT_NAMES+set}" != Xset; then
COLLECT_NAMES=
export COLLECT_NAMES
fi
_LT_EOF
;;
esac
_LT_PROG_LTMAIN
# We use sed instead of cat because bash on DJGPP gets confused if
# if finds mixed CR/LF and LF-only lines. Since sed operates in
# text mode, it properly converts lines to CR/LF. This bash problem
# is reportedly fixed, but why not run on old versions too?
sed '$q' "$ltmain" >> "$cfgfile" \
|| (rm -f "$cfgfile"; exit 1)
_LT_PROG_REPLACE_SHELLFNS
mv -f "$cfgfile" "$ofile" ||
(rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
chmod +x "$ofile"
],
[cat <<_LT_EOF >> "$ofile"
dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
dnl in a comment (ie after a #).
# ### BEGIN LIBTOOL TAG CONFIG: $1
_LT_LIBTOOL_TAG_VARS(_LT_TAG)
# ### END LIBTOOL TAG CONFIG: $1
_LT_EOF
])dnl /m4_if
],
[m4_if([$1], [], [
PACKAGE='$PACKAGE'
VERSION='$VERSION'
TIMESTAMP='$TIMESTAMP'
RM='$RM'
ofile='$ofile'], [])
])dnl /_LT_CONFIG_SAVE_COMMANDS
])# _LT_CONFIG
# LT_SUPPORTED_TAG(TAG)
# ---------------------
# Trace this macro to discover what tags are supported by the libtool
# --tag option, using:
# autoconf --trace 'LT_SUPPORTED_TAG:$1'
AC_DEFUN([LT_SUPPORTED_TAG], [])
# C support is built-in for now
m4_define([_LT_LANG_C_enabled], [])
m4_define([_LT_TAGS], [])
# LT_LANG(LANG)
# -------------
# Enable libtool support for the given language if not already enabled.
AC_DEFUN([LT_LANG],
[AC_BEFORE([$0], [LT_OUTPUT])dnl
m4_case([$1],
[C], [_LT_LANG(C)],
[C++], [_LT_LANG(CXX)],
[Go], [_LT_LANG(GO)],
[Java], [_LT_LANG(GCJ)],
[Fortran 77], [_LT_LANG(F77)],
[Fortran], [_LT_LANG(FC)],
[Windows Resource], [_LT_LANG(RC)],
[m4_ifdef([_LT_LANG_]$1[_CONFIG],
[_LT_LANG($1)],
[m4_fatal([$0: unsupported language: "$1"])])])dnl
])# LT_LANG
# _LT_LANG(LANGNAME)
# ------------------
m4_defun([_LT_LANG],
[m4_ifdef([_LT_LANG_]$1[_enabled], [],
[LT_SUPPORTED_TAG([$1])dnl
m4_append([_LT_TAGS], [$1 ])dnl
m4_define([_LT_LANG_]$1[_enabled], [])dnl
_LT_LANG_$1_CONFIG($1)])dnl
])# _LT_LANG
m4_ifndef([AC_PROG_GO], [
# NOTE: This macro has been submitted for inclusion into #
# GNU Autoconf as AC_PROG_GO. When it is available in #
# a released version of Autoconf we should remove this #
# macro and use it instead. #
m4_defun([AC_PROG_GO],
[AC_LANG_PUSH(Go)dnl
AC_ARG_VAR([GOC], [Go compiler command])dnl
AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
_AC_ARG_VAR_LDFLAGS()dnl
AC_CHECK_TOOL(GOC, gccgo)
if test -z "$GOC"; then
if test -n "$ac_tool_prefix"; then
AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
fi
fi
if test -z "$GOC"; then
AC_CHECK_PROG(GOC, gccgo, gccgo, false)
fi
])#m4_defun
])#m4_ifndef
# _LT_LANG_DEFAULT_CONFIG
# -----------------------
m4_defun([_LT_LANG_DEFAULT_CONFIG],
[AC_PROVIDE_IFELSE([AC_PROG_CXX],
[LT_LANG(CXX)],
[m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
AC_PROVIDE_IFELSE([AC_PROG_F77],
[LT_LANG(F77)],
[m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
AC_PROVIDE_IFELSE([AC_PROG_FC],
[LT_LANG(FC)],
[m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
dnl pulling things in needlessly.
AC_PROVIDE_IFELSE([AC_PROG_GCJ],
[LT_LANG(GCJ)],
[AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
[LT_LANG(GCJ)],
[AC_PROVIDE_IFELSE([LT_PROG_GCJ],
[LT_LANG(GCJ)],
[m4_ifdef([AC_PROG_GCJ],
[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
m4_ifdef([A][M_PROG_GCJ],
[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
m4_ifdef([LT_PROG_GCJ],
[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
AC_PROVIDE_IFELSE([AC_PROG_GO],
[LT_LANG(GO)],
[m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
AC_PROVIDE_IFELSE([LT_PROG_RC],
[LT_LANG(RC)],
[m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
])# _LT_LANG_DEFAULT_CONFIG
# Obsolete macros:
AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
dnl AC_DEFUN([AC_LIBTOOL_F77], [])
dnl AC_DEFUN([AC_LIBTOOL_FC], [])
dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
dnl AC_DEFUN([AC_LIBTOOL_RC], [])
# _LT_TAG_COMPILER
# ----------------
m4_defun([_LT_TAG_COMPILER],
[AC_REQUIRE([AC_PROG_CC])dnl
_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
# If no C compiler was specified, use CC.
LTCC=${LTCC-"$CC"}
# If no C compiler flags were specified, use CFLAGS.
LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
# Allow CC to be a program name with arguments.
compiler=$CC
])# _LT_TAG_COMPILER
# _LT_COMPILER_BOILERPLATE
# ------------------------
# Check for compiler boilerplate output or warnings with
# the simple compiler test code.
m4_defun([_LT_COMPILER_BOILERPLATE],
[m4_require([_LT_DECL_SED])dnl
ac_outfile=conftest.$ac_objext
echo "$lt_simple_compile_test_code" >conftest.$ac_ext
eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
_lt_compiler_boilerplate=`cat conftest.err`
$RM conftest*
])# _LT_COMPILER_BOILERPLATE
# _LT_LINKER_BOILERPLATE
# ----------------------
# Check for linker boilerplate output or warnings with
# the simple link test code.
m4_defun([_LT_LINKER_BOILERPLATE],
[m4_require([_LT_DECL_SED])dnl
ac_outfile=conftest.$ac_objext
echo "$lt_simple_link_test_code" >conftest.$ac_ext
eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
_lt_linker_boilerplate=`cat conftest.err`
$RM -r conftest*
])# _LT_LINKER_BOILERPLATE
# _LT_REQUIRED_DARWIN_CHECKS
# -------------------------
m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
case $host_os in
rhapsody* | darwin*)
AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
AC_CHECK_TOOL([LIPO], [lipo], [:])
AC_CHECK_TOOL([OTOOL], [otool], [:])
AC_CHECK_TOOL([OTOOL64], [otool64], [:])
_LT_DECL([], [DSYMUTIL], [1],
[Tool to manipulate archived DWARF debug symbol files on Mac OS X])
_LT_DECL([], [NMEDIT], [1],
[Tool to change global to local symbols on Mac OS X])
_LT_DECL([], [LIPO], [1],
[Tool to manipulate fat objects and archives on Mac OS X])
_LT_DECL([], [OTOOL], [1],
[ldd/readelf like tool for Mach-O binaries on Mac OS X])
_LT_DECL([], [OTOOL64], [1],
[ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
[lt_cv_apple_cc_single_mod=no
if test -z "${LT_MULTI_MODULE}"; then
# By default we will add the -single_module flag. You can override
# by either setting the environment variable LT_MULTI_MODULE
# non-empty at configure time, or by adding -multi_module to the
# link flags.
rm -rf libconftest.dylib*
echo "int foo(void){return 1;}" > conftest.c
echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-dynamiclib -Wl,-single_module conftest.c 2>conftest.err
_lt_result=$?
# If there is a non-empty error log, and "single_module"
# appears in it, assume the flag caused a linker warning
if test -s conftest.err && $GREP single_module conftest.err; then
cat conftest.err >&AS_MESSAGE_LOG_FD
# Otherwise, if the output was created with a 0 exit code from
# the compiler, it worked.
elif test -f libconftest.dylib && test $_lt_result -eq 0; then
lt_cv_apple_cc_single_mod=yes
else
cat conftest.err >&AS_MESSAGE_LOG_FD
fi
rm -rf libconftest.dylib*
rm -f conftest.*
fi])
AC_CACHE_CHECK([for -exported_symbols_list linker flag],
[lt_cv_ld_exported_symbols_list],
[lt_cv_ld_exported_symbols_list=no
save_LDFLAGS=$LDFLAGS
echo "_main" > conftest.sym
LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[lt_cv_ld_exported_symbols_list=yes],
[lt_cv_ld_exported_symbols_list=no])
LDFLAGS="$save_LDFLAGS"
])
AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
[lt_cv_ld_force_load=no
cat > conftest.c << _LT_EOF
int forced_loaded() { return 2;}
_LT_EOF
echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
$LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
$AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
$RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
cat > conftest.c << _LT_EOF
int main() { return 0;}
_LT_EOF
echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
_lt_result=$?
if test -s conftest.err && $GREP force_load conftest.err; then
cat conftest.err >&AS_MESSAGE_LOG_FD
elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
lt_cv_ld_force_load=yes
else
cat conftest.err >&AS_MESSAGE_LOG_FD
fi
rm -f conftest.err libconftest.a conftest conftest.c
rm -rf conftest.dSYM
])
case $host_os in
rhapsody* | darwin1.[[012]])
_lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
darwin1.*)
_lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
darwin*) # darwin 5.x on
# if running on 10.5 or later, the deployment target defaults
# to the OS version, if on x86, and 10.4, the deployment
# target defaults to 10.4. Don't you love it?
case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
_lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
10.[[012]]*)
_lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
10.*)
_lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
esac
;;
esac
if test "$lt_cv_apple_cc_single_mod" = "yes"; then
_lt_dar_single_mod='$single_module'
fi
if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
_lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
else
_lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
fi
if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
_lt_dsymutil='~$DSYMUTIL $lib || :'
else
_lt_dsymutil=
fi
;;
esac
])
# _LT_DARWIN_LINKER_FEATURES([TAG])
# ---------------------------------
# Checks for linker and compiler features on darwin
m4_defun([_LT_DARWIN_LINKER_FEATURES],
[
m4_require([_LT_REQUIRED_DARWIN_CHECKS])
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
if test "$lt_cv_ld_force_load" = "yes"; then
_LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
[FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes])
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=''
fi
_LT_TAGVAR(link_all_deplibs, $1)=yes
_LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
case $cc_basename in
ifort*) _lt_dar_can_shared=yes ;;
*) _lt_dar_can_shared=$GCC ;;
esac
if test "$_lt_dar_can_shared" = "yes"; then
output_verbose_link_cmd=func_echo_all
_LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
_LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
_LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
_LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
m4_if([$1], [CXX],
[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
_LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
_LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
fi
],[])
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
])
# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
# ----------------------------------
# Links a minimal program and checks the executable
# for the system default hardcoded library path. In most cases,
# this is /usr/lib:/lib, but when the MPI compilers are used
# the location of the communication and MPI libs are included too.
# If we don't find anything, use the default library path according
# to the aix ld manual.
# Store the results from the different compilers for each TAGNAME.
# Allow to override them for all tags through lt_cv_aix_libpath.
m4_defun([_LT_SYS_MODULE_PATH_AIX],
[m4_require([_LT_DECL_SED])dnl
if test "${lt_cv_aix_libpath+set}" = set; then
aix_libpath=$lt_cv_aix_libpath
else
AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
[AC_LINK_IFELSE([AC_LANG_PROGRAM],[
lt_aix_libpath_sed='[
/Import File Strings/,/^$/ {
/^0/ {
s/^0 *\([^ ]*\) *$/\1/
p
}
}]'
_LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
# Check for a 64-bit object if we didn't find anything.
if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
_LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
fi],[])
if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
_LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
fi
])
aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
fi
])# _LT_SYS_MODULE_PATH_AIX
# _LT_SHELL_INIT(ARG)
# -------------------
m4_define([_LT_SHELL_INIT],
[m4_divert_text([M4SH-INIT], [$1
])])# _LT_SHELL_INIT
# _LT_PROG_ECHO_BACKSLASH
# -----------------------
# Find how we can fake an echo command that does not interpret backslash.
# In particular, with Autoconf 2.60 or later we add some code to the start
# of the generated configure script which will find a shell with a builtin
# printf (which we can use as an echo command).
m4_defun([_LT_PROG_ECHO_BACKSLASH],
[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
AC_MSG_CHECKING([how to print strings])
# Test print first, because it will be a builtin if present.
if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
ECHO='print -r --'
elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
ECHO='printf %s\n'
else
# Use this function as a fallback that always works.
func_fallback_echo ()
{
eval 'cat <<_LTECHO_EOF
$[]1
_LTECHO_EOF'
}
ECHO='func_fallback_echo'
fi
# func_echo_all arg...
# Invoke $ECHO with all args, space-separated.
func_echo_all ()
{
$ECHO "$*"
}
case "$ECHO" in
printf*) AC_MSG_RESULT([printf]) ;;
print*) AC_MSG_RESULT([print -r]) ;;
*) AC_MSG_RESULT([cat]) ;;
esac
m4_ifdef([_AS_DETECT_SUGGESTED],
[_AS_DETECT_SUGGESTED([
test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
PATH=/empty FPATH=/empty; export PATH FPATH
test "X`printf %s $ECHO`" = "X$ECHO" \
|| test "X`print -r -- $ECHO`" = "X$ECHO" )])])
_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
])# _LT_PROG_ECHO_BACKSLASH
# _LT_WITH_SYSROOT
# ----------------
AC_DEFUN([_LT_WITH_SYSROOT],
[AC_MSG_CHECKING([for sysroot])
AC_ARG_WITH([sysroot],
[ --with-sysroot[=DIR] Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).],
[], [with_sysroot=no])
dnl lt_sysroot will always be passed unquoted. We quote it here
dnl in case the user passed a directory name.
lt_sysroot=
case ${with_sysroot} in #(
yes)
if test "$GCC" = yes; then
lt_sysroot=`$CC --print-sysroot 2>/dev/null`
fi
;; #(
/*)
lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
;; #(
no|'')
;; #(
*)
AC_MSG_RESULT([${with_sysroot}])
AC_MSG_ERROR([The sysroot must be an absolute path.])
;;
esac
AC_MSG_RESULT([${lt_sysroot:-no}])
_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
[dependent libraries, and in which our libraries should be installed.])])
# _LT_ENABLE_LOCK
# ---------------
m4_defun([_LT_ENABLE_LOCK],
[AC_ARG_ENABLE([libtool-lock],
[AS_HELP_STRING([--disable-libtool-lock],
[avoid locking (might break parallel builds)])])
test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case $host in
ia64-*-hpux*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.$ac_objext` in
*ELF-32*)
HPUX_IA64_MODE="32"
;;
*ELF-64*)
HPUX_IA64_MODE="64"
;;
esac
fi
rm -rf conftest*
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
if test "$lt_cv_prog_gnu_ld" = yes; then
case `/usr/bin/file conftest.$ac_objext` in
*32-bit*)
LD="${LD-ld} -melf32bsmip"
;;
*N32*)
LD="${LD-ld} -melf32bmipn32"
;;
*64-bit*)
LD="${LD-ld} -melf64bmip"
;;
esac
else
case `/usr/bin/file conftest.$ac_objext` in
*32-bit*)
LD="${LD-ld} -32"
;;
*N32*)
LD="${LD-ld} -n32"
;;
*64-bit*)
LD="${LD-ld} -64"
;;
esac
fi
fi
rm -rf conftest*
;;
x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.o` in
*32-bit*)
case $host in
x86_64-*kfreebsd*-gnu)
LD="${LD-ld} -m elf_i386_fbsd"
;;
x86_64-*linux*)
case `/usr/bin/file conftest.o` in
*x86-64*)
LD="${LD-ld} -m elf32_x86_64"
;;
*)
LD="${LD-ld} -m elf_i386"
;;
esac
;;
powerpc64le-*)
LD="${LD-ld} -m elf32lppclinux"
;;
powerpc64-*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
LD="${LD-ld} -m elf_s390"
;;
sparc64-*linux*)
LD="${LD-ld} -m elf32_sparc"
;;
esac
;;
*64-bit*)
case $host in
x86_64-*kfreebsd*-gnu)
LD="${LD-ld} -m elf_x86_64_fbsd"
;;
x86_64-*linux*)
LD="${LD-ld} -m elf_x86_64"
;;
powerpcle-*)
LD="${LD-ld} -m elf64lppc"
;;
powerpc-*)
LD="${LD-ld} -m elf64ppc"
;;
s390*-*linux*|s390*-*tpf*)
LD="${LD-ld} -m elf64_s390"
;;
sparc*-*linux*)
LD="${LD-ld} -m elf64_sparc"
;;
esac
;;
esac
fi
rm -rf conftest*
;;
*-*-sco3.2v5*)
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -belf"
AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
[AC_LANG_PUSH(C)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
AC_LANG_POP])
if test x"$lt_cv_cc_needs_belf" != x"yes"; then
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
CFLAGS="$SAVE_CFLAGS"
fi
;;
*-*solaris*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.o` in
*64-bit*)
case $lt_cv_prog_gnu_ld in
yes*)
case $host in
i?86-*-solaris*)
LD="${LD-ld} -m elf_x86_64"
;;
sparc*-*-solaris*)
LD="${LD-ld} -m elf64_sparc"
;;
esac
# GNU ld 2.21 introduced _sol2 emulations. Use them if available.
if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
LD="${LD-ld}_sol2"
fi
;;
*)
if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
LD="${LD-ld} -64"
fi
;;
esac
;;
esac
fi
rm -rf conftest*
;;
esac
need_locks="$enable_libtool_lock"
])# _LT_ENABLE_LOCK
# _LT_PROG_AR
# -----------
m4_defun([_LT_PROG_AR],
[AC_CHECK_TOOLS(AR, [ar], false)
: ${AR=ar}
: ${AR_FLAGS=cru}
_LT_DECL([], [AR], [1], [The archiver])
_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
[lt_cv_ar_at_file=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
[echo conftest.$ac_objext > conftest.lst
lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
AC_TRY_EVAL([lt_ar_try])
if test "$ac_status" -eq 0; then
# Ensure the archiver fails upon bogus file names.
rm -f conftest.$ac_objext libconftest.a
AC_TRY_EVAL([lt_ar_try])
if test "$ac_status" -ne 0; then
lt_cv_ar_at_file=@
fi
fi
rm -f conftest.* libconftest.a
])
])
if test "x$lt_cv_ar_at_file" = xno; then
archiver_list_spec=
else
archiver_list_spec=$lt_cv_ar_at_file
fi
_LT_DECL([], [archiver_list_spec], [1],
[How to feed a file listing to the archiver])
])# _LT_PROG_AR
# _LT_CMD_OLD_ARCHIVE
# -------------------
m4_defun([_LT_CMD_OLD_ARCHIVE],
[_LT_PROG_AR
AC_CHECK_TOOL(STRIP, strip, :)
test -z "$STRIP" && STRIP=:
_LT_DECL([], [STRIP], [1], [A symbol stripping program])
AC_CHECK_TOOL(RANLIB, ranlib, :)
test -z "$RANLIB" && RANLIB=:
_LT_DECL([], [RANLIB], [1],
[Commands used to install an old-style archive])
# Determine commands to create old-style static archives.
old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
old_postinstall_cmds='chmod 644 $oldlib'
old_postuninstall_cmds=
if test -n "$RANLIB"; then
case $host_os in
openbsd*)
old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
;;
*)
old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
;;
esac
old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
fi
case $host_os in
darwin*)
lock_old_archive_extraction=yes ;;
*)
lock_old_archive_extraction=no ;;
esac
_LT_DECL([], [old_postinstall_cmds], [2])
_LT_DECL([], [old_postuninstall_cmds], [2])
_LT_TAGDECL([], [old_archive_cmds], [2],
[Commands used to build an old-style archive])
_LT_DECL([], [lock_old_archive_extraction], [0],
[Whether to use a lock for old archive extraction])
])# _LT_CMD_OLD_ARCHIVE
# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
# your_sha256_hash
# Check whether the given compiler option works
AC_DEFUN([_LT_COMPILER_OPTION],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_SED])dnl
AC_CACHE_CHECK([$1], [$2],
[$2=no
m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
echo "$lt_simple_compile_test_code" > conftest.$ac_ext
lt_compiler_flag="$3"
# Insert the option either (1) after the last *FLAGS variable, or
# (2) before a word containing "conftest.", or (3) at the end.
# Note that $ac_compile itself does not contain backslashes and begins
# with a dollar sign (not a hyphen), so the echo should work correctly.
# The option is referenced via a variable to avoid confusing sed.
lt_compile=`echo "$ac_compile" | $SED \
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&AS_MESSAGE_LOG_FD
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
$ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
$SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
$2=yes
fi
fi
$RM conftest*
])
if test x"[$]$2" = xyes; then
m4_if([$5], , :, [$5])
else
m4_if([$6], , :, [$6])
fi
])# _LT_COMPILER_OPTION
# Old name:
AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
# [ACTION-SUCCESS], [ACTION-FAILURE])
# ----------------------------------------------------
# Check whether the given linker option works
AC_DEFUN([_LT_LINKER_OPTION],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_SED])dnl
AC_CACHE_CHECK([$1], [$2],
[$2=no
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $3"
echo "$lt_simple_link_test_code" > conftest.$ac_ext
if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
# The linker can only warn and ignore the option if not recognized
# So say no if there are warnings
if test -s conftest.err; then
# Append any errors to the config.log.
cat conftest.err 1>&AS_MESSAGE_LOG_FD
$ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
$SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
if diff conftest.exp conftest.er2 >/dev/null; then
$2=yes
fi
else
$2=yes
fi
fi
$RM -r conftest*
LDFLAGS="$save_LDFLAGS"
])
if test x"[$]$2" = xyes; then
m4_if([$4], , :, [$4])
else
m4_if([$5], , :, [$5])
fi
])# _LT_LINKER_OPTION
# Old name:
AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
# LT_CMD_MAX_LEN
#---------------
AC_DEFUN([LT_CMD_MAX_LEN],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
# find the maximum length of command line arguments
AC_MSG_CHECKING([the maximum length of command line arguments])
AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
i=0
teststring="ABCD"
case $build_os in
msdosdjgpp*)
# On DJGPP, this test can blow up pretty badly due to problems in libc
# (any single argument exceeding 2000 bytes causes a buffer overrun
# during glob expansion). Even if it were fixed, the result of this
# check would be larger than it should be.
lt_cv_sys_max_cmd_len=12288; # 12K is about right
;;
gnu*)
# Under GNU Hurd, this test is not required because there is
# no limit to the length of command line arguments.
# Libtool will interpret -1 as no limit whatsoever
lt_cv_sys_max_cmd_len=-1;
;;
cygwin* | mingw* | cegcc*)
# On Win9x/ME, this test blows up -- it succeeds, but takes
# about 5 minutes as the teststring grows exponentially.
# Worse, since 9x/ME are not pre-emptively multitasking,
# you end up with a "frozen" computer, even though with patience
# the test eventually succeeds (with a max line length of 256k).
# Instead, let's just punt: use the minimum linelength reported by
# all of the supported platforms: 8192 (on NT/2K/XP).
lt_cv_sys_max_cmd_len=8192;
;;
mint*)
# On MiNT this can take a long time and run out of memory.
lt_cv_sys_max_cmd_len=8192;
;;
amigaos*)
# On AmigaOS with pdksh, this test takes hours, literally.
# So we just punt and use a minimum line length of 8192.
lt_cv_sys_max_cmd_len=8192;
;;
netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
# This has been around since 386BSD, at least. Likely further.
if test -x /sbin/sysctl; then
lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
elif test -x /usr/sbin/sysctl; then
lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
else
lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
fi
# And add a safety zone
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
;;
interix*)
# We know the value 262144 and hardcode it with a safety zone (like BSD)
lt_cv_sys_max_cmd_len=196608
;;
os2*)
# The test takes a long time on OS/2.
lt_cv_sys_max_cmd_len=8192
;;
osf*)
# Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
# due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
# nice to cause kernel panics so lets avoid the loop below.
# First set a reasonable default.
lt_cv_sys_max_cmd_len=16384
#
if test -x /sbin/sysconfig; then
case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
*1*) lt_cv_sys_max_cmd_len=-1 ;;
esac
fi
;;
sco3.2v5*)
lt_cv_sys_max_cmd_len=102400
;;
sysv5* | sco5v6* | sysv4.2uw2*)
kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
if test -n "$kargmax"; then
lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
else
lt_cv_sys_max_cmd_len=32768
fi
;;
*)
lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
if test -n "$lt_cv_sys_max_cmd_len" && \
test undefined != "$lt_cv_sys_max_cmd_len"; then
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
else
# Make teststring a little bigger before we do anything with it.
# a 1K string should be a reasonable start.
for i in 1 2 3 4 5 6 7 8 ; do
teststring=$teststring$teststring
done
SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
# If test is not a shell built-in, we'll probably end up computing a
# maximum length that is only half of the actual maximum length, but
# we can't tell.
while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
= "X$teststring$teststring"; } >/dev/null 2>&1 &&
test $i != 17 # 1/2 MB should be enough
do
i=`expr $i + 1`
teststring=$teststring$teststring
done
# Only check the string length outside the loop.
lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
teststring=
# Add a significant safety factor because C++ compilers can tack on
# massive amounts of additional arguments before passing them to the
# linker. It appears as though 1/2 is a usable value.
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
fi
;;
esac
])
if test -n $lt_cv_sys_max_cmd_len ; then
AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
else
AC_MSG_RESULT(none)
fi
max_cmd_len=$lt_cv_sys_max_cmd_len
_LT_DECL([], [max_cmd_len], [0],
[What is the maximum length of a command?])
])# LT_CMD_MAX_LEN
# Old name:
AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
# _LT_HEADER_DLFCN
# ----------------
m4_defun([_LT_HEADER_DLFCN],
[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
])# _LT_HEADER_DLFCN
# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
# your_sha256_hash
m4_defun([_LT_TRY_DLOPEN_SELF],
[m4_require([_LT_HEADER_DLFCN])dnl
if test "$cross_compiling" = yes; then :
[$4]
else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
[#line $LINENO "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#include <stdio.h>
#ifdef RTLD_GLOBAL
# define LT_DLGLOBAL RTLD_GLOBAL
#else
# ifdef DL_GLOBAL
# define LT_DLGLOBAL DL_GLOBAL
# else
# define LT_DLGLOBAL 0
# endif
#endif
/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
find out it does not work in some platform. */
#ifndef LT_DLLAZY_OR_NOW
# ifdef RTLD_LAZY
# define LT_DLLAZY_OR_NOW RTLD_LAZY
# else
# ifdef DL_LAZY
# define LT_DLLAZY_OR_NOW DL_LAZY
# else
# ifdef RTLD_NOW
# define LT_DLLAZY_OR_NOW RTLD_NOW
# else
# ifdef DL_NOW
# define LT_DLLAZY_OR_NOW DL_NOW
# else
# define LT_DLLAZY_OR_NOW 0
# endif
# endif
# endif
# endif
#endif
/* When -fvisbility=hidden is used, assume the code has been annotated
correspondingly for the symbols needed. */
#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
int fnord () __attribute__((visibility("default")));
#endif
int fnord () { return 42; }
int main ()
{
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
int status = $lt_dlunknown;
if (self)
{
if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
else
{
if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
else puts (dlerror ());
}
/* dlclose (self); */
}
else
puts (dlerror ());
return status;
}]
_LT_EOF
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
(./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
lt_status=$?
case x$lt_status in
x$lt_dlno_uscore) $1 ;;
x$lt_dlneed_uscore) $2 ;;
x$lt_dlunknown|x*) $3 ;;
esac
else :
# compilation failed
$3
fi
fi
rm -fr conftest*
])# _LT_TRY_DLOPEN_SELF
# LT_SYS_DLOPEN_SELF
# ------------------
AC_DEFUN([LT_SYS_DLOPEN_SELF],
[m4_require([_LT_HEADER_DLFCN])dnl
if test "x$enable_dlopen" != xyes; then
enable_dlopen=unknown
enable_dlopen_self=unknown
enable_dlopen_self_static=unknown
else
lt_cv_dlopen=no
lt_cv_dlopen_libs=
case $host_os in
beos*)
lt_cv_dlopen="load_add_on"
lt_cv_dlopen_libs=
lt_cv_dlopen_self=yes
;;
mingw* | pw32* | cegcc*)
lt_cv_dlopen="LoadLibrary"
lt_cv_dlopen_libs=
;;
cygwin*)
lt_cv_dlopen="dlopen"
lt_cv_dlopen_libs=
;;
darwin*)
# if libdl is installed we need to link against it
AC_CHECK_LIB([dl], [dlopen],
[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
lt_cv_dlopen="dyld"
lt_cv_dlopen_libs=
lt_cv_dlopen_self=yes
])
;;
*)
AC_CHECK_FUNC([shl_load],
[lt_cv_dlopen="shl_load"],
[AC_CHECK_LIB([dld], [shl_load],
[lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
[AC_CHECK_FUNC([dlopen],
[lt_cv_dlopen="dlopen"],
[AC_CHECK_LIB([dl], [dlopen],
[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
[AC_CHECK_LIB([svld], [dlopen],
[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
[AC_CHECK_LIB([dld], [dld_link],
[lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
])
])
])
])
])
;;
esac
if test "x$lt_cv_dlopen" != xno; then
enable_dlopen=yes
else
enable_dlopen=no
fi
case $lt_cv_dlopen in
dlopen)
save_CPPFLAGS="$CPPFLAGS"
test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
save_LDFLAGS="$LDFLAGS"
wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
save_LIBS="$LIBS"
LIBS="$lt_cv_dlopen_libs $LIBS"
AC_CACHE_CHECK([whether a program can dlopen itself],
lt_cv_dlopen_self, [dnl
_LT_TRY_DLOPEN_SELF(
lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
])
if test "x$lt_cv_dlopen_self" = xyes; then
wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
lt_cv_dlopen_self_static, [dnl
_LT_TRY_DLOPEN_SELF(
lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
])
fi
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
;;
esac
case $lt_cv_dlopen_self in
yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
*) enable_dlopen_self=unknown ;;
esac
case $lt_cv_dlopen_self_static in
yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
*) enable_dlopen_self_static=unknown ;;
esac
fi
_LT_DECL([dlopen_support], [enable_dlopen], [0],
[Whether dlopen is supported])
_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
[Whether dlopen of programs is supported])
_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
[Whether dlopen of statically linked programs is supported])
])# LT_SYS_DLOPEN_SELF
# Old name:
AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
# _LT_COMPILER_C_O([TAGNAME])
# ---------------------------
# Check to see if options -c and -o are simultaneously supported by compiler.
# This macro does not hard code the compiler like AC_PROG_CC_C_O.
m4_defun([_LT_COMPILER_C_O],
[m4_require([_LT_DECL_SED])dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_TAG_COMPILER])dnl
AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
[_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
[_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
$RM -r conftest 2>/dev/null
mkdir conftest
cd conftest
mkdir out
echo "$lt_simple_compile_test_code" > conftest.$ac_ext
lt_compiler_flag="-o out/conftest2.$ac_objext"
# Insert the option either (1) after the last *FLAGS variable, or
# (2) before a word containing "conftest.", or (3) at the end.
# Note that $ac_compile itself does not contain backslashes and begins
# with a dollar sign (not a hyphen), so the echo should work correctly.
lt_compile=`echo "$ac_compile" | $SED \
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&AS_MESSAGE_LOG_FD
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
$ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
$SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
fi
fi
chmod u+w . 2>&AS_MESSAGE_LOG_FD
$RM conftest*
# SGI C++ compiler will create directory out/ii_files/ for
# template instantiation
test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
$RM out/* && rmdir out
cd ..
$RM -r conftest
$RM conftest*
])
_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
[Does compiler simultaneously support -c and -o options?])
])# _LT_COMPILER_C_O
# _LT_COMPILER_FILE_LOCKS([TAGNAME])
# ----------------------------------
# Check to see if we can do hard links to lock some files if needed
m4_defun([_LT_COMPILER_FILE_LOCKS],
[m4_require([_LT_ENABLE_LOCK])dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
_LT_COMPILER_C_O([$1])
hard_links="nottested"
if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
# do not overwrite the value of need_locks provided by the user
AC_MSG_CHECKING([if we can lock with hard links])
hard_links=yes
$RM conftest*
ln conftest.a conftest.b 2>/dev/null && hard_links=no
touch conftest.a
ln conftest.a conftest.b 2>&5 || hard_links=no
ln conftest.a conftest.b 2>/dev/null && hard_links=no
AC_MSG_RESULT([$hard_links])
if test "$hard_links" = no; then
AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
need_locks=warn
fi
else
need_locks=no
fi
_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
])# _LT_COMPILER_FILE_LOCKS
# _LT_CHECK_OBJDIR
# ----------------
m4_defun([_LT_CHECK_OBJDIR],
[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
[rm -f .libs 2>/dev/null
mkdir .libs 2>/dev/null
if test -d .libs; then
lt_cv_objdir=.libs
else
# MS-DOS does not allow filenames that begin with a dot.
lt_cv_objdir=_libs
fi
rmdir .libs 2>/dev/null])
objdir=$lt_cv_objdir
_LT_DECL([], [objdir], [0],
[The name of the directory that contains temporary libtool files])dnl
m4_pattern_allow([LT_OBJDIR])dnl
AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
[Define to the sub-directory in which libtool stores uninstalled libraries.])
])# _LT_CHECK_OBJDIR
# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
# --------------------------------------
# Check hardcoding attributes.
m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
[AC_MSG_CHECKING([how to hardcode library paths into programs])
_LT_TAGVAR(hardcode_action, $1)=
if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
test -n "$_LT_TAGVAR(runpath_var, $1)" ||
test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
# We can hardcode non-existent directories.
if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
# when we should be linking with a yet-to-be-installed one
## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
# Linking always hardcodes the temporary library directory.
_LT_TAGVAR(hardcode_action, $1)=relink
else
# We can link without hardcoding, and we can hardcode nonexisting dirs.
_LT_TAGVAR(hardcode_action, $1)=immediate
fi
else
# We cannot hardcode anything, or else we can only hardcode existing
# directories.
_LT_TAGVAR(hardcode_action, $1)=unsupported
fi
AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
# Fast installation is not supported
enable_fast_install=no
elif test "$shlibpath_overrides_runpath" = yes ||
test "$enable_shared" = no; then
# Fast installation is not necessary
enable_fast_install=needless
fi
_LT_TAGDECL([], [hardcode_action], [0],
[How to hardcode a shared library path into an executable])
])# _LT_LINKER_HARDCODE_LIBPATH
# _LT_CMD_STRIPLIB
# ----------------
m4_defun([_LT_CMD_STRIPLIB],
[m4_require([_LT_DECL_EGREP])
striplib=
old_striplib=
AC_MSG_CHECKING([whether stripping libraries is possible])
if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
test -z "$striplib" && striplib="$STRIP --strip-unneeded"
AC_MSG_RESULT([yes])
else
# FIXME - insert some real tests, host_os isn't really good enough
case $host_os in
darwin*)
if test -n "$STRIP" ; then
striplib="$STRIP -x"
old_striplib="$STRIP -S"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
;;
*)
AC_MSG_RESULT([no])
;;
esac
fi
_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
_LT_DECL([], [striplib], [1])
])# _LT_CMD_STRIPLIB
# _LT_SYS_DYNAMIC_LINKER([TAG])
# -----------------------------
# PORTME Fill in your ld.so characteristics
m4_defun([_LT_SYS_DYNAMIC_LINKER],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_OBJDUMP])dnl
m4_require([_LT_DECL_SED])dnl
m4_require([_LT_CHECK_SHELL_FEATURES])dnl
AC_MSG_CHECKING([dynamic linker characteristics])
m4_if([$1],
[], [
if test "$GCC" = yes; then
case $host_os in
darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
*) lt_awk_arg="/^libraries:/" ;;
esac
case $host_os in
mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
*) lt_sed_strip_eq="s,=/,/,g" ;;
esac
lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
case $lt_search_path_spec in
*\;*)
# if the path contains ";" then we assume it to be the separator
# otherwise default to the standard path separator (i.e. ":") - it is
# assumed that no part of a normal pathname contains ";" but that should
# okay in the real world where ";" in dirpaths is itself problematic.
lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
;;
*)
lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
;;
esac
# Ok, now we have the path, separated by spaces, we can step through it
# and add multilib dir if necessary.
lt_tmp_lt_search_path_spec=
lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
for lt_sys_path in $lt_search_path_spec; do
if test -d "$lt_sys_path/$lt_multi_os_dir"; then
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
else
test -d "$lt_sys_path" && \
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
fi
done
lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
BEGIN {RS=" "; FS="/|\n";} {
lt_foo="";
lt_count=0;
for (lt_i = NF; lt_i > 0; lt_i--) {
if ($lt_i != "" && $lt_i != ".") {
if ($lt_i == "..") {
lt_count++;
} else {
if (lt_count == 0) {
lt_foo="/" $lt_i lt_foo;
} else {
lt_count--;
}
}
}
}
if (lt_foo != "") { lt_freq[[lt_foo]]++; }
if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
}'`
# AWK program above erroneously prepends '/' to C:/dos/paths
# for these hosts.
case $host_os in
mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
$SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
esac
sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
else
sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
fi])
library_names_spec=
libname_spec='lib$name'
soname_spec=
shrext_cmds=".so"
postinstall_cmds=
postuninstall_cmds=
finish_cmds=
finish_eval=
shlibpath_var=
shlibpath_overrides_runpath=unknown
version_type=none
dynamic_linker="$host_os ld.so"
sys_lib_dlsearch_path_spec="/lib /usr/lib"
need_lib_prefix=unknown
hardcode_into_libs=no
# when you set need_version to no, make sure it does not cause -set_version
# flags to be left without arguments
need_version=unknown
case $host_os in
aix3*)
version_type=linux # correct to gnu/linux during the next big refactor
library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
shlibpath_var=LIBPATH
# AIX 3 has no versioning support, so we append a major version to the name.
soname_spec='${libname}${release}${shared_ext}$major'
;;
aix[[4-9]]*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
hardcode_into_libs=yes
if test "$host_cpu" = ia64; then
# AIX 5 supports IA64
library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
shlibpath_var=LD_LIBRARY_PATH
else
# With GCC up to 2.95.x, collect2 would create an import file
# for dependence libraries. The import file would start with
# the line `#! .'. This would cause the generated library to
# depend on `.', always an invalid library. This was fixed in
# development snapshots of GCC prior to 3.0.
case $host_os in
aix4 | aix4.[[01]] | aix4.[[01]].*)
if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
echo ' yes '
echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
:
else
can_build_shared=no
fi
;;
esac
# AIX (on Power*) has no versioning support, so currently we can not hardcode correct
# soname into executable. Probably we can add versioning support to
# collect2, so additional links can be useful in future.
if test "$aix_use_runtimelinking" = yes; then
# If using run time linking (on AIX 4.2 or later) use lib<name>.so
# instead of lib<name>.a to let people know that these are not
# typical AIX shared libraries.
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
else
# We preserve .a as extension for shared libraries through AIX4.2
# and later when we are not doing run time linking.
library_names_spec='${libname}${release}.a $libname.a'
soname_spec='${libname}${release}${shared_ext}$major'
fi
shlibpath_var=LIBPATH
fi
;;
amigaos*)
case $host_cpu in
powerpc)
# Since July 2007 AmigaOS4 officially supports .so libraries.
# When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
;;
m68k)
library_names_spec='$libname.ixlibrary $libname.a'
# Create ${libname}_ixlibrary.a entries in /sys/libs.
finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
;;
esac
;;
beos*)
library_names_spec='${libname}${shared_ext}'
dynamic_linker="$host_os ld.so"
shlibpath_var=LIBRARY_PATH
;;
bsdi[[45]]*)
version_type=linux # correct to gnu/linux during the next big refactor
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
shlibpath_var=LD_LIBRARY_PATH
sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
# the default ld.so.conf also contains /usr/contrib/lib and
# /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
# libtool to hard-code these into programs
;;
cygwin* | mingw* | pw32* | cegcc*)
version_type=windows
shrext_cmds=".dll"
need_version=no
need_lib_prefix=no
case $GCC,$cc_basename in
yes,*)
# gcc
library_names_spec='$libname.dll.a'
# DLL is installed to $(libdir)/../bin by postinstall_cmds
postinstall_cmds='base_file=`basename \${file}`~
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname~
chmod a+x \$dldir/$dlname~
if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
fi'
postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
dlpath=$dir/\$dldll~
$RM \$dlpath'
shlibpath_overrides_runpath=yes
case $host_os in
cygwin*)
# Cygwin DLLs use 'cyg' prefix rather than 'lib'
soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
m4_if([$1], [],[
sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
;;
mingw* | cegcc*)
# MinGW DLLs use traditional 'lib' prefix
soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
;;
pw32*)
# pw32 DLLs use 'pw' prefix rather than 'lib'
library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
;;
esac
dynamic_linker='Win32 ld.exe'
;;
*,cl*)
# Native MSVC
libname_spec='$name'
soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
library_names_spec='${libname}.dll.lib'
case $build_os in
mingw*)
sys_lib_search_path_spec=
lt_save_ifs=$IFS
IFS=';'
for lt_path in $LIB
do
IFS=$lt_save_ifs
# Let DOS variable expansion print the short 8.3 style file name.
lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
done
IFS=$lt_save_ifs
# Convert to MSYS style.
sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
;;
cygwin*)
# Convert to unix form, then to dos form, then back to unix form
# but this time dos style (no spaces!) so that the unix form looks
# like /cygdrive/c/PROGRA~1:/cygdr...
sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
;;
*)
sys_lib_search_path_spec="$LIB"
if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
# It is most probably a Windows format PATH.
sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
else
sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
fi
# FIXME: find the short name or the path components, as spaces are
# common. (e.g. "Program Files" -> "PROGRA~1")
;;
esac
# DLL is installed to $(libdir)/../bin by postinstall_cmds
postinstall_cmds='base_file=`basename \${file}`~
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname'
postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
dlpath=$dir/\$dldll~
$RM \$dlpath'
shlibpath_overrides_runpath=yes
dynamic_linker='Win32 link.exe'
;;
*)
# Assume MSVC wrapper
library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
dynamic_linker='Win32 ld.exe'
;;
esac
# FIXME: first we should search . and the directory the executable is in
shlibpath_var=PATH
;;
darwin* | rhapsody*)
dynamic_linker="$host_os dyld"
version_type=darwin
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
soname_spec='${libname}${release}${major}$shared_ext'
shlibpath_overrides_runpath=yes
shlibpath_var=DYLD_LIBRARY_PATH
shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
m4_if([$1], [],[
sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
;;
dgux*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
;;
freebsd* | dragonfly*)
# DragonFly does not have aout. When/if they implement a new
# versioning mechanism, adjust this.
if test -x /usr/bin/objformat; then
objformat=`/usr/bin/objformat`
else
case $host_os in
freebsd[[23]].*) objformat=aout ;;
*) objformat=elf ;;
esac
fi
version_type=freebsd-$objformat
case $version_type in
freebsd-elf*)
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
need_version=no
need_lib_prefix=no
;;
freebsd-*)
library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
need_version=yes
;;
esac
shlibpath_var=LD_LIBRARY_PATH
case $host_os in
freebsd2.*)
shlibpath_overrides_runpath=yes
;;
freebsd3.[[01]]* | freebsdelf3.[[01]]*)
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
;;
freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
;;
*) # from 4.6 on, and DragonFly
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
;;
esac
;;
haiku*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
dynamic_linker="$host_os runtime_loader"
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LIBRARY_PATH
shlibpath_overrides_runpath=yes
sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
hardcode_into_libs=yes
;;
hpux9* | hpux10* | hpux11*)
# Give a soname corresponding to the major version so that dld.sl refuses to
# link against other versions.
version_type=sunos
need_lib_prefix=no
need_version=no
case $host_cpu in
ia64*)
shrext_cmds='.so'
hardcode_into_libs=yes
dynamic_linker="$host_os dld.so"
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
if test "X$HPUX_IA64_MODE" = X32; then
sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
else
sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
fi
sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
hppa*64*)
shrext_cmds='.sl'
hardcode_into_libs=yes
dynamic_linker="$host_os dld.sl"
shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
*)
shrext_cmds='.sl'
dynamic_linker="$host_os dld.sl"
shlibpath_var=SHLIB_PATH
shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
;;
esac
# HP-UX runs *really* slowly unless shared libraries are mode 555, ...
postinstall_cmds='chmod 555 $lib'
# or fails outright, so override atomically:
install_override_mode=555
;;
interix[[3-9]]*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
;;
irix5* | irix6* | nonstopux*)
case $host_os in
nonstopux*) version_type=nonstopux ;;
*)
if test "$lt_cv_prog_gnu_ld" = yes; then
version_type=linux # correct to gnu/linux during the next big refactor
else
version_type=irix
fi ;;
esac
need_lib_prefix=no
need_version=no
soname_spec='${libname}${release}${shared_ext}$major'
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
case $host_os in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in # libtool.m4 will add one of these switches to LD
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
libsuff= shlibsuff= libmagic=32-bit;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
libsuff=32 shlibsuff=N32 libmagic=N32;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
libsuff=64 shlibsuff=64 libmagic=64-bit;;
*) libsuff= shlibsuff= libmagic=never-match;;
esac
;;
esac
shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
shlibpath_overrides_runpath=no
sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
hardcode_into_libs=yes
;;
# No shared lib support for Linux oldld, aout, or coff.
linux*oldld* | linux*aout* | linux*coff*)
dynamic_linker=no
;;
# This must be glibc/ELF.
linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
# Some binutils ld are patched to set DT_RUNPATH
AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
[lt_cv_shlibpath_overrides_runpath=no
save_LDFLAGS=$LDFLAGS
save_libdir=$libdir
eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
[lt_cv_shlibpath_overrides_runpath=yes])])
LDFLAGS=$save_LDFLAGS
libdir=$save_libdir
])
shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
# This implies no fast_install, which is unacceptable.
# Some rework will be needed to allow for fast_install
# before this can be enabled.
hardcode_into_libs=yes
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
# powerpc, because MkLinux only supported shared libraries with the
# GNU dynamic linker. Since this was broken with cross compilers,
# most powerpc-linux boxes support dynamic linking these days and
# people can always --disable-shared, the test was removed, and we
# assume the GNU/Linux dynamic linker is in use.
dynamic_linker='GNU/Linux ld.so'
;;
netbsdelf*-gnu)
version_type=linux
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='NetBSD ld.elf_so'
;;
netbsd*)
version_type=sunos
need_lib_prefix=no
need_version=no
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
dynamic_linker='NetBSD (a.out) ld.so'
else
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
dynamic_linker='NetBSD ld.elf_so'
fi
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
;;
newsos6)
version_type=linux # correct to gnu/linux during the next big refactor
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
;;
*nto* | *qnx*)
version_type=qnx
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='ldqnx.so'
;;
openbsd*)
version_type=sunos
sys_lib_dlsearch_path_spec="/usr/lib"
need_lib_prefix=no
# Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
case $host_os in
openbsd3.3 | openbsd3.3.*) need_version=yes ;;
*) need_version=no ;;
esac
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
shlibpath_var=LD_LIBRARY_PATH
if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
case $host_os in
openbsd2.[[89]] | openbsd2.[[89]].*)
shlibpath_overrides_runpath=no
;;
*)
shlibpath_overrides_runpath=yes
;;
esac
else
shlibpath_overrides_runpath=yes
fi
;;
os2*)
libname_spec='$name'
shrext_cmds=".dll"
need_lib_prefix=no
library_names_spec='$libname${shared_ext} $libname.a'
dynamic_linker='OS/2 ld.exe'
shlibpath_var=LIBPATH
;;
osf3* | osf4* | osf5*)
version_type=osf
need_lib_prefix=no
need_version=no
soname_spec='${libname}${release}${shared_ext}$major'
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
shlibpath_var=LD_LIBRARY_PATH
sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
;;
rdos*)
dynamic_linker=no
;;
solaris*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
# ldd complains unless libraries are executable
postinstall_cmds='chmod +x $lib'
;;
sunos4*)
version_type=sunos
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
if test "$with_gnu_ld" = yes; then
need_lib_prefix=no
fi
need_version=yes
;;
sysv4 | sysv4.3*)
version_type=linux # correct to gnu/linux during the next big refactor
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
case $host_vendor in
sni)
shlibpath_overrides_runpath=no
need_lib_prefix=no
runpath_var=LD_RUN_PATH
;;
siemens)
need_lib_prefix=no
;;
motorola)
need_lib_prefix=no
need_version=no
shlibpath_overrides_runpath=no
sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
;;
esac
;;
sysv4*MP*)
if test -d /usr/nec ;then
version_type=linux # correct to gnu/linux during the next big refactor
library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
soname_spec='$libname${shared_ext}.$major'
shlibpath_var=LD_LIBRARY_PATH
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
version_type=freebsd-elf
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
if test "$with_gnu_ld" = yes; then
sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
else
sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
case $host_os in
sco3.2v5*)
sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
;;
esac
fi
sys_lib_dlsearch_path_spec='/usr/lib'
;;
tpf*)
# TPF is a cross-target only. Preferred cross-host = GNU/Linux.
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
;;
uts4*)
version_type=linux # correct to gnu/linux during the next big refactor
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
;;
*)
dynamic_linker=no
;;
esac
AC_MSG_RESULT([$dynamic_linker])
test "$dynamic_linker" = no && can_build_shared=no
variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
if test "$GCC" = yes; then
variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
fi
if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
fi
if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
fi
_LT_DECL([], [variables_saved_for_relink], [1],
[Variables whose values should be saved in libtool wrapper scripts and
restored at link time])
_LT_DECL([], [need_lib_prefix], [0],
[Do we need the "lib" prefix for modules?])
_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
_LT_DECL([], [version_type], [0], [Library versioning type])
_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
_LT_DECL([], [shlibpath_overrides_runpath], [0],
[Is shlibpath searched before the hard-coded library search path?])
_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
_LT_DECL([], [library_names_spec], [1],
[[List of archive names. First name is the real one, the rest are links.
The last name is the one that the linker finds with -lNAME]])
_LT_DECL([], [soname_spec], [1],
[[The coded name of the library, if different from the real name]])
_LT_DECL([], [install_override_mode], [1],
[Permission mode override for installation of shared libraries])
_LT_DECL([], [postinstall_cmds], [2],
[Command to use after installation of a shared archive])
_LT_DECL([], [postuninstall_cmds], [2],
[Command to use after uninstallation of a shared archive])
_LT_DECL([], [finish_cmds], [2],
[Commands used to finish a libtool library installation in a directory])
_LT_DECL([], [finish_eval], [1],
[[As "finish_cmds", except a single script fragment to be evaled but
not shown]])
_LT_DECL([], [hardcode_into_libs], [0],
[Whether we should hardcode library paths into libraries])
_LT_DECL([], [sys_lib_search_path_spec], [2],
[Compile-time system search path for libraries])
_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
[Run-time system search path for libraries])
])# _LT_SYS_DYNAMIC_LINKER
# _LT_PATH_TOOL_PREFIX(TOOL)
# --------------------------
# find a file program which can recognize shared library
AC_DEFUN([_LT_PATH_TOOL_PREFIX],
[m4_require([_LT_DECL_EGREP])dnl
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
[case $MAGIC_CMD in
[[\\/*] | ?:[\\/]*])
lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
;;
*)
lt_save_MAGIC_CMD="$MAGIC_CMD"
lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
dnl $ac_dummy forces splitting on constant user-supplied paths.
dnl POSIX.2 word splitting is done only on the output of word expansions,
dnl not every word. This closes a longstanding sh security hole.
ac_dummy="m4_if([$2], , $PATH, [$2])"
for ac_dir in $ac_dummy; do
IFS="$lt_save_ifs"
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$1; then
lt_cv_path_MAGIC_CMD="$ac_dir/$1"
if test -n "$file_magic_test_file"; then
case $deplibs_check_method in
"file_magic "*)
file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
$EGREP "$file_magic_regex" > /dev/null; then
:
else
cat <<_LT_EOF 1>&2
*** Warning: the command libtool uses to detect shared libraries,
*** $file_magic_cmd, produces output that libtool cannot recognize.
*** The result is that libtool may fail to recognize shared libraries
*** as such. This will affect the creation of libtool libraries that
*** depend on shared libraries, but programs linked with such libtool
*** libraries will work regardless of this problem. Nevertheless, you
*** may want to report the problem to your system manager and/or to
*** bug-libtool@gnu.org
_LT_EOF
fi ;;
esac
fi
break
fi
done
IFS="$lt_save_ifs"
MAGIC_CMD="$lt_save_MAGIC_CMD"
;;
esac])
MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
if test -n "$MAGIC_CMD"; then
AC_MSG_RESULT($MAGIC_CMD)
else
AC_MSG_RESULT(no)
fi
_LT_DECL([], [MAGIC_CMD], [0],
[Used to examine libraries when file_magic_cmd begins with "file"])dnl
])# _LT_PATH_TOOL_PREFIX
# Old name:
AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
# _LT_PATH_MAGIC
# --------------
# find a file program which can recognize a shared library
m4_defun([_LT_PATH_MAGIC],
[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
if test -z "$lt_cv_path_MAGIC_CMD"; then
if test -n "$ac_tool_prefix"; then
_LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
else
MAGIC_CMD=:
fi
fi
])# _LT_PATH_MAGIC
# LT_PATH_LD
# ----------
# find the pathname to the GNU or non-GNU linker
AC_DEFUN([LT_PATH_LD],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
m4_require([_LT_DECL_SED])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
AC_ARG_WITH([gnu-ld],
[AS_HELP_STRING([--with-gnu-ld],
[assume the C compiler uses GNU ld @<:@default=no@:>@])],
[test "$withval" = no || with_gnu_ld=yes],
[with_gnu_ld=no])dnl
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by $CC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]]* | ?:[[\\/]]*)
re_direlt='/[[^/]][[^/]]*/\.\./'
# Canonicalize the pathname of ld
ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(lt_cv_path_LD,
[if test -z "$LD"; then
lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
for ac_dir in $PATH; do
IFS="$lt_save_ifs"
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
lt_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some variants of GNU ld only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break
;;
*)
test "$with_gnu_ld" != yes && break
;;
esac
fi
done
IFS="$lt_save_ifs"
else
lt_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$lt_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
_LT_PATH_LD_GNU
AC_SUBST([LD])
_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
])# LT_PATH_LD
# Old names:
AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_PROG_LD], [])
dnl AC_DEFUN([AC_PROG_LD], [])
# _LT_PATH_LD_GNU
#- --------------
m4_defun([_LT_PATH_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
case `$LD -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
lt_cv_prog_gnu_ld=yes
;;
*)
lt_cv_prog_gnu_ld=no
;;
esac])
with_gnu_ld=$lt_cv_prog_gnu_ld
])# _LT_PATH_LD_GNU
# _LT_CMD_RELOAD
# --------------
# find reload flag for linker
# -- PORTME Some linkers may need a different reload flag.
m4_defun([_LT_CMD_RELOAD],
[AC_CACHE_CHECK([for $LD option to reload object files],
lt_cv_ld_reload_flag,
[lt_cv_ld_reload_flag='-r'])
reload_flag=$lt_cv_ld_reload_flag
case $reload_flag in
"" | " "*) ;;
*) reload_flag=" $reload_flag" ;;
esac
reload_cmds='$LD$reload_flag -o $output$reload_objs'
case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
if test "$GCC" != yes; then
reload_cmds=false
fi
;;
darwin*)
if test "$GCC" = yes; then
reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
else
reload_cmds='$LD$reload_flag -o $output$reload_objs'
fi
;;
esac
_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
_LT_TAGDECL([], [reload_cmds], [2])dnl
])# _LT_CMD_RELOAD
# _LT_CHECK_MAGIC_METHOD
# ----------------------
# how to check for library dependencies
# -- PORTME fill in with the dynamic library characteristics
m4_defun([_LT_CHECK_MAGIC_METHOD],
[m4_require([_LT_DECL_EGREP])
m4_require([_LT_DECL_OBJDUMP])
AC_CACHE_CHECK([how to recognize dependent libraries],
lt_cv_deplibs_check_method,
[lt_cv_file_magic_cmd='$MAGIC_CMD'
lt_cv_file_magic_test_file=
lt_cv_deplibs_check_method='unknown'
# Need to set the preceding variable on all platforms that support
# interlibrary dependencies.
# 'none' -- dependencies not supported.
# `unknown' -- same as none, but documents that we really don't know.
# 'pass_all' -- all dependencies passed with no checks.
# 'test_compile' -- check by making test program.
# 'file_magic [[regex]]' -- check by looking for files in library path
# which responds to the $file_magic_cmd with a given extended regex.
# If you have `file' or equivalent on your system and you're not sure
# whether `pass_all' will *always* work, you probably want this one.
case $host_os in
aix[[4-9]]*)
lt_cv_deplibs_check_method=pass_all
;;
beos*)
lt_cv_deplibs_check_method=pass_all
;;
bsdi[[45]]*)
lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
lt_cv_file_magic_cmd='/usr/bin/file -L'
lt_cv_file_magic_test_file=/shlib/libc.so
;;
cygwin*)
# func_win32_libid is a shell function defined in ltmain.sh
lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
lt_cv_file_magic_cmd='func_win32_libid'
;;
mingw* | pw32*)
# Base MSYS/MinGW do not provide the 'file' command needed by
# func_win32_libid shell function, so use a weaker test based on 'objdump',
# unless we find 'file', for example because we are cross-compiling.
# func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
lt_cv_file_magic_cmd='func_win32_libid'
else
# Keep this pattern in sync with the one in func_win32_libid.
lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
lt_cv_file_magic_cmd='$OBJDUMP -f'
fi
;;
cegcc*)
# use the weaker test based on 'objdump'. See mingw*.
lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
lt_cv_file_magic_cmd='$OBJDUMP -f'
;;
darwin* | rhapsody*)
lt_cv_deplibs_check_method=pass_all
;;
freebsd* | dragonfly*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
case $host_cpu in
i*86 )
# Not sure whether the presence of OpenBSD here was a mistake.
# Let's accept both of them until this is cleared up.
lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
;;
esac
else
lt_cv_deplibs_check_method=pass_all
fi
;;
haiku*)
lt_cv_deplibs_check_method=pass_all
;;
hpux10.20* | hpux11*)
lt_cv_file_magic_cmd=/usr/bin/file
case $host_cpu in
ia64*)
lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
;;
hppa*64*)
[lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
;;
*)
lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
lt_cv_file_magic_test_file=/usr/lib/libc.sl
;;
esac
;;
interix[[3-9]]*)
# PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
;;
irix5* | irix6* | nonstopux*)
case $LD in
*-32|*"-32 ") libmagic=32-bit;;
*-n32|*"-n32 ") libmagic=N32;;
*-64|*"-64 ") libmagic=64-bit;;
*) libmagic=never-match;;
esac
lt_cv_deplibs_check_method=pass_all
;;
# This must be glibc/ELF.
linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
else
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
fi
;;
newos6*)
lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=/usr/lib/libnls.so
;;
*nto* | *qnx*)
lt_cv_deplibs_check_method=pass_all
;;
openbsd*)
if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
else
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
fi
;;
osf3* | osf4* | osf5*)
lt_cv_deplibs_check_method=pass_all
;;
rdos*)
lt_cv_deplibs_check_method=pass_all
;;
solaris*)
lt_cv_deplibs_check_method=pass_all
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
lt_cv_deplibs_check_method=pass_all
;;
sysv4 | sysv4.3*)
case $host_vendor in
motorola)
lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
;;
ncr)
lt_cv_deplibs_check_method=pass_all
;;
sequent)
lt_cv_file_magic_cmd='/bin/file'
lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
;;
sni)
lt_cv_file_magic_cmd='/bin/file'
lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
lt_cv_file_magic_test_file=/lib/libc.so
;;
siemens)
lt_cv_deplibs_check_method=pass_all
;;
pc)
lt_cv_deplibs_check_method=pass_all
;;
esac
;;
tpf*)
lt_cv_deplibs_check_method=pass_all
;;
esac
])
file_magic_glob=
want_nocaseglob=no
if test "$build" = "$host"; then
case $host_os in
mingw* | pw32*)
if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
want_nocaseglob=yes
else
file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
fi
;;
esac
fi
file_magic_cmd=$lt_cv_file_magic_cmd
deplibs_check_method=$lt_cv_deplibs_check_method
test -z "$deplibs_check_method" && deplibs_check_method=unknown
_LT_DECL([], [deplibs_check_method], [1],
[Method to check whether dependent libraries are shared objects])
_LT_DECL([], [file_magic_cmd], [1],
[Command to use when deplibs_check_method = "file_magic"])
_LT_DECL([], [file_magic_glob], [1],
[How to find potential files when deplibs_check_method = "file_magic"])
_LT_DECL([], [want_nocaseglob], [1],
[Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
])# _LT_CHECK_MAGIC_METHOD
# LT_PATH_NM
# ----------
# find the pathname to a BSD- or MS-compatible name lister
AC_DEFUN([LT_PATH_NM],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
[if test -n "$NM"; then
# Let the user override the test.
lt_cv_path_NM="$NM"
else
lt_nm_to_check="${ac_tool_prefix}nm"
if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
lt_nm_to_check="$lt_nm_to_check nm"
fi
for lt_tmp_nm in $lt_nm_to_check; do
lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
IFS="$lt_save_ifs"
test -z "$ac_dir" && ac_dir=.
tmp_nm="$ac_dir/$lt_tmp_nm"
if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
# Check to see if the nm accepts a BSD-compat flag.
# Adding the `sed 1q' prevents false positives on HP-UX, which says:
# nm: unknown option "B" ignored
# Tru64's nm complains that /dev/null is an invalid object file
case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
*/dev/null* | *'Invalid file or object type'*)
lt_cv_path_NM="$tmp_nm -B"
break
;;
*)
case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
*/dev/null*)
lt_cv_path_NM="$tmp_nm -p"
break
;;
*)
lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
continue # so that we can try to find one that supports BSD flags
;;
esac
;;
esac
fi
done
IFS="$lt_save_ifs"
done
: ${lt_cv_path_NM=no}
fi])
if test "$lt_cv_path_NM" != "no"; then
NM="$lt_cv_path_NM"
else
# Didn't find any BSD compatible name lister, look for dumpbin.
if test -n "$DUMPBIN"; then :
# Let the user override the test.
else
AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
*COFF*)
DUMPBIN="$DUMPBIN -symbols"
;;
*)
DUMPBIN=:
;;
esac
fi
AC_SUBST([DUMPBIN])
if test "$DUMPBIN" != ":"; then
NM="$DUMPBIN"
fi
fi
test -z "$NM" && NM=nm
AC_SUBST([NM])
_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
[lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&AS_MESSAGE_LOG_FD
(eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&AS_MESSAGE_LOG_FD
(eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
cat conftest.out >&AS_MESSAGE_LOG_FD
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
fi
rm -f conftest*])
])# LT_PATH_NM
# Old names:
AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_PROG_NM], [])
dnl AC_DEFUN([AC_PROG_NM], [])
# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
# --------------------------------
# how to determine the name of the shared library
# associated with a specific link library.
# -- PORTME fill in with the dynamic library characteristics
m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
[m4_require([_LT_DECL_EGREP])
m4_require([_LT_DECL_OBJDUMP])
m4_require([_LT_DECL_DLLTOOL])
AC_CACHE_CHECK([how to associate runtime and link libraries],
lt_cv_sharedlib_from_linklib_cmd,
[lt_cv_sharedlib_from_linklib_cmd='unknown'
case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
# two different shell functions defined in ltmain.sh
# decide which to use based on capabilities of $DLLTOOL
case `$DLLTOOL --help 2>&1` in
*--identify-strict*)
lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
;;
*)
lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
;;
esac
;;
*)
# fallback: assume linklib IS sharedlib
lt_cv_sharedlib_from_linklib_cmd="$ECHO"
;;
esac
])
sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
[Command to associate shared and link libraries])
])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
# _LT_PATH_MANIFEST_TOOL
# ----------------------
# locate the manifest tool
m4_defun([_LT_PATH_MANIFEST_TOOL],
[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
[lt_cv_path_mainfest_tool=no
echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
$MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
cat conftest.err >&AS_MESSAGE_LOG_FD
if $GREP 'Manifest Tool' conftest.out > /dev/null; then
lt_cv_path_mainfest_tool=yes
fi
rm -f conftest*])
if test "x$lt_cv_path_mainfest_tool" != xyes; then
MANIFEST_TOOL=:
fi
_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
])# _LT_PATH_MANIFEST_TOOL
# LT_LIB_M
# --------
# check for math library
AC_DEFUN([LT_LIB_M],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
LIBM=
case $host in
*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
# These system don't have libm, or don't need it
;;
*-ncr-sysv4.3*)
AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
;;
*)
AC_CHECK_LIB(m, cos, LIBM="-lm")
;;
esac
AC_SUBST([LIBM])
])# LT_LIB_M
# Old name:
AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_CHECK_LIBM], [])
# _LT_COMPILER_NO_RTTI([TAGNAME])
# -------------------------------
m4_defun([_LT_COMPILER_NO_RTTI],
[m4_require([_LT_TAG_COMPILER])dnl
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
if test "$GCC" = yes; then
case $cc_basename in
nvcc*)
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
*)
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
esac
_LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
lt_cv_prog_compiler_rtti_exceptions,
[-fno-rtti -fno-exceptions], [],
[_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
fi
_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
[Compiler flag to turn off builtin functions])
])# _LT_COMPILER_NO_RTTI
# _LT_CMD_GLOBAL_SYMBOLS
# ----------------------
m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([LT_PATH_NM])dnl
AC_REQUIRE([LT_PATH_LD])dnl
m4_require([_LT_DECL_SED])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_TAG_COMPILER])dnl
# Check for command to grab the raw symbol name followed by C symbol from nm.
AC_MSG_CHECKING([command to parse $NM output from $compiler object])
AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
[
# These are sane defaults that work on at least a few old systems.
# [They come from Ultrix. What could be older than Ultrix?!! ;)]
# Character class describing NM global symbol codes.
symcode='[[BCDEGRST]]'
# Regexp to match symbols that can be accessed directly from C.
sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
# Define system-specific variables.
case $host_os in
aix*)
symcode='[[BCDT]]'
;;
cygwin* | mingw* | pw32* | cegcc*)
symcode='[[ABCDGISTW]]'
;;
hpux*)
if test "$host_cpu" = ia64; then
symcode='[[ABCDEGRST]]'
fi
;;
irix* | nonstopux*)
symcode='[[BCDEGRST]]'
;;
osf*)
symcode='[[BCDEGQRST]]'
;;
solaris*)
symcode='[[BDRT]]'
;;
sco3.2v5*)
symcode='[[DT]]'
;;
sysv4.2uw2*)
symcode='[[DT]]'
;;
sysv5* | sco5v6* | unixware* | OpenUNIX*)
symcode='[[ABDT]]'
;;
sysv4)
symcode='[[DFNSTU]]'
;;
esac
# If we're using GNU nm, then use its standard symbol codes.
case `$NM -V 2>&1` in
*GNU* | *'with BFD'*)
symcode='[[ABCDGIRSTW]]' ;;
esac
# Transform an extracted symbol line into a proper C declaration.
# Some systems (esp. on ia64) link data and code symbols differently,
# so use this general approach.
lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
# Transform an extracted symbol line into symbol name and symbol address
lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
# Handle CRLF in mingw tool chain
opt_cr=
case $build_os in
mingw*)
opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
;;
esac
# Try without a prefix underscore, then with it.
for ac_symprfx in "" "_"; do
# Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
symxfrm="\\1 $ac_symprfx\\2 \\2"
# Write the raw and C identifiers.
if test "$lt_cv_nm_interface" = "MS dumpbin"; then
# Fake it for dumpbin and say T for any non-static function
# and D for any global variable.
# Also find C++ and __fastcall symbols from MSVC++,
# which start with @ or ?.
lt_cv_sys_global_symbol_pipe="$AWK ['"\
" {last_section=section; section=\$ 3};"\
" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
" \$ 0!~/External *\|/{next};"\
" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
" {if(hide[section]) next};"\
" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
" s[1]~/^[@?]/{print s[1], s[1]; next};"\
" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
" ' prfx=^$ac_symprfx]"
else
lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
fi
lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
# Check to see that the pipe works correctly.
pipe_works=no
rm -f conftest*
cat > conftest.$ac_ext <<_LT_EOF
#ifdef __cplusplus
extern "C" {
#endif
char nm_test_var;
void nm_test_func(void);
void nm_test_func(void){}
#ifdef __cplusplus
}
#endif
int main(){nm_test_var='a';nm_test_func();return(0);}
_LT_EOF
if AC_TRY_EVAL(ac_compile); then
# Now try to grab the symbols.
nlist=conftest.nm
if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
else
rm -f "$nlist"T
fi
# Make sure that we snagged all the symbols we need.
if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
cat <<_LT_EOF > conftest.$ac_ext
/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
/* DATA imports from DLLs on WIN32 con't be const, because runtime
relocations are performed -- see ld's documentation on pseudo-relocs. */
# define LT@&t@_DLSYM_CONST
#elif defined(__osf__)
/* This system does not cope well with relocations in const data. */
# define LT@&t@_DLSYM_CONST
#else
# define LT@&t@_DLSYM_CONST const
#endif
#ifdef __cplusplus
extern "C" {
#endif
_LT_EOF
# Now generate the symbol file.
eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
cat <<_LT_EOF >> conftest.$ac_ext
/* The mapping between symbol names and symbols. */
LT@&t@_DLSYM_CONST struct {
const char *name;
void *address;
}
lt__PROGRAM__LTX_preloaded_symbols[[]] =
{
{ "@PROGRAM@", (void *) 0 },
_LT_EOF
$SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
cat <<\_LT_EOF >> conftest.$ac_ext
{0, (void *) 0}
};
/* This works around a problem in FreeBSD linker */
#ifdef FREEBSD_WORKAROUND
static const void *lt_preloaded_setup() {
return lt__PROGRAM__LTX_preloaded_symbols;
}
#endif
#ifdef __cplusplus
}
#endif
_LT_EOF
# Now try linking the two files.
mv conftest.$ac_objext conftstm.$ac_objext
lt_globsym_save_LIBS=$LIBS
lt_globsym_save_CFLAGS=$CFLAGS
LIBS="conftstm.$ac_objext"
CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
pipe_works=yes
fi
LIBS=$lt_globsym_save_LIBS
CFLAGS=$lt_globsym_save_CFLAGS
else
echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
fi
else
echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
fi
else
echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
fi
else
echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
cat conftest.$ac_ext >&5
fi
rm -rf conftest* conftst*
# Do not use the global_symbol_pipe unless it works.
if test "$pipe_works" = yes; then
break
else
lt_cv_sys_global_symbol_pipe=
fi
done
])
if test -z "$lt_cv_sys_global_symbol_pipe"; then
lt_cv_sys_global_symbol_to_cdecl=
fi
if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
AC_MSG_RESULT(failed)
else
AC_MSG_RESULT(ok)
fi
# Response file support.
if test "$lt_cv_nm_interface" = "MS dumpbin"; then
nm_file_list_spec='@'
elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
nm_file_list_spec='@'
fi
_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
[Take the output of nm and produce a listing of raw symbols and C names])
_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
[Transform the output of nm in a proper C declaration])
_LT_DECL([global_symbol_to_c_name_address],
[lt_cv_sys_global_symbol_to_c_name_address], [1],
[Transform the output of nm in a C name address pair])
_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
[lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
[Transform the output of nm in a C name address pair when lib prefix is needed])
_LT_DECL([], [nm_file_list_spec], [1],
[Specify filename containing input files for $NM])
]) # _LT_CMD_GLOBAL_SYMBOLS
# _LT_COMPILER_PIC([TAGNAME])
# ---------------------------
m4_defun([_LT_COMPILER_PIC],
[m4_require([_LT_TAG_COMPILER])dnl
_LT_TAGVAR(lt_prog_compiler_wl, $1)=
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_static, $1)=
m4_if([$1], [CXX], [
# C++ specific cases for pic, static, wl, etc.
if test "$GXX" = yes; then
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
case $host_os in
aix*)
# All AIX code is PIC.
if test "$host_cpu" = ia64; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
;;
amigaos*)
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
m68k)
# FIXME: we need at least 68020 code to build shared libraries, but
# adding the `-m68020' flag to GCC prevents building anything better,
# like `-m68040'.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
;;
esac
;;
beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
# PIC is the default for these OSes.
;;
mingw* | cygwin* | os2* | pw32* | cegcc*)
# This hack is so that the source file can tell whether it is being
# built for inclusion in a dll (and should export symbols for example).
# Although the cygwin gcc ignores -fPIC, still need this for old-style
# (--disable-auto-import) libraries
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
;;
darwin* | rhapsody*)
# PIC is the default on this platform
# Common symbols not allowed in MH_DYLIB files
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
;;
*djgpp*)
# DJGPP does not support shared libraries at all
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
;;
haiku*)
# PIC is the default for Haiku.
# The "-static" flag exists, but is broken.
_LT_TAGVAR(lt_prog_compiler_static, $1)=
;;
interix[[3-9]]*)
# Interix 3.x gcc -fpic/-fPIC options generate broken code.
# Instead, we relocate shared libraries at runtime.
;;
sysv4*MP*)
if test -d /usr/nec; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
fi
;;
hpux*)
# PIC is the default for 64-bit PA HP-UX, but not for 32-bit
# PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
# sets the default TLS model and affects inlining.
case $host_cpu in
hppa*64*)
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
esac
;;
*qnx* | *nto*)
# QNX uses GNU C++, but need to define -shared option too, otherwise
# it will coredump.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
esac
else
case $host_os in
aix[[4-9]]*)
# All AIX code is PIC.
if test "$host_cpu" = ia64; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
fi
;;
chorus*)
case $cc_basename in
cxch68*)
# Green Hills C++ Compiler
# _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
;;
esac
;;
mingw* | cygwin* | os2* | pw32* | cegcc*)
# This hack is so that the source file can tell whether it is being
# built for inclusion in a dll (and should export symbols for example).
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
;;
dgux*)
case $cc_basename in
ec++*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
;;
ghcx*)
# Green Hills C++ Compiler
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
;;
*)
;;
esac
;;
freebsd* | dragonfly*)
# FreeBSD uses GNU C++
;;
hpux9* | hpux10* | hpux11*)
case $cc_basename in
CC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
if test "$host_cpu" != ia64; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
fi
;;
aCC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
case $host_cpu in
hppa*64*|ia64*)
# +Z the default
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
;;
esac
;;
*)
;;
esac
;;
interix*)
# This is c89, which is MS Visual C++ (no shared libs)
# Anyone wants to do a port?
;;
irix5* | irix6* | nonstopux*)
case $cc_basename in
CC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
# CC pic flag -KPIC is the default.
;;
*)
;;
esac
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# KAI C++ Compiler
_LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
ecpc* )
# old Intel C++ for x86_64 which still supported -KPIC.
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
;;
icpc* )
# Intel C++, used to be incompatible with GCC.
# ICC 10 doesn't accept -KPIC any more.
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
;;
pgCC* | pgcpp*)
# Portland Group C++ compiler
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
cxx*)
# Compaq C++
# Make sure the PIC flag is empty. It appears that all Alpha
# Linux and Compaq Tru64 Unix objects are PIC.
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
# IBM XL 8.0, 9.0 on PPC and BlueGene
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*)
# Sun C++ 5.9
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
;;
esac
;;
esac
;;
lynxos*)
;;
m88k*)
;;
mvs*)
case $cc_basename in
cxx*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
;;
*)
;;
esac
;;
netbsd* | netbsdelf*-gnu)
;;
*qnx* | *nto*)
# QNX uses GNU C++, but need to define -shared option too, otherwise
# it will coredump.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
;;
osf3* | osf4* | osf5*)
case $cc_basename in
KCC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
;;
RCC*)
# Rational C++ 2.4.1
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
;;
cxx*)
# Digital/Compaq C++
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# Make sure the PIC flag is empty. It appears that all Alpha
# Linux and Compaq Tru64 Unix objects are PIC.
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
*)
;;
esac
;;
psos*)
;;
solaris*)
case $cc_basename in
CC* | sunCC*)
# Sun C++ 4.2, 5.x and Centerline C++
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
;;
gcx*)
# Green Hills C++ Compiler
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
;;
*)
;;
esac
;;
sunos4*)
case $cc_basename in
CC*)
# Sun C++ 4.x
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
lcc*)
# Lucid
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
;;
*)
;;
esac
;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
case $cc_basename in
CC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
esac
;;
tandem*)
case $cc_basename in
NCC*)
# NonStop-UX NCC 3.20
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
;;
*)
;;
esac
;;
vxworks*)
;;
*)
_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
;;
esac
fi
],
[
if test "$GCC" = yes; then
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
case $host_os in
aix*)
# All AIX code is PIC.
if test "$host_cpu" = ia64; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
;;
amigaos*)
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
m68k)
# FIXME: we need at least 68020 code to build shared libraries, but
# adding the `-m68020' flag to GCC prevents building anything better,
# like `-m68040'.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
;;
esac
;;
beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
# PIC is the default for these OSes.
;;
mingw* | cygwin* | pw32* | os2* | cegcc*)
# This hack is so that the source file can tell whether it is being
# built for inclusion in a dll (and should export symbols for example).
# Although the cygwin gcc ignores -fPIC, still need this for old-style
# (--disable-auto-import) libraries
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
;;
darwin* | rhapsody*)
# PIC is the default on this platform
# Common symbols not allowed in MH_DYLIB files
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
;;
haiku*)
# PIC is the default for Haiku.
# The "-static" flag exists, but is broken.
_LT_TAGVAR(lt_prog_compiler_static, $1)=
;;
hpux*)
# PIC is the default for 64-bit PA HP-UX, but not for 32-bit
# PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
# sets the default TLS model and affects inlining.
case $host_cpu in
hppa*64*)
# +Z the default
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
esac
;;
interix[[3-9]]*)
# Interix 3.x gcc -fpic/-fPIC options generate broken code.
# Instead, we relocate shared libraries at runtime.
;;
msdosdjgpp*)
# Just because we use GCC doesn't mean we suddenly get shared libraries
# on systems that don't support them.
_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
enable_shared=no
;;
*nto* | *qnx*)
# QNX uses GNU C++, but need to define -shared option too, otherwise
# it will coredump.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
;;
sysv4*MP*)
if test -d /usr/nec; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
fi
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
esac
case $cc_basename in
nvcc*) # Cuda Compiler Driver 2.2
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
fi
;;
esac
else
# PORTME Check for flag to pass linker flags through the system compiler.
case $host_os in
aix*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
if test "$host_cpu" = ia64; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
fi
;;
mingw* | cygwin* | pw32* | os2* | cegcc*)
# This hack is so that the source file can tell whether it is being
# built for inclusion in a dll (and should export symbols for example).
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
;;
hpux9* | hpux10* | hpux11*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
# not for PA HP-UX.
case $host_cpu in
hppa*64*|ia64*)
# +Z the default
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
;;
esac
# Is there a better lt_prog_compiler_static that works with the bundled CC?
_LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
;;
irix5* | irix6* | nonstopux*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# PIC (with -KPIC) is the default.
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
# old Intel for x86_64 which still supported -KPIC.
ecc*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
;;
# icc used to be incompatible with GCC.
# ICC 10 doesn't accept -KPIC any more.
icc* | ifort*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
;;
# Lahey Fortran 8.1.
lf95*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
;;
nagfor*)
# NAG Fortran compiler
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
# Portland Group compilers (*not* the Pentium gcc compiler,
# which looks to be a dead project)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
ccc*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# All Alpha code is PIC.
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
xl* | bgxl* | bgf* | mpixl*)
# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
# Sun Fortran 8.3 passes all unrecognized flags to the linker
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
_LT_TAGVAR(lt_prog_compiler_wl, $1)=''
;;
*Sun\ F* | *Sun*Fortran*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
;;
*Sun\ C*)
# Sun C 5.9
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
;;
*Intel*\ [[CF]]*Compiler*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
;;
*Portland\ Group*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
esac
;;
esac
;;
newsos6)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
*nto* | *qnx*)
# QNX uses GNU C++, but need to define -shared option too, otherwise
# it will coredump.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
;;
osf3* | osf4* | osf5*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# All OSF/1 code is PIC.
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
rdos*)
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
solaris*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
case $cc_basename in
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
esac
;;
sunos4*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
sysv4 | sysv4.2uw2* | sysv4.3*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
sysv4*MP*)
if test -d /usr/nec ;then
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
unicos*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
;;
uts4*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
*)
_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
;;
esac
fi
])
case $host_os in
# For platforms which do not support PIC, -DPIC is meaningless:
*djgpp*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
;;
*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
;;
esac
AC_CACHE_CHECK([for $compiler option to produce PIC],
[_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
[_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
#
# Check to make sure the PIC flag actually works.
#
if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
_LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
[_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
[$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
[case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
"" | " "*) ;;
*) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
esac],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
fi
_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
[Additional compiler flags for building library objects])
_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
[How to pass a linker flag through the compiler])
#
# Check to make sure the static flag actually works.
#
wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
_LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
$lt_tmp_static_flag,
[],
[_LT_TAGVAR(lt_prog_compiler_static, $1)=])
_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
[Compiler flag to prevent dynamic linking])
])# _LT_COMPILER_PIC
# _LT_LINKER_SHLIBS([TAGNAME])
# ----------------------------
# See if the linker supports building shared libraries.
m4_defun([_LT_LINKER_SHLIBS],
[AC_REQUIRE([LT_PATH_LD])dnl
AC_REQUIRE([LT_PATH_NM])dnl
m4_require([_LT_PATH_MANIFEST_TOOL])dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_DECL_SED])dnl
m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
m4_require([_LT_TAG_COMPILER])dnl
AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
m4_if([$1], [CXX], [
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
_LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
case $host_os in
aix[[4-9]]*)
# If we're using GNU nm, then we don't want the "-C" option.
# -C means demangle to AIX nm, but means don't demangle with GNU nm
# Also, AIX nm treats weak defined symbols like other global defined
# symbols, whereas GNU nm marks them as "W".
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
_LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
else
_LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
fi
;;
pw32*)
_LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
;;
cygwin* | mingw* | cegcc*)
case $cc_basename in
cl*)
_LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
;;
*)
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
_LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
;;
esac
;;
linux* | k*bsd*-gnu | gnu*)
_LT_TAGVAR(link_all_deplibs, $1)=no
;;
*)
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
;;
esac
], [
runpath_var=
_LT_TAGVAR(allow_undefined_flag, $1)=
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(archive_cmds, $1)=
_LT_TAGVAR(archive_expsym_cmds, $1)=
_LT_TAGVAR(compiler_needs_object, $1)=no
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
_LT_TAGVAR(hardcode_automatic, $1)=no
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
_LT_TAGVAR(inherit_rpath, $1)=no
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(module_cmds, $1)=
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(old_archive_from_new_cmds, $1)=
_LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
_LT_TAGVAR(thread_safe_flag_spec, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
# include_expsyms should be a list of space-separated symbols to be *always*
# included in the symbol list
_LT_TAGVAR(include_expsyms, $1)=
# exclude_expsyms can be an extended regexp of symbols to exclude
# it will be wrapped by ` (' and `)$', so one must not match beginning or
# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
# as well as any symbol that contains `d'.
_LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
# platforms (ab)use it in PIC code, but their linkers get confused if
# the symbol is explicitly referenced. Since portable code cannot
# rely on this symbol name, it's probably fine to never include it in
# preloaded symbol tables.
# Exclude shared library initialization/finalization symbols.
dnl Note also adjust exclude_expsyms for C++ above.
extract_expsyms_cmds=
case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*)
with_gnu_ld=no
;;
linux* | k*bsd*-gnu | gnu*)
_LT_TAGVAR(link_all_deplibs, $1)=no
;;
esac
_LT_TAGVAR(ld_shlibs, $1)=yes
# On some targets, GNU ld is compatible enough with the native linker
# that we're better off using the native interface for both.
lt_use_gnu_ld_interface=no
if test "$with_gnu_ld" = yes; then
case $host_os in
aix*)
# The AIX port of GNU ld has always aspired to compatibility
# with the native linker. However, as the warning in the GNU ld
# block says, versions before 2.19.5* couldn't really create working
# shared libraries, regardless of the interface used.
case `$LD -v 2>&1` in
*\ \(GNU\ Binutils\)\ 2.19.5*) ;;
*\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
*\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
*)
lt_use_gnu_ld_interface=yes
;;
esac
;;
*)
lt_use_gnu_ld_interface=yes
;;
esac
fi
if test "$lt_use_gnu_ld_interface" = yes; then
# If archive_cmds runs LD, not CC, wlarc should be empty
wlarc='${wl}'
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
runpath_var=LD_RUN_PATH
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
# ancient GNU ld didn't support --whole-archive et. al.
if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
_LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
supports_anon_versioning=no
case `$LD -v 2>&1` in
*GNU\ gold*) supports_anon_versioning=yes ;;
*\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
*\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
*\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
*\ 2.11.*) ;; # other 2.11 versions
*) supports_anon_versioning=yes ;;
esac
# See if GNU ld supports shared libraries.
case $host_os in
aix[[3-9]]*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
*** Warning: the GNU linker, at least up to release 2.19, is reported
*** to be unable to reliably create shared libraries on AIX.
*** Therefore, libtool is disabling shared libraries support. If you
*** really care for shared libraries, you may want to install binutils
*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
*** You will then need to restart the configuration process.
_LT_EOF
fi
;;
amigaos*)
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)=''
;;
m68k)
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_minus_L, $1)=yes
;;
esac
;;
beos*)
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
# support --undefined. This deserves some investigation. FIXME
_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
cygwin* | mingw* | pw32* | cegcc*)
# _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
_LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
# If the export-symbols file already is a .def file (1st line
# is EXPORTS), use it as is; otherwise, prepend...
_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
cp $export_symbols $output_objdir/$soname.def;
else
echo EXPORTS > $output_objdir/$soname.def;
cat $export_symbols >> $output_objdir/$soname.def;
fi~
$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
haiku*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
interix[[3-9]]*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
# Instead, shared libraries are loaded at an image base (0x10000000 by
# default) and relocated if they conflict, which is a slow very memory
# consuming and fragmenting process. To avoid this, we pick a random,
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space.
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;;
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
tmp_diet=no
if test "$host_os" = linux-dietlibc; then
case $cc_basename in
diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
esac
fi
if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
&& test "$tmp_diet" = no
then
tmp_addflag=' $pic_flag'
tmp_sharedflag='-shared'
case $cc_basename,$host_cpu in
pgcc*) # Portland Group C compiler
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
tmp_addflag=' $pic_flag'
;;
pgf77* | pgf90* | pgf95* | pgfortran*)
# Portland Group f77 and f90 compilers
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
tmp_addflag=' $pic_flag -Mnomain' ;;
ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
tmp_addflag=' -i_dynamic' ;;
efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
tmp_addflag=' -i_dynamic -nofor_main' ;;
ifc* | ifort*) # Intel Fortran compiler
tmp_addflag=' -nofor_main' ;;
lf95*) # Lahey Fortran 8.1
_LT_TAGVAR(whole_archive_flag_spec, $1)=
tmp_sharedflag='--shared' ;;
xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
tmp_sharedflag='-qmkshrobj'
tmp_addflag= ;;
nvcc*) # Cuda Compiler Driver 2.2
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
;;
esac
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*) # Sun C 5.9
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
tmp_sharedflag='-G' ;;
*Sun\ F*) # Sun Fortran 8.3
tmp_sharedflag='-G' ;;
esac
_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
if test "x$supports_anon_versioning" = xyes; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
echo "local: *; };" >> $output_objdir/$libname.ver~
$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
fi
case $cc_basename in
xlf* | bgf* | bgxlf* | mpixlf*)
# IBM XL Fortran 10.1 on PPC cannot create shared libs itself
_LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
if test "x$supports_anon_versioning" = xyes; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
echo "local: *; };" >> $output_objdir/$libname.ver~
$LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
fi
;;
esac
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc=
else
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
fi
;;
solaris*)
if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
*** Warning: The releases 2.8.* of the GNU linker cannot reliably
*** create shared libraries on Solaris systems. Therefore, libtool
*** is disabling shared libraries support. We urge you to upgrade GNU
*** binutils to release 2.9.1 or newer. Another option is to modify
*** your PATH or compiler configuration so that the native linker is
*** used, and then restart.
_LT_EOF
elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
*** reliably create shared libraries on SCO systems. Therefore, libtool
*** is disabling shared libraries support. We urge you to upgrade GNU
*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
*** your PATH or compiler configuration so that the native linker is
*** used, and then restart.
_LT_EOF
;;
*)
# For security reasons, it is highly recommended that you always
# use absolute paths for naming shared libraries, and exclude the
# DT_RUNPATH tag from executables and libraries. But doing so
# requires that you compile everything twice, which is a pain.
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
;;
sunos4*)
_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
wlarc=
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
*)
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
runpath_var=
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
else
# PORTME fill in a description of your system's linker (not GNU ld)
case $host_os in
aix3*)
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=yes
_LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
_LT_TAGVAR(hardcode_direct, $1)=unsupported
fi
;;
aix[[4-9]]*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
exp_sym_flag='-Bexport'
no_entry_flag=""
else
# If we're using GNU nm, then we don't want the "-C" option.
# -C means demangle to AIX nm, but means don't demangle with GNU nm
# Also, AIX nm treats weak defined symbols like other global
# defined symbols, whereas GNU nm marks them as "W".
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
_LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
else
_LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
fi
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
;;
esac
exp_sym_flag='-bexport'
no_entry_flag='-bnoentry'
fi
# When large executables or shared objects are built, AIX ld can
# have problems creating the table of contents. If linking a library
# or program results in "error TOC overflow" add -mminimal-toc to
# CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
# enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
_LT_TAGVAR(archive_cmds, $1)=''
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
_LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
if test "$GCC" = yes; then
case $host_os in aix4.[[012]]|aix4.[[012]].*)
# We only want to do this on AIX 4.2 and lower, the check
# below for broken collect2 doesn't work under 4.3+
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" &&
strings "$collect2name" | $GREP resolve_lib_name >/dev/null
then
# We have reworked collect2
:
else
# We have old collect2
_LT_TAGVAR(hardcode_direct, $1)=unsupported
# It fails to find uninstalled libraries when the uninstalled
# path is not listed in the libpath. Setting hardcode_minus_L
# to unsupported forces relinking
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=
fi
;;
esac
shared_flag='-shared'
if test "$aix_use_runtimelinking" = yes; then
shared_flag="$shared_flag "'${wl}-G'
fi
_LT_TAGVAR(link_all_deplibs, $1)=no
else
# not using gcc
if test "$host_cpu" = ia64; then
# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
# chokes on -Wl,-G. The following line is correct:
shared_flag='-G'
else
if test "$aix_use_runtimelinking" = yes; then
shared_flag='${wl}-G'
else
shared_flag='${wl}-bM:SRE'
fi
fi
fi
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
# It seems that -bexpall does not export symbols beginning with
# underscore (_), so it is better to generate a list of symbols to export.
_LT_TAGVAR(always_export_symbols, $1)=yes
if test "$aix_use_runtimelinking" = yes; then
# Warning - without using the other runtime loading flags (-brtl),
# -berok will link without error, but may produce a broken library.
_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
# Determine the default libpath from the value encoded in an
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
else
if test "$host_cpu" = ia64; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
_LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
# Warning - without using the other run time loading flags,
# -berok will link without error, but may produce a broken library.
_LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
if test "$with_gnu_ld" = yes; then
# We only use this code for GNU lds that support --whole-archive.
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
else
# Exported symbols can be pulled into shared objects from archives
_LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
# This is similar to how AIX traditionally builds its shared libraries.
_LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
fi
fi
;;
amigaos*)
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)=''
;;
m68k)
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_minus_L, $1)=yes
;;
esac
;;
bsdi[[45]]*)
_LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
;;
cygwin* | mingw* | pw32* | cegcc*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
case $cc_basename in
cl*)
# Native MSVC
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=yes
_LT_TAGVAR(file_list_spec, $1)='@'
# Tell ltmain to make .lib files, not .a files.
libext=lib
# Tell ltmain to make .dll files, not .so files.
shrext_cmds=".dll"
# FIXME: Setting linknames here is a bad hack.
_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
else
sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
fi~
$CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
linknames='
# The linker will not automatically build a static lib if we build a DLL.
# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
_LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
# Don't use ranlib
_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
lt_tool_outputfile="@TOOL_OUTPUT@"~
case $lt_outputfile in
*.exe|*.EXE) ;;
*)
lt_outputfile="$lt_outputfile.exe"
lt_tool_outputfile="$lt_tool_outputfile.exe"
;;
esac~
if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
$MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
$RM "$lt_outputfile.manifest";
fi'
;;
*)
# Assume MSVC wrapper
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Tell ltmain to make .lib files, not .a files.
libext=lib
# Tell ltmain to make .dll files, not .so files.
shrext_cmds=".dll"
# FIXME: Setting linknames here is a bad hack.
_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
# The linker will automatically build a .lib file if we build a DLL.
_LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
# FIXME: Should let the user specify the lib program.
_LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
;;
esac
;;
darwin* | rhapsody*)
_LT_DARWIN_LINKER_FEATURES($1)
;;
dgux*)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
# FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
# support. Future versions do this automatically, but an explicit c++rt0.o
# does not break anything, and helps significantly (at the cost of a little
# extra space).
freebsd2.2*)
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
# Unfortunately, older versions of FreeBSD 2 do not have this feature.
freebsd2.*)
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
# FreeBSD 3 and greater uses gcc -shared to do shared libraries.
freebsd* | dragonfly*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
hpux9*)
if test "$GCC" = yes; then
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
else
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
fi
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_direct, $1)=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
;;
hpux10*)
if test "$GCC" = yes && test "$with_gnu_ld" = no; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
fi
if test "$with_gnu_ld" = no; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
fi
;;
hpux11*)
if test "$GCC" = yes && test "$with_gnu_ld" = no; then
case $host_cpu in
hppa*64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
ia64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
else
case $host_cpu in
hppa*64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
ia64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
m4_if($1, [], [
# Older versions of the 11.00 compiler do not understand -b yet
# (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
_LT_LINKER_OPTION([if $CC understands -b],
_LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
[_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
[_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
[_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
;;
esac
fi
if test "$with_gnu_ld" = no; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
case $host_cpu in
hppa*64*|ia64*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
*)
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
if test "$GCC" = yes; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
# Try to use the -exported_symbol ld option, if it does not
# work, assume that -exports_file does not work either and
# implicitly export all symbols.
# This should be the same for all languages, so no per-tag cache variable.
AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
[lt_cv_irix_exported_symbol],
[save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
AC_LINK_IFELSE(
[AC_LANG_SOURCE(
[AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
[C++], [[int foo (void) { return 0; }]],
[Fortran 77], [[
subroutine foo
end]],
[Fortran], [[
subroutine foo
end]])])],
[lt_cv_irix_exported_symbol=yes],
[lt_cv_irix_exported_symbol=no])
LDFLAGS="$save_LDFLAGS"])
if test "$lt_cv_irix_exported_symbol" = yes; then
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
fi
else
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(inherit_rpath, $1)=yes
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
netbsd* | netbsdelf*-gnu)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
else
_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
fi
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
newsos6)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
*nto* | *qnx*)
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
else
case $host_os in
openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
;;
esac
fi
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
os2*)
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
_LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
;;
osf3*)
if test "$GCC" = yes; then
_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
else
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
;;
osf4* | osf5*) # as osf3* with the addition of -msym flag
if test "$GCC" = yes; then
_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
else
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
# Both c and cxx compiler support -rpath directly
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
;;
solaris*)
_LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
if test "$GCC" = yes; then
wlarc='${wl}'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
else
case `$CC -V 2>&1` in
*"Compilers 5.0"*)
wlarc=''
_LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
;;
*)
wlarc='${wl}'
_LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
$CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
;;
esac
fi
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
case $host_os in
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
# The compiler driver will combine and reorder linker options,
# but understands `-z linker_flag'. GCC discards it without `$wl',
# but is careful enough not to reorder.
# Supported since Solaris 2.6 (maybe 2.5.1?)
if test "$GCC" = yes; then
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
fi
;;
esac
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
sunos4*)
if test "x$host_vendor" = xsequent; then
# Use $CC to link under sequent, because it throws in some extra .o
# files that make .init and .fini sections work.
_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
fi
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
sysv4)
case $host_vendor in
sni)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
;;
siemens)
## LD is ld it makes a PLAMLIB
## CC just makes a GrossModule.
_LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
_LT_TAGVAR(hardcode_direct, $1)=no
;;
motorola)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
;;
esac
runpath_var='LD_RUN_PATH'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
sysv4.3*)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
;;
sysv4*MP*)
if test -d /usr/nec; then
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var=LD_RUN_PATH
hardcode_runpath_var=yes
_LT_TAGVAR(ld_shlibs, $1)=yes
fi
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var='LD_RUN_PATH'
if test "$GCC" = yes; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
fi
;;
sysv5* | sco3.2v5* | sco5v6*)
# Note: We can NOT use -z defs as we might desire, because we do not
# link with -lc, and that would cause any symbols used from libc to
# always be unresolved, which means just about no library would
# ever link correctly. If we're not using GNU ld we use -z text
# though, which does catch some bad symbols but isn't as heavy-handed
# as -z defs.
_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
runpath_var='LD_RUN_PATH'
if test "$GCC" = yes; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
fi
;;
uts4*)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
*)
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
if test x$host_vendor = xsni; then
case $host in
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
;;
esac
fi
fi
])
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
_LT_DECL([], [extract_expsyms_cmds], [2],
[The commands to extract the exported symbol list from a shared archive])
#
# Do we need to explicitly link libc?
#
case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
x|xyes)
# Assume -lc should be added
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
if test "$enable_shared" = yes && test "$GCC" = yes; then
case $_LT_TAGVAR(archive_cmds, $1) in
*'~'*)
# FIXME: we may have to deal with multi-command sequences.
;;
'$CC '*)
# Test whether the compiler implicitly links with -lc since on some
# systems, -lgcc has to come before -lc. If gcc already passes -lc
# to ld, don't add -lc before -lgcc.
AC_CACHE_CHECK([whether -lc should be explicitly linked in],
[lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
[$RM conftest*
echo "$lt_simple_compile_test_code" > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
soname=conftest
lib=conftest
libobjs=conftest.$ac_objext
deplibs=
wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
compiler_flags=-v
linker_flags=-v
verstring=
output_objdir=.
libname=conftest
lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
_LT_TAGVAR(allow_undefined_flag, $1)=
if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
then
lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
else
lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
fi
_LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
else
cat conftest.err 1>&5
fi
$RM conftest*
])
_LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
;;
esac
fi
;;
esac
_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
[Whether or not to add -lc for building shared libraries])
_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
[enable_shared_with_static_runtimes], [0],
[Whether or not to disallow shared libs when runtime libs are static])
_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
[Compiler flag to allow reflexive dlopens])
_LT_TAGDECL([], [whole_archive_flag_spec], [1],
[Compiler flag to generate shared objects directly from archives])
_LT_TAGDECL([], [compiler_needs_object], [1],
[Whether the compiler copes with passing no objects directly])
_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
[Create an old-style archive from a shared archive])
_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
[Create a temporary old-style archive to link instead of a shared archive])
_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
_LT_TAGDECL([], [archive_expsym_cmds], [2])
_LT_TAGDECL([], [module_cmds], [2],
[Commands used to build a loadable module if different from building
a shared archive.])
_LT_TAGDECL([], [module_expsym_cmds], [2])
_LT_TAGDECL([], [with_gnu_ld], [1],
[Whether we are building with GNU ld or not])
_LT_TAGDECL([], [allow_undefined_flag], [1],
[Flag that allows shared libraries with undefined symbols to be built])
_LT_TAGDECL([], [no_undefined_flag], [1],
[Flag that enforces no undefined symbols])
_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
[Flag to hardcode $libdir into a binary during linking.
This must work even if $libdir does not exist])
_LT_TAGDECL([], [hardcode_libdir_separator], [1],
[Whether we need a single "-rpath" flag with a separated argument])
_LT_TAGDECL([], [hardcode_direct], [0],
[Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
DIR into the resulting binary])
_LT_TAGDECL([], [hardcode_direct_absolute], [0],
[Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
DIR into the resulting binary and the resulting library dependency is
"absolute", i.e impossible to change by setting ${shlibpath_var} if the
library is relocated])
_LT_TAGDECL([], [hardcode_minus_L], [0],
[Set to "yes" if using the -LDIR flag during linking hardcodes DIR
into the resulting binary])
_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
[Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
into the resulting binary])
_LT_TAGDECL([], [hardcode_automatic], [0],
[Set to "yes" if building a shared library automatically hardcodes DIR
into the library and all subsequent libraries and executables linked
against it])
_LT_TAGDECL([], [inherit_rpath], [0],
[Set to yes if linker adds runtime paths of dependent libraries
to runtime path list])
_LT_TAGDECL([], [link_all_deplibs], [0],
[Whether libtool must link a program against all its dependency libraries])
_LT_TAGDECL([], [always_export_symbols], [0],
[Set to "yes" if exported symbols are required])
_LT_TAGDECL([], [export_symbols_cmds], [2],
[The commands to list exported symbols])
_LT_TAGDECL([], [exclude_expsyms], [1],
[Symbols that should not be listed in the preloaded symbols])
_LT_TAGDECL([], [include_expsyms], [1],
[Symbols that must always be exported])
_LT_TAGDECL([], [prelink_cmds], [2],
[Commands necessary for linking programs (against libraries) with templates])
_LT_TAGDECL([], [postlink_cmds], [2],
[Commands necessary for finishing linking programs])
_LT_TAGDECL([], [file_list_spec], [1],
[Specify filename containing input files])
dnl FIXME: Not yet implemented
dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
dnl [Compiler flag to generate thread safe objects])
])# _LT_LINKER_SHLIBS
# _LT_LANG_C_CONFIG([TAG])
# ------------------------
# Ensure that the configuration variables for a C compiler are suitably
# defined. These variables are subsequently used by _LT_CONFIG to write
# the compiler configuration to `libtool'.
m4_defun([_LT_LANG_C_CONFIG],
[m4_require([_LT_DECL_EGREP])dnl
lt_save_CC="$CC"
AC_LANG_PUSH(C)
# Source file extension for C test sources.
ac_ext=c
# Object file extension for compiled C test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# Code to be used in simple compile tests
lt_simple_compile_test_code="int some_variable = 0;"
# Code to be used in simple link tests
lt_simple_link_test_code='int main(){return(0);}'
_LT_TAG_COMPILER
# Save the default compiler, since it gets overwritten when the other
# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
compiler_DEFAULT=$CC
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
if test -n "$compiler"; then
_LT_COMPILER_NO_RTTI($1)
_LT_COMPILER_PIC($1)
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
LT_SYS_DLOPEN_SELF
_LT_CMD_STRIPLIB
# Report which library types will actually be built
AC_MSG_CHECKING([if libtool supports shared libraries])
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
test "$can_build_shared" = "no" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
test "$enable_shared" = yes && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
test "$enable_shared" = yes && enable_static=no
fi
;;
esac
AC_MSG_RESULT([$enable_shared])
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
test "$enable_shared" = yes || enable_static=yes
AC_MSG_RESULT([$enable_static])
_LT_CONFIG($1)
fi
AC_LANG_POP
CC="$lt_save_CC"
])# _LT_LANG_C_CONFIG
# _LT_LANG_CXX_CONFIG([TAG])
# --------------------------
# Ensure that the configuration variables for a C++ compiler are suitably
# defined. These variables are subsequently used by _LT_CONFIG to write
# the compiler configuration to `libtool'.
m4_defun([_LT_LANG_CXX_CONFIG],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_PATH_MANIFEST_TOOL])dnl
if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
(test "X$CXX" != "Xg++"))) ; then
AC_PROG_CXXCPP
else
_lt_caught_CXX_error=yes
fi
AC_LANG_PUSH(C++)
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(allow_undefined_flag, $1)=
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(archive_expsym_cmds, $1)=
_LT_TAGVAR(compiler_needs_object, $1)=no
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
_LT_TAGVAR(hardcode_automatic, $1)=no
_LT_TAGVAR(inherit_rpath, $1)=no
_LT_TAGVAR(module_cmds, $1)=
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
_LT_TAGVAR(reload_flag, $1)=$reload_flag
_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
_LT_TAGVAR(no_undefined_flag, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
# Source file extension for C++ test sources.
ac_ext=cpp
# Object file extension for compiled C++ test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# No sense in running all these tests if we already determined that
# the CXX compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
if test "$_lt_caught_CXX_error" != yes; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="int some_variable = 0;"
# Code to be used in simple link tests
lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
lt_save_CC=$CC
lt_save_CFLAGS=$CFLAGS
lt_save_LD=$LD
lt_save_GCC=$GCC
GCC=$GXX
lt_save_with_gnu_ld=$with_gnu_ld
lt_save_path_LD=$lt_cv_path_LD
if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
else
$as_unset lt_cv_prog_gnu_ld
fi
if test -n "${lt_cv_path_LDCXX+set}"; then
lt_cv_path_LD=$lt_cv_path_LDCXX
else
$as_unset lt_cv_path_LD
fi
test -z "${LDCXX+set}" || LD=$LDCXX
CC=${CXX-"c++"}
CFLAGS=$CXXFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
if test -n "$compiler"; then
# We don't want -fno-exception when compiling C++ code, so set the
# no_builtin_flag separately
if test "$GXX" = yes; then
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
else
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
fi
if test "$GXX" = yes; then
# Set up default GNU C++ configuration
LT_PATH_LD
# Check if GNU C++ uses GNU ld as the underlying linker, since the
# archiving commands below assume that GNU ld is being used.
if test "$with_gnu_ld" = yes; then
_LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
# If archive_cmds runs LD, not CC, wlarc should be empty
# XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
# investigate it a little bit more. (MM)
wlarc='${wl}'
# ancient GNU ld didn't support --whole-archive et. al.
if eval "`$CC -print-prog-name=ld` --help 2>&1" |
$GREP 'no-whole-archive' > /dev/null; then
_LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
else
with_gnu_ld=no
wlarc=
# A generic and very simple default shared library creation
# command for GNU C++ for the case where it uses the native
# linker, instead of GNU ld. If possible, this setting should
# overridden to take advantage of the native linker features on
# the platform it is being used on.
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
fi
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
GXX=no
with_gnu_ld=no
wlarc=
fi
# PORTME: fill in a description of your system's C++ link characteristics
AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
_LT_TAGVAR(ld_shlibs, $1)=yes
case $host_os in
aix3*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aix[[4-9]]*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
exp_sym_flag='-Bexport'
no_entry_flag=""
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
for ld_flag in $LDFLAGS; do
case $ld_flag in
*-brtl*)
aix_use_runtimelinking=yes
break
;;
esac
done
;;
esac
exp_sym_flag='-bexport'
no_entry_flag='-bnoentry'
fi
# When large executables or shared objects are built, AIX ld can
# have problems creating the table of contents. If linking a library
# or program results in "error TOC overflow" add -mminimal-toc to
# CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
# enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
_LT_TAGVAR(archive_cmds, $1)=''
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
_LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
if test "$GXX" = yes; then
case $host_os in aix4.[[012]]|aix4.[[012]].*)
# We only want to do this on AIX 4.2 and lower, the check
# below for broken collect2 doesn't work under 4.3+
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" &&
strings "$collect2name" | $GREP resolve_lib_name >/dev/null
then
# We have reworked collect2
:
else
# We have old collect2
_LT_TAGVAR(hardcode_direct, $1)=unsupported
# It fails to find uninstalled libraries when the uninstalled
# path is not listed in the libpath. Setting hardcode_minus_L
# to unsupported forces relinking
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=
fi
esac
shared_flag='-shared'
if test "$aix_use_runtimelinking" = yes; then
shared_flag="$shared_flag "'${wl}-G'
fi
else
# not using gcc
if test "$host_cpu" = ia64; then
# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
# chokes on -Wl,-G. The following line is correct:
shared_flag='-G'
else
if test "$aix_use_runtimelinking" = yes; then
shared_flag='${wl}-G'
else
shared_flag='${wl}-bM:SRE'
fi
fi
fi
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
# It seems that -bexpall does not export symbols beginning with
# underscore (_), so it is better to generate a list of symbols to
# export.
_LT_TAGVAR(always_export_symbols, $1)=yes
if test "$aix_use_runtimelinking" = yes; then
# Warning - without using the other runtime loading flags (-brtl),
# -berok will link without error, but may produce a broken library.
_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
# Determine the default libpath from the value encoded in an empty
# executable.
_LT_SYS_MODULE_PATH_AIX([$1])
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
else
if test "$host_cpu" = ia64; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
_LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
# Warning - without using the other run time loading flags,
# -berok will link without error, but may produce a broken library.
_LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
if test "$with_gnu_ld" = yes; then
# We only use this code for GNU lds that support --whole-archive.
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
else
# Exported symbols can be pulled into shared objects from archives
_LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
# This is similar to how AIX traditionally builds its shared
# libraries.
_LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
fi
fi
;;
beos*)
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
# support --undefined. This deserves some investigation. FIXME
_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
chorus*)
case $cc_basename in
*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
;;
cygwin* | mingw* | pw32* | cegcc*)
case $GXX,$cc_basename in
,cl* | no,cl*)
# Native MSVC
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=yes
_LT_TAGVAR(file_list_spec, $1)='@'
# Tell ltmain to make .lib files, not .a files.
libext=lib
# Tell ltmain to make .dll files, not .so files.
shrext_cmds=".dll"
# FIXME: Setting linknames here is a bad hack.
_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
$SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
else
$SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
fi~
$CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
linknames='
# The linker will not automatically build a static lib if we build a DLL.
# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
# Don't use ranlib
_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
lt_tool_outputfile="@TOOL_OUTPUT@"~
case $lt_outputfile in
*.exe|*.EXE) ;;
*)
lt_outputfile="$lt_outputfile.exe"
lt_tool_outputfile="$lt_tool_outputfile.exe"
;;
esac~
func_to_tool_file "$lt_outputfile"~
if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
$MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
$RM "$lt_outputfile.manifest";
fi'
;;
*)
# g++
# _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
# If the export-symbols file already is a .def file (1st line
# is EXPORTS), use it as is; otherwise, prepend...
_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
cp $export_symbols $output_objdir/$soname.def;
else
echo EXPORTS > $output_objdir/$soname.def;
cat $export_symbols >> $output_objdir/$soname.def;
fi~
$CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
;;
darwin* | rhapsody*)
_LT_DARWIN_LINKER_FEATURES($1)
;;
dgux*)
case $cc_basename in
ec++*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
ghcx*)
# Green Hills C++ Compiler
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
;;
freebsd2.*)
# C++ shared libraries reported to be fairly broken before
# switch to ELF
_LT_TAGVAR(ld_shlibs, $1)=no
;;
freebsd-elf*)
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
;;
freebsd* | dragonfly*)
# FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
# conventions
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
haiku*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
hpux9*)
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
# but as the default
# location of the library.
case $cc_basename in
CC*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aCC*)
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
#
# There doesn't appear to be a way to prevent this compiler from
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test "$GXX" = yes; then
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
else
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
;;
hpux10*|hpux11*)
if test $with_gnu_ld = no; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
case $host_cpu in
hppa*64*|ia64*)
;;
*)
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
;;
esac
fi
case $host_cpu in
hppa*64*|ia64*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
*)
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
# but as the default
# location of the library.
;;
esac
case $cc_basename in
CC*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aCC*)
case $host_cpu in
hppa*64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
ia64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
esac
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
#
# There doesn't appear to be a way to prevent this compiler from
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test "$GXX" = yes; then
if test $with_gnu_ld = no; then
case $host_cpu in
hppa*64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
ia64*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
esac
fi
else
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
;;
interix[[3-9]]*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
# Instead, shared libraries are loaded at an image base (0x10000000 by
# default) and relocated if they conflict, which is a slow very memory
# consuming and fragmenting process. To avoid this, we pick a random,
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space.
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;;
irix5* | irix6*)
case $cc_basename in
CC*)
# SGI C++
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
# Archives containing C++ object files must be created using
# "CC -ar", where "CC" is the IRIX C++ compiler. This is
# necessary to make sure instantiated templates are included
# in the archive.
_LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
;;
*)
if test "$GXX" = yes; then
if test "$with_gnu_ld" = no; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
else
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
fi
fi
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
esac
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(inherit_rpath, $1)=yes
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# Kuck and Associates, Inc. (KAI) C++ Compiler
# KCC will only create a shared library if the output file
# ends with ".so" (or ".sl" for HP-UX), so rename the library
# to its proper name (with version) after linking.
_LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
#
# There doesn't appear to be a way to prevent this compiler from
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
# Archives containing C++ object files must be created using
# "CC -Bstatic", where "CC" is the KAI C++ compiler.
_LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
;;
icpc* | ecpc* )
# Intel C++
with_gnu_ld=yes
# version 8.0 and above of icpc choke on multiply defined symbols
# if we add $predep_objects and $postdep_objects, however 7.1 and
# earlier do not add the objects themselves.
case `$CC -V 2>&1` in
*"Version 7."*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
;;
*) # Version 8.0 or newer
tmp_idyn=
case $host_cpu in
ia64*) tmp_idyn=' -i_dynamic';;
esac
_LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
;;
esac
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
;;
pgCC* | pgcpp*)
# Portland Group C++ compiler
case `$CC -V` in
*pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
_LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
rm -rf $tpldir~
$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
_LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
rm -rf $tpldir~
$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
$RANLIB $oldlib'
_LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
rm -rf $tpldir~
$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
rm -rf $tpldir~
$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
;;
*) # Version 6 and above use weak symbols
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
;;
esac
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
;;
cxx*)
# Compaq C++
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
runpath_var=LD_RUN_PATH
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
#
# There doesn't appear to be a way to prevent this compiler from
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
;;
xl* | mpixl* | bgxl*)
# IBM XL 8.0 on PPC, with GNU ld
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
_LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
if test "x$supports_anon_versioning" = xyes; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
echo "local: *; };" >> $output_objdir/$libname.ver~
$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
fi
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*)
# Sun C++ 5.9
_LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
_LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
# Not sure whether something based on
# $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
# would be better.
output_verbose_link_cmd='func_echo_all'
# Archives containing C++ object files must be created using
# "CC -xar", where "CC" is the Sun C++ compiler. This is
# necessary to make sure instantiated templates are included
# in the archive.
_LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
;;
esac
;;
esac
;;
lynxos*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
m88k*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
mvs*)
case $cc_basename in
cxx*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
;;
netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
wlarc=
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
fi
# Workaround some broken pre-1.5 toolchains
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
;;
*nto* | *qnx*)
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
openbsd2*)
# C++ shared libraries are fairly broken
_LT_TAGVAR(ld_shlibs, $1)=no
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
_LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
fi
output_verbose_link_cmd=func_echo_all
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
osf3* | osf4* | osf5*)
case $cc_basename in
KCC*)
# Kuck and Associates, Inc. (KAI) C++ Compiler
# KCC will only create a shared library if the output file
# ends with ".so" (or ".sl" for HP-UX), so rename the library
# to its proper name (with version) after linking.
_LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Archives containing C++ object files must be created using
# the KAI C++ compiler.
case $host in
osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
esac
;;
RCC*)
# Rational C++ 2.4.1
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
cxx*)
case $host in
osf3*)
_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
;;
*)
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
echo "-hidden">> $lib.exp~
$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
$RM $lib.exp'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
;;
esac
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
#
# There doesn't appear to be a way to prevent this compiler from
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test "$GXX" = yes && test "$with_gnu_ld" = no; then
_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
case $host in
osf3*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
;;
esac
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
;;
psos*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
sunos4*)
case $cc_basename in
CC*)
# Sun C++ 4.x
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
lcc*)
# Lucid
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
;;
solaris*)
case $cc_basename in
CC* | sunCC*)
# Sun C++ 4.2, 5.x and Centerline C++
_LT_TAGVAR(archive_cmds_need_lc,$1)=yes
_LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
_LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
$CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
case $host_os in
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
# The compiler driver will combine and reorder linker options,
# but understands `-z linker_flag'.
# Supported since Solaris 2.6 (maybe 2.5.1?)
_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
;;
esac
_LT_TAGVAR(link_all_deplibs, $1)=yes
output_verbose_link_cmd='func_echo_all'
# Archives containing C++ object files must be created using
# "CC -xar", where "CC" is the Sun C++ compiler. This is
# necessary to make sure instantiated templates are included
# in the archive.
_LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
;;
gcx*)
# Green Hills C++ Compiler
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
# The C++ compiler must be used to create the archive.
_LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
;;
*)
# GNU C++ compiler with Solaris linker
if test "$GXX" = yes && test "$with_gnu_ld" = no; then
_LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
if $CC --version | $GREP -v '^2\.7' > /dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
$CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
# g++ 2.7 appears to require `-G' NOT `-shared' on this
# platform.
_LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
$CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
fi
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
case $host_os in
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
_LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
;;
esac
fi
;;
esac
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var='LD_RUN_PATH'
case $cc_basename in
CC*)
_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
;;
sysv5* | sco3.2v5* | sco5v6*)
# Note: We can NOT use -z defs as we might desire, because we do not
# link with -lc, and that would cause any symbols used from libc to
# always be unresolved, which means just about no library would
# ever link correctly. If we're not using GNU ld we use -z text
# though, which does catch some bad symbols but isn't as heavy-handed
# as -z defs.
_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
runpath_var='LD_RUN_PATH'
case $cc_basename in
CC*)
_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
'"$_LT_TAGVAR(old_archive_cmds, $1)"
_LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
'"$_LT_TAGVAR(reload_cmds, $1)"
;;
*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
;;
tandem*)
case $cc_basename in
NCC*)
# NonStop-UX NCC 3.20
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
;;
vxworks*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
*)
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
;;
esac
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
_LT_TAGVAR(GCC, $1)="$GXX"
_LT_TAGVAR(LD, $1)="$LD"
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
## the running order or otherwise move them around unless you know exactly
## what you are doing...
_LT_SYS_HIDDEN_LIBDEPS($1)
_LT_COMPILER_PIC($1)
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
_LT_CONFIG($1)
fi # test -n "$compiler"
CC=$lt_save_CC
CFLAGS=$lt_save_CFLAGS
LDCXX=$LD
LD=$lt_save_LD
GCC=$lt_save_GCC
with_gnu_ld=$lt_save_with_gnu_ld
lt_cv_path_LDCXX=$lt_cv_path_LD
lt_cv_path_LD=$lt_save_path_LD
lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
fi # test "$_lt_caught_CXX_error" != yes
AC_LANG_POP
])# _LT_LANG_CXX_CONFIG
# _LT_FUNC_STRIPNAME_CNF
# ----------------------
# func_stripname_cnf prefix suffix name
# strip PREFIX and SUFFIX off of NAME.
# PREFIX and SUFFIX must not contain globbing or regex special
# characters, hashes, percent signs, but SUFFIX may contain a leading
# dot (in which case that matches only a dot).
#
# This function is identical to the (non-XSI) version of func_stripname,
# except this one can be used by m4 code that may be executed by configure,
# rather than the libtool script.
m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
AC_REQUIRE([_LT_DECL_SED])
AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
func_stripname_cnf ()
{
case ${2} in
.*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
esac
} # func_stripname_cnf
])# _LT_FUNC_STRIPNAME_CNF
# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
# ---------------------------------
# Figure out "hidden" library dependencies from verbose
# compiler output when linking a shared library.
# Parse the compiler output and extract the necessary
# objects, libraries and library flags.
m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
# Dependencies to place before and after the object being linked:
_LT_TAGVAR(predep_objects, $1)=
_LT_TAGVAR(postdep_objects, $1)=
_LT_TAGVAR(predeps, $1)=
_LT_TAGVAR(postdeps, $1)=
_LT_TAGVAR(compiler_lib_search_path, $1)=
dnl we can't use the lt_simple_compile_test_code here,
dnl because it contains code intended for an executable,
dnl not a library. It's possible we should let each
dnl tag define a new lt_????_link_test_code variable,
dnl but it's only used here...
m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
int a;
void foo (void) { a = 0; }
_LT_EOF
], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
class Foo
{
public:
Foo (void) { a = 0; }
private:
int a;
};
_LT_EOF
], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
subroutine foo
implicit none
integer*4 a
a=0
return
end
_LT_EOF
], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
subroutine foo
implicit none
integer a
a=0
return
end
_LT_EOF
], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
public class foo {
private int a;
public void bar (void) {
a = 0;
}
};
_LT_EOF
], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
package foo
func foo() {
}
_LT_EOF
])
_lt_libdeps_save_CFLAGS=$CFLAGS
case "$CC $CFLAGS " in #(
*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
esac
dnl Parse the compiler output and extract the necessary
dnl objects, libraries and library flags.
if AC_TRY_EVAL(ac_compile); then
# Parse the compiler output and extract the necessary
# objects, libraries and library flags.
# Sentinel used to keep track of whether or not we are before
# the conftest object file.
pre_test_object_deps_done=no
for p in `eval "$output_verbose_link_cmd"`; do
case ${prev}${p} in
-L* | -R* | -l*)
# Some compilers place space between "-{L,R}" and the path.
# Remove the space.
if test $p = "-L" ||
test $p = "-R"; then
prev=$p
continue
fi
# Expand the sysroot to ease extracting the directories later.
if test -z "$prev"; then
case $p in
-L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
-R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
-l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
esac
fi
case $p in
=*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
esac
if test "$pre_test_object_deps_done" = no; then
case ${prev} in
-L | -R)
# Internal compiler library paths should come after those
# provided the user. The postdeps already come after the
# user supplied libs so there is no need to process them.
if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
_LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
else
_LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
fi
;;
# The "-l" case would never come before the object being
# linked, so don't bother handling this case.
esac
else
if test -z "$_LT_TAGVAR(postdeps, $1)"; then
_LT_TAGVAR(postdeps, $1)="${prev}${p}"
else
_LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
fi
fi
prev=
;;
*.lto.$objext) ;; # Ignore GCC LTO objects
*.$objext)
# This assumes that the test object file only shows up
# once in the compiler output.
if test "$p" = "conftest.$objext"; then
pre_test_object_deps_done=yes
continue
fi
if test "$pre_test_object_deps_done" = no; then
if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
_LT_TAGVAR(predep_objects, $1)="$p"
else
_LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
fi
else
if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
_LT_TAGVAR(postdep_objects, $1)="$p"
else
_LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
fi
fi
;;
*) ;; # Ignore the rest.
esac
done
# Clean up.
rm -f a.out a.exe
else
echo "libtool.m4: error: problem compiling $1 test program"
fi
$RM -f confest.$objext
CFLAGS=$_lt_libdeps_save_CFLAGS
# PORTME: override above test on systems where it is broken
m4_if([$1], [CXX],
[case $host_os in
interix[[3-9]]*)
# Interix 3.5 installs completely hosed .la files for C++, so rather than
# hack all around it, let's just trust "g++" to DTRT.
_LT_TAGVAR(predep_objects,$1)=
_LT_TAGVAR(postdep_objects,$1)=
_LT_TAGVAR(postdeps,$1)=
;;
linux*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*)
# Sun C++ 5.9
# The more standards-conforming stlport4 library is
# incompatible with the Cstd library. Avoid specifying
# it if it's in CXXFLAGS. Ignore libCrun as
# -library=stlport4 depends on it.
case " $CXX $CXXFLAGS " in
*" -library=stlport4 "*)
solaris_use_stlport4=yes
;;
esac
if test "$solaris_use_stlport4" != yes; then
_LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
fi
;;
esac
;;
solaris*)
case $cc_basename in
CC* | sunCC*)
# The more standards-conforming stlport4 library is
# incompatible with the Cstd library. Avoid specifying
# it if it's in CXXFLAGS. Ignore libCrun as
# -library=stlport4 depends on it.
case " $CXX $CXXFLAGS " in
*" -library=stlport4 "*)
solaris_use_stlport4=yes
;;
esac
# Adding this requires a known-good setup of shared libraries for
# Sun compiler versions before 5.6, else PIC objects from an old
# archive will be linked into the output, leading to subtle bugs.
if test "$solaris_use_stlport4" != yes; then
_LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
fi
;;
esac
;;
esac
])
case " $_LT_TAGVAR(postdeps, $1) " in
*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
esac
_LT_TAGVAR(compiler_lib_search_dirs, $1)=
if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
_LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
fi
_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
[The directories searched by this compiler when creating a shared library])
_LT_TAGDECL([], [predep_objects], [1],
[Dependencies to place before and after the objects being linked to
create a shared library])
_LT_TAGDECL([], [postdep_objects], [1])
_LT_TAGDECL([], [predeps], [1])
_LT_TAGDECL([], [postdeps], [1])
_LT_TAGDECL([], [compiler_lib_search_path], [1],
[The library search path used internally by the compiler when linking
a shared library])
])# _LT_SYS_HIDDEN_LIBDEPS
# _LT_LANG_F77_CONFIG([TAG])
# --------------------------
# Ensure that the configuration variables for a Fortran 77 compiler are
# suitably defined. These variables are subsequently used by _LT_CONFIG
# to write the compiler configuration to `libtool'.
m4_defun([_LT_LANG_F77_CONFIG],
[AC_LANG_PUSH(Fortran 77)
if test -z "$F77" || test "X$F77" = "Xno"; then
_lt_disable_F77=yes
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(allow_undefined_flag, $1)=
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(archive_expsym_cmds, $1)=
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=no
_LT_TAGVAR(inherit_rpath, $1)=no
_LT_TAGVAR(module_cmds, $1)=
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
_LT_TAGVAR(reload_flag, $1)=$reload_flag
_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
_LT_TAGVAR(no_undefined_flag, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
# Source file extension for f77 test sources.
ac_ext=f
# Object file extension for compiled f77 test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# No sense in running all these tests if we already determined that
# the F77 compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
if test "$_lt_disable_F77" != yes; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="\
subroutine t
return
end
"
# Code to be used in simple link tests
lt_simple_link_test_code="\
program t
end
"
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
lt_save_CC="$CC"
lt_save_GCC=$GCC
lt_save_CFLAGS=$CFLAGS
CC=${F77-"f77"}
CFLAGS=$FFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
GCC=$G77
if test -n "$compiler"; then
AC_MSG_CHECKING([if libtool supports shared libraries])
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
test "$can_build_shared" = "no" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
test "$enable_shared" = yes && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
test "$enable_shared" = yes && enable_static=no
fi
;;
esac
AC_MSG_RESULT([$enable_shared])
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
test "$enable_shared" = yes || enable_static=yes
AC_MSG_RESULT([$enable_static])
_LT_TAGVAR(GCC, $1)="$G77"
_LT_TAGVAR(LD, $1)="$LD"
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
## the running order or otherwise move them around unless you know exactly
## what you are doing...
_LT_COMPILER_PIC($1)
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
_LT_CONFIG($1)
fi # test -n "$compiler"
GCC=$lt_save_GCC
CC="$lt_save_CC"
CFLAGS="$lt_save_CFLAGS"
fi # test "$_lt_disable_F77" != yes
AC_LANG_POP
])# _LT_LANG_F77_CONFIG
# _LT_LANG_FC_CONFIG([TAG])
# -------------------------
# Ensure that the configuration variables for a Fortran compiler are
# suitably defined. These variables are subsequently used by _LT_CONFIG
# to write the compiler configuration to `libtool'.
m4_defun([_LT_LANG_FC_CONFIG],
[AC_LANG_PUSH(Fortran)
if test -z "$FC" || test "X$FC" = "Xno"; then
_lt_disable_FC=yes
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(allow_undefined_flag, $1)=
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(archive_expsym_cmds, $1)=
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=no
_LT_TAGVAR(inherit_rpath, $1)=no
_LT_TAGVAR(module_cmds, $1)=
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
_LT_TAGVAR(reload_flag, $1)=$reload_flag
_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
_LT_TAGVAR(no_undefined_flag, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
# Source file extension for fc test sources.
ac_ext=${ac_fc_srcext-f}
# Object file extension for compiled fc test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# No sense in running all these tests if we already determined that
# the FC compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
if test "$_lt_disable_FC" != yes; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="\
subroutine t
return
end
"
# Code to be used in simple link tests
lt_simple_link_test_code="\
program t
end
"
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
lt_save_CC="$CC"
lt_save_GCC=$GCC
lt_save_CFLAGS=$CFLAGS
CC=${FC-"f95"}
CFLAGS=$FCFLAGS
compiler=$CC
GCC=$ac_cv_fc_compiler_gnu
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
if test -n "$compiler"; then
AC_MSG_CHECKING([if libtool supports shared libraries])
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
test "$can_build_shared" = "no" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
test "$enable_shared" = yes && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
test "$enable_shared" = yes && enable_static=no
fi
;;
esac
AC_MSG_RESULT([$enable_shared])
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
test "$enable_shared" = yes || enable_static=yes
AC_MSG_RESULT([$enable_static])
_LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
_LT_TAGVAR(LD, $1)="$LD"
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
## the running order or otherwise move them around unless you know exactly
## what you are doing...
_LT_SYS_HIDDEN_LIBDEPS($1)
_LT_COMPILER_PIC($1)
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
_LT_CONFIG($1)
fi # test -n "$compiler"
GCC=$lt_save_GCC
CC=$lt_save_CC
CFLAGS=$lt_save_CFLAGS
fi # test "$_lt_disable_FC" != yes
AC_LANG_POP
])# _LT_LANG_FC_CONFIG
# _LT_LANG_GCJ_CONFIG([TAG])
# --------------------------
# Ensure that the configuration variables for the GNU Java Compiler compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
# to write the compiler configuration to `libtool'.
m4_defun([_LT_LANG_GCJ_CONFIG],
[AC_REQUIRE([LT_PROG_GCJ])dnl
AC_LANG_SAVE
# Source file extension for Java test sources.
ac_ext=java
# Object file extension for compiled Java test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# Code to be used in simple compile tests
lt_simple_compile_test_code="class foo {}"
# Code to be used in simple link tests
lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
lt_save_CC=$CC
lt_save_CFLAGS=$CFLAGS
lt_save_GCC=$GCC
GCC=yes
CC=${GCJ-"gcj"}
CFLAGS=$GCJFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_TAGVAR(LD, $1)="$LD"
_LT_CC_BASENAME([$compiler])
# GCJ did not exist at the time GCC didn't implicitly link libc in.
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
_LT_TAGVAR(reload_flag, $1)=$reload_flag
_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
if test -n "$compiler"; then
_LT_COMPILER_NO_RTTI($1)
_LT_COMPILER_PIC($1)
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
_LT_CONFIG($1)
fi
AC_LANG_RESTORE
GCC=$lt_save_GCC
CC=$lt_save_CC
CFLAGS=$lt_save_CFLAGS
])# _LT_LANG_GCJ_CONFIG
# _LT_LANG_GO_CONFIG([TAG])
# --------------------------
# Ensure that the configuration variables for the GNU Go compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
# to write the compiler configuration to `libtool'.
m4_defun([_LT_LANG_GO_CONFIG],
[AC_REQUIRE([LT_PROG_GO])dnl
AC_LANG_SAVE
# Source file extension for Go test sources.
ac_ext=go
# Object file extension for compiled Go test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# Code to be used in simple compile tests
lt_simple_compile_test_code="package main; func main() { }"
# Code to be used in simple link tests
lt_simple_link_test_code='package main; func main() { }'
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
lt_save_CC=$CC
lt_save_CFLAGS=$CFLAGS
lt_save_GCC=$GCC
GCC=yes
CC=${GOC-"gccgo"}
CFLAGS=$GOFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_TAGVAR(LD, $1)="$LD"
_LT_CC_BASENAME([$compiler])
# Go did not exist at the time GCC didn't implicitly link libc in.
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
_LT_TAGVAR(reload_flag, $1)=$reload_flag
_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
if test -n "$compiler"; then
_LT_COMPILER_NO_RTTI($1)
_LT_COMPILER_PIC($1)
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
_LT_CONFIG($1)
fi
AC_LANG_RESTORE
GCC=$lt_save_GCC
CC=$lt_save_CC
CFLAGS=$lt_save_CFLAGS
])# _LT_LANG_GO_CONFIG
# _LT_LANG_RC_CONFIG([TAG])
# -------------------------
# Ensure that the configuration variables for the Windows resource compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
# to write the compiler configuration to `libtool'.
m4_defun([_LT_LANG_RC_CONFIG],
[AC_REQUIRE([LT_PROG_RC])dnl
AC_LANG_SAVE
# Source file extension for RC test sources.
ac_ext=rc
# Object file extension for compiled RC test sources.
objext=o
_LT_TAGVAR(objext, $1)=$objext
# Code to be used in simple compile tests
lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
# Code to be used in simple link tests
lt_simple_link_test_code="$lt_simple_compile_test_code"
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
# save warnings/boilerplate of simple test code
_LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
lt_save_CC="$CC"
lt_save_CFLAGS=$CFLAGS
lt_save_GCC=$GCC
GCC=
CC=${RC-"windres"}
CFLAGS=
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
if test -n "$compiler"; then
:
_LT_CONFIG($1)
fi
GCC=$lt_save_GCC
AC_LANG_RESTORE
CC=$lt_save_CC
CFLAGS=$lt_save_CFLAGS
])# _LT_LANG_RC_CONFIG
# LT_PROG_GCJ
# -----------
AC_DEFUN([LT_PROG_GCJ],
[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
[m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
[AC_CHECK_TOOL(GCJ, gcj,)
test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
AC_SUBST(GCJFLAGS)])])[]dnl
])
# Old name:
AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
# LT_PROG_GO
# ----------
AC_DEFUN([LT_PROG_GO],
[AC_CHECK_TOOL(GOC, gccgo,)
])
# LT_PROG_RC
# ----------
AC_DEFUN([LT_PROG_RC],
[AC_CHECK_TOOL(RC, windres,)
])
# Old name:
AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([LT_AC_PROG_RC], [])
# _LT_DECL_EGREP
# --------------
# If we don't have a new enough Autoconf to choose the best grep
# available, choose the one first in the user's PATH.
m4_defun([_LT_DECL_EGREP],
[AC_REQUIRE([AC_PROG_EGREP])dnl
AC_REQUIRE([AC_PROG_FGREP])dnl
test -z "$GREP" && GREP=grep
_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
_LT_DECL([], [EGREP], [1], [An ERE matcher])
_LT_DECL([], [FGREP], [1], [A literal string matcher])
dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
AC_SUBST([GREP])
])
# _LT_DECL_OBJDUMP
# --------------
# If we don't have a new enough Autoconf to choose the best objdump
# available, choose the one first in the user's PATH.
m4_defun([_LT_DECL_OBJDUMP],
[AC_CHECK_TOOL(OBJDUMP, objdump, false)
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
AC_SUBST([OBJDUMP])
])
# _LT_DECL_DLLTOOL
# ----------------
# Ensure DLLTOOL variable is set.
m4_defun([_LT_DECL_DLLTOOL],
[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
AC_SUBST([DLLTOOL])
])
# _LT_DECL_SED
# ------------
# Check for a fully-functional sed program, that truncates
# as few characters as possible. Prefer GNU sed if found.
m4_defun([_LT_DECL_SED],
[AC_PROG_SED
test -z "$SED" && SED=sed
Xsed="$SED -e 1s/^X//"
_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
[Sed that helps us avoid accidentally triggering echo(1) options like -n])
])# _LT_DECL_SED
m4_ifndef([AC_PROG_SED], [
# NOTE: This macro has been submitted for inclusion into #
# GNU Autoconf as AC_PROG_SED. When it is available in #
# a released version of Autoconf we should remove this #
# macro and use it instead. #
m4_defun([AC_PROG_SED],
[AC_MSG_CHECKING([for a sed that does not truncate output])
AC_CACHE_VAL(lt_cv_path_SED,
[# Loop through the user's path and test for sed and gsed.
# Then use that list of sed's as ones to test for truncation.
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for lt_ac_prog in sed gsed; do
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
fi
done
done
done
IFS=$as_save_IFS
lt_ac_max=0
lt_ac_count=0
# Add /usr/xpg4/bin/sed as it is typically found on Solaris
# along with /bin/sed that truncates output.
for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
test ! -f $lt_ac_sed && continue
cat /dev/null > conftest.in
lt_ac_count=0
echo $ECHO_N "0123456789$ECHO_C" >conftest.in
# Check for GNU sed and select it if it is found.
if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
lt_cv_path_SED=$lt_ac_sed
break
fi
while true; do
cat conftest.in conftest.in >conftest.tmp
mv conftest.tmp conftest.in
cp conftest.in conftest.nl
echo >>conftest.nl
$lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
cmp -s conftest.out conftest.nl || break
# 10000 chars as input seems more than enough
test $lt_ac_count -gt 10 && break
lt_ac_count=`expr $lt_ac_count + 1`
if test $lt_ac_count -gt $lt_ac_max; then
lt_ac_max=$lt_ac_count
lt_cv_path_SED=$lt_ac_sed
fi
done
done
])
SED=$lt_cv_path_SED
AC_SUBST([SED])
AC_MSG_RESULT([$SED])
])#AC_PROG_SED
])#m4_ifndef
# Old name:
AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([LT_AC_PROG_SED], [])
# _LT_CHECK_SHELL_FEATURES
# ------------------------
# Find out whether the shell is Bourne or XSI compatible,
# or has some other useful features.
m4_defun([_LT_CHECK_SHELL_FEATURES],
[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
# Try some XSI features
xsi_shell=no
( _lt_dummy="a/b/c"
test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
= c,a/b,b/c, \
&& eval 'test $(( 1 + 1 )) -eq 2 \
&& test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
&& xsi_shell=yes
AC_MSG_RESULT([$xsi_shell])
_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
AC_MSG_CHECKING([whether the shell understands "+="])
lt_shell_append=no
( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
>/dev/null 2>&1 \
&& lt_shell_append=yes
AC_MSG_RESULT([$lt_shell_append])
_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
lt_unset=unset
else
lt_unset=false
fi
_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
# test EBCDIC or ASCII
case `echo X|tr X '\101'` in
A) # ASCII based system
# \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
lt_SP2NL='tr \040 \012'
lt_NL2SP='tr \015\012 \040\040'
;;
*) # EBCDIC based system
lt_SP2NL='tr \100 \n'
lt_NL2SP='tr \r\n \100\100'
;;
esac
_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
])# _LT_CHECK_SHELL_FEATURES
# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
# ------------------------------------------------------
# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
m4_defun([_LT_PROG_FUNCTION_REPLACE],
[dnl {
sed -e '/^$1 ()$/,/^} # $1 /c\
$1 ()\
{\
m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1])
} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
&& mv -f "$cfgfile.tmp" "$cfgfile" \
|| (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:
])
# _LT_PROG_REPLACE_SHELLFNS
# -------------------------
# Replace existing portable implementations of several shell functions with
# equivalent extended shell implementations where those features are available..
m4_defun([_LT_PROG_REPLACE_SHELLFNS],
[if test x"$xsi_shell" = xyes; then
_LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
case ${1} in
*/*) func_dirname_result="${1%/*}${2}" ;;
* ) func_dirname_result="${3}" ;;
esac])
_LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
func_basename_result="${1##*/}"])
_LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
case ${1} in
*/*) func_dirname_result="${1%/*}${2}" ;;
* ) func_dirname_result="${3}" ;;
esac
func_basename_result="${1##*/}"])
_LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
# pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
# positional parameters, so assign one to ordinary parameter first.
func_stripname_result=${3}
func_stripname_result=${func_stripname_result#"${1}"}
func_stripname_result=${func_stripname_result%"${2}"}])
_LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
func_split_long_opt_name=${1%%=*}
func_split_long_opt_arg=${1#*=}])
_LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
func_split_short_opt_arg=${1#??}
func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
_LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
case ${1} in
*.lo) func_lo2o_result=${1%.lo}.${objext} ;;
*) func_lo2o_result=${1} ;;
esac])
_LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo])
_LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))])
_LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}])
fi
if test x"$lt_shell_append" = xyes; then
_LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"])
_LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
func_quote_for_eval "${2}"
dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
# Save a `func_append' function call where possible by direct use of '+='
sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
&& mv -f "$cfgfile.tmp" "$cfgfile" \
|| (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:
else
# Save a `func_append' function call even when '+=' is not available
sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
&& mv -f "$cfgfile.tmp" "$cfgfile" \
|| (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
test 0 -eq $? || _lt_function_replace_fail=:
fi
if test x"$_lt_function_replace_fail" = x":"; then
AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
fi
])
# _LT_PATH_CONVERSION_FUNCTIONS
# -----------------------------
# Determine which file name conversion functions should be used by
# func_to_host_file (and, implicitly, by func_to_host_path). These are needed
# for certain cross-compile configurations and native mingw.
m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
AC_MSG_CHECKING([how to convert $build file names to $host format])
AC_CACHE_VAL(lt_cv_to_host_file_cmd,
[case $host in
*-*-mingw* )
case $build in
*-*-mingw* ) # actually msys
lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
;;
*-*-cygwin* )
lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
;;
* ) # otherwise, assume *nix
lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
;;
esac
;;
*-*-cygwin* )
case $build in
*-*-mingw* ) # actually msys
lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
;;
*-*-cygwin* )
lt_cv_to_host_file_cmd=func_convert_file_noop
;;
* ) # otherwise, assume *nix
lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
;;
esac
;;
* ) # unhandled hosts (and "normal" native builds)
lt_cv_to_host_file_cmd=func_convert_file_noop
;;
esac
])
to_host_file_cmd=$lt_cv_to_host_file_cmd
AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
[0], [convert $build file names to $host format])dnl
AC_MSG_CHECKING([how to convert $build file names to toolchain format])
AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
[#assume ordinary cross tools, or native build.
lt_cv_to_tool_file_cmd=func_convert_file_noop
case $host in
*-*-mingw* )
case $build in
*-*-mingw* ) # actually msys
lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
;;
esac
;;
esac
])
to_tool_file_cmd=$lt_cv_to_tool_file_cmd
AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
[0], [convert $build files to toolchain format])dnl
])# _LT_PATH_CONVERSION_FUNCTIONS
# Helper functions for option handling. -*- Autoconf -*-
#
# Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 7 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option `$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl `shared' nor `disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
])
])# _LT_SET_OPTIONS
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the `shared' and
# `disable-shared' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the `static' and
# `disable-static' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the `fast-install'
# and `disable-fast-install' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
# LT_INIT options.
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for lt_pkg in $withval; do
IFS="$lt_save_ifs"
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[pic_mode=default])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59 which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# your_sha256_hash-------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# your_sha256_hash-
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# @configure_input@
# serial 3337 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.2])
m4_define([LT_PACKAGE_REVISION], [1.3337])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.2'
macro_revision='1.3337'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 1 (pkg-config-0.24)
#
#
# This program is free software; you can redistribute it and/or modify
# (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
#
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
# only at the first occurence in configure.ac, so if the first place
# it's called might be skipped (such as if it is within an "if", you
# have to call PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <path_to_url
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])# PKG_CHECK_MODULES
# Configure paths for SDL
# Sam Lantinga 9/21/99
# stolen from Manish Singh
# stolen back from Frank Belew
# stolen from Manish Singh
# Shamelessly stolen from Owen Taylor
# serial 1
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl
AC_DEFUN([AM_PATH_SDL],
[dnl
dnl Get the cflags and libraries from the sdl-config script
dnl
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
sdl_prefix="$withval", sdl_prefix="")
AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
sdl_exec_prefix="$withval", sdl_exec_prefix="")
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
, enable_sdltest=yes)
if test x$sdl_exec_prefix != x ; then
sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
fi
fi
if test x$sdl_prefix != x ; then
sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_prefix/bin/sdl-config
fi
fi
as_save_PATH="$PATH"
if test "x$prefix" != xNONE; then
PATH="$prefix/bin:$prefix/usr/bin:$PATH"
fi
AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
PATH="$as_save_PATH"
min_sdl_version=ifelse([$1], ,0.11.0,$1)
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
no_sdl=""
if test "$SDL_CONFIG" = "no" ; then
no_sdl=yes
else
SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_sdltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity
dnl checks the results of sdl-config to some extent
dnl
rm -f conf.sdltest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
char*
my_strdup (char *str)
{
char *new_str;
if (str)
{
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
strcpy (new_str, str);
}
else
new_str = NULL;
return new_str;
}
int main (int argc, char *argv[])
{
int major, minor, micro;
char *tmp_version;
/* This hangs on some systems (?)
system ("touch conf.sdltest");
*/
{ FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = my_strdup("$min_sdl_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
printf("%s, bad version string\n", "$min_sdl_version");
exit(1);
}
if (($sdl_major_version > major) ||
(($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
(($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
printf("*** best to upgrade to the required version.\n");
printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
printf("*** to point to the correct copy of sdl-config, and remove the file\n");
printf("*** config.cache before re-running configure\n");
return 1;
}
}
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_sdl" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$SDL_CONFIG" = "no" ; then
echo "*** The sdl-config script installed by SDL could not be found"
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the SDL_CONFIG environment variable to the"
echo "*** full path to sdl-config."
else
if test -f conf.sdltest ; then
:
else
echo "*** Could not run SDL test program, checking why..."
CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include "SDL.h"
int main(int argc, char *argv[])
{ return 0; }
#undef main
#define main K_and_R_C_main
], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding SDL or finding the wrong"
echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means SDL was incorrectly installed"
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
SDL_CFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
rm -f conf.sdltest
])
m4_include([acinclude.m4])
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/aclocal.m4
|
m4sugar
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 127,348
|
```objective-c
/**
* qrencode - QR Code encoder
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** \mainpage
* Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D
* symbology.
*
* \section encoding Encoding
*
* There are two methods to encode data: <b>encoding a string/data</b> or
* <b>encoding a structured data</b>.
*
* \subsection encoding-string Encoding a string/data
* You can encode a string by calling QRcode_encodeString().
* The given string is parsed automatically and encoded. If you want to encode
* data that can be represented as a C string style (NUL terminated), you can
* simply use this way.
*
* If the input data contains Kanji (Shift-JIS) characters and you want to
* encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint.
* Otherwise, all of non-alphanumeric characters are encoded as 8 bit data.
* If you want to encode a whole string in 8 bit mode, you can use
* QRcode_encodeString8bit() instead.
*
* Please note that a C string can not contain NUL characters. If your data
* contains NUL, you must use QRcode_encodeData().
*
* \subsection encoding-input Encoding a structured data
* You can construct a structured input data manually. If the structure of the
* input data is known, you can use this way.
* At first, create a ::QRinput object by QRinput_new(). Then add input data
* to the QRinput object by QRinput_append(). Finally call QRcode_encodeInput()
* to encode the QRinput data.
* You can reuse the QRinput data again to encode it in other symbols with
* different parameters.
*
* \section result Result
* The encoded symbol is resulted as a ::QRcode object. It will contain
* its version number, width of the symbol and an array represents the symbol.
* See ::QRcode for the details. You can free the object by QRcode_free().
*
* Please note that the version of the result may be larger than specified.
* In such cases, the input data would be too large to be encoded in a
* symbol of the specified version.
*
* \section structured Structured append
* Libqrencode can generate "Structured-appended" symbols that enables to split
* a large data set into mulitple QR codes. A QR code reader concatenates
* multiple QR code symbols into a string.
* Just like QRcode_encodeString(), you can use QRcode_encodeStringStructured()
* to generate structured-appended symbols. This functions returns an instance
* of ::QRcode_List. The returned list is a singly-linked list of QRcode: you
* can retrieve each QR code in this way:
*
* \code
* QRcode_List *qrcodes;
* QRcode_List *entry;
* QRcode *qrcode;
*
* qrcodes = QRcode_encodeStringStructured(...);
* entry = qrcodes;
* while(entry != NULL) {
* qrcode = entry->code;
* // do something
* entry = entry->next;
* }
* QRcode_List_free(entry);
* \endcode
*
* Instead of using auto-parsing functions, you can construct your own
* structured input. At first, instantiate an object of ::QRinput_Struct
* by calling QRinput_Struct_new(). This object can hold multiple ::QRinput,
* and one QR code is generated for a ::QRinput.
* QRinput_Struct_appendInput() appends a ::QRinput to a ::QRinput_Struct
* object. In order to generate structured-appended symbols, it is required to
* embed headers to each symbol. You can use
* QRinput_Struct_insertStructuredAppendHeaders() to insert appropriate
* headers to each symbol. You should call this function just once before
* encoding symbols.
*/
#ifndef __QRENCODE_H__
#define __QRENCODE_H__
#if defined(__cplusplus)
extern "C" {
#endif
/**
* Encoding mode.
*/
typedef enum {
QR_MODE_NUL = -1, ///< Terminator (NUL character). Internal use only
QR_MODE_NUM = 0, ///< Numeric mode
QR_MODE_AN, ///< Alphabet-numeric mode
QR_MODE_8, ///< 8-bit data mode
QR_MODE_KANJI, ///< Kanji (shift-jis) mode
QR_MODE_STRUCTURE, ///< Internal use only
QR_MODE_ECI, ///< ECI mode
QR_MODE_FNC1FIRST, ///< FNC1, first position
QR_MODE_FNC1SECOND, ///< FNC1, second position
} QRencodeMode;
/**
* Level of error correction.
*/
typedef enum {
QR_ECLEVEL_L = 0, ///< lowest
QR_ECLEVEL_M,
QR_ECLEVEL_Q,
QR_ECLEVEL_H ///< highest
} QRecLevel;
/**
* Maximum version (size) of QR-code symbol.
*/
#define QRSPEC_VERSION_MAX 40
/**
* Maximum version (size) of QR-code symbol.
*/
#define MQRSPEC_VERSION_MAX 4
/******************************************************************************
* Input data (qrinput.c)
*****************************************************************************/
/**
* Singly linked list to contain input strings. An instance of this class
* contains its version and error correction level too. It is required to
* set them by QRinput_setVersion() and QRinput_setErrorCorrectionLevel(),
* or use QRinput_new2() to instantiate an object.
*/
typedef struct _QRinput QRinput;
/**
* Instantiate an input data object. The version is set to 0 (auto-select)
* and the error correction level is set to QR_ECLEVEL_L.
* @return an input object (initialized). On error, NULL is returned and errno
* is set to indicate the error.
* @throw ENOMEM unable to allocate memory.
*/
extern QRinput *QRinput_new(void);
/**
* Instantiate an input data object.
* @param version version number.
* @param level Error correction level.
* @return an input object (initialized). On error, NULL is returned and errno
* is set to indicate the error.
* @throw ENOMEM unable to allocate memory for input objects.
* @throw EINVAL invalid arguments.
*/
extern QRinput *QRinput_new2(int version, QRecLevel level);
/**
* Instantiate an input data object. Object's Micro QR Code flag is set.
* Unlike with full-sized QR Code, version number must be specified (>0).
* @param version version number (1--4).
* @param level Error correction level.
* @return an input object (initialized). On error, NULL is returned and errno
* is set to indicate the error.
* @throw ENOMEM unable to allocate memory for input objects.
* @throw EINVAL invalid arguments.
*/
extern QRinput *QRinput_newMQR(int version, QRecLevel level);
/**
* Append data to an input object.
* The data is copied and appended to the input object.
* @param input input object.
* @param mode encoding mode.
* @param size size of data (byte).
* @param data a pointer to the memory area of the input data.
* @retval 0 success.
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw EINVAL input data is invalid.
*
*/
extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data);
/**
* Append ECI header.
* @param input input object.
* @param ecinum ECI indicator number (0 - 999999)
* @retval 0 success.
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw EINVAL input data is invalid.
*
*/
extern int QRinput_appendECIheader(QRinput *input, unsigned int ecinum);
/**
* Get current version.
* @param input input object.
* @return current version.
*/
extern int QRinput_getVersion(QRinput *input);
/**
* Set version of the QR code that is to be encoded.
* This function cannot be applied to Micro QR Code.
* @param input input object.
* @param version version number (0 = auto)
* @retval 0 success.
* @retval -1 invalid argument.
*/
extern int QRinput_setVersion(QRinput *input, int version);
/**
* Get current error correction level.
* @param input input object.
* @return Current error correcntion level.
*/
extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input);
/**
* Set error correction level of the QR code that is to be encoded.
* This function cannot be applied to Micro QR Code.
* @param input input object.
* @param level Error correction level.
* @retval 0 success.
* @retval -1 invalid argument.
*/
extern int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level);
/**
* Set version and error correction level of the QR code at once.
* This function is recommened for Micro QR Code.
* @param input input object.
* @param version version number (0 = auto)
* @param level Error correction level.
* @retval 0 success.
* @retval -1 invalid argument.
*/
extern int QRinput_setVersionAndErrorCorrectionLevel(QRinput *input, int version, QRecLevel level);
/**
* Free the input object.
* All of data chunks in the input object are freed too.
* @param input input object.
*/
extern void QRinput_free(QRinput *input);
/**
* Validate the input data.
* @param mode encoding mode.
* @param size size of data (byte).
* @param data a pointer to the memory area of the input data.
* @retval 0 success.
* @retval -1 invalid arguments.
*/
extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data);
/**
* Set of QRinput for structured symbols.
*/
typedef struct _QRinput_Struct QRinput_Struct;
/**
* Instantiate a set of input data object.
* @return an instance of QRinput_Struct. On error, NULL is returned and errno
* is set to indicate the error.
* @throw ENOMEM unable to allocate memory.
*/
extern QRinput_Struct *QRinput_Struct_new(void);
/**
* Set parity of structured symbols.
* @param s structured input object.
* @param parity parity of s.
*/
extern void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity);
/**
* Append a QRinput object to the set. QRinput created by QRinput_newMQR()
* will be rejected.
* @warning never append the same QRinput object twice or more.
* @param s structured input object.
* @param input an input object.
* @retval >0 number of input objects in the structure.
* @retval -1 an error occurred. See Exceptions for the details.
* @throw ENOMEM unable to allocate memory.
* @throw EINVAL invalid arguments.
*/
extern int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input);
/**
* Free all of QRinput in the set.
* @param s a structured input object.
*/
extern void QRinput_Struct_free(QRinput_Struct *s);
/**
* Split a QRinput to QRinput_Struct. It calculates a parity, set it, then
* insert structured-append headers. QRinput created by QRinput_newMQR() will
* be rejected.
* @param input input object. Version number and error correction level must be
* set.
* @return a set of input data. On error, NULL is returned, and errno is set
* to indicate the error. See Exceptions for the details.
* @throw ERANGE input data is too large.
* @throw EINVAL invalid input data.
* @throw ENOMEM unable to allocate memory.
*/
extern QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input);
/**
* Insert structured-append headers to the input structure. It calculates
* a parity and set it if the parity is not set yet.
* @param s input structure
* @retval 0 success.
* @retval -1 an error occurred and errno is set to indeicate the error.
* See Execptions for the details.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory.
*/
extern int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s);
/**
* Set FNC1-1st position flag.
*/
extern int QRinput_setFNC1First(QRinput *input);
/**
* Set FNC1-2nd position flag and application identifier.
*/
extern int QRinput_setFNC1Second(QRinput *input, unsigned char appid);
/******************************************************************************
* QRcode output (qrencode.c)
*****************************************************************************/
/**
* QRcode class.
* Symbol data is represented as an array contains width*width uchars.
* Each uchar represents a module (dot). If the less significant bit of
* the uchar is 1, the corresponding module is black. The other bits are
* meaningless for usual applications, but here its specification is described.
*
* <pre>
* MSB 76543210 LSB
* |||||||`- 1=black/0=white
* ||||||`-- data and ecc code area
* |||||`--- format information
* ||||`---- version information
* |||`----- timing pattern
* ||`------ alignment pattern
* |`------- finder pattern and separator
* `-------- non-data modules (format, timing, etc.)
* </pre>
*/
typedef struct {
int version; ///< version of the symbol
int width; ///< width of the symbol
unsigned char *data; ///< symbol data
} QRcode;
/**
* Singly-linked list of QRcode. Used to represent a structured symbols.
* A list is terminated with NULL.
*/
typedef struct _QRcode_List {
QRcode *code;
struct _QRcode_List *next;
} QRcode_List;
/**
* Create a symbol from the input data.
* @warning This function is THREAD UNSAFE when pthread is disabled.
* @param input input data.
* @return an instance of QRcode class. The version of the result QRcode may
* be larger than the designated version. On error, NULL is returned,
* and errno is set to indicate the error. See Exceptions for the
* details.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory for input objects.
*/
extern QRcode *QRcode_encodeInput(QRinput *input);
/**
* Create a symbol from the string. The library automatically parses the input
* string and encodes in a QR Code symbol.
* @warning This function is THREAD UNSAFE when pthread is disabled.
* @param string input string. It must be NUL terminated.
* @param version version of the symbol. If 0, the library chooses the minimum
* version for the given input data.
* @param level error correction level.
* @param hint tell the library how Japanese Kanji characters should be
* encoded. If QR_MODE_KANJI is given, the library assumes that the
* given string contains Shift-JIS characters and encodes them in
* Kanji-mode. If QR_MODE_8 is given, all of non-alphanumerical
* characters will be encoded as is. If you want to embed UTF-8
* string, choose this. Other mode will cause EINVAL error.
* @param casesensitive case-sensitive(1) or not(0).
* @return an instance of QRcode class. The version of the result QRcode may
* be larger than the designated version. On error, NULL is returned,
* and errno is set to indicate the error. See Exceptions for the
* details.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory for input objects.
* @throw ERANGE input data is too large.
*/
extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
/**
* Same to QRcode_encodeString(), but encode whole data in 8-bit mode.
* @warning This function is THREAD UNSAFE when pthread is disabled.
*/
extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level);
/**
* Micro QR Code version of QRcode_encodeString().
* @warning This function is THREAD UNSAFE when pthread is disabled.
*/
extern QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
/**
* Micro QR Code version of QRcode_encodeString8bit().
* @warning This function is THREAD UNSAFE when pthread is disabled.
*/
extern QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level);
/**
* Encode byte stream (may include '\0') in 8-bit mode.
* @warning This function is THREAD UNSAFE when pthread is disabled.
* @param size size of the input data.
* @param data input data.
* @param version version of the symbol. If 0, the library chooses the minimum
* version for the given input data.
* @param level error correction level.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory for input objects.
* @throw ERANGE input data is too large.
*/
extern QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level);
/**
* Micro QR Code version of QRcode_encodeData().
* @warning This function is THREAD UNSAFE when pthread is disabled.
*/
extern QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level);
/**
* Free the instance of QRcode class.
* @param qrcode an instance of QRcode class.
*/
extern void QRcode_free(QRcode *qrcode);
/**
* Create structured symbols from the input data.
* @warning This function is THREAD UNSAFE when pthread is disabled.
* @param s
* @return a singly-linked list of QRcode.
*/
extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s);
/**
* Create structured symbols from the string. The library automatically parses
* the input string and encodes in a QR Code symbol.
* @warning This function is THREAD UNSAFE when pthread is disabled.
* @param string input string. It must be NUL terminated.
* @param version version of the symbol.
* @param level error correction level.
* @param hint tell the library how Japanese Kanji characters should be
* encoded. If QR_MODE_KANJI is given, the library assumes that the
* given string contains Shift-JIS characters and encodes them in
* Kanji-mode. If QR_MODE_8 is given, all of non-alphanumerical
* characters will be encoded as is. If you want to embed UTF-8
* string, choose this. Other mode will cause EINVAL error.
* @param casesensitive case-sensitive(1) or not(0).
* @return a singly-linked list of QRcode. On error, NULL is returned, and
* errno is set to indicate the error. See Exceptions for the details.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory for input objects.
*/
extern QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive);
/**
* Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode.
* @warning This function is THREAD UNSAFE when pthread is disabled.
*/
extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level);
/**
* Create structured symbols from byte stream (may include '\0'). Wholde data
* are encoded in 8-bit mode.
* @warning This function is THREAD UNSAFE when pthread is disabled.
* @param size size of the input data.
* @param data input dat.
* @param version version of the symbol.
* @param level error correction level.
* @return a singly-linked list of QRcode. On error, NULL is returned, and
* errno is set to indicate the error. See Exceptions for the details.
* @throw EINVAL invalid input object.
* @throw ENOMEM unable to allocate memory for input objects.
*/
extern QRcode_List *QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level);
/**
* Return the number of symbols included in a QRcode_List.
* @param qrlist a head entry of a QRcode_List.
* @return number of symbols in the list.
*/
extern int QRcode_List_size(QRcode_List *qrlist);
/**
* Free the QRcode_List.
* @param qrlist a head entry of a QRcode_List.
*/
extern void QRcode_List_free(QRcode_List *qrlist);
/******************************************************************************
* System utilities
*****************************************************************************/
/**
* Return a string that identifies the library version.
* @param major_version
* @param minor_version
* @param micro_version
*/
extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version);
/**
* Return a string that identifies the library version.
* @return a string identifies the library version. The string is held by the
* library. Do NOT free it.
*/
extern char *QRcode_APIVersionString(void);
/**
* Clear all caches. This is only for debug purpose. If you are attacking a
* complicated memory leak bug, try this to reduce the reachable blocks record.
* @warning This function is THREAD UNSAFE when pthread is disabled.
*/
extern void QRcode_clearCache(void);
#if defined(__cplusplus)
}
#endif
#endif /* __QRENCODE_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrencode.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 4,798
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Binary sequence class.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __BITSTREAM_H__
#define __BITSTREAM_H__
typedef struct {
int length;
unsigned char *data;
} BitStream;
extern BitStream *BitStream_new(void);
extern int BitStream_append(BitStream *bstream, BitStream *arg);
extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num);
extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data);
#define BitStream_size(__bstream__) (__bstream__->length)
extern unsigned char *BitStream_toByte(BitStream *bstream);
extern void BitStream_free(BitStream *bstream);
#endif /* __BITSTREAM_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/bitstream.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 265
|
```c
/*
* qrencode - QR Code encoder
*
* Micor QR Code specification in convenient format.
*
* The following data / specifications are taken from
* "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
* or
* "Automatic identification and data capture techniques --
* QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_LIBPTHREAD
#include <pthread.h>
#endif
#include "mqrspec.h"
/******************************************************************************
* Version and capacity
*****************************************************************************/
typedef struct {
int width; //< Edge length of the symbol
int ec[4]; //< Number of ECC code (bytes)
} MQRspec_Capacity;
/**
* Table of the capacity of symbols
* See Table 1 (pp.106) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004.
*/
static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = {
{ 0, {0, 0, 0, 0}},
{ 11, {2, 0, 0, 0}},
{ 13, {5, 6, 0, 0}},
{ 15, {6, 8, 0, 0}},
{ 17, {8, 10, 14, 0}}
};
int MQRspec_getDataLengthBit(int version, QRecLevel level)
{
int w;
int ecc;
w = mqrspecCapacity[version].width - 1;
ecc = mqrspecCapacity[version].ec[level];
if(ecc == 0) return 0;
return w * w - 64 - ecc * 8;
}
int MQRspec_getDataLength(int version, QRecLevel level)
{
return (MQRspec_getDataLengthBit(version, level) + 4) / 8;
}
int MQRspec_getECCLength(int version, QRecLevel level)
{
return mqrspecCapacity[version].ec[level];
}
int MQRspec_getWidth(int version)
{
return mqrspecCapacity[version].width;
}
/******************************************************************************
* Length indicator
*****************************************************************************/
/**
* See Table 3 (pp.107) of Appendix 1, JIS X0510:2004.
*/
static const int lengthTableBits[4][4] = {
{ 3, 4, 5, 6},
{ 0, 3, 4, 5},
{ 0, 0, 4, 5},
{ 0, 0, 3, 4}
};
int MQRspec_lengthIndicator(QRencodeMode mode, int version)
{
return lengthTableBits[mode][version - 1];
}
int MQRspec_maximumWords(QRencodeMode mode, int version)
{
int bits;
int words;
bits = lengthTableBits[mode][version - 1];
words = (1 << bits) - 1;
if(mode == QR_MODE_KANJI) {
words *= 2; // the number of bytes is required
}
return words;
}
/******************************************************************************
* Format information
*****************************************************************************/
/* See calcFormatInfo in tests/test_mqrspec.c */
static const unsigned int formatInfo[4][8] = {
{0x4445, 0x55ae, 0x6793, 0x7678, 0x06de, 0x1735, 0x2508, 0x34e3},
{0x4172, 0x5099, 0x62a4, 0x734f, 0x03e9, 0x1202, 0x203f, 0x31d4},
{0x4e2b, 0x5fc0, 0x6dfd, 0x7c16, 0x0cb0, 0x1d5b, 0x2f66, 0x3e8d},
{0x4b1c, 0x5af7, 0x68ca, 0x7921, 0x0987, 0x186c, 0x2a51, 0x3bba}
};
/* See Table 10 of Appendix 1. (pp.115) */
static const int typeTable[MQRSPEC_VERSION_MAX + 1][3] = {
{-1, -1, -1},
{ 0, -1, -1},
{ 1, 2, -1},
{ 3, 4, -1},
{ 5, 6, 7}
};
unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level)
{
int type;
if(mask < 0 || mask > 3) return 0;
if(version <= 0 || version > MQRSPEC_VERSION_MAX) return 0;
if(level == QR_ECLEVEL_H) return 0;
type = typeTable[version][level];
if(type < 0) return 0;
return formatInfo[mask][type];
}
/******************************************************************************
* Frame
*****************************************************************************/
/**
* Cache of initial frames.
*/
/* C99 says that static storage shall be initialized to a null pointer
* by compiler. */
static unsigned char *frames[MQRSPEC_VERSION_MAX + 1];
#ifdef HAVE_LIBPTHREAD
static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
/**
* Put a finder pattern.
* @param frame
* @param width
* @param ox,oy upper-left coordinate of the pattern
*/
static void putFinderPattern(unsigned char *frame, int width, int ox, int oy)
{
static const unsigned char finder[] = {
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
};
int x, y;
const unsigned char *s;
frame += oy * width + ox;
s = finder;
for(y=0; y<7; y++) {
for(x=0; x<7; x++) {
frame[x] = s[x];
}
frame += width;
s += 7;
}
}
static unsigned char *MQRspec_createFrame(int version)
{
unsigned char *frame, *p, *q;
int width;
int x, y;
width = mqrspecCapacity[version].width;
frame = (unsigned char *)malloc(width * width);
if(frame == NULL) return NULL;
memset(frame, 0, width * width);
/* Finder pattern */
putFinderPattern(frame, width, 0, 0);
/* Separator */
p = frame;
for(y=0; y<7; y++) {
p[7] = 0xc0;
p += width;
}
memset(frame + width * 7, 0xc0, 8);
/* Mask format information area */
memset(frame + width * 8 + 1, 0x84, 8);
p = frame + width + 8;
for(y=0; y<7; y++) {
*p = 0x84;
p += width;
}
/* Timing pattern */
p = frame + 8;
q = frame + width * 8;
for(x=1; x<width-7; x++) {
*p = 0x90 | (x & 1);
*q = 0x90 | (x & 1);
p++;
q += width;
}
return frame;
}
unsigned char *MQRspec_newFrame(int version)
{
unsigned char *frame;
int width;
if(version < 1 || version > MQRSPEC_VERSION_MAX) return NULL;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_lock(&frames_mutex);
#endif
if(frames[version] == NULL) {
frames[version] = MQRspec_createFrame(version);
}
#ifdef HAVE_LIBPTHREAD
pthread_mutex_unlock(&frames_mutex);
#endif
if(frames[version] == NULL) return NULL;
width = mqrspecCapacity[version].width;
frame = (unsigned char *)malloc(width * width);
if(frame == NULL) return NULL;
memcpy(frame, frames[version], width * width);
return frame;
}
void MQRspec_clearCache(void)
{
int i;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_lock(&frames_mutex);
#endif
for(i=1; i<=MQRSPEC_VERSION_MAX; i++) {
free(frames[i]);
frames[i] = NULL;
}
#ifdef HAVE_LIBPTHREAD
pthread_mutex_unlock(&frames_mutex);
#endif
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/mqrspec.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,240
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Reed solomon encoder. This code is taken from Phil Karn's libfec then
* editted and packed into a pair of .c and .h files.
*
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __RSCODE_H__
#define __RSCODE_H__
/*
* General purpose RS codec, 8-bit symbols.
*/
typedef struct _RS RS;
extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad);
extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity);
extern void free_rs_char(RS *rs);
extern void free_rs_cache(void);
#endif /* __RSCODE_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/rscode.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 266
|
```c
/**
* qrencode - QR Code encoder
*
* QR Code encoding tool
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <png.h>
#include <getopt.h>
#include "qrencode.h"
#define INCHES_PER_METER (100.0/2.54)
static int casesensitive = 1;
static int eightbit = 0;
static int version = 0;
static int size = 3;
static int margin = -1;
static int dpi = 72;
static int structured = 0;
static int rle = 0;
static int micro = 0;
static QRecLevel level = QR_ECLEVEL_L;
static QRencodeMode hint = QR_MODE_8;
static unsigned int fg_color[4] = {0, 0, 0, 255};
static unsigned int bg_color[4] = {255, 255, 255, 255};
static int verbose = 0;
enum imageType {
PNG_TYPE,
EPS_TYPE,
SVG_TYPE,
ANSI_TYPE,
ANSI256_TYPE,
ASCII_TYPE,
ASCIIi_TYPE,
UTF8_TYPE,
ANSIUTF8_TYPE
};
static enum imageType image_type = PNG_TYPE;
static const struct option options[] = {
{"help" , no_argument , NULL, 'h'},
{"output" , required_argument, NULL, 'o'},
{"level" , required_argument, NULL, 'l'},
{"size" , required_argument, NULL, 's'},
{"symversion" , required_argument, NULL, 'v'},
{"margin" , required_argument, NULL, 'm'},
{"dpi" , required_argument, NULL, 'd'},
{"type" , required_argument, NULL, 't'},
{"structured" , no_argument , NULL, 'S'},
{"kanji" , no_argument , NULL, 'k'},
{"casesensitive", no_argument , NULL, 'c'},
{"ignorecase" , no_argument , NULL, 'i'},
{"8bit" , no_argument , NULL, '8'},
{"rle" , no_argument , &rle, 1},
{"micro" , no_argument , NULL, 'M'},
{"foreground" , required_argument, NULL, 'f'},
{"background" , required_argument, NULL, 'b'},
{"version" , no_argument , NULL, 'V'},
{"verbose" , no_argument , &verbose, 1},
{NULL, 0, NULL, 0}
};
static char *optstring = "ho:l:s:v:m:d:t:Skci8MV";
static void usage(int help, int longopt)
{
fprintf(stderr,
"qrencode version %s\n"
if(help) {
if(longopt) {
fprintf(stderr,
"Usage: qrencode [OPTION]... [STRING]\n"
"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
" -h, --help display the help message. -h displays only the help of short\n"
" options.\n\n"
" -o FILENAME, --output=FILENAME\n"
" write image to FILENAME. If '-' is specified, the result\n"
" will be output to standard output. If -S is given, structured\n"
" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
" (suffix is removed from FILENAME, if specified)\n"
" -s NUMBER, --size=NUMBER\n"
" specify module size in dots (pixels). (default=3)\n\n"
" -l {LMQH}, --level={LMQH}\n"
" specify error correction level from L (lowest) to H (highest).\n"
" (default=L)\n\n"
" -v NUMBER, --symversion=NUMBER\n"
" specify the version of the symbol. See SYMBOL VERSIONS for more\n"
" information. (default=auto)\n\n"
" -m NUMBER, --margin=NUMBER\n"
" specify the width of the margins. (default=4 (2 for Micro QR)))\n\n"
" -d NUMBER, --dpi=NUMBER\n"
" specify the DPI of the generated PNG. (default=72)\n\n"
" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={PNG,EPS,\n"
" SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
" specify the type of the generated image. (default=PNG)\n\n"
" -S, --structured\n"
" make structured symbols. Version must be specified.\n\n"
" -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
" -c, --casesensitive\n"
" encode lower-case alphabet characters in 8-bit mode. (default)\n\n"
" -i, --ignorecase\n"
" ignore case distinctions and use only upper-case characters.\n\n"
" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
" --rle enable run-length encoding for SVG.\n\n"
" -M, --micro encode in a Micro QR Code. (experimental)\n\n"
" --foreground=RRGGBB[AA]\n"
" --background=RRGGBB[AA]\n"
" specify foreground/background color in hexadecimal notation.\n"
" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
" Color output support available only in PNG and SVG.\n"
" -V, --version\n"
" display the version number and copyrights of the qrencode.\n\n"
" --verbose\n"
" display verbose information to stderr.\n\n"
" [STRING] input data. If it is not specified, data will be taken from\n"
" standard input.\n\n"
"*SYMBOL VERSIONS\n"
" The symbol versions of QR Code range from Version 1 to Version\n"
" 40. Each version has a different module configuration or number\n"
" of modules, ranging from Version 1 (21 x 21 modules) up to\n"
" Version 40 (177 x 177 modules). Each higher version number\n"
" comprises 4 additional modules per side by default. See\n"
" path_to_url for a detailed\n"
" version list.\n"
);
} else {
fprintf(stderr,
"Usage: qrencode [OPTION]... [STRING]\n"
"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
" -h display this message.\n"
" --help display the usage of long options.\n"
" -o FILENAME write image to FILENAME. If '-' is specified, the result\n"
" will be output to standard output. If -S is given, structured\n"
" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
" (suffix is removed from FILENAME, if specified)\n"
" -s NUMBER specify module size in dots (pixels). (default=3)\n"
" -l {LMQH} specify error correction level from L (lowest) to H (highest).\n"
" (default=L)\n"
" -v NUMBER specify the version of the symbol. (default=auto)\n"
" -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n"
" -d NUMBER specify the DPI of the generated PNG. (default=72)\n"
" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
" specify the type of the generated image. (default=PNG)\n"
" -S make structured symbols. Version must be specified.\n"
" -k assume that the input text contains kanji (shift-jis).\n"
" -c encode lower-case alphabet characters in 8-bit mode. (default)\n"
" -i ignore case distinctions and use only upper-case characters.\n"
" -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
" -M encode in a Micro QR Code.\n"
" --foreground=RRGGBB[AA]\n"
" --background=RRGGBB[AA]\n"
" specify foreground/background color in hexadecimal notation.\n"
" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
" Color output support available only in PNG and SVG.\n"
" -V display the version number and copyrights of the qrencode.\n"
" [STRING] input data. If it is not specified, data will be taken from\n"
" standard input.\n"
);
}
}
}
static int color_set(unsigned int color[4], const char *value)
{
int len = strlen(value);
int count;
if(len == 6) {
count = sscanf(value, "%02x%02x%02x%n", &color[0], &color[1], &color[2], &len);
if(count < 3 || len != 6) {
return -1;
}
color[3] = 255;
} else if(len == 8) {
count = sscanf(value, "%02x%02x%02x%02x%n", &color[0], &color[1], &color[2], &color[3], &len);
if(count < 4 || len != 8) {
return -1;
}
} else {
return -1;
}
return 0;
}
#define MAX_DATA_SIZE (7090 * 16) /* from the specification */
static unsigned char *readStdin(int *length)
{
unsigned char *buffer;
int ret;
buffer = (unsigned char *)malloc(MAX_DATA_SIZE + 1);
if(buffer == NULL) {
fprintf(stderr, "Memory allocation failed.\n");
exit(EXIT_FAILURE);
}
ret = fread(buffer, 1, MAX_DATA_SIZE, stdin);
if(ret == 0) {
fprintf(stderr, "No input data.\n");
exit(EXIT_FAILURE);
}
if(feof(stdin) == 0) {
fprintf(stderr, "Input data is too large.\n");
exit(EXIT_FAILURE);
}
buffer[ret] = '\0';
*length = ret;
return buffer;
}
static FILE *openFile(const char *outfile)
{
FILE *fp;
if(outfile == NULL || (outfile[0] == '-' && outfile[1] == '\0')) {
fp = stdout;
} else {
fp = fopen(outfile, "wb");
if(fp == NULL) {
fprintf(stderr, "Failed to create file: %s\n", outfile);
perror(NULL);
exit(EXIT_FAILURE);
}
}
return fp;
}
static int writePNG(QRcode *qrcode, const char *outfile)
{
// static FILE *fp; // avoid clobbering by setjmp.
// png_structp png_ptr;
// png_infop info_ptr;
// png_colorp palette;
// png_byte alpha_values[2];
// unsigned char *row, *p, *q;
// int x, y, xx, yy, bit;
// int realwidth;
// realwidth = (qrcode->width + margin * 2) * size;
// row = (unsigned char *)malloc((realwidth + 7) / 8);
// if(row == NULL) {
// fprintf(stderr, "Failed to allocate memory.\n");
// exit(EXIT_FAILURE);
// }
// if(outfile[0] == '-' && outfile[1] == '\0') {
// fp = stdout;
// } else {
// fp = fopen(outfile, "wb");
// if(fp == NULL) {
// fprintf(stderr, "Failed to create file: %s\n", outfile);
// perror(NULL);
// exit(EXIT_FAILURE);
// }
// }
// png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
// if(png_ptr == NULL) {
// fprintf(stderr, "Failed to initialize PNG writer.\n");
// exit(EXIT_FAILURE);
// }
// info_ptr = png_create_info_struct(png_ptr);
// if(info_ptr == NULL) {
// fprintf(stderr, "Failed to initialize PNG write.\n");
// exit(EXIT_FAILURE);
// }
// if(setjmp(png_jmpbuf(png_ptr))) {
// png_destroy_write_struct(&png_ptr, &info_ptr);
// fprintf(stderr, "Failed to write PNG image.\n");
// exit(EXIT_FAILURE);
// }
// palette = (png_colorp) malloc(sizeof(png_color) * 2);
// if(palette == NULL) {
// fprintf(stderr, "Failed to allocate memory.\n");
// exit(EXIT_FAILURE);
// }
// palette[0].red = fg_color[0];
// palette[0].green = fg_color[1];
// palette[0].blue = fg_color[2];
// palette[1].red = bg_color[0];
// palette[1].green = bg_color[1];
// palette[1].blue = bg_color[2];
// alpha_values[0] = fg_color[3];
// alpha_values[1] = bg_color[3];
// png_set_PLTE(png_ptr, info_ptr, palette, 2);
// png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
// png_init_io(png_ptr, fp);
// png_set_IHDR(png_ptr, info_ptr,
// realwidth, realwidth,
// 1,
// PNG_COLOR_TYPE_PALETTE,
// PNG_INTERLACE_NONE,
// PNG_COMPRESSION_TYPE_DEFAULT,
// PNG_FILTER_TYPE_DEFAULT);
// png_set_pHYs(png_ptr, info_ptr,
// dpi * INCHES_PER_METER,
// dpi * INCHES_PER_METER,
// PNG_RESOLUTION_METER);
// png_write_info(png_ptr, info_ptr);
// /* top margin */
// memset(row, 0xff, (realwidth + 7) / 8);
// for(y=0; y<margin * size; y++) {
// png_write_row(png_ptr, row);
// }
// /* data */
// p = qrcode->data;
// for(y=0; y<qrcode->width; y++) {
// bit = 7;
// memset(row, 0xff, (realwidth + 7) / 8);
// q = row;
// q += margin * size / 8;
// bit = 7 - (margin * size % 8);
// for(x=0; x<qrcode->width; x++) {
// for(xx=0; xx<size; xx++) {
// *q ^= (*p & 1) << bit;
// bit--;
// if(bit < 0) {
// q++;
// bit = 7;
// }
// }
// p++;
// }
// for(yy=0; yy<size; yy++) {
// png_write_row(png_ptr, row);
// }
// }
// /* bottom margin */
// memset(row, 0xff, (realwidth + 7) / 8);
// for(y=0; y<margin * size; y++) {
// png_write_row(png_ptr, row);
// }
// png_write_end(png_ptr, info_ptr);
// png_destroy_write_struct(&png_ptr, &info_ptr);
// fclose(fp);
// free(row);
// free(palette);
// return 0;
}
static int writeEPS(QRcode *qrcode, const char *outfile)
{
FILE *fp;
unsigned char *row, *p;
int x, y, yy;
int realwidth;
fp = openFile(outfile);
realwidth = (qrcode->width + margin * 2) * size;
/* EPS file header */
fprintf(fp, "%%!PS-Adobe-2.0 EPSF-1.2\n"
"%%%%BoundingBox: 0 0 %d %d\n"
"%%%%Pages: 1 1\n"
"%%%%EndComments\n", realwidth, realwidth);
/* draw point */
fprintf(fp, "/p { "
"moveto "
"0 1 rlineto "
"1 0 rlineto "
"0 -1 rlineto "
"fill "
"} bind def "
"%d %d scale ", size, size);
/* data */
p = qrcode->data;
for(y=0; y<qrcode->width; y++) {
row = (p+(y*qrcode->width));
yy = (margin + qrcode->width - y - 1);
for(x=0; x<qrcode->width; x++) {
if(*(row+x)&0x1) {
fprintf(fp, "%d %d p ", margin + x, yy);
}
}
}
fprintf(fp, "\n%%%%EOF\n");
fclose(fp);
return 0;
}
static void writeSVG_writeRect(FILE *fp, int x, int y, int width, char* col, float opacity)
{
if(fg_color[3] != 255) {
fprintf(fp, "\t\t\t<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"1\" "\
"fill=\"#%s\" fill-opacity=\"%f\" />\n",
x, y, width, col, opacity );
} else {
fprintf(fp, "\t\t\t<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"1\" "\
"fill=\"#%s\" />\n",
x, y, width, col );
}
}
static int writeSVG( QRcode *qrcode, const char *outfile )
{
FILE *fp;
unsigned char *row, *p;
int x, y, x0, pen;
int symwidth, realwidth;
float scale;
char fg[7], bg[7];
float fg_opacity;
float bg_opacity;
fp = openFile(outfile);
scale = dpi * INCHES_PER_METER / 100.0;
symwidth = qrcode->width + margin * 2;
realwidth = symwidth * size;
snprintf(fg, 7, "%02x%02x%02x", fg_color[0], fg_color[1], fg_color[2]);
snprintf(bg, 7, "%02x%02x%02x", bg_color[0], bg_color[1], bg_color[2]);
fg_opacity = (float)fg_color[3] / 255;
bg_opacity = (float)bg_color[3] / 255;
/* XML declaration */
fputs( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", fp );
/* DTD
No document type specified because "while a DTD is provided in [the SVG]
specification, the use of DTDs for validating XML documents is known to be
problematic. In particular, DTDs do not handle namespaces gracefully. It
is *not* recommended that a DOCTYPE declaration be included in SVG
documents."
path_to_url#Namespace
*/
/* Vanity remark */
fprintf( fp, "<!-- Created with qrencode %s (path_to_url -->\n",
QRcode_APIVersionString() );
/* SVG code start */
fprintf( fp, "<svg width=\"%0.2fcm\" height=\"%0.2fcm\" viewBox=\"0 0 %d %d\""\
" preserveAspectRatio=\"none\" version=\"1.1\""\
" xmlns=\"path_to_url">\n",
realwidth / scale, realwidth / scale, symwidth, symwidth
);
/* Make named group */
fputs( "\t<g id=\"QRcode\">\n", fp );
/* Make solid background */
if(bg_color[3] != 255) {
fprintf(fp, "\t\t<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" fill-opacity=\"%f\" />\n", symwidth, symwidth, bg, bg_opacity);
} else {
fprintf(fp, "\t\t<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", symwidth, symwidth, bg);
}
/* Create new viewbox for QR data */
fputs( "\t\t<g id=\"Pattern\">\n", fp);
/* Write data */
p = qrcode->data;
for(y=0; y<qrcode->width; y++) {
row = (p+(y*qrcode->width));
if( !rle ) {
/* no RLE */
for(x=0; x<qrcode->width; x++) {
if(*(row+x)&0x1) {
writeSVG_writeRect(fp, margin + x,
margin + y, 1,
fg, fg_opacity);
}
}
} else {
/* simple RLE */
pen = 0;
x0 = 0;
for(x=0; x<qrcode->width; x++) {
if( !pen ) {
pen = *(row+x)&0x1;
x0 = x;
} else {
if(!(*(row+x)&0x1)) {
writeSVG_writeRect(fp, x0 + margin, y + margin, x-x0, fg, fg_opacity);
pen = 0;
}
}
}
if( pen ) {
writeSVG_writeRect(fp, x0 + margin, y + margin, qrcode->width - x0, fg, fg_opacity);
}
}
}
/* Close QR data viewbox */
fputs( "\t\t</g>\n", fp );
/* Close group */
fputs( "\t</g>\n", fp );
/* Close SVG code */
fputs( "</svg>\n", fp );
fclose( fp );
return 0;
}
static void writeANSI_margin(FILE* fp, int realwidth,
char* buffer, int buffer_s,
char* white, int white_s )
{
int y;
strncpy(buffer, white, white_s);
memset(buffer + white_s, ' ', realwidth * 2);
strcpy(buffer + white_s + realwidth * 2, "\033[0m\n"); // reset to default colors
for(y=0; y<margin; y++ ){
fputs(buffer, fp);
}
}
static int writeANSI(QRcode *qrcode, const char *outfile)
{
FILE *fp;
unsigned char *row, *p;
int x, y;
int realwidth;
int last;
char *white, *black, *buffer;
int white_s, black_s, buffer_s;
if( image_type == ANSI256_TYPE ){
/* codes for 256 color compatible terminals */
white = "\033[48;5;231m";
white_s = 11;
black = "\033[48;5;16m";
black_s = 10;
} else {
white = "\033[47m";
white_s = 5;
black = "\033[40m";
black_s = 5;
}
size = 1;
fp = openFile(outfile);
realwidth = (qrcode->width + margin * 2) * size;
buffer_s = ( realwidth * white_s ) * 2;
buffer = (char *)malloc( buffer_s );
if(buffer == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
/* top margin */
writeANSI_margin(fp, realwidth, buffer, buffer_s, white, white_s);
/* data */
p = qrcode->data;
for(y=0; y<qrcode->width; y++) {
row = (p+(y*qrcode->width));
bzero( buffer, buffer_s );
strncpy( buffer, white, white_s );
for(x=0; x<margin; x++ ){
strncat( buffer, " ", 2 );
}
last = 0;
for(x=0; x<qrcode->width; x++) {
if(*(row+x)&0x1) {
if( last != 1 ){
strncat( buffer, black, black_s );
last = 1;
}
} else {
if( last != 0 ){
strncat( buffer, white, white_s );
last = 0;
}
}
strncat( buffer, " ", 2 );
}
if( last != 0 ){
strncat( buffer, white, white_s );
}
for(x=0; x<margin; x++ ){
strncat( buffer, " ", 2 );
}
strncat( buffer, "\033[0m\n", 5 );
fputs( buffer, fp );
}
/* bottom margin */
writeANSI_margin(fp, realwidth, buffer, buffer_s, white, white_s);
fclose(fp);
free(buffer);
return 0;
}
static void writeUTF8_margin(FILE* fp, int realwidth,
const char* white, const char *reset,
int use_ansi)
{
int x, y;
for (y = 0; y < margin/2; y++) {
fputs(white, fp);
for (x = 0; x < realwidth; x++)
fputs("\342\226\210", fp);
fputs(reset, fp);
fputc('\n', fp);
}
}
static int writeUTF8(QRcode *qrcode, const char *outfile, int use_ansi)
{
FILE *fp;
int x, y;
int realwidth;
const char *white, *reset;
if (use_ansi){
white = "\033[40;37;1m";
reset = "\033[0m";
} else {
white = "";
reset = "";
}
fp = openFile(outfile);
realwidth = (qrcode->width + margin * 2);
/* top margin */
writeUTF8_margin(fp, realwidth, white, reset, use_ansi);
/* data */
for(y = 0; y < qrcode->width; y += 2) {
unsigned char *row1, *row2;
row1 = qrcode->data + y*qrcode->width;
row2 = row1 + qrcode->width;
fputs(white, fp);
for (x = 0; x < margin; x++)
fputs("\342\226\210", fp);
for (x = 0; x < qrcode->width; x++) {
if(row1[x] & 1) {
if(y < qrcode->width - 1 && row2[x] & 1) {
fputc(' ', fp);
} else {
fputs("\342\226\204", fp);
}
} else {
if(y < qrcode->width - 1 && row2[x] & 1) {
fputs("\342\226\200", fp);
} else {
fputs("\342\226\210", fp);
}
}
}
for (x = 0; x < margin; x++)
fputs("\342\226\210", fp);
fputs(reset, fp);
fputc('\n', fp);
}
/* bottom margin */
writeUTF8_margin(fp, realwidth, white, reset, use_ansi);
fclose(fp);
return 0;
}
static void writeASCII_margin(FILE* fp, int realwidth, char* buffer, int buffer_s, int invert)
{
int y, h;
h = margin;
memset(buffer, (invert?'#':' '), realwidth);
buffer[realwidth] = '\n';
buffer[realwidth + 1] = '\0';
for(y=0; y<h; y++ ){
fputs(buffer, fp);
}
}
static int writeASCII(QRcode *qrcode, const char *outfile, int invert)
{
FILE *fp;
unsigned char *row;
int x, y;
int realwidth;
char *buffer, *p;
int buffer_s;
char black = '#';
char white = ' ';
if(invert) {
black = ' ';
white = '#';
}
size = 1;
fp = openFile(outfile);
realwidth = (qrcode->width + margin * 2) * 2;
buffer_s = realwidth + 2;
buffer = (char *)malloc( buffer_s );
if(buffer == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
/* top margin */
writeASCII_margin(fp, realwidth, buffer, buffer_s, invert);
/* data */
for(y=0; y<qrcode->width; y++) {
row = qrcode->data+(y*qrcode->width);
p = buffer;
memset(p, white, margin * 2);
p += margin * 2;
for(x=0; x<qrcode->width; x++) {
if(row[x]&0x1) {
*p++ = black;
*p++ = black;
} else {
*p++ = white;
*p++ = white;
}
}
memset(p, white, margin * 2);
p += margin * 2;
*p++ = '\n';
*p++ = '\0';
fputs( buffer, fp );
}
/* bottom margin */
writeASCII_margin(fp, realwidth, buffer, buffer_s, invert);
fclose(fp);
free(buffer);
return 0;
}
static QRcode *encode(const unsigned char *intext, int length)
{
QRcode *code;
if(micro) {
if(eightbit) {
code = QRcode_encodeDataMQR(length, intext, version, level);
} else {
code = QRcode_encodeStringMQR((char *)intext, version, level, hint, casesensitive);
}
} else {
if(eightbit) {
code = QRcode_encodeData(length, intext, version, level);
} else {
code = QRcode_encodeString((char *)intext, version, level, hint, casesensitive);
}
}
return code;
}
static void qrencode(const unsigned char *intext, int length, const char *outfile)
{
QRcode *qrcode;
qrcode = encode(intext, length);
if(qrcode == NULL) {
perror("Failed to encode the input data");
exit(EXIT_FAILURE);
}
if(verbose) {
fprintf(stderr, "File: %s, Version: %d\n", (outfile!=NULL)?outfile:"(stdout)", qrcode->version);
}
switch(image_type) {
case PNG_TYPE:
writePNG(qrcode, outfile);
break;
case EPS_TYPE:
writeEPS(qrcode, outfile);
break;
case SVG_TYPE:
writeSVG(qrcode, outfile);
break;
case ANSI_TYPE:
case ANSI256_TYPE:
writeANSI(qrcode, outfile);
break;
case ASCIIi_TYPE:
writeASCII(qrcode, outfile, 1);
break;
case ASCII_TYPE:
writeASCII(qrcode, outfile, 0);
break;
case UTF8_TYPE:
writeUTF8(qrcode, outfile, 0);
break;
case ANSIUTF8_TYPE:
writeUTF8(qrcode, outfile, 1);
break;
default:
fprintf(stderr, "Unknown image type.\n");
exit(EXIT_FAILURE);
}
QRcode_free(qrcode);
}
static QRcode_List *encodeStructured(const unsigned char *intext, int length)
{
QRcode_List *list;
if(eightbit) {
list = QRcode_encodeDataStructured(length, intext, version, level);
} else {
list = QRcode_encodeStringStructured((char *)intext, version, level, hint, casesensitive);
}
return list;
}
static void qrencodeStructured(const unsigned char *intext, int length, const char *outfile)
{
QRcode_List *qrlist, *p;
char filename[FILENAME_MAX];
char *base, *q, *suffix = NULL;
const char *type_suffix;
int i = 1;
size_t suffix_size;
switch(image_type) {
case PNG_TYPE:
type_suffix = ".png";
break;
case EPS_TYPE:
type_suffix = ".eps";
break;
case SVG_TYPE:
type_suffix = ".svg";
break;
case ANSI_TYPE:
case ANSI256_TYPE:
case ASCII_TYPE:
case UTF8_TYPE:
case ANSIUTF8_TYPE:
type_suffix = ".txt";
break;
default:
fprintf(stderr, "Unknown image type.\n");
exit(EXIT_FAILURE);
}
if(outfile == NULL) {
fprintf(stderr, "An output filename must be specified to store the structured images.\n");
exit(EXIT_FAILURE);
}
base = strdup(outfile);
if(base == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
suffix_size = strlen(type_suffix);
if(strlen(base) > suffix_size) {
q = base + strlen(base) - suffix_size;
if(strcasecmp(type_suffix, q) == 0) {
suffix = strdup(q);
*q = '\0';
}
}
qrlist = encodeStructured(intext, length);
if(qrlist == NULL) {
perror("Failed to encode the input data");
exit(EXIT_FAILURE);
}
for(p = qrlist; p != NULL; p = p->next) {
if(p->code == NULL) {
fprintf(stderr, "Failed to encode the input data.\n");
exit(EXIT_FAILURE);
}
if(suffix) {
snprintf(filename, FILENAME_MAX, "%s-%02d%s", base, i, suffix);
} else {
snprintf(filename, FILENAME_MAX, "%s-%02d", base, i);
}
if(verbose) {
fprintf(stderr, "File: %s, Version: %d\n", filename, p->code->version);
}
switch(image_type) {
case PNG_TYPE:
writePNG(p->code, filename);
break;
case EPS_TYPE:
writeEPS(p->code, filename);
break;
case SVG_TYPE:
writeSVG(p->code, filename);
break;
case ANSI_TYPE:
case ANSI256_TYPE:
writeANSI(p->code, filename);
break;
case ASCIIi_TYPE:
writeASCII(p->code, filename, 1);
break;
case ASCII_TYPE:
writeASCII(p->code, filename, 0);
break;
case UTF8_TYPE:
writeUTF8(p->code, filename, 0);
break;
case ANSIUTF8_TYPE:
writeUTF8(p->code, filename, 0);
break;
default:
fprintf(stderr, "Unknown image type.\n");
exit(EXIT_FAILURE);
}
i++;
}
free(base);
if(suffix) {
free(suffix);
}
QRcode_List_free(qrlist);
}
int main(int argc, char **argv)
{
int opt, lindex = -1;
char *outfile = NULL;
unsigned char *intext = NULL;
int length = 0;
while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) {
switch(opt) {
case 'h':
if(lindex == 0) {
usage(1, 1);
} else {
usage(1, 0);
}
exit(EXIT_SUCCESS);
break;
case 'o':
outfile = optarg;
break;
case 's':
size = atoi(optarg);
if(size <= 0) {
fprintf(stderr, "Invalid size: %d\n", size);
exit(EXIT_FAILURE);
}
break;
case 'v':
version = atoi(optarg);
if(version < 0) {
fprintf(stderr, "Invalid version: %d\n", version);
exit(EXIT_FAILURE);
}
break;
case 'l':
switch(*optarg) {
case 'l':
case 'L':
level = QR_ECLEVEL_L;
break;
case 'm':
case 'M':
level = QR_ECLEVEL_M;
break;
case 'q':
case 'Q':
level = QR_ECLEVEL_Q;
break;
case 'h':
case 'H':
level = QR_ECLEVEL_H;
break;
default:
fprintf(stderr, "Invalid level: %s\n", optarg);
exit(EXIT_FAILURE);
break;
}
break;
case 'm':
margin = atoi(optarg);
if(margin < 0) {
fprintf(stderr, "Invalid margin: %d\n", margin);
exit(EXIT_FAILURE);
}
break;
case 'd':
dpi = atoi(optarg);
if( dpi < 0 ) {
fprintf(stderr, "Invalid DPI: %d\n", dpi);
exit(EXIT_FAILURE);
}
break;
case 't':
if(strcasecmp(optarg, "png") == 0) {
image_type = PNG_TYPE;
} else if(strcasecmp(optarg, "eps") == 0) {
image_type = EPS_TYPE;
} else if(strcasecmp(optarg, "svg") == 0) {
image_type = SVG_TYPE;
} else if(strcasecmp(optarg, "ansi") == 0) {
image_type = ANSI_TYPE;
} else if(strcasecmp(optarg, "ansi256") == 0) {
image_type = ANSI256_TYPE;
} else if(strcasecmp(optarg, "asciii") == 0) {
image_type = ASCIIi_TYPE;
} else if(strcasecmp(optarg, "ascii") == 0) {
image_type = ASCII_TYPE;
} else if(strcasecmp(optarg, "utf8") == 0) {
image_type = UTF8_TYPE;
} else if(strcasecmp(optarg, "ansiutf8") == 0) {
image_type = ANSIUTF8_TYPE;
} else {
fprintf(stderr, "Invalid image type: %s\n", optarg);
exit(EXIT_FAILURE);
}
break;
case 'S':
structured = 1;
break;
case 'k':
hint = QR_MODE_KANJI;
break;
case 'c':
casesensitive = 1;
break;
case 'i':
casesensitive = 0;
break;
case '8':
eightbit = 1;
break;
case 'M':
micro = 1;
break;
case 'f':
if(color_set(fg_color, optarg)) {
fprintf(stderr, "Invalid foreground color value.\n");
exit(EXIT_FAILURE);
}
break;
case 'b':
if(color_set(bg_color, optarg)) {
fprintf(stderr, "Invalid background color value.\n");
exit(EXIT_FAILURE);
}
break;
case 'V':
usage(0, 0);
exit(EXIT_SUCCESS);
break;
case 0:
break;
default:
fprintf(stderr, "Try `qrencode --help' for more information.\n");
exit(EXIT_FAILURE);
break;
}
}
if(argc == 1) {
usage(1, 0);
exit(EXIT_SUCCESS);
}
if(outfile == NULL && image_type == PNG_TYPE) {
fprintf(stderr, "No output filename is given.\n");
exit(EXIT_FAILURE);
}
if(optind < argc) {
intext = (unsigned char *)argv[optind];
length = strlen((char *)intext);
}
if(intext == NULL) {
intext = readStdin(&length);
}
if(micro && version > MQRSPEC_VERSION_MAX) {
fprintf(stderr, "Version should be less or equal to %d.\n", MQRSPEC_VERSION_MAX);
exit(EXIT_FAILURE);
} else if(!micro && version > QRSPEC_VERSION_MAX) {
fprintf(stderr, "Version should be less or equal to %d.\n", QRSPEC_VERSION_MAX);
exit(EXIT_FAILURE);
}
if(margin < 0) {
if(micro) {
margin = 2;
} else {
margin = 4;
}
}
if(micro) {
if(version == 0) {
fprintf(stderr, "Version must be specified to encode a Micro QR Code symbol.\n");
exit(EXIT_FAILURE);
}
if(structured) {
fprintf(stderr, "Micro QR Code does not support structured symbols.\n");
exit(EXIT_FAILURE);
}
}
if(structured) {
if(version == 0) {
fprintf(stderr, "Version must be specified to encode structured symbols.\n");
exit(EXIT_FAILURE);
}
qrencodeStructured(intext, length, outfile);
} else {
qrencode(intext, length, outfile);
}
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrenc.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 9,296
|
```objective-c
/**
* qrencode - QR Code encoder
*
* Header for test use
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __QRENCODE_INNER_H__
#define __QRENCODE_INNER_H__
/**
* This header file includes definitions for test use.
*/
/******************************************************************************
* Raw code
*****************************************************************************/
typedef struct {
int dataLength;
unsigned char *data;
int eccLength;
unsigned char *ecc;
} RSblock;
typedef struct {
int version;
int dataLength;
int eccLength;
unsigned char *datacode;
unsigned char *ecccode;
int b1;
int blocks;
RSblock *rsblock;
int count;
} QRRawCode;
extern QRRawCode *QRraw_new(QRinput *input);
extern unsigned char QRraw_getCode(QRRawCode *raw);
extern void QRraw_free(QRRawCode *raw);
/******************************************************************************
* Raw code for Micro QR Code
*****************************************************************************/
typedef struct {
int version;
int dataLength;
int eccLength;
unsigned char *datacode;
unsigned char *ecccode;
RSblock *rsblock;
int oddbits;
int count;
} MQRRawCode;
extern MQRRawCode *MQRraw_new(QRinput *input);
extern unsigned char MQRraw_getCode(MQRRawCode *raw);
extern void MQRraw_free(MQRRawCode *raw);
/******************************************************************************
* Frame filling
*****************************************************************************/
extern unsigned char *FrameFiller_test(int version);
extern unsigned char *FrameFiller_testMQR(int version);
/******************************************************************************
* QR-code encoding
*****************************************************************************/
extern QRcode *QRcode_encodeMask(QRinput *input, int mask);
extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask);
extern QRcode *QRcode_new(int version, int width, unsigned char *data);
#endif /* __QRENCODE_INNER_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrencode_inner.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 489
|
```c
/*
* qrencode - QR Code encoder
*
* Input data splitter.
*
* The following data / specifications are taken from
* "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
* or
* "Automatic identification and data capture techniques --
* QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "qrencode.h"
#include "qrinput.h"
#include "qrspec.h"
#include "split.h"
#define isdigit(__c__) ((unsigned char)((signed char)(__c__) - '0') < 10)
#define isalnum(__c__) (QRinput_lookAnTable(__c__) >= 0)
char *strdup___(const char *s)
{
size_t len = strlen(s) + 1;
void *new = malloc(len);
if(new == NULL) return NULL;
return (char *)memcpy(new, s, len);
}
static QRencodeMode Split_identifyMode(const char *string, QRencodeMode hint)
{
unsigned char c, d;
unsigned int word;
c = string[0];
if(c == '\0') return QR_MODE_NUL;
if(isdigit(c)) {
return QR_MODE_NUM;
} else if(isalnum(c)) {
return QR_MODE_AN;
} else if(hint == QR_MODE_KANJI) {
d = string[1];
if(d != '\0') {
word = ((unsigned int)c << 8) | d;
if((word >= 0x8140 && word <= 0x9ffc) || (word >= 0xe040 && word <= 0xebbf)) {
return QR_MODE_KANJI;
}
}
}
return QR_MODE_8;
}
static int Split_eatNum(const char *string, QRinput *input, QRencodeMode hint);
static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint);
static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint);
static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint);
static int Split_eatNum(const char *string, QRinput *input,QRencodeMode hint)
{
const char *p;
int ret;
int run;
int dif;
int ln;
QRencodeMode mode;
ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
p = string;
while(isdigit(*p)) {
p++;
}
run = (int)(p - string);
mode = Split_identifyMode(p, hint);
if(mode == QR_MODE_8) {
dif = QRinput_estimateBitsModeNum(run) + 4 + ln
+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
if(dif > 0) {
return Split_eat8(string, input, hint);
}
}
if(mode == QR_MODE_AN) {
dif = QRinput_estimateBitsModeNum(run) + 4 + ln
+ QRinput_estimateBitsModeAn(1) /* + 4 + la */
- QRinput_estimateBitsModeAn(run + 1) /* - 4 - la */;
if(dif > 0) {
return Split_eatAn(string, input, hint);
}
}
ret = QRinput_append(input, QR_MODE_NUM, run, (unsigned char *)string);
if(ret < 0) return -1;
return run;
}
static int Split_eatAn(const char *string, QRinput *input, QRencodeMode hint)
{
const char *p, *q;
int ret;
int run;
int dif;
int la, ln;
la = QRspec_lengthIndicator(QR_MODE_AN, input->version);
ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
p = string;
while(isalnum(*p)) {
if(isdigit(*p)) {
q = p;
while(isdigit(*q)) {
q++;
}
dif = QRinput_estimateBitsModeAn((int)(p - string)) /* + 4 + la */
+ QRinput_estimateBitsModeNum((int)(q - p)) + 4 + ln
+ (isalnum(*q)?(4 + ln):0)
- QRinput_estimateBitsModeAn((int)(p - string)) /* - 4 - la */;
if(dif < 0) {
break;
} else {
p = q;
}
} else {
p++;
}
}
run = (int)(p - string);
if(*p && !isalnum(*p)) {
dif = QRinput_estimateBitsModeAn(run) + 4 + la
+ QRinput_estimateBitsMode8(1) /* + 4 + l8 */
- QRinput_estimateBitsMode8(run + 1) /* - 4 - l8 */;
if(dif > 0) {
return Split_eat8(string, input, hint);
}
}
ret = QRinput_append(input, QR_MODE_AN, run, (unsigned char *)string);
if(ret < 0) return -1;
return run;
}
static int Split_eatKanji(const char *string, QRinput *input, QRencodeMode hint)
{
const char *p;
int ret;
int run;
p = string;
while(Split_identifyMode(p, hint) == QR_MODE_KANJI) {
p += 2;
}
run = (int)(p - string);
ret = QRinput_append(input, QR_MODE_KANJI, run, (unsigned char *)string);
if(ret < 0) return -1;
return run;
}
static int Split_eat8(const char *string, QRinput *input, QRencodeMode hint)
{
const char *p, *q;
QRencodeMode mode;
int ret;
int run;
int dif;
int la, ln, l8;
int swcost;
la = QRspec_lengthIndicator(QR_MODE_AN, input->version);
ln = QRspec_lengthIndicator(QR_MODE_NUM, input->version);
l8 = QRspec_lengthIndicator(QR_MODE_8, input->version);
p = string + 1;
while(*p != '\0') {
mode = Split_identifyMode(p, hint);
if(mode == QR_MODE_KANJI) {
break;
}
if(mode == QR_MODE_NUM) {
q = p;
while(isdigit(*q)) {
q++;
}
if(Split_identifyMode(q, hint) == QR_MODE_8) {
swcost = 4 + l8;
} else {
swcost = 0;
}
dif = QRinput_estimateBitsMode8((int)(p - string)) /* + 4 + l8 */
+ QRinput_estimateBitsModeNum((int)(q - p)) + 4 + ln
+ swcost
- QRinput_estimateBitsMode8((int)(p - string)) /* - 4 - l8 */;
if(dif < 0) {
break;
} else {
p = q;
}
} else if(mode == QR_MODE_AN) {
q = p;
while(isalnum(*q)) {
q++;
}
if(Split_identifyMode(q, hint) == QR_MODE_8) {
swcost = 4 + l8;
} else {
swcost = 0;
}
dif = QRinput_estimateBitsMode8((int)(p - string)) /* + 4 + l8 */
+ QRinput_estimateBitsModeAn((int)(q - p)) + 4 + la
+ swcost
- QRinput_estimateBitsMode8((int)(p - string)) /* - 4 - l8 */;
if(dif < 0) {
break;
} else {
p = q;
}
} else {
p++;
}
}
run = (int)(p - string);
ret = QRinput_append(input, QR_MODE_8, run, (unsigned char *)string);
if(ret < 0) return -1;
return run;
}
static int Split_splitString(const char *string, QRinput *input,
QRencodeMode hint)
{
int length;
QRencodeMode mode;
if(*string == '\0') return 0;
mode = Split_identifyMode(string, hint);
if(mode == QR_MODE_NUM) {
length = Split_eatNum(string, input, hint);
} else if(mode == QR_MODE_AN) {
length = Split_eatAn(string, input, hint);
} else if(mode == QR_MODE_KANJI && hint == QR_MODE_KANJI) {
length = Split_eatKanji(string, input, hint);
} else {
length = Split_eat8(string, input, hint);
}
if(length == 0) return 0;
if(length < 0) return -1;
return Split_splitString(&string[length], input, hint);
}
static char *dupAndToUpper(const char *str, QRencodeMode hint)
{
char *newstr, *p;
QRencodeMode mode;
newstr = strdup___(str);
if(newstr == NULL) return NULL;
p = newstr;
while(*p != '\0') {
mode = Split_identifyMode(p, hint);
if(mode == QR_MODE_KANJI) {
p += 2;
} else {
if (*p >= 'a' && *p <= 'z') {
*p = (char)((int)*p - 32);
}
p++;
}
}
return newstr;
}
int Split_splitStringToQRinput(const char *string, QRinput *input,
QRencodeMode hint, int casesensitive)
{
char *newstr;
int ret;
if(string == NULL || *string == '\0') {
errno = EINVAL;
return -1;
}
if(!casesensitive) {
newstr = dupAndToUpper(string, hint);
if(newstr == NULL) return -1;
ret = Split_splitString(newstr, input, hint);
free(newstr);
} else {
ret = Split_splitString(string, input, hint);
}
return ret;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/split.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,403
|
```objective-c
/*
* qrencode - QR Code encoder
*
* QR Code specification in convenient format.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __QRSPEC_H__
#define __QRSPEC_H__
#include "qrencode.h"
/******************************************************************************
* Version and capacity
*****************************************************************************/
/**
* Maximum width of a symbol
*/
#define QRSPEC_WIDTH_MAX 177
/**
* Return maximum data code length (bytes) for the version.
* @param version
* @param level
* @return maximum size (bytes)
*/
extern int QRspec_getDataLength(int version, QRecLevel level);
/**
* Return maximum error correction code length (bytes) for the version.
* @param version
* @param level
* @return ECC size (bytes)
*/
extern int QRspec_getECCLength(int version, QRecLevel level);
/**
* Return a version number that satisfies the input code length.
* @param size input code length (byte)
* @param level
* @return version number
*/
extern int QRspec_getMinimumVersion(int size, QRecLevel level);
/**
* Return the width of the symbol for the version.
* @param version
* @return width
*/
extern int QRspec_getWidth(int version);
/**
* Return the numer of remainder bits.
* @param version
* @return number of remainder bits
*/
extern int QRspec_getRemainder(int version);
/******************************************************************************
* Length indicator
*****************************************************************************/
/**
* Return the size of lenght indicator for the mode and version.
* @param mode
* @param version
* @return the size of the appropriate length indicator (bits).
*/
extern int QRspec_lengthIndicator(QRencodeMode mode, int version);
/**
* Return the maximum length for the mode and version.
* @param mode
* @param version
* @return the maximum length (bytes)
*/
extern int QRspec_maximumWords(QRencodeMode mode, int version);
/******************************************************************************
* Error correction code
*****************************************************************************/
/**
* Return an array of ECC specification.
* @param version
* @param level
* @param spec an array of ECC specification contains as following:
* {# of type1 blocks, # of data code, # of ecc code,
* # of type2 blocks, # of data code}
*/
void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]);
#define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3])
#define QRspec_rsBlockNum1(__spec__) (__spec__[0])
#define QRspec_rsDataCodes1(__spec__) (__spec__[1])
#define QRspec_rsEccCodes1(__spec__) (__spec__[2])
#define QRspec_rsBlockNum2(__spec__) (__spec__[3])
#define QRspec_rsDataCodes2(__spec__) (__spec__[4])
#define QRspec_rsEccCodes2(__spec__) (__spec__[2])
#define QRspec_rsDataLength(__spec__) \
((QRspec_rsBlockNum1(__spec__) * QRspec_rsDataCodes1(__spec__)) + \
(QRspec_rsBlockNum2(__spec__) * QRspec_rsDataCodes2(__spec__)))
#define QRspec_rsEccLength(__spec__) \
(QRspec_rsBlockNum(__spec__) * QRspec_rsEccCodes1(__spec__))
/******************************************************************************
* Version information pattern
*****************************************************************************/
/**
* Return BCH encoded version information pattern that is used for the symbol
* of version 7 or greater. Use lower 18 bits.
* @param version
* @return BCH encoded version information pattern
*/
extern unsigned int QRspec_getVersionPattern(int version);
/******************************************************************************
* Format information
*****************************************************************************/
/**
* Return BCH encoded format information pattern.
* @param mask
* @param level
* @return BCH encoded format information pattern
*/
extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level);
/******************************************************************************
* Frame
*****************************************************************************/
/**
* Return a copy of initialized frame.
* When the same version is requested twice or more, a copy of cached frame
* is returned.
* @param version
* @return Array of unsigned char. You can free it by free().
*/
extern unsigned char *QRspec_newFrame(int version);
/**
* Clear the frame cache. Typically for debug.
*/
extern void QRspec_clearCache(void);
/******************************************************************************
* Mode indicator
*****************************************************************************/
/**
* Mode indicator. See Table 2 of JIS X0510:2004, pp.16.
*/
#define QRSPEC_MODEID_ECI 7
#define QRSPEC_MODEID_NUM 1
#define QRSPEC_MODEID_AN 2
#define QRSPEC_MODEID_8 4
#define QRSPEC_MODEID_KANJI 8
#define QRSPEC_MODEID_FNC1FIRST 5
#define QRSPEC_MODEID_FNC1SECOND 9
#define QRSPEC_MODEID_STRUCTURE 3
#define QRSPEC_MODEID_TERMINATOR 0
#endif /* __QRSPEC_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrspec.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,137
|
```c
/*
* qrencode - QR Code encoder
*
* Masking.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include "qrencode.h"
#include "qrspec.h"
#include "mask.h"
int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level)
{
unsigned int format;
unsigned char v;
int i;
int blacks = 0;
format = QRspec_getFormatInfo(mask, level);
for(i=0; i<8; i++) {
if(format & 1) {
blacks += 2;
v = 0x85;
} else {
v = 0x84;
}
frame[width * 8 + width - 1 - i] = v;
if(i < 6) {
frame[width * i + 8] = v;
} else {
frame[width * (i + 1) + 8] = v;
}
format= format >> 1;
}
for(i=0; i<7; i++) {
if(format & 1) {
blacks += 2;
v = 0x85;
} else {
v = 0x84;
}
frame[width * (width - 7 + i) + 8] = v;
if(i == 0) {
frame[width * 8 + 7] = v;
} else {
frame[width * 8 + 6 - i] = v;
}
format= format >> 1;
}
return blacks;
}
/**
* Demerit coefficients.
* See Section 8.8.2, pp.45, JIS X0510:2004.
*/
#define N1 (3)
#define N2 (3)
#define N3 (40)
#define N4 (10)
#define MASKMAKER(__exp__) \
int x, y;\
int b = 0;\
\
for(y=0; y<width; y++) {\
for(x=0; x<width; x++) {\
if(*s & 0x80) {\
*d = *s;\
} else {\
*d = *s ^ ((__exp__) == 0);\
}\
b += (int)(*d & 1);\
s++; d++;\
}\
}\
return b;
static int Mask_mask0(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER((x+y)&1)
}
static int Mask_mask1(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER(y&1)
}
static int Mask_mask2(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER(x%3)
}
static int Mask_mask3(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER((x+y)%3)
}
static int Mask_mask4(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER(((y/2)+(x/3))&1)
}
static int Mask_mask5(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER(((x*y)&1)+(x*y)%3)
}
static int Mask_mask6(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER((((x*y)&1)+(x*y)%3)&1)
}
static int Mask_mask7(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER((((x*y)%3)+((x+y)&1))&1)
}
#define maskNum (8)
typedef int MaskMaker(int, const unsigned char *, unsigned char *);
static MaskMaker *maskMakers[maskNum] = {
Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3,
Mask_mask4, Mask_mask5, Mask_mask6, Mask_mask7
};
#ifdef WITH_TESTS
unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask)
{
unsigned char *masked;
masked = (unsigned char *)malloc(width * width);
if(masked == NULL) return NULL;
maskMakers[mask](width, frame, masked);
return masked;
}
#endif
unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level)
{
unsigned char *masked;
if(mask < 0 || mask >= maskNum) {
errno = EINVAL;
return NULL;
}
masked = (unsigned char *)malloc(width * width);
if(masked == NULL) return NULL;
maskMakers[mask](width, frame, masked);
Mask_writeFormatInformation(width, masked, mask, level);
return masked;
}
//static int n1;
//static int n2;
//static int n3;
//static int n4;
int Mask_calcN1N3(int length, int *runLength)
{
int i;
int demerit = 0;
int fact;
for(i=0; i<length; i++) {
if(runLength[i] >= 5) {
demerit += N1 + (runLength[i] - 5);
//n1 += N1 + (runLength[i] - 5);
}
if((i & 1)) {
if(i >= 3 && i < length-2 && (runLength[i] % 3) == 0) {
fact = runLength[i] / 3;
if(runLength[i-2] == fact &&
runLength[i-1] == fact &&
runLength[i+1] == fact &&
runLength[i+2] == fact) {
if(i == 3 || runLength[i-3] >= 4 * fact) {
demerit += N3;
//n3 += N3;
} else if(i+4 >= length || runLength[i+3] >= 4 * fact) {
demerit += N3;
//n3 += N3;
}
}
}
}
}
return demerit;
}
int Mask_calcN2(int width, unsigned char *frame)
{
int x, y;
unsigned char *p;
unsigned char b22, w22;
int demerit = 0;
p = frame + width + 1;
for(y=1; y<width; y++) {
for(x=1; x<width; x++) {
b22 = p[0] & p[-1] & p[-width] & p [-width-1];
w22 = p[0] | p[-1] | p[-width] | p [-width-1];
if((b22 | (w22 ^ 1))&1) {
demerit += N2;
}
p++;
}
p++;
}
return demerit;
}
int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength)
{
int head;
int i;
unsigned char *p;
int pitch;
pitch = (dir==0)?1:width;
if(frame[0] & 1) {
runLength[0] = -1;
head = 1;
} else {
head = 0;
}
runLength[head] = 1;
p = frame + pitch;
for(i=1; i<width; i++) {
if((p[0] ^ p[-pitch]) & 1) {
head++;
runLength[head] = 1;
} else {
runLength[head]++;
}
p += pitch;
}
return head + 1;
}
int Mask_evaluateSymbol(int width, unsigned char *frame)
{
int x, y;
int demerit = 0;
int runLength[QRSPEC_WIDTH_MAX + 1];
int length;
demerit += Mask_calcN2(width, frame);
for(y=0; y<width; y++) {
length = Mask_calcRunLength(width, frame + y * width, 0, runLength);
demerit += Mask_calcN1N3(length, runLength);
}
for(x=0; x<width; x++) {
length = Mask_calcRunLength(width, frame + x, 1, runLength);
demerit += Mask_calcN1N3(length, runLength);
}
return demerit;
}
unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level)
{
int i;
unsigned char *mask, *bestMask;
int minDemerit = INT_MAX;
int blacks;
int bratio;
int demerit;
int w2 = width * width;
mask = (unsigned char *)malloc(w2);
if(mask == NULL) return NULL;
bestMask = NULL;
for(i=0; i<maskNum; i++) {
// n1 = n2 = n3 = n4 = 0;
demerit = 0;
blacks = maskMakers[i](width, frame, mask);
blacks += Mask_writeFormatInformation(width, mask, i, level);
bratio = (200 * blacks + w2) / w2 / 2; /* (int)(100*blacks/w2+0.5) */
demerit = (abs(bratio - 50) / 5) * N4;
// n4 = demerit;
demerit += Mask_evaluateSymbol(width, mask);
// printf("(%d,%d,%d,%d)=%d\n", n1, n2, n3 ,n4, demerit);
if(demerit < minDemerit) {
minDemerit = demerit;
free(bestMask);
bestMask = mask;
mask = (unsigned char *)malloc(w2);
if(mask == NULL) break;
}
}
free(mask);
return bestMask;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/mask.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,287
|
```objective-c
/*
* qrencode - QR Code encoder
*
* Masking for Micro QR Code.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __MMASK_H__
#define __MMASK_H__
extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level);
extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level);
#ifdef WITH_TESTS
extern int MMask_evaluateSymbol(int width, unsigned char *frame);
extern void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level);
extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask);
#endif
#endif /* __MMASK_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/mmask.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 261
|
```c
/*
* qrencode - QR Code encoder
*
* Binary sequence class.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bitstream.h"
BitStream *BitStream_new(void)
{
BitStream *bstream;
bstream = (BitStream *)malloc(sizeof(BitStream));
if(bstream == NULL) return NULL;
bstream->length = 0;
bstream->data = NULL;
return bstream;
}
static int BitStream_allocate(BitStream *bstream, int length)
{
unsigned char *data;
if(bstream == NULL) {
return -1;
}
data = (unsigned char *)malloc(length);
if(data == NULL) {
return -1;
}
if(bstream->data) {
free(bstream->data);
}
bstream->length = length;
bstream->data = data;
return 0;
}
static BitStream *BitStream_newFromNum(int bits, unsigned int num)
{
unsigned int mask;
int i;
unsigned char *p;
BitStream *bstream;
bstream = BitStream_new();
if(bstream == NULL) return NULL;
if(BitStream_allocate(bstream, bits)) {
BitStream_free(bstream);
return NULL;
}
p = bstream->data;
mask = 1 << (bits - 1);
for(i=0; i<bits; i++) {
if(num & mask) {
*p = 1;
} else {
*p = 0;
}
p++;
mask = mask >> 1;
}
return bstream;
}
static BitStream *BitStream_newFromBytes(int size, unsigned char *data)
{
unsigned char mask;
int i, j;
unsigned char *p;
BitStream *bstream;
bstream = BitStream_new();
if(bstream == NULL) return NULL;
if(BitStream_allocate(bstream, size * 8)) {
BitStream_free(bstream);
return NULL;
}
p = bstream->data;
for(i=0; i<size; i++) {
mask = 0x80;
for(j=0; j<8; j++) {
if(data[i] & mask) {
*p = 1;
} else {
*p = 0;
}
p++;
mask = mask >> 1;
}
}
return bstream;
}
int BitStream_append(BitStream *bstream, BitStream *arg)
{
unsigned char *data;
if(arg == NULL) {
return -1;
}
if(arg->length == 0) {
return 0;
}
if(bstream->length == 0) {
if(BitStream_allocate(bstream, arg->length)) {
return -1;
}
memcpy(bstream->data, arg->data, arg->length);
return 0;
}
data = (unsigned char *)malloc(bstream->length + arg->length);
if(data == NULL) {
return -1;
}
memcpy(data, bstream->data, bstream->length);
memcpy(data + bstream->length, arg->data, arg->length);
free(bstream->data);
bstream->length += arg->length;
bstream->data = data;
return 0;
}
int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num)
{
BitStream *b;
int ret;
if(bits == 0) return 0;
b = BitStream_newFromNum(bits, num);
if(b == NULL) return -1;
ret = BitStream_append(bstream, b);
BitStream_free(b);
return ret;
}
int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data)
{
BitStream *b;
int ret;
if(size == 0) return 0;
b = BitStream_newFromBytes(size, data);
if(b == NULL) return -1;
ret = BitStream_append(bstream, b);
BitStream_free(b);
return ret;
}
unsigned char *BitStream_toByte(BitStream *bstream)
{
int i, j, size, bytes;
unsigned char *data, v;
unsigned char *p;
size = BitStream_size(bstream);
if(size == 0) {
return NULL;
}
data = (unsigned char *)malloc((size + 7) / 8);
if(data == NULL) {
return NULL;
}
bytes = size / 8;
p = bstream->data;
for(i=0; i<bytes; i++) {
v = 0;
for(j=0; j<8; j++) {
v = v << 1;
v |= *p;
p++;
}
data[i] = v;
}
if(size & 7) {
v = 0;
for(j=0; j<(size & 7); j++) {
v = v << 1;
v |= *p;
p++;
}
data[bytes] = v;
}
return data;
}
void BitStream_free(BitStream *bstream)
{
if(bstream != NULL) {
free(bstream->data);
free(bstream);
}
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/bitstream.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,234
|
```c
/*
* qrencode - QR Code encoder
*
* Masking for Micro QR Code.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include "qrencode.h"
#include "mqrspec.h"
#include "mmask.h"
void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level)
{
unsigned int format;
unsigned char v;
int i;
format = MQRspec_getFormatInfo(mask, version, level);
for(i=0; i<8; i++) {
v = 0x84 | (format & 1);
frame[width * (i + 1) + 8] = v;
format = format >> 1;
}
for(i=0; i<7; i++) {
v = 0x84 | (format & 1);
frame[width * 8 + 7 - i] = v;
format = format >> 1;
}
}
#define MASKMAKER(__exp__) \
int x, y;\
\
for(y=0; y<width; y++) {\
for(x=0; x<width; x++) {\
if(*s & 0x80) {\
*d = *s;\
} else {\
*d = *s ^ ((__exp__) == 0);\
}\
s++; d++;\
}\
}
static void Mask_mask0(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER(y&1)
}
static void Mask_mask1(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER(((y/2)+(x/3))&1)
}
static void Mask_mask2(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER((((x*y)&1)+(x*y)%3)&1)
}
static void Mask_mask3(int width, const unsigned char *s, unsigned char *d)
{
MASKMAKER((((x+y)&1)+((x*y)%3))&1)
}
#define maskNum (4)
typedef void MaskMaker(int, const unsigned char *, unsigned char *);
static MaskMaker *maskMakers[maskNum] = {
Mask_mask0, Mask_mask1, Mask_mask2, Mask_mask3
};
#ifdef WITH_TESTS
unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask)
{
unsigned char *masked;
masked = (unsigned char *)malloc(width * width);
if(masked == NULL) return NULL;
maskMakers[mask](width, frame, masked);
return masked;
}
#endif
unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level)
{
unsigned char *masked;
int width;
if(mask < 0 || mask >= maskNum) {
errno = EINVAL;
return NULL;
}
width = MQRspec_getWidth(version);
masked = (unsigned char *)malloc(width * width);
if(masked == NULL) return NULL;
maskMakers[mask](width, frame, masked);
MMask_writeFormatInformation(version, width, masked, mask, level);
return masked;
}
int MMask_evaluateSymbol(int width, unsigned char *frame)
{
int x, y;
unsigned char *p;
int sum1 = 0, sum2 = 0;
p = frame + width * (width - 1);
for(x=1; x<width; x++) {
sum1 += (p[x] & 1);
}
p = frame + width * 2 - 1;
for(y=1; y<width; y++) {
sum2 += (*p & 1);
p += width;
}
return (sum1 <= sum2)?(sum1 * 16 + sum2):(sum2 * 16 + sum1);
}
unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level)
{
int i;
unsigned char *mask, *bestMask;
int maxScore = 0;
int score;
int width;
width = MQRspec_getWidth(version);
mask = (unsigned char *)malloc(width * width);
if(mask == NULL) return NULL;
bestMask = NULL;
for(i=0; i<maskNum; i++) {
score = 0;
maskMakers[i](width, frame, mask);
MMask_writeFormatInformation(version, width, mask, i, level);
score = MMask_evaluateSymbol(width, mask);
if(score > maxScore) {
maxScore = score;
free(bestMask);
bestMask = mask;
mask = (unsigned char *)malloc(width * width);
if(mask == NULL) break;
}
}
free(mask);
return bestMask;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/mmask.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,151
|
```c
/*
* qrencode - QR Code encoder
*
* Reed solomon encoder. This code is taken from Phil Karn's libfec then
* editted and packed into a pair of .c and .h files.
*
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_LIBPTHREAD
# include <pthread.h>
#endif
#include "rscode.h"
/* Stuff specific to the 8-bit symbol version of the general purpose RS codecs
*
*/
typedef unsigned char data_t;
/**
* Reed-Solomon codec control block
*/
struct _RS {
int mm; /* Bits per symbol */
int nn; /* Symbols per block (= (1<<mm)-1) */
data_t *alpha_to; /* log lookup table */
data_t *index_of; /* Antilog lookup table */
data_t *genpoly; /* Generator polynomial */
int nroots; /* Number of generator roots = number of parity symbols */
int fcr; /* First consecutive root, index form */
int prim; /* Primitive element, index form */
int iprim; /* prim-th root of 1, index form */
int pad; /* Padding bytes in shortened block */
int gfpoly;
struct _RS *next;
};
static RS *rslist = NULL;
#ifdef HAVE_LIBPTHREAD
static pthread_mutex_t rslist_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static int modnn(RS *rs, int x){
while (x >= rs->nn) {
x -= rs->nn;
x = (x >> rs->mm) + (x & rs->nn);
}
return x;
}
#define MODNN(x) modnn(rs,x)
#define MM (rs->mm)
#define NN (rs->nn)
#define ALPHA_TO (rs->alpha_to)
#define INDEX_OF (rs->index_of)
#define GENPOLY (rs->genpoly)
#define NROOTS (rs->nroots)
#define FCR (rs->fcr)
#define PRIM (rs->prim)
#define IPRIM (rs->iprim)
#define PAD (rs->pad)
#define A0 (NN)
/* Initialize a Reed-Solomon codec
* symsize = symbol size, bits
* gfpoly = Field generator polynomial coefficients
* fcr = first root of RS code generator polynomial, index form
* prim = primitive element to generate polynomial roots
* nroots = RS code generator polynomial degree (number of roots)
* pad = padding bytes at front of shortened block
*/
static RS *init_rs_char(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
{
RS *rs;
/* Common code for intializing a Reed-Solomon control block (char or int symbols)
*/
//#undef NULL
//#define NULL ((void *)0)
int i, j, sr,root,iprim;
rs = NULL;
/* Check parameter ranges */
if(symsize < 0 || symsize > (int)(8*sizeof(data_t))){
goto done;
}
if(fcr < 0 || fcr >= (1<<symsize))
goto done;
if(prim <= 0 || prim >= (1<<symsize))
goto done;
if(nroots < 0 || nroots >= (1<<symsize))
goto done; /* Can't have more roots than symbol values! */
if(pad < 0 || pad >= ((1<<symsize) -1 - nroots))
goto done; /* Too much padding */
rs = (RS *)calloc(1,sizeof(RS));
if(rs == NULL)
goto done;
rs->mm = symsize;
rs->nn = (1<<symsize)-1;
rs->pad = pad;
rs->alpha_to = (data_t *)malloc(sizeof(data_t)*(rs->nn+1));
if(rs->alpha_to == NULL){
free(rs);
rs = NULL;
goto done;
}
rs->index_of = (data_t *)malloc(sizeof(data_t)*(rs->nn+1));
if(rs->index_of == NULL){
free(rs->alpha_to);
free(rs);
rs = NULL;
goto done;
}
/* Generate Galois field lookup tables */
rs->index_of[0] = A0; /* log(zero) = -inf */
rs->alpha_to[A0] = 0; /* alpha**-inf = 0 */
sr = 1;
for(i=0;i<rs->nn;i++){
rs->index_of[sr] = i;
rs->alpha_to[i] = sr;
sr <<= 1;
if(sr & (1<<symsize))
sr ^= gfpoly;
sr &= rs->nn;
}
if(sr != 1){
/* field generator polynomial is not primitive! */
free(rs->alpha_to);
free(rs->index_of);
free(rs);
rs = NULL;
goto done;
}
/* Form RS code generator polynomial from its roots */
rs->genpoly = (data_t *)malloc(sizeof(data_t)*(nroots+1));
if(rs->genpoly == NULL){
free(rs->alpha_to);
free(rs->index_of);
free(rs);
rs = NULL;
goto done;
}
rs->fcr = fcr;
rs->prim = prim;
rs->nroots = nroots;
rs->gfpoly = gfpoly;
/* Find prim-th root of 1, used in decoding */
for(iprim=1;(iprim % prim) != 0;iprim += rs->nn)
;
rs->iprim = iprim / prim;
rs->genpoly[0] = 1;
for (i = 0,root=fcr*prim; i < nroots; i++,root += prim) {
rs->genpoly[i+1] = 1;
/* Multiply rs->genpoly[] by @**(root + x) */
for (j = i; j > 0; j--){
if (rs->genpoly[j] != 0)
rs->genpoly[j] = rs->genpoly[j-1] ^ rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[j]] + root)];
else
rs->genpoly[j] = rs->genpoly[j-1];
}
/* rs->genpoly[0] can never be zero */
rs->genpoly[0] = rs->alpha_to[modnn(rs,rs->index_of[rs->genpoly[0]] + root)];
}
/* convert rs->genpoly[] to index form for quicker encoding */
for (i = 0; i <= nroots; i++)
rs->genpoly[i] = rs->index_of[rs->genpoly[i]];
done:;
return rs;
}
RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad)
{
RS *rs;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_lock(&rslist_mutex);
#endif
for(rs = rslist; rs != NULL; rs = rs->next) {
if(rs->pad != pad) continue;
if(rs->nroots != nroots) continue;
if(rs->mm != symsize) continue;
if(rs->gfpoly != gfpoly) continue;
if(rs->fcr != fcr) continue;
if(rs->prim != prim) continue;
goto DONE;
}
rs = init_rs_char(symsize, gfpoly, fcr, prim, nroots, pad);
if(rs == NULL) goto DONE;
rs->next = rslist;
rslist = rs;
DONE:
#ifdef HAVE_LIBPTHREAD
pthread_mutex_unlock(&rslist_mutex);
#endif
return rs;
}
void free_rs_char(RS *rs)
{
free(rs->alpha_to);
free(rs->index_of);
free(rs->genpoly);
free(rs);
}
void free_rs_cache(void)
{
RS *rs, *next;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_lock(&rslist_mutex);
#endif
rs = rslist;
while(rs != NULL) {
next = rs->next;
free_rs_char(rs);
rs = next;
}
rslist = NULL;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_unlock(&rslist_mutex);
#endif
}
/* The guts of the Reed-Solomon encoder, meant to be #included
* into a function body with the following typedefs, macros and variables supplied
* according to the code parameters:
* data_t - a typedef for the data symbol
* data_t data[] - array of NN-NROOTS-PAD and type data_t to be encoded
* data_t parity[] - an array of NROOTS and type data_t to be written with parity symbols
* NROOTS - the number of roots in the RS code generator polynomial,
* which is the same as the number of parity symbols in a block.
Integer variable or literal.
*
* NN - the total number of symbols in a RS block. Integer variable or literal.
* PAD - the number of pad symbols in a block. Integer variable or literal.
* ALPHA_TO - The address of an array of NN elements to convert Galois field
* elements in index (log) form to polynomial form. Read only.
* INDEX_OF - The address of an array of NN elements to convert Galois field
* elements in polynomial form to index (log) form. Read only.
* MODNN - a function to reduce its argument modulo NN. May be inline or a macro.
* GENPOLY - an array of NROOTS+1 elements containing the generator polynomial in index form
* The memset() and memmove() functions are used. The appropriate header
* file declaring these functions (usually <string.h>) must be included by the calling
* program.
*/
#undef A0
#define A0 (NN) /* Special reserved value encoding zero in index form */
void encode_rs_char(RS *rs, const data_t *data, data_t *parity)
{
int i, j;
data_t feedback;
memset(parity,0,NROOTS*sizeof(data_t));
for(i=0;i<NN-NROOTS-PAD;i++){
feedback = INDEX_OF[data[i] ^ parity[0]];
if(feedback != A0){ /* feedback term is non-zero */
#ifdef UNNORMALIZED
/* This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
* always be for the polynomials constructed by init_rs()
*/
feedback = MODNN(NN - GENPOLY[NROOTS] + feedback);
#endif
for(j=1;j<NROOTS;j++)
parity[j] ^= ALPHA_TO[MODNN(feedback + GENPOLY[NROOTS-j])];
}
/* Shift */
memmove(&parity[0],&parity[1],sizeof(data_t)*(NROOTS-1));
if(feedback != A0)
parity[NROOTS-1] = ALPHA_TO[MODNN(feedback + GENPOLY[0])];
else
parity[NROOTS-1] = 0;
}
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/rscode.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,532
|
```c
/*
* qrencode - QR Code encoder
*
* QR Code specification in convenient format.
*
* The following data / specifications are taken from
* "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004)
* or
* "Automatic identification and data capture techniques --
* QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library 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
*
* You should have received a copy of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_LIBPTHREAD
#include <pthread.h>
#endif
#include "qrspec.h"
#include "qrinput.h"
/******************************************************************************
* Version and capacity
*****************************************************************************/
typedef struct {
int width; //< Edge length of the symbol
int words; //< Data capacity (bytes)
int remainder; //< Remainder bit (bits)
int ec[4]; //< Number of ECC code (bytes)
} QRspec_Capacity;
/**
* Table of the capacity of symbols
* See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004.
*/
static const QRspec_Capacity qrspecCapacity[QRSPEC_VERSION_MAX + 1] = {
{ 0, 0, 0, { 0, 0, 0, 0}},
{ 21, 26, 0, { 7, 10, 13, 17}}, // 1
{ 25, 44, 7, { 10, 16, 22, 28}},
{ 29, 70, 7, { 15, 26, 36, 44}},
{ 33, 100, 7, { 20, 36, 52, 64}},
{ 37, 134, 7, { 26, 48, 72, 88}}, // 5
{ 41, 172, 7, { 36, 64, 96, 112}},
{ 45, 196, 0, { 40, 72, 108, 130}},
{ 49, 242, 0, { 48, 88, 132, 156}},
{ 53, 292, 0, { 60, 110, 160, 192}},
{ 57, 346, 0, { 72, 130, 192, 224}}, //10
{ 61, 404, 0, { 80, 150, 224, 264}},
{ 65, 466, 0, { 96, 176, 260, 308}},
{ 69, 532, 0, { 104, 198, 288, 352}},
{ 73, 581, 3, { 120, 216, 320, 384}},
{ 77, 655, 3, { 132, 240, 360, 432}}, //15
{ 81, 733, 3, { 144, 280, 408, 480}},
{ 85, 815, 3, { 168, 308, 448, 532}},
{ 89, 901, 3, { 180, 338, 504, 588}},
{ 93, 991, 3, { 196, 364, 546, 650}},
{ 97, 1085, 3, { 224, 416, 600, 700}}, //20
{101, 1156, 4, { 224, 442, 644, 750}},
{105, 1258, 4, { 252, 476, 690, 816}},
{109, 1364, 4, { 270, 504, 750, 900}},
{113, 1474, 4, { 300, 560, 810, 960}},
{117, 1588, 4, { 312, 588, 870, 1050}}, //25
{121, 1706, 4, { 336, 644, 952, 1110}},
{125, 1828, 4, { 360, 700, 1020, 1200}},
{129, 1921, 3, { 390, 728, 1050, 1260}},
{133, 2051, 3, { 420, 784, 1140, 1350}},
{137, 2185, 3, { 450, 812, 1200, 1440}}, //30
{141, 2323, 3, { 480, 868, 1290, 1530}},
{145, 2465, 3, { 510, 924, 1350, 1620}},
{149, 2611, 3, { 540, 980, 1440, 1710}},
{153, 2761, 3, { 570, 1036, 1530, 1800}},
{157, 2876, 0, { 570, 1064, 1590, 1890}}, //35
{161, 3034, 0, { 600, 1120, 1680, 1980}},
{165, 3196, 0, { 630, 1204, 1770, 2100}},
{169, 3362, 0, { 660, 1260, 1860, 2220}},
{173, 3532, 0, { 720, 1316, 1950, 2310}},
{177, 3706, 0, { 750, 1372, 2040, 2430}} //40
};
int QRspec_getDataLength(int version, QRecLevel level)
{
return qrspecCapacity[version].words - qrspecCapacity[version].ec[level];
}
int QRspec_getECCLength(int version, QRecLevel level)
{
return qrspecCapacity[version].ec[level];
}
int QRspec_getMinimumVersion(int size, QRecLevel level)
{
int i;
int words;
for(i=1; i<= QRSPEC_VERSION_MAX; i++) {
words = qrspecCapacity[i].words - qrspecCapacity[i].ec[level];
if(words >= size) return i;
}
return -1;
}
int QRspec_getWidth(int version)
{
return qrspecCapacity[version].width;
}
int QRspec_getRemainder(int version)
{
return qrspecCapacity[version].remainder;
}
/******************************************************************************
* Length indicator
*****************************************************************************/
static const int lengthTableBits[4][3] = {
{10, 12, 14},
{ 9, 11, 13},
{ 8, 16, 16},
{ 8, 10, 12}
};
int QRspec_lengthIndicator(QRencodeMode mode, int version)
{
int l;
if(!QRinput_isSplittableMode(mode)) return 0;
if(version <= 9) {
l = 0;
} else if(version <= 26) {
l = 1;
} else {
l = 2;
}
return lengthTableBits[mode][l];
}
int QRspec_maximumWords(QRencodeMode mode, int version)
{
int l;
int bits;
int words;
if(!QRinput_isSplittableMode(mode)) return 0;
if(version <= 9) {
l = 0;
} else if(version <= 26) {
l = 1;
} else {
l = 2;
}
bits = lengthTableBits[mode][l];
words = (1 << bits) - 1;
if(mode == QR_MODE_KANJI) {
words *= 2; // the number of bytes is required
}
return words;
}
/******************************************************************************
* Error correction code
*****************************************************************************/
/**
* Table of the error correction code (Reed-Solomon block)
* See Table 12-16 (pp.30-36), JIS X0510:2004.
*/
static const int eccTable[QRSPEC_VERSION_MAX+1][4][2] = {
{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}},
{{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}}, // 1
{{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}},
{{ 1, 0}, { 1, 0}, { 2, 0}, { 2, 0}},
{{ 1, 0}, { 2, 0}, { 2, 0}, { 4, 0}},
{{ 1, 0}, { 2, 0}, { 2, 2}, { 2, 2}}, // 5
{{ 2, 0}, { 4, 0}, { 4, 0}, { 4, 0}},
{{ 2, 0}, { 4, 0}, { 2, 4}, { 4, 1}},
{{ 2, 0}, { 2, 2}, { 4, 2}, { 4, 2}},
{{ 2, 0}, { 3, 2}, { 4, 4}, { 4, 4}},
{{ 2, 2}, { 4, 1}, { 6, 2}, { 6, 2}}, //10
{{ 4, 0}, { 1, 4}, { 4, 4}, { 3, 8}},
{{ 2, 2}, { 6, 2}, { 4, 6}, { 7, 4}},
{{ 4, 0}, { 8, 1}, { 8, 4}, {12, 4}},
{{ 3, 1}, { 4, 5}, {11, 5}, {11, 5}},
{{ 5, 1}, { 5, 5}, { 5, 7}, {11, 7}}, //15
{{ 5, 1}, { 7, 3}, {15, 2}, { 3, 13}},
{{ 1, 5}, {10, 1}, { 1, 15}, { 2, 17}},
{{ 5, 1}, { 9, 4}, {17, 1}, { 2, 19}},
{{ 3, 4}, { 3, 11}, {17, 4}, { 9, 16}},
{{ 3, 5}, { 3, 13}, {15, 5}, {15, 10}}, //20
{{ 4, 4}, {17, 0}, {17, 6}, {19, 6}},
{{ 2, 7}, {17, 0}, { 7, 16}, {34, 0}},
{{ 4, 5}, { 4, 14}, {11, 14}, {16, 14}},
{{ 6, 4}, { 6, 14}, {11, 16}, {30, 2}},
{{ 8, 4}, { 8, 13}, { 7, 22}, {22, 13}}, //25
{{10, 2}, {19, 4}, {28, 6}, {33, 4}},
{{ 8, 4}, {22, 3}, { 8, 26}, {12, 28}},
{{ 3, 10}, { 3, 23}, { 4, 31}, {11, 31}},
{{ 7, 7}, {21, 7}, { 1, 37}, {19, 26}},
{{ 5, 10}, {19, 10}, {15, 25}, {23, 25}}, //30
{{13, 3}, { 2, 29}, {42, 1}, {23, 28}},
{{17, 0}, {10, 23}, {10, 35}, {19, 35}},
{{17, 1}, {14, 21}, {29, 19}, {11, 46}},
{{13, 6}, {14, 23}, {44, 7}, {59, 1}},
{{12, 7}, {12, 26}, {39, 14}, {22, 41}}, //35
{{ 6, 14}, { 6, 34}, {46, 10}, { 2, 64}},
{{17, 4}, {29, 14}, {49, 10}, {24, 46}},
{{ 4, 18}, {13, 32}, {48, 14}, {42, 32}},
{{20, 4}, {40, 7}, {43, 22}, {10, 67}},
{{19, 6}, {18, 31}, {34, 34}, {20, 61}},//40
};
void QRspec_getEccSpec(int version, QRecLevel level, int spec[5])
{
int b1, b2;
int data, ecc;
b1 = eccTable[version][level][0];
b2 = eccTable[version][level][1];
data = QRspec_getDataLength(version, level);
ecc = QRspec_getECCLength(version, level);
if(b2 == 0) {
spec[0] = b1;
spec[1] = data / b1;
spec[2] = ecc / b1;
spec[3] = spec[4] = 0;
} else {
spec[0] = b1;
spec[1] = data / (b1 + b2);
spec[2] = ecc / (b1 + b2);
spec[3] = b2;
spec[4] = spec[1] + 1;
}
}
/******************************************************************************
* Alignment pattern
*****************************************************************************/
/**
* Positions of alignment patterns.
* This array includes only the second and the third position of the alignment
* patterns. Rest of them can be calculated from the distance between them.
*
* See Table 1 in Appendix E (pp.71) of JIS X0510:2004.
*/
static const int alignmentPattern[QRSPEC_VERSION_MAX+1][2] = {
{ 0, 0},
{ 0, 0}, {18, 0}, {22, 0}, {26, 0}, {30, 0}, // 1- 5
{34, 0}, {22, 38}, {24, 42}, {26, 46}, {28, 50}, // 6-10
{30, 54}, {32, 58}, {34, 62}, {26, 46}, {26, 48}, //11-15
{26, 50}, {30, 54}, {30, 56}, {30, 58}, {34, 62}, //16-20
{28, 50}, {26, 50}, {30, 54}, {28, 54}, {32, 58}, //21-25
{30, 58}, {34, 62}, {26, 50}, {30, 54}, {26, 52}, //26-30
{30, 56}, {34, 60}, {30, 58}, {34, 62}, {30, 54}, //31-35
{24, 50}, {28, 54}, {32, 58}, {26, 54}, {30, 58}, //35-40
};
/**
* Put an alignment marker.
* @param frame
* @param width
* @param ox,oy center coordinate of the pattern
*/
static void QRspec_putAlignmentMarker(unsigned char *frame, int width, int ox, int oy)
{
static const unsigned char finder[] = {
0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
0xa1, 0xa0, 0xa0, 0xa0, 0xa1,
0xa1, 0xa0, 0xa1, 0xa0, 0xa1,
0xa1, 0xa0, 0xa0, 0xa0, 0xa1,
0xa1, 0xa1, 0xa1, 0xa1, 0xa1,
};
int x, y;
const unsigned char *s;
frame += (oy - 2) * width + ox - 2;
s = finder;
for(y=0; y<5; y++) {
for(x=0; x<5; x++) {
frame[x] = s[x];
}
frame += width;
s += 5;
}
}
static void QRspec_putAlignmentPattern(int version, unsigned char *frame, int width)
{
int d, w, x, y, cx, cy;
if(version < 2) return;
d = alignmentPattern[version][1] - alignmentPattern[version][0];
if(d < 0) {
w = 2;
} else {
w = (width - alignmentPattern[version][0]) / d + 2;
}
if(w * w - 3 == 1) {
x = alignmentPattern[version][0];
y = alignmentPattern[version][0];
QRspec_putAlignmentMarker(frame, width, x, y);
return;
}
cx = alignmentPattern[version][0];
for(x=1; x<w - 1; x++) {
QRspec_putAlignmentMarker(frame, width, 6, cx);
QRspec_putAlignmentMarker(frame, width, cx, 6);
cx += d;
}
cy = alignmentPattern[version][0];
for(y=0; y<w-1; y++) {
cx = alignmentPattern[version][0];
for(x=0; x<w-1; x++) {
QRspec_putAlignmentMarker(frame, width, cx, cy);
cx += d;
}
cy += d;
}
}
/******************************************************************************
* Version information pattern
*****************************************************************************/
/**
* Version information pattern (BCH coded).
* See Table 1 in Appendix D (pp.68) of JIS X0510:2004.
*/
static const unsigned int versionPattern[QRSPEC_VERSION_MAX - 6] = {
0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d,
0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9,
0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75,
0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64,
0x27541, 0x28c69
};
unsigned int QRspec_getVersionPattern(int version)
{
if(version < 7 || version > QRSPEC_VERSION_MAX) return 0;
return versionPattern[version - 7];
}
/******************************************************************************
* Format information
*****************************************************************************/
/* See calcFormatInfo in tests/test_qrspec.c */
static const unsigned int formatInfo[4][8] = {
{0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976},
{0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0},
{0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed},
{0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b}
};
unsigned int QRspec_getFormatInfo(int mask, QRecLevel level)
{
if(mask < 0 || mask > 7) return 0;
return formatInfo[level][mask];
}
/******************************************************************************
* Frame
*****************************************************************************/
/**
* Cache of initial frames.
*/
/* C99 says that static storage shall be initialized to a null pointer
* by compiler. */
static unsigned char *frames[QRSPEC_VERSION_MAX + 1];
#ifdef HAVE_LIBPTHREAD
static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
/**
* Put a finder pattern.
* @param frame
* @param width
* @param ox,oy upper-left coordinate of the pattern
*/
static void putFinderPattern(unsigned char *frame, int width, int ox, int oy)
{
static const unsigned char finder[] = {
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
};
int x, y;
const unsigned char *s;
frame += oy * width + ox;
s = finder;
for(y=0; y<7; y++) {
for(x=0; x<7; x++) {
frame[x] = s[x];
}
frame += width;
s += 7;
}
}
static unsigned char *QRspec_createFrame(int version)
{
unsigned char *frame, *p, *q;
int width;
int x, y;
unsigned int verinfo, v;
width = qrspecCapacity[version].width;
frame = (unsigned char *)malloc(width * width);
if(frame == NULL) return NULL;
memset(frame, 0, width * width);
/* Finder pattern */
putFinderPattern(frame, width, 0, 0);
putFinderPattern(frame, width, width - 7, 0);
putFinderPattern(frame, width, 0, width - 7);
/* Separator */
p = frame;
q = frame + width * (width - 7);
for(y=0; y<7; y++) {
p[7] = 0xc0;
p[width - 8] = 0xc0;
q[7] = 0xc0;
p += width;
q += width;
}
memset(frame + width * 7, 0xc0, 8);
memset(frame + width * 8 - 8, 0xc0, 8);
memset(frame + width * (width - 8), 0xc0, 8);
/* Mask format information area */
memset(frame + width * 8, 0x84, 9);
memset(frame + width * 9 - 8, 0x84, 8);
p = frame + 8;
for(y=0; y<8; y++) {
*p = 0x84;
p += width;
}
p = frame + width * (width - 7) + 8;
for(y=0; y<7; y++) {
*p = 0x84;
p += width;
}
/* Timing pattern */
p = frame + width * 6 + 8;
q = frame + width * 8 + 6;
for(x=1; x<width-15; x++) {
*p = 0x90 | (x & 1);
*q = 0x90 | (x & 1);
p++;
q += width;
}
/* Alignment pattern */
QRspec_putAlignmentPattern(version, frame, width);
/* Version information */
if(version >= 7) {
verinfo = QRspec_getVersionPattern(version);
p = frame + width * (width - 11);
v = verinfo;
for(x=0; x<6; x++) {
for(y=0; y<3; y++) {
p[width * y + x] = 0x88 | (v & 1);
v = v >> 1;
}
}
p = frame + width - 11;
v = verinfo;
for(y=0; y<6; y++) {
for(x=0; x<3; x++) {
p[x] = 0x88 | (v & 1);
v = v >> 1;
}
p += width;
}
}
/* and a little bit... */
frame[width * (width - 8) + 8] = 0x81;
return frame;
}
unsigned char *QRspec_newFrame(int version)
{
unsigned char *frame;
int width;
if(version < 1 || version > QRSPEC_VERSION_MAX) return NULL;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_lock(&frames_mutex);
#endif
if(frames[version] == NULL) {
frames[version] = QRspec_createFrame(version);
}
#ifdef HAVE_LIBPTHREAD
pthread_mutex_unlock(&frames_mutex);
#endif
if(frames[version] == NULL) return NULL;
width = qrspecCapacity[version].width;
frame = (unsigned char *)malloc(width * width);
if(frame == NULL) return NULL;
memcpy(frame, frames[version], width * width);
return frame;
}
void QRspec_clearCache(void)
{
int i;
#ifdef HAVE_LIBPTHREAD
pthread_mutex_lock(&frames_mutex);
#endif
for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
free(frames[i]);
frames[i] = NULL;
}
#ifdef HAVE_LIBPTHREAD
pthread_mutex_unlock(&frames_mutex);
#endif
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/qrspec.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 6,509
|
```c
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <pthread.h>
#include <time.h>
#include <errno.h>
#include "../qrencode.h"
#define THREADS (10)
static pthread_t threads[THREADS];
struct timeval tv;
void timerStart(const char *str)
{
printf("%s: START\n", str);
gettimeofday(&tv, NULL);
}
void timerStop(void)
{
struct timeval tc;
gettimeofday(&tc, NULL);
printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000
+ (tc.tv_usec - tv.tv_usec) / 1000);
}
void *encode_ver1to10(void *arg)
{
QRcode *code;
int i;
int version;
static const char *data = "This is test.";
for(i=0; i<500; i++) {
for(version = 0; version < 11; version++) {
code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
if(code == NULL) {
perror("Failed to encode:");
} else {
QRcode_free(code);
}
}
}
return NULL;
}
void prof_ver1to10(void)
{
int i;
timerStart("Version 1 - 10 (500 symbols for each)");
for(i=0; i<THREADS; i++) {
pthread_create(&threads[i], NULL, encode_ver1to10, NULL);
}
for(i=0; i<THREADS; i++) {
pthread_join(threads[i], NULL);
}
timerStop();
}
void *encode_ver31to40(void *arg)
{
QRcode *code;
int i;
int version;
static const char *data = "This is test.";
for(i=0; i<50; i++) {
for(version = 31; version < 41; version++) {
code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
if(code == NULL) {
perror("Failed to encode:");
} else {
QRcode_free(code);
}
}
}
return NULL;
}
void prof_ver31to40(void)
{
int i;
timerStart("Version 31 - 40 (50 symbols for each)");
for(i=0; i<THREADS; i++) {
pthread_create(&threads[i], NULL, encode_ver31to40, NULL);
}
for(i=0; i<THREADS; i++) {
pthread_join(threads[i], NULL);
}
timerStop();
}
int main(void)
{
prof_ver1to10();
prof_ver31to40();
QRcode_clearCache();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/pthread_qrencode.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 599
|
```c
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "common.h"
#include "../qrspec.h"
#include "../qrinput.h"
#include "../mask.h"
#include "../split.h"
#include "../bitstream.h"
static int inputTest(QRinput_List *list, const char *fmt, ...)
{
va_list ap;
int size;
QRencodeMode mode;
int i, err = 0;
va_start(ap, fmt);
i = 1;
while(*fmt) {
if(list == NULL) {
err = 1;
break;
}
size = va_arg(ap, int);
if(list->size != size) {
err = 1;
break;
}
switch(*fmt++) {
case 'n':
mode = QR_MODE_NUM;
break;
case 'a':
mode = QR_MODE_AN;
break;
case 'k':
mode = QR_MODE_KANJI;
break;
case '8':
mode = QR_MODE_8;
break;
default:
return -1;
break;
}
if(list->mode != mode) {
err = 1;
break;
}
list = list->next;
i++;
}
va_end(ap);
if(list != NULL) {
err = 1;
}
if(err) {
return -i;
}
return 0;
}
int inputSize(QRinput *input)
{
BitStream *bstream;
int size;
bstream = QRinput_mergeBitStream(input);
size = BitStream_size(bstream);
BitStream_free(bstream);
return size;
}
void test_split1(void)
{
QRinput *input;
BitStream *stream;
testStart("Split test: null string");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("", input, QR_MODE_8, 0);
stream = QRinput_mergeBitStream(input);
testEndExp(BitStream_size(stream) == 0);
QRinput_free(input);
BitStream_free(stream);
}
void test_split2(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: single typed strings (num)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("0123", input, QR_MODE_8, 0);
list = input->head;
if(inputTest(list, "n", 4)) {
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: single typed strings (num2)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("12345678901234567890", input, QR_MODE_KANJI, 0);
list = input->head;
if(inputTest(list, "n", 20)) {
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_split3(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: single typed strings (an)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("ab:-E", input, QR_MODE_8, 0);
list = input->head;
if(inputTest(list, "a", 5)) {
printQRinputInfo(input);
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: num + an");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("0123abcde", input, QR_MODE_KANJI, 0);
list = input->head;
if(inputTest(list, "a", 9)) {
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: an + num + an");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("Ab345fg", input, QR_MODE_KANJI, 0);
list = input->head;
if(inputTest(list, "a", 7)) {
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_split4(void)
{
QRinput *input;
QRinput *i1, *i2;
int s1, s2, size;
#define CHUNKA "ABCDEFGHIJK"
#define CHUNKB "123456"
#define CHUNKC "1234567"
testStart("Split test: an and num entries");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(CHUNKA/**/CHUNKB, input, QR_MODE_8, 0);
i1 = QRinput_new();
QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKA/**/CHUNKB);
i2 = QRinput_new();
QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
size = inputSize(input);
s1 = inputSize(i1);
s2 = inputSize(i2);
testEndExp(size == ((s1 < s2)?s1:s2));
QRinput_free(input);
QRinput_free(i1);
QRinput_free(i2);
testStart("Split test: num and an entries");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(CHUNKB/**/CHUNKA, input, QR_MODE_8, 0);
i1 = QRinput_new();
QRinput_append(i1, QR_MODE_AN, 17, (unsigned char *)CHUNKB/**/CHUNKA);
i2 = QRinput_new();
QRinput_append(i2, QR_MODE_NUM, 6, (unsigned char *)CHUNKB);
QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
size = inputSize(input);
s1 = inputSize(i1);
s2 = inputSize(i2);
testEndExp(size == ((s1 < s2)?s1:s2));
QRinput_free(input);
QRinput_free(i1);
QRinput_free(i2);
testStart("Split test: num and an entries (should be splitted)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(CHUNKC/**/CHUNKA, input, QR_MODE_8, 0);
i1 = QRinput_new();
QRinput_append(i1, QR_MODE_AN, 18, (unsigned char *)CHUNKC/**/CHUNKA);
i2 = QRinput_new();
QRinput_append(i2, QR_MODE_NUM, 7, (unsigned char *)CHUNKC);
QRinput_append(i2, QR_MODE_AN, 11, (unsigned char *)CHUNKA);
size = inputSize(input);
s1 = inputSize(i1);
s2 = inputSize(i2);
testEndExp(size == ((s1 < s2)?s1:s2));
QRinput_free(input);
QRinput_free(i1);
QRinput_free(i2);
}
void test_split5(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: bit, an, bit, num");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, QR_MODE_8, 0);
list = input->head;
if(inputTest(list, "8a8n", 2, 11, 2, 6)) {
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_split6(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: kanji, an, kanji, num");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("\x82\xd9""abcdeabcdea\x82\xb0""123456", input, QR_MODE_KANJI, 0);
list = input->head;
if(inputTest(list, "kakn", 2, 11, 2, 6)) {
printQRinputInfo(input);
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_split7(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: an and num as bits");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("\x82\xd9""abcde\x82\xb0""12345", input, QR_MODE_8, 0);
list = input->head;
if(inputTest(list, "8n", 9, 5)) {
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_split8(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: terminated with a half of kanji code");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("\x82\xd9""abcdefgh\x82", input, QR_MODE_KANJI, 0);
list = input->head;
if(inputTest(list, "ka8", 2, 8, 1)) {
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_split3c(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: single typed strings (an, case-sensitive)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("ab:-E", input, QR_MODE_8, 1);
list = input->head;
if(inputTest(list, "8", 5)) {
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: num + an");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("0123abcde", input, QR_MODE_KANJI, 1);
list = input->head;
if(inputTest(list, "n8", 4, 5)) {
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: an + num + an");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("Ab345fg", input, QR_MODE_KANJI, 1);
list = input->head;
if(inputTest(list, "8", 7)) {
printQRinputInfo(input);
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_toupper(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: check dupAndToUpper (lower->upper)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("abcde", input, QR_MODE_8, 0);
list = input->head;
if(inputTest(list, "a", 5)) {
err++;
}
if(strncmp((char *)list->data, "ABCDE", list->size)) {
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: check dupAndToUpper (kanji)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_KANJI, 0);
list = input->head;
if(inputTest(list, "k", 10)) {
printQRinputInfo(input);
err++;
}
if(strncmp((char *)list->data, "\x83n\x83q\x83t\x83w\x83z", list->size)) {
err++;
}
testEnd(err);
QRinput_free(input);
err = 0;
testStart("Split test: check dupAndToUpper (8bit)");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("\x83n\x83q\x83t\x83w\x83z", input, QR_MODE_8, 0);
list = input->head;
if(inputTest(list, "8", 10)) {
printQRinputInfo(input);
err++;
}
if(strncmp((char *)list->data, "\x83N\x83Q\x83T\x83W\x83Z", list->size)) {
err++;
}
testEnd(err);
QRinput_free(input);
}
void test_splitNum8(void)
{
QRinput *input;
QRinput_List *list;
int err = 0;
testStart("Split test: num and 8bit to 8bit");
input = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput("1abcdefg", input, QR_MODE_8, 1);
list = input->head;
if(inputTest(list, "8", 8)) {
err++;
printQRinputInfo(input);
}
testEnd(err);
QRinput_free(input);
}
void test_splitAnNAn(void)
{
QRinput *input1, *input2, *input3;
int s1, s2, s3;
char *strall = "326A80A9C5004C0875571F8B71C311F2F86";
char *str1 = "326A80A9C5004C";
char *str2 = "0875571";
char *str3 = "F8B71C311F2F86";
testStart("Split test: An-N-An switching cost test");
input1 = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(strall, input1, QR_MODE_8, 0);
input2 = QRinput_new();
QRinput_append(input2, QR_MODE_AN, 35, (unsigned char *)strall);
input3 = QRinput_new();
QRinput_append(input3, QR_MODE_AN, 14, (unsigned char *)str1);
QRinput_append(input3, QR_MODE_NUM, 7, (unsigned char *)str2);
QRinput_append(input3, QR_MODE_AN, 14, (unsigned char *)str3);
s1 = inputSize(input1);
s2 = inputSize(input2);
s3 = inputSize(input3);
assert_equal(s1, s2, "Incorrect split");
assert_exp(s2 < s3, "Incorrect estimation");
testFinish();
QRinput_free(input1);
QRinput_free(input2);
QRinput_free(input3);
}
void test_splitAn8An(void)
{
QRinput *input1, *input2, *input3;
int s1, s2, s3;
char *strall = "ABCDabcdefABCD";
char *str1 = "ABCD";
char *str2 = "abcdef";
char *str3 = "ABCD";
testStart("Split test: An-8-An switching cost test");
input1 = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1);
input2 = QRinput_new();
QRinput_append(input2, QR_MODE_8, 14, (unsigned char *)strall);
input3 = QRinput_new();
QRinput_append(input3, QR_MODE_AN, 4, (unsigned char *)str1);
QRinput_append(input3, QR_MODE_8, 6, (unsigned char *)str2);
QRinput_append(input3, QR_MODE_AN, 4, (unsigned char *)str3);
s1 = inputSize(input1);
s2 = inputSize(input2);
s3 = inputSize(input3);
assert_equal(s1, s2, "Incorrect split");
assert_exp(s2 < s3, "Incorrect estimation");
testFinish();
QRinput_free(input1);
QRinput_free(input2);
QRinput_free(input3);
}
void test_split8An8(void)
{
QRinput *input1, *input2, *input3;
int s1, s2, s3;
char *strall = "abcABCDEFGHabc";
char *str1 = "abc";
char *str2 = "ABCDEFGH";
char *str3 = "abc";
testStart("Split test: 8-An-8 switching cost test");
input1 = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1);
input2 = QRinput_new();
QRinput_append(input2, QR_MODE_8, 14, (unsigned char *)strall);
input3 = QRinput_new();
QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str1);
QRinput_append(input3, QR_MODE_AN, 8, (unsigned char *)str2);
QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str3);
s1 = inputSize(input1);
s2 = inputSize(input2);
s3 = inputSize(input3);
assert_equal(s1, s2, "Incorrect split");
assert_exp(s2 < s3, "Incorrect estimation");
testFinish();
QRinput_free(input1);
QRinput_free(input2);
QRinput_free(input3);
}
void test_split8N8(void)
{
QRinput *input1, *input2, *input3;
int s1, s2, s3;
char *strall = "abc1234abc";
char *str1 = "abc";
char *str2 = "1234";
char *str3 = "abc";
testStart("Split test: 8-N-8 switching cost test");
input1 = QRinput_new2(0, QR_ECLEVEL_L);
Split_splitStringToQRinput(strall, input1, QR_MODE_8, 1);
input2 = QRinput_new();
QRinput_append(input2, QR_MODE_8, 10, (unsigned char *)strall);
input3 = QRinput_new();
QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str1);
QRinput_append(input3, QR_MODE_NUM, 4, (unsigned char *)str2);
QRinput_append(input3, QR_MODE_8, 3, (unsigned char *)str3);
s1 = inputSize(input1);
s2 = inputSize(input2);
s3 = inputSize(input3);
assert_equal(s1, s2, "Incorrect split");
assert_exp(s2 < s3, "Incorrect estimation");
testFinish();
QRinput_free(input1);
QRinput_free(input2);
QRinput_free(input3);
}
int main(void)
{
test_split1();
test_split2();
test_split3();
test_split4();
test_split5();
test_split6();
test_split7();
test_split8();
test_split3c();
test_toupper();
test_splitNum8();
test_splitAnNAn();
test_splitAn8An();
test_split8An8();
test_split8N8();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_split.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 4,259
|
```c
/*
* This tool creates a frame pattern data for debug purpose used by
* test_qrspec. test_qrspec and create_frame_pattern uses the same function
* of libqrencode. This means the test is meaningless if test_qrspec is run
* with a pattern data created by create_frame_pattern of the same version.
* In order to test it correctly, create a pattern data by the tool of the
* previous version, or use the frame data attached to the package.
*/
#include <stdio.h>
#include <string.h>
#include <png.h>
#include "common.h"
#include "../qrspec.h"
void append_pattern(int version, FILE *fp)
{
int width;
unsigned char *frame;
frame = QRspec_newFrame(version);
width = QRspec_getWidth(version);
fwrite(frame, 1, width * width, fp);
free(frame);
}
static int writePNG(unsigned char *frame, int width, const char *outfile)
{
static FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
unsigned char *row, *p, *q;
int x, y, xx, yy, bit;
int realwidth;
const int margin = 0;
const int size = 1;
realwidth = (width + margin * 2) * size;
row = (unsigned char *)malloc((realwidth + 7) / 8);
if(row == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
if(outfile[0] == '-' && outfile[1] == '\0') {
fp = stdout;
} else {
fp = fopen(outfile, "wb");
if(fp == NULL) {
fprintf(stderr, "Failed to create file: %s\n", outfile);
perror(NULL);
exit(EXIT_FAILURE);
}
}
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(png_ptr == NULL) {
fclose(fp);
fprintf(stderr, "Failed to initialize PNG writer.\n");
exit(EXIT_FAILURE);
}
info_ptr = png_create_info_struct(png_ptr);
if(info_ptr == NULL) {
fclose(fp);
fprintf(stderr, "Failed to initialize PNG write.\n");
exit(EXIT_FAILURE);
}
if(setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
fprintf(stderr, "Failed to write PNG image.\n");
exit(EXIT_FAILURE);
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr,
realwidth, realwidth,
1,
PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr, info_ptr);
/* top margin */
memset(row, 0xff, (realwidth + 7) / 8);
for(y=0; y<margin * size; y++) {
png_write_row(png_ptr, row);
}
/* data */
p = frame;
for(y=0; y<width; y++) {
bit = 7;
memset(row, 0xff, (realwidth + 7) / 8);
q = row;
q += margin * size / 8;
bit = 7 - (margin * size % 8);
for(x=0; x<width; x++) {
for(xx=0; xx<size; xx++) {
*q ^= (*p & 1) << bit;
bit--;
if(bit < 0) {
q++;
bit = 7;
}
}
p++;
}
for(yy=0; yy<size; yy++) {
png_write_row(png_ptr, row);
}
}
/* bottom margin */
memset(row, 0xff, (realwidth + 7) / 8);
for(y=0; y<margin * size; y++) {
png_write_row(png_ptr, row);
}
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
free(row);
return 0;
}
void write_pattern_image(int version, const char *filename)
{
int width;
unsigned char *frame;
static char str[256];
frame = QRspec_newFrame(version);
width = QRspec_getWidth(version);
snprintf(str, 256, "%s-%d.png", filename, version);
writePNG(frame, width, str);
free(frame);
}
void write_pattern(const char *filename)
{
FILE *fp;
int i;
fp = fopen(filename, "wb");
if(fp == NULL) {
perror("Failed to open a file to write:");
abort();
}
for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
append_pattern(i, fp);
write_pattern_image(i, filename);
}
fclose(fp);
}
int main(int argc, char **argv)
{
if(argc < 2) {
printf("Create empty frame patterns.\nUsage: %s FILENAME\n", argv[0]);
exit(0);
}
write_pattern(argv[1]);
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/create_frame_pattern.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,114
|
```objective-c
#ifndef __DECODER_H__
#define __DECODER_H__
#include "../qrencode.h"
typedef struct _DataChunk {
QRencodeMode mode;
int size;
int bits;
unsigned char *data;
struct _DataChunk *next;
} DataChunk;
typedef struct {
int size;
unsigned char *data;
int mqr;
int version;
QRecLevel level;
DataChunk *chunks, *last;
} QRdata;
struct FormatInfo {
int version;
QRecLevel level;
};
extern struct FormatInfo MQRformat[];
QRdata *QRdata_new(void);
QRdata *QRdata_newMQR(void);
int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream);
void QRdata_dump(QRdata *data);
void QRdata_free(QRdata *data);
unsigned int QRcode_decodeVersion(QRcode *code);
int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask);
unsigned char *QRcode_unmask(QRcode *code);
unsigned char *QRcode_extractBits(QRcode *code, int *length);
QRdata *QRcode_decodeBits(QRcode *code);
QRdata *QRcode_decode(QRcode *code);
int QRcode_decodeFormatMQR(QRcode *code, int *vesion, QRecLevel *level, int *mask);
unsigned char *QRcode_unmaskMQR(QRcode *code);
unsigned char *QRcode_extractBitsMQR(QRcode *code, int *length);
QRdata *QRcode_decodeBitsMQR(QRcode *code);
QRdata *QRcode_decodeMQR(QRcode *code);
#endif /* __DECODER_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/decoder.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 357
|
```c
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "common.h"
#include "../qrencode_inner.h"
#include "../qrspec.h"
#include "../mqrspec.h"
#include "../qrinput.h"
#include "../mask.h"
#include "../rscode.h"
#include "../split.h"
#include "decoder.h"
static const char decodeAnTable[45] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*',
'+', '-', '.', '/', ':'
};
typedef struct {
char *str;
int version;
QRecLevel level;
QRencodeMode hint;
int casesensitive;
} TestString;
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0))
int inputSize(QRinput *input)
{
BitStream *bstream;
int size;
bstream = QRinput_mergeBitStream(input);
size = BitStream_size(bstream);
BitStream_free(bstream);
return size;
}
void test_qrraw_new(void)
{
int i;
QRinput *stream;
char num[9] = "01234567";
QRRawCode *raw;
testStart("Test QRRaw_new()");
stream = QRinput_new();
QRinput_setVersion(stream, 10);
QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_Q);
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
raw = QRraw_new(stream);
assert_nonnull(raw, "Failed QRraw_new().\n");
assert_zero(raw->count, "QRraw.count = %d != 0\n", raw->count);
assert_equal(raw->version, 10, "QRraw.version was not as expected. (%d)\n", raw->version);
assert_equal(raw->dataLength, 19 * 6 + 20 * 2, "QRraw.dataLength was not as expected.\n");
assert_equal(raw->eccLength, 24 * 8, "QRraw.eccLength was not as expected.\n");
assert_equal(raw->b1, 6, "QRraw.b1 was not as expected.\n");
assert_equal(raw->blocks, 8, "QRraw.blocks was not as expected.\n");
for(i=0; i<raw->b1; i++) {
assert_equal(raw->rsblock[i].dataLength, 19, "QRraw.rsblock[].dataLength was not as expected.\n");
}
for(i=raw->b1; i<raw->blocks; i++) {
assert_equal(raw->rsblock[i].dataLength, 20, "QRraw.rsblock[].dataLength was not as expected.\n");
}
for(i=0; i<raw->blocks; i++) {
assert_equal(raw->rsblock[i].eccLength, 24, "QRraw.rsblock[].eccLength was not as expected.\n");
}
QRinput_free(stream);
QRraw_free(raw);
testFinish();
}
void test_iterate()
{
int i;
QRinput *stream;
char num[9] = "01234567";
unsigned char *data;
QRRawCode *raw;
int err = 0;
testStart("Test getCode (1-L)");
stream = QRinput_new();
QRinput_setVersion(stream, 1);
QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_L);
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
raw = QRraw_new(stream);
data = raw->datacode;
for(i=0; i<raw->dataLength; i++) {
if(data[i] != QRraw_getCode(raw)) {
err++;
}
}
QRinput_free(stream);
QRraw_free(raw);
testEnd(err);
}
void test_iterate2()
{
int i;
QRinput *stream;
char num[9] = "01234567";
QRRawCode *raw;
int err = 0;
unsigned char correct[] = {
0x10, 0x11, 0xec, 0xec, 0x20, 0xec, 0x11, 0x11,
0x0c, 0x11, 0xec, 0xec, 0x56, 0xec, 0x11, 0x11,
0x61, 0x11, 0xec, 0xec, 0x80, 0xec, 0x11, 0x11,
0xec, 0x11, 0xec, 0xec, 0x11, 0xec, 0x11, 0x11,
0xec, 0x11, 0xec, 0xec, 0x11, 0xec, 0x11, 0x11,
0xec, 0x11, 0xec, 0xec, 0x11, 0x11,
0x5c, 0xde, 0x68, 0x68, 0x4d, 0xb3, 0xdb, 0xdb,
0xd5, 0x14, 0xe1, 0xe1, 0x5b, 0x2a, 0x1f, 0x1f,
0x49, 0xc4, 0x78, 0x78, 0xf7, 0xe0, 0x5b, 0x5b,
0xc3, 0xa7, 0xc1, 0xc1, 0x5d, 0x9a, 0xea, 0xea,
0x48, 0xad, 0x9d, 0x9d, 0x58, 0xb3, 0x3f, 0x3f,
0x10, 0xdb, 0xbf, 0xbf, 0xeb, 0xec, 0x05, 0x05,
0x98, 0x35, 0x83, 0x83, 0xa9, 0x95, 0xa6, 0xa6,
0xea, 0x7b, 0x8d, 0x8d, 0x04, 0x3c, 0x08, 0x08,
0x64, 0xce, 0x3e, 0x3e, 0x4d, 0x9b, 0x30, 0x30,
0x4e, 0x65, 0xd6, 0xd6, 0xe4, 0x53, 0x2c, 0x2c,
0x46, 0x1d, 0x2e, 0x2e, 0x29, 0x16, 0x27, 0x27
};
testStart("Test getCode (5-H)");
stream = QRinput_new();
QRinput_setVersion(stream, 5);
QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_H);
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
raw = QRraw_new(stream);
for(i=0; i<raw->dataLength; i++) {
if(correct[i] != QRraw_getCode(raw)) {
err++;
}
}
QRinput_free(stream);
QRraw_free(raw);
testEnd(err);
}
void print_filler(void)
{
int width;
int version = 7;
unsigned char *frame;
width = QRspec_getWidth(version);
frame = FrameFiller_test(version);
if(frame == NULL) abort();
printFrame(width, frame);
free(frame);
}
void test_filler(void)
{
unsigned char *frame;
int i, j, w, e, length;
testStart("Frame filler test");
for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
length = QRspec_getDataLength(i, QR_ECLEVEL_L) * 8
+ QRspec_getECCLength(i, QR_ECLEVEL_L) * 8
+ QRspec_getRemainder(i);
frame = FrameFiller_test(i);
if(frame == NULL) {
assert_nonnull(frame, "Something wrong in version %d\n", i);
} else {
w = QRspec_getWidth(i);
e = 0;
for(j=0; j<w*w; j++) {
if(frame[j] == 0) e++;
}
assert_zero(e, "Not filled bit is found. (%d,%d)\n", j%w,j/w);
e = w * (w - 9 - ((i > 6)?3:0));
assert_equal(frame[e], (unsigned char)((length - 1) & 127) | 0x80,
"Number of cell does not match.\n");
free(frame);
}
}
testFinish();
}
void print_fillerMQR(void)
{
int width;
int version = 3;
unsigned char *frame;
for(version = 1; version <= MQRSPEC_VERSION_MAX; version++) {
width = MQRspec_getWidth(version);
frame = FrameFiller_testMQR(version);
if(frame == NULL) abort();
printFrame(width, frame);
}
}
void test_fillerMQR(void)
{
unsigned char *frame;
int i, j, w, e, length;
testStart("Micro QR Code Frame filler test");
for(i=1; i<=MQRSPEC_VERSION_MAX; i++) {
length = MQRspec_getDataLengthBit(i, QR_ECLEVEL_L)
+ MQRspec_getECCLength(i, QR_ECLEVEL_L) * 8;
frame = FrameFiller_testMQR(i);
if(frame == NULL) {
assert_nonnull(frame, "Something wrong in version %d\n", i);
} else {
w = MQRspec_getWidth(i);
e = 0;
for(j=0; j<w*w; j++) {
if(frame[j] == 0) e++;
}
assert_zero(e, "Not filled bit is found. (%d,%d)\n", j%w,j/w);
if(i & 1) {
e = w * 9 + 1;
} else {
e = w * (w - 1) + 1;
}
assert_equal(frame[e], (unsigned char)((length - 1) & 127) | 0x80,
"Number of cell does not match in version %d.\n", i);
free(frame);
}
}
testFinish();
}
void test_format(void)
{
unsigned char *frame;
unsigned int format;
int width;
int i;
unsigned int decode;
int blacks, b1 = 0, b2 = 0;
testStart("Test format information(level L,mask 0)");
width = QRspec_getWidth(1);
frame = QRspec_newFrame(1);
if(frame == NULL) goto ABORT;
format = QRspec_getFormatInfo(1, QR_ECLEVEL_L);
blacks = Mask_writeFormatInformation(width, frame, 1, QR_ECLEVEL_L);
decode = 0;
for(i=0; i<15; i++) {
if((1<<i) & format) b2 += 2;
}
for(i=0; i<8; i++) {
decode = decode << 1;
decode |= frame[width * 8 + i + (i > 5)] & 1;
if(decode & 1) b1++;
}
for(i=0; i<7; i++) {
decode = decode << 1;
decode |= frame[width * ((6 - i) + (i < 1)) + 8] & 1;
if(decode & 1) b1++;
}
if(decode != format) {
printf("Upper-left format information is invalid.\n");
printf("%08x, %08x\n", format, decode);
testEnd(1);
return;
}
decode = 0;
for(i=0; i<7; i++) {
decode = decode << 1;
decode |= frame[width * (width - 1 - i) + 8] & 1;
if(decode & 1) b1++;
}
for(i=0; i<8; i++) {
decode = decode << 1;
decode |= frame[width * 8 + width - 8 + i] & 1;
if(decode & 1) b1++;
}
if(decode != format) {
printf("Bottom and right format information is invalid.\n");
printf("%08x, %08x\n", format, decode);
testEnd(1);
return;
}
if(b2 != blacks || b1 != b2) {
printf("Number of dark modules is incorrect.\n");
printf("Return value: %d, dark modules in frame: %d, should be: %d\n", blacks, b1, b2);
testEnd(1);
return;
}
free(frame);
ABORT:
testEnd(0);
}
unsigned int m1pat[8][21] = {
{0x1fc77f, 0x105c41, 0x174c5d, 0x174b5d, 0x175b5d, 0x104241, 0x1fd57f,
0x000000, 0x154512, 0x1a16a2, 0x0376ee, 0x19abb2, 0x04eee1, 0x001442,
0x1fc111, 0x10444b, 0x175d5d, 0x174aae, 0x175ae5, 0x1043b8, 0x1fd2e5},
{0x1fdd7f, 0x104641, 0x17565d, 0x17415d, 0x17415d, 0x105841, 0x1fd57f,
0x000a00, 0x146f25, 0x10bc08, 0x09dc44, 0x130118, 0x0e444b, 0x001ee8,
0x1fdbbb, 0x104ee1, 0x1747f7, 0x174004, 0x17504f, 0x104912, 0x1fd84f},
{0x1fcb7f, 0x104f41, 0x17505d, 0x17585d, 0x17575d, 0x105141, 0x1fd57f,
0x001300, 0x17c97c, 0x02b52c, 0x046a9f, 0x01083c, 0x03f290, 0x0017cc,
0x1fcd60, 0x1057c5, 0x17512c, 0x175920, 0x175694, 0x104036, 0x1fde94},
{0x1fdb7f, 0x105441, 0x174d5d, 0x17585d, 0x174c5d, 0x104c41, 0x1fd57f,
0x001800, 0x16e44b, 0x02b52c, 0x12f1f2, 0x1a258a, 0x03f290, 0x001ca1,
0x1fd0d6, 0x1057c5, 0x174a41, 0x175496, 0x175694, 0x104b5b, 0x1fd322},
{0x1fd37f, 0x104741, 0x17475d, 0x175f5d, 0x175f5d, 0x105941, 0x1fd57f,
0x001400, 0x1171f9, 0x0c8dcf, 0x15ed83, 0x108f20, 0x0dca73, 0x001f2f,
0x1fda7c, 0x1040d9, 0x1759cf, 0x1741c3, 0x174188, 0x10472a, 0x1fd677},
{0x1fcd7f, 0x105741, 0x17505d, 0x17545d, 0x17475d, 0x104941, 0x1fd57f,
0x001b00, 0x1059ce, 0x05a95d, 0x046a9f, 0x03001c, 0x0e444b, 0x001fec,
0x1fcd60, 0x104bb4, 0x17412c, 0x174100, 0x17404f, 0x104816, 0x1fde94},
{0x1fdd7f, 0x105741, 0x17545d, 0x17445d, 0x17555d, 0x104f41, 0x1fd57f,
0x000b00, 0x13fd97, 0x05a95d, 0x00f8d6, 0x028604, 0x0e444b, 0x001f2f,
0x1fd9f2, 0x105bb4, 0x175365, 0x175718, 0x17404f, 0x1048d5, 0x1fda06},
{0x1fc77f, 0x104841, 0x174e5d, 0x174b5d, 0x174f5d, 0x105041, 0x1fd57f,
0x000400, 0x12d7a0, 0x1a16a2, 0x0a527c, 0x1d39fb, 0x04eee1, 0x0010d0,
0x1fc358, 0x10544b, 0x1749cf, 0x1758e7, 0x174ae5, 0x10472a, 0x1fd0ac}
};
void test_encode(void)
{
QRinput *stream;
char num[9] = "01234567";
unsigned char *frame;
int err = 0;
int x, y, w;
int mask;
QRcode *qrcode;
testStart("Test encode (1-M)");
stream = QRinput_new();
if(stream == NULL) goto ABORT;
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
for(mask=0; mask<8; mask++) {
QRinput_setVersion(stream, 1);
QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_M);
qrcode = QRcode_encodeMask(stream, mask);
if(qrcode == NULL) goto ABORT;
w = qrcode->width;
frame = qrcode->data;
for(y=0; y<w; y++) {
for(x=0; x<w; x++) {
if(((m1pat[mask][y] >> (20-x)) & 1) != (frame[y*w+x]&1)) {
printf("Diff in mask=%d (%d,%d)\n", mask, x, y);
err++;
}
}
}
QRcode_free(qrcode);
}
QRinput_free(stream);
ABORT:
testEnd(err);
}
void test_encode2(void)
{
QRcode *qrcode;
testStart("Test encode (2-H) (no padding test)");
qrcode = QRcode_encodeString("abcdefghijk123456789012", 0, QR_ECLEVEL_H, QR_MODE_8, 0);
testEndExp(qrcode->version == 2);
QRcode_free(qrcode);
}
void test_encode3(void)
{
QRcode *code1, *code2;
QRinput *input;
testStart("Compare encodeString and encodeInput");
code1 = QRcode_encodeString("0123456", 0, QR_ECLEVEL_L, QR_MODE_8, 0);
input = QRinput_new2(0, QR_ECLEVEL_L);
QRinput_append(input, QR_MODE_NUM, 7, (unsigned char *)"0123456");
code2 = QRcode_encodeInput(input);
testEnd(memcmp(code1->data, code2->data, code1->width * code1->width));
QRcode_free(code1);
QRcode_free(code2);
QRinput_free(input);
}
void test_encodeNull(void)
{
QRcode *qrcode;
testStart("Test encode NULL.");
qrcode = QRcode_encodeString(NULL, 0, QR_ECLEVEL_H, QR_MODE_8, 0);
assert_null(qrcode, "QRcode_encodeString() returned something.\n");
testFinish();
if(qrcode != NULL) QRcode_free(qrcode);
}
void test_encodeEmpty(void)
{
QRcode *qrcode;
testStart("Test encode an empty string.");
qrcode = QRcode_encodeString("", 0, QR_ECLEVEL_H, QR_MODE_8, 0);
assert_null(qrcode, "QRcode_encodeString() returned something.\n");
testFinish();
if(qrcode != NULL) QRcode_free(qrcode);
}
void test_encodeNull8(void)
{
QRcode *qrcode;
testStart("Test encode NULL.");
qrcode = QRcode_encodeString8bit(NULL, 0, QR_ECLEVEL_H);
assert_null(qrcode, "QRcode_encodeString8bit() returned something.\n");
testFinish();
if(qrcode != NULL) QRcode_free(qrcode);
}
void test_encodeEmpty8(void)
{
QRcode *qrcode;
testStart("Test encode an empty string.");
qrcode = QRcode_encodeString8bit("", 0, QR_ECLEVEL_H);
assert_null(qrcode, "QRcode_encodeString8bit() returned something.\n");
testFinish();
if(qrcode != NULL) QRcode_free(qrcode);
}
void test_encodeTooLong(void)
{
QRcode *code;
char *data;
testStart("Encode too large data");
data = (char *)malloc(4300);
memset(data, 'a', 4295);
memset(data + 4295, '0', 4);
data[4299] = '\0';
code = QRcode_encodeString(data, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
assert_null(code, "Too large data is incorrectly accepted.\n");
assert_equal(errno, ERANGE, "errno != ERANGE\n");
testFinish();
if(code != NULL) {
QRcode_free(code);
}
free(data);
}
void test_01234567(void)
{
QRinput *stream;
char num[9] = "01234567";
int i, err = 0;
QRcode *qrcode;
unsigned char correct[] = {
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x84, 0x03, 0x02, 0x03, 0x03, 0xc0, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x03, 0x03, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x02, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x02, 0x02, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x03, 0xc0, 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x03, 0xc0, 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1,
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x91, 0x90, 0x91, 0x90, 0x91, 0xc0, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x85, 0x02, 0x02, 0x03, 0x03, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
0x85, 0x84, 0x85, 0x85, 0x85, 0x85, 0x91, 0x84, 0x84, 0x03, 0x02, 0x02, 0x03, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84,
0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x90, 0x03, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02,
0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x91, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03,
0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x90, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02,
0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x91, 0x03, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02,
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x81, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x02, 0x02,
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x84, 0x03, 0x03, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x03,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02,
0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc0, 0x85, 0x02, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02,
0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc0, 0x84, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02,
0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0x85, 0x03, 0x03, 0x03, 0x02, 0x03, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02};
testStart("Encode 01234567 in 1-M");
stream = QRinput_new2(1, QR_ECLEVEL_M);
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
qrcode = QRcode_encodeInput(stream);
for(i=0; i<qrcode->width * qrcode->width; i++) {
if(qrcode->data[i] != correct[i]) {
err++;
}
}
testEnd(err);
QRinput_free(stream);
QRcode_free(qrcode);
}
void print_01234567(void)
{
QRinput *stream;
char num[9] = "01234567";
QRcode *qrcode;
stream = QRinput_new2(1, QR_ECLEVEL_M);
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
qrcode = QRcode_encodeInput(stream);
printQRcode(qrcode);
QRinput_free(stream);
QRcode_free(qrcode);
}
void test_invalid_input(void)
{
QRinput *input;
QRcode *code;
testStart("Testing invalid input.");
input = QRinput_new();
QRinput_append(input, QR_MODE_AN, 5, (unsigned char *)"TEST1");
input->version = -1;
input->level = QR_ECLEVEL_L;
code = QRcode_encodeInput(input);
assert_null(code, "invalid version(-1) was not checked.\n");
if(code != NULL) QRcode_free(code);
input->version = 41;
input->level = QR_ECLEVEL_L;
code = QRcode_encodeInput(input);
assert_null(code, "invalid version(41) access was not checked.\n");
if(code != NULL) QRcode_free(code);
input->version = 1;
input->level = (QRecLevel)(QR_ECLEVEL_H + 1);
code = QRcode_encodeInput(input);
assert_null(code, "invalid level(H+1) access was not checked.\n");
if(code != NULL) QRcode_free(code);
input->version = 1;
input->level = (QRecLevel)-1;
code = QRcode_encodeInput(input);
assert_null(code, "invalid level(-1) access was not checked.\n");
if(code != NULL) QRcode_free(code);
QRinput_free(input);
testFinish();
}
void test_struct_semilong(void)
{
QRcode_List *codes, *list;
const char *str = your_sha256_hashdsfasdf";
int num, size;
testStart("Testing semi-long structured-append symbols");
codes = QRcode_encodeString8bitStructured(str, 1, QR_ECLEVEL_L);
list = codes;
num = 0;
while(list != NULL) {
num++;
assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
list = list->next;
}
size = QRcode_List_size(codes);
assert_equal(num, size, "QRcode_List_size returns wrong size?");
QRcode_List_free(codes);
codes = QRcode_encodeStringStructured(str, 1, QR_ECLEVEL_L, QR_MODE_8, 1);
list = codes;
num = 0;
while(list != NULL) {
num++;
assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
list = list->next;
}
size = QRcode_List_size(codes);
assert_equal(num, size, "QRcode_List_size returns wrong size?");
QRcode_List_free(codes);
testFinish();
}
void test_struct_example(void)
{
QRcode_List *codes, *list;
const char *str = "an example of four Structured Append symbols,";
int num;
testStart("Testing the example of structured-append symbols");
codes = QRcode_encodeString8bitStructured(str, 1, QR_ECLEVEL_M);
list = codes;
num = 0;
while(list != NULL) {
num++;
assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version);
list = list->next;
}
assert_equal(num, 4, "number of symbols is %d (4 expected).", num);
testFinish();
QRcode_List_free(codes);
}
void test_null_free(void)
{
testStart("Testing free NULL pointers");
assert_nothing(QRcode_free(NULL), "Check QRcode_free(NULL).\n");
assert_nothing(QRcode_List_free(NULL), "Check QRcode_List_free(NULL).\n");
assert_nothing(QRraw_free(NULL), "Check QRraw_free(NULL).\n");
testFinish();
}
void test_encodeTooLongMQR(void)
{
QRcode *code;
char *data[] = {"012345", "ABC0EFG", "0123456789", "0123456789ABCDEFG"};
testStart("Encode too large data for MQR.");
code = QRcode_encodeStringMQR(data[0], 1, QR_ECLEVEL_L, QR_MODE_8, 0);
assert_null(code, "6 byte length numeric string was accepted to version 1.\n");
assert_equal(errno, ERANGE, "errno != ERANGE\n");
code = QRcode_encodeStringMQR(data[1], 2, QR_ECLEVEL_L, QR_MODE_8, 0);
assert_null(code, "7 byte length alphanumeric string was accepted to version 2.\n");
assert_equal(errno, ERANGE, "errno != ERANGE\n");
code = QRcode_encodeString8bitMQR(data[2], 3, QR_ECLEVEL_L);
assert_null(code, "9 byte length 8bit string was accepted to version 3.\n");
assert_equal(errno, ERANGE, "errno != ERANGE\n");
code = QRcode_encodeString8bitMQR(data[3], 4, QR_ECLEVEL_L);
assert_null(code, "16 byte length 8bit string was accepted to version 4.\n");
assert_equal(errno, ERANGE, "errno != ERANGE\n");
testFinish();
if(code != NULL) {
printQRcode(code);
QRcode_free(code);
}
}
void test_mqrraw_new(void)
{
QRinput *stream;
char *num = "01234";
unsigned char datacode[] = {0xa0, 0x62, 0x02};
MQRRawCode *raw;
testStart("Test MQRRaw_new()");
stream = QRinput_newMQR(1, QR_ECLEVEL_L);
QRinput_append(stream, QR_MODE_NUM, 5, (unsigned char *)num);
raw = MQRraw_new(stream);
assert_nonnull(raw, "Failed MQRraw_new().\n");
assert_zero(raw->count, "MQRraw.count = %d != 0\n", raw->count);
assert_equal(raw->version, 1, "MQRraw.version was not as expected. (%d)\n", raw->version);
assert_equal(raw->dataLength, 3, "MQRraw.dataLength was not as expected.\n");
assert_equal(raw->eccLength, 2, "MQRraw.eccLength was not as expected.\n");
assert_zero(memcmp(raw->datacode, datacode, 3), "Datacode doesn't match.\n");
QRinput_free(stream);
MQRraw_free(raw);
testFinish();
}
void test_encodeData(void)
{
QRcode *qrcode;
testStart("Test QRencode_encodeData.");
qrcode = QRcode_encodeData(0, NULL, 0, QR_ECLEVEL_H);
assert_null(qrcode, "QRcode_encodeData(NULL, 0) returned something.\n");
if(qrcode != NULL) QRcode_free(qrcode);
qrcode = QRcode_encodeData(10, (unsigned char*)"test\0\0test", 0, QR_ECLEVEL_H);
assert_nonnull(qrcode, "QRcode_encodeData() failed.\n");
if(qrcode != NULL) QRcode_free(qrcode);
testFinish();
}
void test_formatInfo(void)
{
QRcode *qrcode;
QRecLevel level;
int mask;
int ret;
testStart("Test format info in QR code.");
qrcode = QRcode_encodeString("AC-42", 1, QR_ECLEVEL_H, QR_MODE_8, 1);
ret = QRcode_decodeFormat(qrcode, &level, &mask);
assert_zero(ret, "Failed to decode.\n");
assert_equal(level, QR_ECLEVEL_H, "Decoded format is wrong.\n");
if(qrcode != NULL) QRcode_free(qrcode);
testFinish();
}
void test_formatInfoMQR(void)
{
QRcode *qrcode;
QRecLevel level;
int version, mask;
int i, ret;
testStart("Test format info in Micro QR code.");
for(i=0; i<8; i++) {
qrcode = QRcode_encodeStringMQR("1",
MQRformat[i].version,
MQRformat[i].level,
QR_MODE_8, 1);
ret = QRcode_decodeFormatMQR(qrcode, &version, &level, &mask);
assert_zero(ret, "Failed to decode.\n");
assert_equal(MQRformat[i].version, version, "Decoded verion is wrong.\n");
assert_equal(MQRformat[i].level, level, "Decoded level is wrong.\n");
QRcode_free(qrcode);
}
testFinish();
}
void test_decodeSimple(void)
{
char *str = "AC-42";
QRcode *qrcode;
QRdata *qrdata;
testStart("Test code words.");
qrcode = QRcode_encodeString(str, 1, QR_ECLEVEL_H, QR_MODE_8, 1);
qrdata = QRcode_decode(qrcode);
assert_nonnull(qrdata, "Failed to decode.\n");
if(qrdata != NULL) {
assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched: %d, expected %d.\n", qrdata->size, (int)strlen(str));
assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str);
}
if(qrdata != NULL) QRdata_free(qrdata);
if(qrcode != NULL) QRcode_free(qrcode);
testFinish();
}
void test_decodeLong(void)
{
char *str = "12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ?????????????";
QRcode *qrcode;
QRdata *qrdata;
testStart("Test code words (long, splitted).");
qrcode = QRcode_encodeString(str, 0, QR_ECLEVEL_H, QR_MODE_8, 1);
qrdata = QRcode_decode(qrcode);
assert_nonnull(qrdata, "Failed to decode.\n");
if(qrdata != NULL) {
assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched.\n");
assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str);
}
if(qrdata != NULL) QRdata_free(qrdata);
if(qrcode != NULL) QRcode_free(qrcode);
testFinish();
}
void test_decodeVeryLong(void)
{
char str[4000];
int i;
QRcode *qrcode;
QRdata *qrdata;
testStart("Test code words (very long string).");
for(i=0; i<3999; i++) {
str[i] = decodeAnTable[(int)drand(45)];
}
str[3999] = '\0';
qrcode = QRcode_encodeString(str, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
qrdata = QRcode_decode(qrcode);
assert_nonnull(qrdata, "Failed to decode.\n");
if(qrdata != NULL) {
assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched.\n");
assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str);
}
if(qrdata != NULL) QRdata_free(qrdata);
if(qrcode != NULL) QRcode_free(qrcode);
testFinish();
}
void test_decodeShortMQR(void)
{
char str[]="55";
QRcode *qrcode;
QRdata *qrdata;
int i;
testStart("Test code words (MQR).");
for(i=0; i<8; i++) {
qrcode = QRcode_encodeStringMQR(str,
MQRformat[i].version,
MQRformat[i].level,
QR_MODE_8, 1);
qrdata = QRcode_decodeMQR(qrcode);
assert_nonnull(qrdata, "Failed to decode.\n");
assert_zero(strcmp((char *)qrdata->data, str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, str);
if(qrdata != NULL) QRdata_free(qrdata);
if(qrcode != NULL) QRcode_free(qrcode);
}
testFinish();
}
void test_oddBitCalcMQR(void)
{
/* test issue #25 (odd bits calculation bug) */
/* test pattern contributed by vlad417 */
TestString tests[] = {
{"46194", 1, QR_ECLEVEL_L, QR_MODE_8, 1},
{"WBA5Y47YPQQ", 3, QR_ECLEVEL_L, QR_MODE_8, 1}
};
QRcode *qrcode;
QRdata *qrdata;
int i;
testStart("Odd bits calculation bug checking (MQR).");
for(i=0; i<_countof(tests); i++) {
qrcode = QRcode_encodeStringMQR(tests[i].str,
tests[i].version,
tests[i].level,
tests[i].hint,
tests[i].casesensitive);
assert_nonnull(qrcode, "Failed to encode: %s\n", tests[i].str);
if(qrcode == NULL) continue;
qrdata = QRcode_decodeMQR(qrcode);
assert_nonnull(qrdata, "Failed to decode.\n");
assert_zero(strcmp((char *)qrdata->data, tests[i].str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, tests[i].str);
if(qrdata != NULL) QRdata_free(qrdata);
QRcode_free(qrcode);
}
testFinish();
}
void test_mqrencode(void)
{
char *str = "MICROQR";
char pattern[] = {
"#######_#_#_#_#"
"#_____#_#__####"
"#_###_#_#_####_"
"#_###_#_#__##_#"
"#_###_#___#__##"
"#_____#____#_#_"
"#######__##_#_#"
"_________#__#__"
"#___#__####_#_#"
"_#######_#_##_#"
"##___#_#____#__"
"_##_#_####____#"
"#__###___#__##_"
"_###_#_###_#_#_"
"##____####_###_"
};
QRcode qrcode;
QRdata *qrdata;
unsigned char *frame;
int i;
testStart("Encoding test (MQR).");
qrcode.width = 15;
qrcode.version = 3;
frame = MQRspec_newFrame(qrcode.version);
for(i=0; i<225; i++) {
frame[i] ^= (pattern[i] == '#')?1:0;
}
qrcode.data = frame;
qrdata = QRcode_decodeMQR(&qrcode);
assert_equal(qrdata->version, 3, "Format info decoder returns wrong version number: %d (%d expected)\n", qrdata->version, 3);
assert_equal(qrdata->level, 1, "Format info decoder returns wrong level: %d (%d expected)\n", qrdata->level, 1);
assert_zero(strcmp((char *)qrdata->data, str), "Decoded data (%s) mismatched (%s)\n", (char *)qrdata->data, str);
QRdata_free(qrdata);
free(frame);
testFinish();
}
void test_apiversion(void)
{
int major_version, minor_version, micro_version;
char *str, *str2;
testStart("API Version check");
QRcode_APIVersion(&major_version, &minor_version, µ_version);
assert_equal(major_version, MAJOR_VERSION, "Major version number mismatched: %d (%d expected)\n", major_version, MAJOR_VERSION);
assert_equal(minor_version, MINOR_VERSION, "Minor version number mismatched: %d (%d expected)\n", minor_version, MINOR_VERSION);
assert_equal(micro_version, MICRO_VERSION, "Micro version number mismatched: %d (%d expected)\n", micro_version, MICRO_VERSION);
str = QRcode_APIVersionString();
str2 = QRcode_APIVersionString();
assert_zero(strcmp(VERSION, str), "Version string mismatched: %s (%s expected)\n", str, VERSION);
assert_equal(str, str2, "Version strings are not identical.");
testFinish();
}
int main(void)
{
test_iterate();
test_iterate2();
//print_filler();
test_filler();
test_format();
test_encode();
test_encode2();
test_encode3();
test_encodeNull();
test_encodeEmpty();
test_encodeNull8();
test_encodeEmpty8();
test_encodeTooLong();
test_01234567();
test_invalid_input();
// print_01234567();
test_struct_example();
test_struct_semilong();
test_null_free();
test_qrraw_new();
test_mqrraw_new();
test_encodeData();
test_formatInfo();
test_decodeSimple();
test_decodeLong();
test_decodeVeryLong();
//print_fillerMQR();
test_fillerMQR();
test_formatInfoMQR();
test_encodeTooLongMQR();
test_decodeShortMQR();
test_oddBitCalcMQR();
test_mqrencode();
test_apiversion();
QRcode_clearCache();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_qrencode.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 11,472
|
```c
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "common.h"
#include "../qrinput.h"
#include "../qrencode_inner.h"
#include "../split.h"
#include "decoder.h"
int encodeAndCheckBStream(int mqr, int version, QRecLevel level, QRencodeMode mode, char *data, char *correct)
{
QRinput *input;
BitStream *bstream;
int ret;
if(mqr) {
input = QRinput_newMQR(version, level);
} else {
input = QRinput_new2(version, level);
}
QRinput_append(input, mode, strlen(data), (unsigned char *)data);
bstream = QRinput_getBitStream(input);
ret = cmpBin(correct, bstream);
if(ret) {
printf("result : ");
printBstream(bstream);
printf("correct: %s\n", correct);
}
QRinput_free(input);
BitStream_free(bstream);
return ret;
}
int mergeAndCheckBStream(int mqr, QRencodeMode mode, char *data, char *correct)
{
QRinput *input;
BitStream *bstream;
int ret;
if(mqr) {
input = QRinput_newMQR(1, QR_ECLEVEL_L);
} else {
input = QRinput_new();
}
QRinput_append(input, mode, strlen(data), (unsigned char *)data);
bstream = QRinput_mergeBitStream(input);
ret = cmpBin(correct, bstream);
QRinput_free(input);
BitStream_free(bstream);
return ret;
}
void test_encodeKanji(void)
{
char str[5]= {0x93, 0x5f,0xe4, 0xaa, 0x00};
char *correct = "10000000001001101100111111101010101010";
testStart("Encoding kanji stream.");
testEnd(mergeAndCheckBStream(0, QR_MODE_KANJI, str, correct));
}
void test_encode8(void)
{
char str[] = "AC-42";
char correct[] = "0100000001010100000101000011001011010011010000110010";
testStart("Encoding 8bit stream.");
testEnd(mergeAndCheckBStream(0, QR_MODE_8, str, correct));
}
void test_encode8_versionup(void)
{
QRinput *stream;
BitStream *bstream;
char *str;
int version;
testStart("Encoding 8bit stream. (auto-version up test)");
str = (char *)malloc(2900);
memset(str, 0xff, 2900);
stream = QRinput_new();
QRinput_append(stream, QR_MODE_8, 2900, (unsigned char *)str);
bstream = QRinput_mergeBitStream(stream);
version = QRinput_getVersion(stream);
assert_equal(version, 40, "Version is %d (40 expected).\n", version);
testFinish();
QRinput_free(stream);
BitStream_free(bstream);
free(str);
}
void test_encodeAn(void)
{
char *str = "AC-42";
char correct[] = "00100000001010011100111011100111001000010";
testStart("Encoding alphabet-numeric stream.");
testEnd(mergeAndCheckBStream(0, QR_MODE_AN, str, correct));
}
void test_encodeAn2(void)
{
QRinput *stream;
char str[] = "!,;$%";
int ret;
testStart("Encoding INVALID alphabet-numeric stream.");
stream = QRinput_new();
ret = QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str);
testEnd(!ret);
QRinput_free(stream);
}
void test_encodeNumeric(void)
{
char *str = "01234567";
char correct[] = "00010000001000000000110001010110011000011";
testStart("Encoding numeric stream. (8 digits)");
testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct));
}
void test_encodeNumeric_versionup(void)
{
QRinput *stream;
BitStream *bstream;
char *str;
int version;
testStart("Encoding numeric stream. (auto-version up test)");
str = (char *)malloc(1050);
memset(str, '1', 1050);
stream = QRinput_new2(0, QR_ECLEVEL_L);
QRinput_append(stream, QR_MODE_NUM, 1050, (unsigned char *)str);
bstream = QRinput_mergeBitStream(stream);
version = QRinput_getVersion(stream);
assert_equal(version, 14, "Version is %d (14 expected).", version);
testFinish();
QRinput_free(stream);
BitStream_free(bstream);
free(str);
}
void test_encodeNumericPadded(void)
{
char *str = "01234567";
char *correct;
char *correctHead = "000100000010000000001100010101100110000110000000";
int i, ret;
testStart("Encoding numeric stream. (8 digits)(padded)");
correct = (char *)malloc(19 * 8 + 1);
correct[0] = '\0';
strcat(correct, correctHead);
for(i=0; i<13; i++) {
strcat(correct, (i&1)?"00010001":"11101100");
}
ret = encodeAndCheckBStream(0, 0, QR_ECLEVEL_L, QR_MODE_NUM, str, correct);
testEnd(ret);
free(correct);
}
void test_encodeNumericPadded2(void)
{
char *str = "0123456";
char *correct;
char *correctHead = "000100000001110000001100010101100101100000000000";
int i, ret;
testStart("Encoding numeric stream. (7 digits)(padded)");
correct = (char *)malloc(19 * 8 + 1);
correct[0] = '\0';
strcat(correct, correctHead);
for(i=0; i<13; i++) {
strcat(correct, (i&1)?"00010001":"11101100");
}
ret = encodeAndCheckBStream(0, 0, QR_ECLEVEL_L, QR_MODE_NUM, str, correct);
testEnd(ret);
free(correct);
}
void test_padding(void)
{
QRinput *input;
BitStream *bstream;
int i, size;
char data[] = "0123456789ABCDeFG";
unsigned char c;
testStart("Padding bit check. (less than 5 bits)");
input = QRinput_new2(1, QR_ECLEVEL_L);
QRinput_append(input, QR_MODE_8, 17, (unsigned char *)data);
bstream = QRinput_getBitStream(input);
size = BitStream_size(bstream);
assert_equal(size, 152, "# of bit is incorrect (%d != 152).\n", size);
c = 0;
for(i=0; i<4; i++) {
c += bstream->data[size - i - 1];
}
assert_zero(c, "Padding bits are not zero.");
testFinish();
QRinput_free(input);
BitStream_free(bstream);
}
void test_padding2(void)
{
QRinput *input;
BitStream *bstream;
int i, size, ret;
char data[] = "0123456789ABCDeF";
char correct[153];
unsigned char c;
testStart("Padding bit check. (1 or 2 padding bytes)");
/* 16 byte data (4 bit terminator and 1 byte padding) */
memset(correct, 0, 153);
memcpy(correct, "010000010000", 12);
for(size=0; size<16; size++) {
c = 0x80;
for(i=0; i<8; i++) {
correct[size * 8 + i + 12] = (data[size]&c)?'1':'0';
c = c >> 1;
}
}
memcpy(correct + 140, "000011101100", 12);
input = QRinput_new2(1, QR_ECLEVEL_L);
QRinput_append(input, QR_MODE_8, 16, (unsigned char *)data);
bstream = QRinput_getBitStream(input);
size = BitStream_size(bstream);
assert_equal(size, 152, "16byte: # of bit is incorrect (%d != 152).\n", size);
ret = ncmpBin(correct, bstream, 152);
assert_zero(ret, "Padding bits incorrect.\n");
printBstream(bstream);
QRinput_free(input);
BitStream_free(bstream);
/* 15 byte data (4 bit terminator and 2 byte paddings) */
memcpy(correct, "010000001111", 12);
memcpy(correct + 132, "00001110110000010001", 20);
input = QRinput_new2(1, QR_ECLEVEL_L);
QRinput_append(input, QR_MODE_8, 15, (unsigned char *)data);
bstream = QRinput_getBitStream(input);
size = BitStream_size(bstream);
assert_equal(size, 152, "15byte: # of bit is incorrect (%d != 152).\n", size);
ret = ncmpBin(correct, bstream, 152);
assert_zero(ret, "Padding bits incorrect.\n");
printBstream(bstream);
testFinish();
QRinput_free(input);
BitStream_free(bstream);
}
void test_encodeNumeric2(void)
{
char *str = "0123456789012345";
char *correct = your_sha256_hash0101";
testStart("Encoding numeric stream. (16 digits)");
testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct));
}
void test_encodeNumeric3(void)
{
char *str = "0123456";
char *correct = "0001 0000000111 0000001100 0101011001 0110";
testStart("Encoding numeric stream. (7 digits)");
testEnd(mergeAndCheckBStream(0, QR_MODE_NUM, str, correct));
}
void test_encodeTooLong(void)
{
QRinput *stream;
unsigned char *data;
BitStream *bstream;
data = (unsigned char *)malloc(4297);
memset(data, 'A', 4297);
testStart("Encoding long string. (4297 bytes of alphanumeric)");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_AN, 4297, data);
bstream = QRinput_mergeBitStream(stream);
testEndExp(bstream == NULL);
QRinput_free(stream);
if(bstream != NULL) {
BitStream_free(bstream);
}
free(data);
}
void test_encodeAnNum(void)
{
QRinput *input;
BitStream *bstream;
testStart("Bit length check of alpha-numeric stream. (11 + 12)");
input = QRinput_new();
QRinput_append(input, QR_MODE_AN, 11, (unsigned char *)"ABCDEFGHIJK");
QRinput_append(input, QR_MODE_NUM, 12, (unsigned char *)"123456789012");
bstream = QRinput_mergeBitStream(input);
testEndExp(BitStream_size(bstream) == 128);
QRinput_free(input);
BitStream_free(bstream);
testStart("Bit length check of alphabet stream. (23)");
input = QRinput_new();
QRinput_append(input, QR_MODE_AN, 23, (unsigned char *)"ABCDEFGHIJK123456789012");
bstream = QRinput_mergeBitStream(input);
testEndExp(BitStream_size(bstream) == 140);
QRinput_free(input);
BitStream_free(bstream);
}
void test_struct_listop(void)
{
QRinput_Struct *s;
QRinput *inputs[5];
QRinput_InputList *l;
int i, ret;
testStart("QRinput_Struct list operation test.");
s = QRinput_Struct_new();
QRinput_Struct_setParity(s, 10);
assert_nonnull(s, "QRinput_Struct_new() failed.");
assert_equal(s->parity, 10, "QRinput_Struct_setParity() failed.");
for(i=0; i<5; i++) {
inputs[i] = QRinput_new();
QRinput_append(inputs[i], QR_MODE_AN, 5, (unsigned char *)"ABCDE");
ret = QRinput_Struct_appendInput(s, inputs[i]);
}
assert_equal(ret, 5, "QRinput_Struct_appendInput() returns wrong num?");
assert_equal(s->size, 5, "QRiput_Struct.size counts wrong number.");
l = s->head;
i = 0;
while(l != NULL) {
assert_equal(l->input, inputs[i], "QRinput_Struct input list order would be wrong?");
l = l->next;
i++;
}
QRinput_Struct_free(s);
testFinish();
}
void test_insertStructuredAppendHeader(void)
{
QRinput *stream;
char correct[] = "0011000011111010010101000000000101000001";
BitStream *bstream;
int ret;
testStart("Insert a structured-append header");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_8, 1, (unsigned char *)"A");
ret = QRinput_insertStructuredAppendHeader(stream, 16, 1, 0xa5);
assert_zero(ret, "QRinput_insertStructuredAppendHeader() returns nonzero.\n");
bstream = QRinput_mergeBitStream(stream);
assert_nonnull(bstream->data, "Bstream->data is null.");
assert_zero(cmpBin(correct, bstream), "bitstream is wrong.");
testFinish();
QRinput_free(stream);
BitStream_free(bstream);
}
void test_insertStructuredAppendHeader_error(void)
{
QRinput *stream;
int ret;
testStart("Insert a structured-append header (errors expected)");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_8, 1, (unsigned char *)"A");
ret = QRinput_insertStructuredAppendHeader(stream, 17, 1, 0xa5);
assert_equal(-1, ret, "QRinput_insertStructuredAppendHeader() returns 0.");
assert_equal(EINVAL, errno, "errno is not set correctly (%d returned).", errno);
ret = QRinput_insertStructuredAppendHeader(stream, 16, 17, 0xa5);
assert_equal(-1, ret, "QRinput_insertStructuredAppendHeader() returns 0.");
assert_equal(EINVAL, errno, "errno is not set correctly (%d returned).", errno);
ret = QRinput_insertStructuredAppendHeader(stream, 16, 0, 0xa5);
assert_equal(-1, ret, "QRinput_insertStructuredAppendHeader() returns 0.");
assert_equal(EINVAL, errno, "errno is not set correctly (%d returned).", errno);
testFinish();
QRinput_free(stream);
}
void test_struct_insertStructuredAppendHeaders(void)
{
QRinput *input;
QRinput_Struct *s;
QRinput_InputList *p;
int i;
testStart("Insert structured-append headers to a QRinput_Struct.");
s = QRinput_Struct_new();
for(i=0; i<10; i++) {
input = QRinput_new();
QRinput_append(input, QR_MODE_8, 1, (unsigned char *)"A");
QRinput_Struct_appendInput(s, input);
}
QRinput_Struct_insertStructuredAppendHeaders(s);
p = s->head;
i = 1;
while(p != NULL) {
assert_equal(p->input->head->mode, QR_MODE_STRUCTURE, "a structured-append header is not inserted.");
assert_equal(p->input->head->data[0], 10, "size of the structured-header is wrong: #%d, %d should be %d\n", i, p->input->head->data[0], 10);
assert_equal(p->input->head->data[1], i, "index of the structured-header is wrong: #%d, %d should be %d\n", i, p->input->head->data[1], i);
assert_equal(p->input->head->data[2], 0, "parity of the structured-header is wrong: #%d\n", i);
p = p->next;
i++;
}
testFinish();
QRinput_Struct_free(s);
}
static int check_lengthOfCode(QRencodeMode mode, char *data, int size, int version)
{
QRinput *input;
BitStream *b;
int bits;
int bytes;
input = QRinput_new();
QRinput_setVersion(input, version);
QRinput_append(input, mode, size, (unsigned char *)data);
b = QRinput_mergeBitStream(input);
bits = BitStream_size(b);
bytes = QRinput_lengthOfCode(mode, version, bits);
QRinput_free(input);
BitStream_free(b);
return bytes;
}
void test_lengthOfCode_num(void)
{
int i, bytes;
char *data;
data = (char *)malloc(8000);
for(i=0; i<8000; i++) {
data[i] = '0' + i % 10;
}
testStart("Checking length of code (numeric)");
for(i=1; i<=9; i++) {
bytes = check_lengthOfCode(QR_MODE_NUM, data, i, 1);
assert_equal(i, bytes, "lengthOfCode failed. (QR_MODE_NUM, version:1, size:%d)\n", i);
}
for(i=1023; i<=1025; i++) {
bytes = check_lengthOfCode(QR_MODE_NUM, data, i, 1);
assert_equal(1023, bytes, "lengthOfCode failed. (QR_MODE_NUM, version:1, size:%d)\n", i);
}
testFinish();
free(data);
}
void test_lengthOfCode_kanji(void)
{
int i, bytes;
unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa};
testStart("Checking length of code (kanji)");
for(i=2; i<=4; i+=2) {
bytes = check_lengthOfCode(QR_MODE_KANJI, (char *)str, i, 1);
assert_equal(i, bytes, "lengthOfCode failed. (QR_MODE_KANJI, version:1, size:%d)\n", i);
}
testFinish();
}
void test_struct_split_example(void)
{
QRinput *input;
QRinput_Struct *s;
QRinput_InputList *e;
QRinput_List *l;
const char *str[4] = { "an example ", "of four Str", "uctured Appe", "nd symbols,"};
int i;
BitStream *bstream;
testStart("Testing the example of structured-append symbols");
s = QRinput_Struct_new();
for(i=0; i<4; i++) {
input = QRinput_new2(1, QR_ECLEVEL_M);
QRinput_append(input, QR_MODE_8, strlen(str[i]), (unsigned char *)str[i]);
QRinput_Struct_appendInput(s, input);
}
QRinput_Struct_insertStructuredAppendHeaders(s);
e = s->head;
i = 0;
while(e != NULL) {
bstream = QRinput_mergeBitStream(e->input);
BitStream_free(bstream);
l = e->input->head->next;
assert_equal(l->mode, QR_MODE_8, "#%d: wrong mode (%d).\n", i, l->mode);
assert_equal(e->input->level, QR_ECLEVEL_M, "#%d: wrong level (%d).\n", i, e->input->level);
e = e->next;
i++;
}
testFinish();
QRinput_Struct_free(s);
}
void test_struct_split_tooLarge(void)
{
QRinput *input;
QRinput_Struct *s;
char *str;
int errsv;
testStart("Testing structured-append symbols. (too large data)");
str = (char *)malloc(128);
memset(str, 'a', 128);
input = QRinput_new2(1, QR_ECLEVEL_H);
QRinput_append(input, QR_MODE_8, 128, (unsigned char *)str);
s = QRinput_splitQRinputToStruct(input);
errsv = errno;
assert_null(s, "returns non-null.");
assert_equal(errsv, ERANGE, "did not return ERANGE.");
testFinish();
if(s != NULL) QRinput_Struct_free(s);
QRinput_free(input);
free(str);
}
void test_struct_split_invalidVersion(void)
{
QRinput *input;
QRinput_Struct *s;
char *str;
int errsv;
testStart("Testing structured-append symbols. (invalid version 0)");
str = (char *)malloc(128);
memset(str, 'a', 128);
input = QRinput_new2(0, QR_ECLEVEL_H);
QRinput_append(input, QR_MODE_8, 128, (unsigned char *)str);
s = QRinput_splitQRinputToStruct(input);
errsv = errno;
assert_null(s, "returns non-null.");
assert_equal(errsv, ERANGE, "did not return ERANGE.");
testFinish();
if(s != NULL) QRinput_Struct_free(s);
QRinput_free(input);
free(str);
}
void test_struct_singlestructure(void)
{
QRinput *input;
QRinput_Struct *s;
char *str = "TEST";
testStart("Testing structured-append symbols. (single structure)");
input = QRinput_new2(10, QR_ECLEVEL_H);
QRinput_append(input, QR_MODE_AN, strlen(str), (unsigned char *)str);
s = QRinput_splitQRinputToStruct(input);
assert_nonnull(s, "must return a code.");
assert_equal(s->size, 1, "size must be 1, but %d returned.", s->size);
if(s->size != 1) {
printQRinputStruct(s);
}
testFinish();
if(s != NULL) QRinput_Struct_free(s);
QRinput_free(input);
}
void test_splitentry(void)
{
QRinput *i1, *i2;
QRinput_List *e;
const char *str = "abcdefghij";
int size1, size2, i;
unsigned char *d1, *d2;
testStart("Testing QRinput_splitEntry. (next == NULL)");
i1 = QRinput_new();
QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
i2 = QRinput_dup(i1);
e = i2->head;
e = i2->head;
QRinput_splitEntry(e, 4);
size1 = size2 = 0;
e = i1->head;
while(e != NULL) {
size1 += e->size;
e = e->next;
}
e = i2->head;
while(e != NULL) {
size2 += e->size;
e = e->next;
}
d1 = (unsigned char *)malloc(size1);
e = i1->head;
i = 0;
while(e != NULL) {
memcpy(&d1[i], e->data, e->size);
i += e->size;
e = e->next;
}
d2 = (unsigned char *)malloc(size2);
e = i2->head;
i = 0;
while(e != NULL) {
memcpy(&d2[i], e->data, e->size);
i += e->size;
e = e->next;
}
assert_equal(size1, size2, "sizes are different. (%d:%d)\n", size1, size2);
assert_equal(i2->head->size, 4, "split failed (first half)");
assert_equal(i2->head->next->size, 6, "split failed(second half)");
assert_zero(memcmp(d1, d2, size1), "strings are different.");
QRinput_free(i1);
QRinput_free(i2);
free(d1);
free(d2);
testFinish();
}
void test_splitentry2(void)
{
QRinput *i1, *i2;
QRinput_List *e;
const char *str = "abcdefghij";
int size1, size2, i;
unsigned char *d1, *d2;
testStart("Testing QRinput_splitEntry. (next != NULL)");
i1 = QRinput_new();
QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
QRinput_append(i1, QR_MODE_8, strlen(str), (unsigned char *)str);
i2 = QRinput_dup(i1);
e = i2->head;
e = i2->head;
QRinput_splitEntry(e, 4);
size1 = size2 = 0;
e = i1->head;
while(e != NULL) {
size1 += e->size;
e = e->next;
}
e = i2->head;
while(e != NULL) {
size2 += e->size;
e = e->next;
}
d1 = (unsigned char *)malloc(size1);
e = i1->head;
i = 0;
while(e != NULL) {
memcpy(&d1[i], e->data, e->size);
i += e->size;
e = e->next;
}
d2 = (unsigned char *)malloc(size2);
e = i2->head;
i = 0;
while(e != NULL) {
memcpy(&d2[i], e->data, e->size);
i += e->size;
e = e->next;
}
assert_equal(size1, size2, "sizes are different. (%d:%d)\n", size1, size2);
assert_equal(i2->head->size, 4, "split failed (first half)");
assert_equal(i2->head->next->size, 6, "split failed(second half)");
assert_zero(memcmp(d1, d2, size1), "strings are different.");
QRinput_free(i1);
QRinput_free(i2);
free(d1);
free(d2);
testFinish();
}
void test_splitentry3(void)
{
QRinput *input;
QRinput_Struct *s;
QRinput_List *e00, *e01, *e10, *e11;
QRinput_InputList *list;
const char *str = "abcdefghijklmno";
testStart("Testing QRinput_splitEntry. (does not split an entry)");
/* version 1 symbol contains 152 bit (19 byte) data.
* 20 bits for a structured-append header, so 132 bits can be used.
* 15 bytes of 8-bit data is suitable for the symbol.
* (mode(4) + length(8) + data(120) == 132.)
*/
input = QRinput_new2(1, QR_ECLEVEL_L);
QRinput_append(input, QR_MODE_8, strlen(str), (unsigned char *)str);
QRinput_append(input, QR_MODE_8, strlen(str), (unsigned char *)str);
s = QRinput_splitQRinputToStruct(input);
list = s->head;
e00 = list->input->head;
e01 = e00->next;
list = list->next;
e10 = list->input->head;
e11 = e10->next;
assert_equal(e00->mode, QR_MODE_STRUCTURE, "Structure header is missing?");
assert_equal(e01->mode, QR_MODE_8, "no data?!");
assert_null(e01->next, "Input list is not terminated!\n");
assert_equal(e10->mode, QR_MODE_STRUCTURE, "Structure header is missing?");
assert_equal(e11->mode, QR_MODE_8, "no data?!");
assert_null(e11->next, "Input list is not terminated!\n");
QRinput_free(input);
QRinput_Struct_free(s);
testFinish();
}
void test_parity(void)
{
QRinput *input;
QRinput_Struct *s;
const char *text = "an example of four Structured Append symbols,";
const char *str[4] = {
"an example ",
"of four Str",
"uctured Appe",
"nd symbols,"};
unsigned char p1, p2;
int i, len;
testStart("Testing parity calc.");
s = QRinput_Struct_new();
for(i=0; i<4; i++) {
input = QRinput_new2(1, QR_ECLEVEL_M);
QRinput_append(input, QR_MODE_8, strlen(str[i]), (unsigned char *)str[i]);
QRinput_Struct_appendInput(s, input);
}
QRinput_Struct_insertStructuredAppendHeaders(s);
p1 = s->parity;
p2 = 0;
len = strlen(text);
for(i=0; i<len; i++) {
p2 ^= text[i];
}
assert_equal(p1, p2, "Parity numbers didn't match. (%02x should be %02x).\n", p1, p2);
testFinish();
QRinput_Struct_free(s);
}
void test_parity2(void)
{
QRinput *input;
QRinput_Struct *s;
const char *text = "an example of four Structured Append symbols,";
unsigned char p1, p2;
int i, len;
testStart("Testing parity calc.(split)");
input = QRinput_new2(1, QR_ECLEVEL_L);
QRinput_append(input, QR_MODE_8, strlen(text), (unsigned char *)text);
s = QRinput_splitQRinputToStruct(input);
p1 = s->parity;
p2 = 0;
len = strlen(text);
for(i=0; i<len; i++) {
p2 ^= text[i];
}
assert_equal(p1, p2, "Parity numbers didn't match. (%02x should be %02x).\n", p1, p2);
testFinish();
QRinput_free(input);
QRinput_Struct_free(s);
}
void test_null_free(void)
{
testStart("Testing free NULL pointers");
assert_nothing(QRinput_free(NULL), "Check QRinput_free(NULL).\n");
assert_nothing(QRinput_Struct_free(NULL), "Check QRinput_Struct_free(NULL).\n");
testFinish();
}
void test_mqr_new(void)
{
QRinput *input;
testStart("Testing QRinput_newMQR().");
input = QRinput_newMQR(0, QR_ECLEVEL_L);
assert_null(input, "Version 0 passed.\n");
QRinput_free(input);
input = QRinput_newMQR(5, QR_ECLEVEL_L);
assert_null(input, "Version 5 passed.\n");
QRinput_free(input);
input = QRinput_newMQR(1, QR_ECLEVEL_M);
assert_null(input, "Invalid ECLEVEL passed.\n");
QRinput_free(input);
input = QRinput_newMQR(1, QR_ECLEVEL_L);
assert_equal(input->version, 1, "QRinput.version was not as expected.\n");
assert_equal(input->level, QR_ECLEVEL_L, "QRinput.version was not as expected.\n");
QRinput_free(input);
testFinish();
}
void test_mqr_setversion(void)
{
QRinput *input;
int ret;
testStart("Testing QRinput_setVersion() for MQR.");
input = QRinput_newMQR(1, QR_ECLEVEL_L);
ret = QRinput_setVersion(input, 2);
assert_exp((ret < 0), "QRinput_setVersion should be denied.\n");
QRinput_free(input);
testFinish();
}
void test_mqr_setlevel(void)
{
QRinput *input;
int ret;
testStart("Testing QRinput_setErrorCorrectionLevel() for MQR.");
input = QRinput_newMQR(1, QR_ECLEVEL_L);
ret = QRinput_setErrorCorrectionLevel(input, QR_ECLEVEL_M);
assert_exp((ret < 0), "QRinput_setErrorCorrectionLevel should be denied.\n");
QRinput_free(input);
testFinish();
}
void test_paddingMQR(void)
{
char *dataM1[] = {"65", "513", "5139", "51365"};
char *correctM1[] = {"01010000010000000000",
"01110000000010000000",
"10010000000011001000",
"10110000000011000001"};
char *dataM2[] = {"513513", "51351365"};
char *correctM2[] = {"0 0110 1000000001 1000000001 0000000",
"0 1000 1000000001 1000000001 1000001"};
int i, ret;
testStart("Padding bit check of MQR. (only 0 padding)");
for(i=0; i<4; i++) {
ret = encodeAndCheckBStream(1, 1, QR_ECLEVEL_L, QR_MODE_NUM, dataM1[i], correctM1[i]);
assert_zero(ret, "Number %s incorrectly encoded.\n", dataM1[i]);
}
for(i=0; i<2; i++) {
ret = encodeAndCheckBStream(1, 2, QR_ECLEVEL_M, QR_MODE_NUM, dataM2[i], correctM2[i]);
assert_zero(ret, "Number %s incorrectly encoded.\n", dataM2[i]);
}
testFinish();
}
void test_padding2MQR(void)
{
char *data[] = {"9", "513513", "513", "513"};
int ver[] = {1, 2, 2, 3};
char *correct[] = {"00110010 00000000 0000",
"0 0110 1000000001 1000000001 0000000 11101100",
"0 0011 1000000001 000000000 11101100 00010001",
"00 00011 1000000001 0000000 11101100 00010001 11101100 00010001 11101100 00010001 11101100 0000"
};
int i, ret;
testStart("Padding bit check. (1 or 2 padding bytes)");
for(i=0; i<4; i++) {
ret = encodeAndCheckBStream(1, ver[i], QR_ECLEVEL_L, QR_MODE_NUM, data[i], correct[i]);
assert_zero(ret, "Number %s incorrectly encoded.\n", data[i]);
}
testFinish();
}
void test_textMQR(void)
{
int version = 3;
QRecLevel level = QR_ECLEVEL_M;
char *str = "MICROQR";
char *correct = {"01 0111 01111110000 01000110111 10001010010 011011 0000000 0000 11101100 0000"};
int ret;
testStart("Text encoding (Micro QR)");
ret = encodeAndCheckBStream(1, version, level, QR_MODE_AN, str, correct);
assert_zero(ret, "AlphaNumeric string '%s' incorrectly encoded.\n", str);
testFinish();
}
void test_ECIinvalid(void)
{
QRinput *stream;
int ret;
testStart("Appending invalid ECI header");
stream = QRinput_new();
ret = QRinput_appendECIheader(stream, 999999);
assert_zero(ret, "Valid ECI header rejected.");
ret = QRinput_appendECIheader(stream, 1000000);
assert_nonzero(ret, "Invalid ECI header accepted.");
QRinput_free(stream);
testFinish();
}
void test_encodeECI(void)
{
QRinput *input;
BitStream *bstream;
unsigned char str[] = {0xa1, 0xa2, 0xa3, 0xa4, 0xa5};
char *correct = "0111 00001001 0100 00000101 10100001 10100010 10100011 10100100 10100101";
int ret;
testStart("Encoding characters with ECI header.");
input = QRinput_new();
ret = QRinput_appendECIheader(input, 9);
assert_zero(ret, "Valid ECI header rejected.\n");
ret = QRinput_append(input, QR_MODE_8, 5, str);
assert_zero(ret, "Failed to append characters.\n");
bstream = QRinput_mergeBitStream(input);
assert_nonnull(bstream, "Failed to merge.\n");
if(bstream != NULL) {
ret = ncmpBin(correct, bstream, 64);
assert_zero(ret, "Encodation of ECI header was invalid.\n");
BitStream_free(bstream);
}
QRinput_free(input);
testFinish();
}
int main(void)
{
test_encodeNumeric();
test_encodeNumeric2();
test_encodeNumeric3();
test_encodeNumeric_versionup();
test_encode8();
test_encode8_versionup();
test_encodeTooLong();
test_encodeAn();
test_encodeAn2();
test_encodeKanji();
test_encodeNumericPadded();
test_encodeNumericPadded2();
test_encodeAnNum();
test_padding();
test_padding2();
test_struct_listop();
test_insertStructuredAppendHeader();
test_insertStructuredAppendHeader_error();
test_struct_insertStructuredAppendHeaders();
test_lengthOfCode_num();
test_splitentry();
test_splitentry2();
test_splitentry3();
test_struct_split_example();
test_struct_split_tooLarge();
test_struct_split_invalidVersion();
test_struct_singlestructure();
test_parity();
test_parity2();
test_null_free();
test_mqr_new();
test_mqr_setversion();
test_mqr_setlevel();
test_paddingMQR();
test_padding2MQR();
test_textMQR();
test_ECIinvalid();
test_encodeECI();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_qrinput.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 8,050
|
```c
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "../qrencode_inner.h"
#include "../qrinput.h"
#include "../rscode.h"
/* See pp. 73 of JIS X0510:2004 */
void test_rscode1(void)
{
QRinput *stream;
QRRawCode *code;
static const char str[9] = "01234567";
static unsigned char correct[26] = {
0x10, 0x20, 0x0c, 0x56, 0x61, 0x80, 0xec, 0x11, 0xec, 0x11, 0xec, 0x11,
0xec, 0x11, 0xec, 0x11, 0xa5, 0x24, 0xd4, 0xc1, 0xed, 0x36, 0xc7, 0x87,
0x2c, 0x55};
testStart("RS ecc test");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)str);
QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_M);
code = QRraw_new(stream);
testEnd(memcmp(correct + 16, code->rsblock[0].ecc, 10));
QRinput_free(stream);
QRraw_free(code);
}
int main(void)
{
test_rscode1();
free_rs_cache();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_rs.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 333
|
```c
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <SDL.h>
#include <getopt.h>
#include <errno.h>
#include "../config.h"
#include "../qrspec.h"
#include "../qrinput.h"
#include "../split.h"
#include "../qrencode_inner.h"
static SDL_Surface *screen = NULL;
static int casesensitive = 1;
static int eightbit = 0;
static int version = 1;
static int size = 4;
static int margin = 4;
static int structured = 0;
static int micro = 0;
static QRecLevel level = QR_ECLEVEL_L;
static QRencodeMode hint = QR_MODE_8;
static char **textv;
static int textc;
static const struct option options[] = {
{"help" , no_argument , NULL, 'h'},
{"level" , required_argument, NULL, 'l'},
{"size" , required_argument, NULL, 's'},
{"symversion" , required_argument, NULL, 'v'},
{"margin" , required_argument, NULL, 'm'},
{"structured" , no_argument , NULL, 'S'},
{"kanji" , no_argument , NULL, 'k'},
{"casesensitive", no_argument , NULL, 'c'},
{"ignorecase" , no_argument , NULL, 'i'},
{"8bit" , no_argument , NULL, '8'},
{"micro" , no_argument , NULL, 'M'},
{"version" , no_argument , NULL, 'V'},
{NULL, 0, NULL, 0}
};
static char *optstring = "hl:s:v:m:Skci8MV";
static char levelChar[4] = {'L', 'M', 'Q', 'H'};
static void usage(int help, int longopt)
{
fprintf(stderr,
"view_qrcode version %s\n"
if(help) {
if(longopt) {
fprintf(stderr,
"Usage: view_qrcode [OPTION]... [STRING]\n"
"Encode input data in a QR Code and display.\n\n"
" -h, --help display the help message. -h displays only the help of short\n"
" options.\n\n"
" -s NUMBER, --size=NUMBER\n"
" specify module size in dots (pixels). (default=3)\n\n"
" -l {LMQH}, --level={LMQH}\n"
" specify error correction level from L (lowest) to H (highest).\n"
" (default=L)\n\n"
" -v NUMBER, --symversion=NUMBER\n"
" specify the version of the symbol. (default=auto)\n\n"
" -m NUMBER, --margin=NUMBER\n"
" specify the width of the margins. (default=4)\n\n"
" -S, --structured\n"
" make structured symbols. Version must be specified.\n\n"
" -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
" -c, --casesensitive\n"
" encode lower-case alphabet characters in 8-bit mode. (default)\n\n"
" -i, --ignorecase\n"
" ignore case distinctions and use only upper-case characters.\n\n"
" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
" -M, --micro encode in a Micro QR Code. (experimental)\n\n"
" -V, --version\n"
" display the version number and copyrights of the qrencode.\n\n"
" [STRING] input data. If it is not specified, data will be taken from\n"
" standard input.\n"
);
} else {
fprintf(stderr,
"Usage: view_qrcode [OPTION]... [STRING]\n"
"Encode input data in a QR Code and display.\n\n"
" -h display this message.\n"
" --help display the usage of long options.\n"
" -s NUMBER specify module size in dots (pixels). (default=3)\n"
" -l {LMQH} specify error correction level from L (lowest) to H (highest).\n"
" (default=L)\n"
" -v NUMBER specify the version of the symbol. (default=auto)\n"
" -m NUMBER specify the width of the margins. (default=4)\n"
" -S make structured symbols. Version must be specified.\n"
" -k assume that the input text contains kanji (shift-jis).\n"
" -c encode lower-case alphabet characters in 8-bit mode. (default)\n"
" -i ignore case distinctions and use only upper-case characters.\n"
" -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
" -M encode in a Micro QR Code.\n"
" -V display the version number and copyrights of the qrencode.\n"
" [STRING] input data. If it is not specified, data will be taken from\n"
" standard input.\n"
);
}
}
}
#define MAX_DATA_SIZE (7090 * 16) /* from the specification */
static unsigned char *readStdin(int *length)
{
unsigned char *buffer;
int ret;
buffer = (unsigned char *)malloc(MAX_DATA_SIZE + 1);
if(buffer == NULL) {
fprintf(stderr, "Memory allocation failed.\n");
exit(EXIT_FAILURE);
}
ret = fread(buffer, 1, MAX_DATA_SIZE, stdin);
if(ret == 0) {
fprintf(stderr, "No input data.\n");
exit(EXIT_FAILURE);
}
if(feof(stdin) == 0) {
fprintf(stderr, "Input data is too large.\n");
exit(EXIT_FAILURE);
}
buffer[ret] = '\0';
*length = ret;
return buffer;
}
static void draw_QRcode(QRcode *qrcode, int ox, int oy)
{
int x, y, width;
unsigned char *p;
SDL_Rect rect;
ox += margin * size;
oy += margin * size;
width = qrcode->width;
p = qrcode->data;
for(y=0; y<width; y++) {
for(x=0; x<width; x++) {
rect.x = ox + x * size;
rect.y = oy + y * size;
rect.w = size;
rect.h = size;
SDL_FillRect(screen, &rect, (*p&1)?0:0xffffff);
p++;
}
}
}
void draw_singleQRcode(QRinput *stream, int mask)
{
QRcode *qrcode;
int width;
QRinput_setVersionAndErrorCorrectionLevel(stream, version, level);
if(micro) {
qrcode = QRcode_encodeMaskMQR(stream, mask);
} else {
qrcode = QRcode_encodeMask(stream, mask);
}
if(qrcode == NULL) {
width = (11 + margin * 2) * size;
fprintf(stderr, "Input data does not fit to this setting.\n");
} else {
version = qrcode->version;
width = (qrcode->width + margin * 2) * size;
}
screen = SDL_SetVideoMode(width, width, 32, 0);
SDL_FillRect(screen, NULL, 0xffffff);
if(qrcode) {
draw_QRcode(qrcode, 0, 0);
}
SDL_Flip(screen);
QRcode_free(qrcode);
}
void draw_structuredQRcode(QRinput_Struct *s)
{
int i, w, h, n, x, y;
int swidth;
QRcode_List *qrcodes, *p;
qrcodes = QRcode_encodeInputStructured(s);
if(qrcodes == NULL) return;
swidth = (qrcodes->code->width + margin * 2) * size;
n = QRcode_List_size(qrcodes);
w = (n < 4)?n:4;
h = (n - 1) / 4 + 1;
screen = SDL_SetVideoMode(swidth * w, swidth * h, 32, 0);
SDL_FillRect(screen, NULL, 0xffffff);
p = qrcodes;
for(i=0; i<n; i++) {
x = (i % 4) * swidth;
y = (i / 4) * swidth;
draw_QRcode(p->code, x, y);
p = p->next;
}
SDL_Flip(screen);
QRcode_List_free(qrcodes);
}
void draw_structuredQRcodeFromText(int argc, char **argv)
{
QRinput_Struct *s;
QRinput *input;
int i, ret;
s = QRinput_Struct_new();
if(s == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
for(i=0; i<argc; i++) {
input = QRinput_new2(version, level);
if(input == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
if(eightbit) {
ret = QRinput_append(input, QR_MODE_8, strlen(argv[i]), (unsigned char *)argv[i]);
} else {
ret = Split_splitStringToQRinput(argv[i], input, hint, casesensitive);
}
if(ret < 0) {
perror("Encoding the input string");
exit(EXIT_FAILURE);
}
ret = QRinput_Struct_appendInput(s, input);
if(ret < 0) {
perror("Encoding the input string");
exit(EXIT_FAILURE);
}
}
ret = QRinput_Struct_insertStructuredAppendHeaders(s);
if(ret < 0) {
fprintf(stderr, "Too many inputs.\n");
}
draw_structuredQRcode(s);
QRinput_Struct_free(s);
}
void draw_structuredQRcodeFromQRinput(QRinput *stream)
{
QRinput_Struct *s;
QRinput_setVersion(stream, version);
QRinput_setErrorCorrectionLevel(stream, level);
s = QRinput_splitQRinputToStruct(stream);
if(s != NULL) {
draw_structuredQRcode(s);
QRinput_Struct_free(s);
} else {
fprintf(stderr, "Input data is too large for this setting.\n");
}
}
void view(int mode, QRinput *input)
{
int flag = 1;
int mask = -1;
SDL_Event event;
int loop;
while(flag) {
if(mode) {
draw_structuredQRcodeFromText(textc, textv);
} else {
if(structured) {
draw_structuredQRcodeFromQRinput(input);
} else {
draw_singleQRcode(input, mask);
}
}
if(mode || structured) {
printf("Version %d, Level %c.\n", version, levelChar[level]);
} else {
printf("Version %d, Level %c, Mask %d.\n", version, levelChar[level], mask);
}
loop = 1;
while(loop) {
usleep(10000);
while(SDL_PollEvent(&event)) {
if(event.type == SDL_KEYDOWN) {
switch(event.key.keysym.sym) {
case SDLK_RIGHT:
version++;
if(version > QRSPEC_VERSION_MAX)
version = QRSPEC_VERSION_MAX;
loop = 0;
break;
case SDLK_LEFT:
version--;
if(version < 1)
version = 1;
loop = 0;
break;
case SDLK_UP:
size++;
loop = 0;
break;
case SDLK_DOWN:
size--;
if(size < 1) size = 1;
loop = 0;
break;
case SDLK_0:
case SDLK_1:
case SDLK_2:
case SDLK_3:
case SDLK_4:
case SDLK_5:
case SDLK_6:
case SDLK_7:
if(!mode && !structured) {
mask = (event.key.keysym.sym - SDLK_0);
loop = 0;
}
break;
case SDLK_8:
if(!mode && !structured) {
mask = -1;
loop = 0;
}
break;
case SDLK_l:
level = QR_ECLEVEL_L;
loop = 0;
break;
case SDLK_m:
level = QR_ECLEVEL_M;
loop = 0;
break;
case SDLK_h:
level = QR_ECLEVEL_H;
loop = 0;
break;
case SDLK_q:
level = QR_ECLEVEL_Q;
loop = 0;
break;
case SDLK_ESCAPE:
loop = 0;
flag = 0;
break;
default:
break;
}
}
if(event.type == SDL_QUIT) {
loop = 0;
flag = 0;
}
}
}
}
}
void view_simple(const unsigned char *str, int length)
{
QRinput *input;
int ret;
if(micro) {
input = QRinput_newMQR(version, level);
} else {
input = QRinput_new2(version, level);
}
if(input == NULL) {
fprintf(stderr, "Memory allocation error.\n");
exit(EXIT_FAILURE);
}
if(eightbit) {
ret = QRinput_append(input, QR_MODE_8, length, str);
} else {
ret = Split_splitStringToQRinput((char *)str, input, hint, casesensitive);
}
if(ret < 0) {
perror("Encoding the input string");
exit(EXIT_FAILURE);
}
view(0, input);
QRinput_free(input);
}
void view_multiText(char **argv, int argc)
{
textc = argc;
textv = argv;
view(1, NULL);
}
int main(int argc, char **argv)
{
int opt, lindex = -1;
unsigned char *intext = NULL;
int length = 0;
while((opt = getopt_long(argc, argv, optstring, options, &lindex)) != -1) {
switch(opt) {
case 'h':
if(lindex == 0) {
usage(1, 1);
} else {
usage(1, 0);
}
exit(EXIT_SUCCESS);
break;
case 's':
size = atoi(optarg);
if(size <= 0) {
fprintf(stderr, "Invalid size: %d\n", size);
exit(EXIT_FAILURE);
}
break;
case 'v':
version = atoi(optarg);
if(version < 0) {
fprintf(stderr, "Invalid version: %d\n", version);
exit(EXIT_FAILURE);
}
break;
case 'l':
switch(*optarg) {
case 'l':
case 'L':
level = QR_ECLEVEL_L;
break;
case 'm':
case 'M':
level = QR_ECLEVEL_M;
break;
case 'q':
case 'Q':
level = QR_ECLEVEL_Q;
break;
case 'h':
case 'H':
level = QR_ECLEVEL_H;
break;
default:
fprintf(stderr, "Invalid level: %s\n", optarg);
exit(EXIT_FAILURE);
break;
}
break;
case 'm':
margin = atoi(optarg);
if(margin < 0) {
fprintf(stderr, "Invalid margin: %d\n", margin);
exit(EXIT_FAILURE);
}
break;
case 'S':
structured = 1;
case 'k':
hint = QR_MODE_KANJI;
break;
case 'c':
casesensitive = 1;
break;
case 'i':
casesensitive = 0;
break;
case '8':
eightbit = 1;
break;
case 'M':
micro = 1;
break;
case 'V':
usage(0, 0);
exit(EXIT_SUCCESS);
break;
default:
fprintf(stderr, "Try `view_qrcode --help' for more information.\n");
exit(EXIT_FAILURE);
break;
}
}
if(argc == 1) {
usage(1, 0);
exit(EXIT_SUCCESS);
}
if(optind < argc) {
intext = (unsigned char *)argv[optind];
length = strlen((char *)intext);
}
if(intext == NULL) {
intext = readStdin(&length);
}
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Failed initializing SDL: %s\n", SDL_GetError());
return -1;
}
if(structured && version < 1) {
fprintf(stderr, "Version number must be greater than 0 to encode structured symbols.\n");
exit(EXIT_FAILURE);
}
if(structured && (argc - optind > 1)) {
view_multiText(argv + optind, argc - optind);
} else {
view_simple(intext, length);
}
SDL_Quit();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/view_qrcode.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 3,798
|
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iconv.h>
#include "../qrspec.h"
#include "../bitstream.h"
#include "../mask.h"
#include "../mqrspec.h"
#include "../mmask.h"
#include "decoder.h"
static unsigned int bitToInt(unsigned char *bits, int length)
{
int i;
unsigned int val = 0;
for(i=0; i<length; i++) {
val = val << 1;
val |= (bits[i] & 1);
}
return val;
}
DataChunk *DataChunk_new(QRencodeMode mode)
{
DataChunk *chunk;
chunk = (DataChunk *)calloc(1, sizeof(DataChunk));
if(chunk == NULL) return NULL;
chunk->mode = mode;
return chunk;
}
void DataChunk_free(DataChunk *chunk)
{
if(chunk) {
if(chunk->data) free(chunk->data);
free(chunk);
}
}
static int decodeLength(int *bits_length, unsigned char **bits, QRencodeMode mode, int version, int mqr)
{
int i;
int length = 0;
int lbits;
if(mqr) {
lbits = MQRspec_lengthIndicator(mode, version);
} else {
lbits = QRspec_lengthIndicator(mode, version);
}
if(*bits_length < lbits) {
printf("Bit length is too short: %d\n", *bits_length);
return 0;
}
length = 0;
for(i=0; i<lbits; i++) {
length = length << 1;
length += (*bits)[i];
}
*bits_length -= lbits;
*bits += lbits;
return length;
}
static DataChunk *decodeNum(int *bits_length, unsigned char **bits, int version, int mqr)
{
int i;
int size, sizeInBit, words, remain;
unsigned char *p;
char *buf, *q;
unsigned int val;
DataChunk *chunk;
size = decodeLength(bits_length, bits, QR_MODE_NUM, version, mqr);
if(size < 0) return NULL;
words = size / 3;
remain = size - words * 3;
sizeInBit = words * 10;
if(remain == 2) {
sizeInBit += 7;
} else if(remain == 1) {
sizeInBit += 4;
}
if(*bits_length < sizeInBit) {
printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit);
return NULL;
}
buf = (char *)malloc(size + 1);
p = *bits;
q = buf;
for(i=0; i<words; i++) {
val = bitToInt(p, 10);
sprintf(q, "%03d", val);
p += 10;
q += 3;
}
if(remain == 2) {
val = bitToInt(p, 7);
sprintf(q, "%02d", val);
} else if(remain == 1) {
val = bitToInt(p, 4);
sprintf(q, "%1d", val);
}
buf[size] = '\0';
chunk = DataChunk_new(QR_MODE_NUM);
chunk->size = size;
chunk->data = (unsigned char *)buf;
*bits_length -= sizeInBit;
*bits += sizeInBit;
return chunk;
}
static const char decodeAnTable[45] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*',
'+', '-', '.', '/', ':'
};
static DataChunk *decodeAn(int *bits_length, unsigned char **bits, int version, int mqr)
{
int i;
int size, sizeInBit, words, remain;
unsigned char *p;
char *buf, *q;
unsigned int val;
int ch, cl;
DataChunk *chunk;
size = decodeLength(bits_length, bits, QR_MODE_AN, version, mqr);
if(size < 0) return NULL;
words = size / 2;
remain = size - words * 2;
sizeInBit = words * 11 + remain * 6;
if(*bits_length < sizeInBit) {
printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit);
return NULL;
}
buf = (char *)malloc(size + 1);
p = *bits;
q = buf;
for(i=0; i<words; i++) {
val = bitToInt(p, 11);
ch = val / 45;
cl = val % 45;
sprintf(q, "%c%c", decodeAnTable[ch], decodeAnTable[cl]);
p += 11;
q += 2;
}
if(remain == 1) {
val = bitToInt(p, 6);
sprintf(q, "%c", decodeAnTable[val]);
}
chunk = DataChunk_new(QR_MODE_AN);
chunk->size = size;
chunk->data = (unsigned char *)buf;
*bits_length -= sizeInBit;
*bits += sizeInBit;
return chunk;
}
static DataChunk *decode8(int *bits_length, unsigned char **bits, int version, int mqr)
{
int i;
int size, sizeInBit;
unsigned char *p;
unsigned char *buf, *q;
DataChunk *chunk;
size = decodeLength(bits_length, bits, QR_MODE_8, version, mqr);
if(size < 0) return NULL;
sizeInBit = size * 8;
if(*bits_length < sizeInBit) {
printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit);
return NULL;
}
buf = (unsigned char *)malloc(size);
p = *bits;
q = buf;
for(i=0; i<size; i++) {
*q = (unsigned char)bitToInt(p, 8);
p += 8;
q += 1;
}
chunk = DataChunk_new(QR_MODE_8);
chunk->size = size;
chunk->data = buf;
*bits_length -= sizeInBit;
*bits += sizeInBit;
return chunk;
}
static DataChunk *decodeKanji(int *bits_length, unsigned char **bits, int version, int mqr)
{
int i;
int size, sizeInBit;
unsigned char *p;
char *buf, *q;
unsigned int val;
int ch, cl;
DataChunk *chunk;
size = decodeLength(bits_length, bits, QR_MODE_KANJI, version, mqr);
if(size < 0) return NULL;
sizeInBit = size * 13;
if(*bits_length < sizeInBit) {
printf("Bit length is too short: %d, expected %d.\n", *bits_length, sizeInBit);
return NULL;
}
buf = (char *)malloc(size * 2 + 1);
p = *bits;
q = buf;
for(i=0; i<size; i++) {
val = bitToInt(p, 13);
ch = val / 0xc0;
cl = val - ch * 0xc0;
val = ch * 256 + cl;
if(val >= 0x1f00) {
val += 0xc140;
} else {
val += 0x8140;
}
sprintf(q, "%c%c", (val>>8) & 0xff, val & 0xff);
p += 13;
q += 2;
}
chunk = DataChunk_new(QR_MODE_KANJI);
chunk->size = size * 2;
chunk->data = (unsigned char *)buf;
*bits_length -= sizeInBit;
*bits += sizeInBit;
return chunk;
}
static DataChunk *decodeChunk(int *bits_length, unsigned char **bits, int version)
{
int val;
if(*bits_length < 4) {
return NULL;
}
val = bitToInt(*bits, 4);;
*bits_length -= 4;
*bits += 4;
switch(val) {
case 0:
return NULL;
case 1:
return decodeNum(bits_length, bits, version, 0);
case 2:
return decodeAn(bits_length, bits, version, 0);
case 4:
return decode8(bits_length, bits, version, 0);
case 8:
return decodeKanji(bits_length, bits, version, 0);
default:
break;
}
printf("Invalid mode in a chunk: %d\n", val);
return NULL;
}
static DataChunk *decodeChunkMQR(int *bits_length, unsigned char **bits, int version)
{
int modebits, termbits;
unsigned int val;
modebits = version - 1;
termbits = version * 2 + 1;
if(*bits_length >= termbits) {
val = bitToInt(*bits, termbits);
if(val == 0) {
*bits += termbits;
*bits_length -= termbits;
return NULL;
}
} else {
if(*bits_length < modebits) {
val = bitToInt(*bits, *bits_length);
} else {
val = bitToInt(*bits, modebits);
}
if(val == 0) {
return NULL;
} else {
printf("Terminating bits include 1-bit.\n");
return NULL;
}
}
val = bitToInt(*bits, modebits);
if(version == 4 && val > 3) {
printf("Invalid mode number %d.\n", val);
}
*bits_length -= modebits;
*bits += modebits;
switch(val) {
case 0:
return decodeNum(bits_length, bits, version, 1);
case 1:
return decodeAn(bits_length, bits, version, 1);
case 2:
return decode8(bits_length, bits, version, 1);
case 3:
return decodeKanji(bits_length, bits, version, 1);
default:
break;
}
printf("Invalid mode in a chunk: %d\n", val);
return NULL;
}
void dumpNum(DataChunk *chunk)
{
printf("%s\n", chunk->data);
}
void dumpAn(DataChunk *chunk)
{
printf("%s\n", chunk->data);
}
void dump8(DataChunk *chunk)
{
int i, j;
unsigned char c;
int count = 0;
unsigned char buf[16];
for(i=0; i<chunk->size; i++) {
buf[count] = chunk->data[i];
c = chunk->data[i];
if(c >= ' ' && c <= '~') {
putchar(c);
} else {
putchar('.');
}
count++;
if(count >= 16) {
putchar(' ');
for(j=0; j<16; j++) {
printf(" %02x", buf[j]);
}
count = 0;
putchar('\n');
}
}
if(count > 0) {
for(i=0; i<16 - count; i++) {
putchar(' ');
}
putchar(' ');
for(j=0; j<count; j++) {
printf(" %02x", buf[j]);
}
count = 0;
putchar('\n');
}
}
void dumpKanji(DataChunk *chunk)
{
iconv_t conv;
char *inbuf, *outbuf, *outp;
size_t inbytes, outbytes, ret;
conv = iconv_open("UTF-8", "SHIFT_JIS");
inbytes = chunk->size;
inbuf = (char *)chunk->data;
outbytes = inbytes * 4 + 1;
outbuf = (char *)malloc(inbytes * 4 + 1);
outp = outbuf;
ret = iconv(conv, &inbuf, &inbytes, &outp, &outbytes);
if(ret == (size_t) -1) { perror(NULL); }
*outp = '\0';
printf("%s\n", outbuf);
iconv_close(conv);
free(outbuf);
}
static void dumpChunk(DataChunk *chunk)
{
switch(chunk->mode) {
case QR_MODE_NUM:
printf("Numeric: %d bytes\n", chunk->size);
dumpNum(chunk);
break;
case QR_MODE_AN:
printf("AlphaNumeric: %d bytes\n", chunk->size);
dumpAn(chunk);
break;
case QR_MODE_8:
printf("8-bit data: %d bytes\n", chunk->size);
dump8(chunk);
break;
case QR_MODE_KANJI:
printf("Kanji: %d bytes\n", chunk->size);
dumpKanji(chunk);
break;
default:
printf("Invalid or reserved: %d bytes\n", chunk->size);
dump8(chunk);
break;
}
}
void dumpChunks(QRdata *qrdata)
{
DataChunk *chunk;
chunk = qrdata->chunks;
while(chunk != NULL) {
dumpChunk(chunk);
chunk = chunk->next;
}
}
void QRdata_concatChunks(QRdata *qrdata)
{
int idx;
unsigned char *data;
DataChunk *chunk;
int size = 0;
chunk = qrdata->chunks;
while(chunk != NULL) {
size += chunk->size;
chunk = chunk->next;
}
if(size <= 0) {
return;
}
data = malloc(size + 1);
chunk = qrdata->chunks;
idx = 0;
while(chunk != NULL) {
memcpy(&data[idx], chunk->data, chunk->size);
idx += chunk->size;
chunk = chunk->next;
}
data[size] = '\0';
qrdata->size = size;
qrdata->data = data;
}
int appendChunk(QRdata *qrdata, int *bits_length, unsigned char **bits)
{
DataChunk *chunk;
if(qrdata->mqr) {
chunk = decodeChunkMQR(bits_length, bits, qrdata->version);
} else {
chunk = decodeChunk(bits_length, bits, qrdata->version);
}
if(chunk == NULL) {
return 1;
}
if(qrdata->last == NULL) {
qrdata->chunks = chunk;
} else {
qrdata->last->next = chunk;
}
qrdata->last = chunk;
return 0;
}
QRdata *QRdata_new(void)
{
QRdata *qrdata;
qrdata = (QRdata *)calloc(sizeof(QRdata), 1);
if(qrdata == NULL) return NULL;
return qrdata;
}
QRdata *QRdata_newMQR(void)
{
QRdata *qrdata;
qrdata = (QRdata *)calloc(sizeof(QRdata), 1);
if(qrdata == NULL) return NULL;
qrdata->mqr = 1;
return qrdata;
}
void QRdata_free(QRdata *qrdata)
{
DataChunk *chunk, *next;
chunk = qrdata->chunks;
while(chunk != NULL) {
next = chunk->next;
DataChunk_free(chunk);
chunk = next;
}
if(qrdata->data != NULL) {
free(qrdata->data);
}
free(qrdata);
}
static int QRdata_decodeBits(QRdata *qrdata, int length, unsigned char *bits)
{
int ret = 0;
while(ret == 0) {
ret = appendChunk(qrdata, &length, &bits);
}
return length;
}
int QRdata_decodeBitStream(QRdata *qrdata, BitStream *bstream)
{
return QRdata_decodeBits(qrdata, bstream->length, bstream->data);
}
void QRdata_dump(QRdata *data)
{
dumpChunks(data);
}
unsigned int QRcode_decodeVersion(QRcode *code)
{
unsigned int v1, v2;
int x, y, width;
unsigned char *p;
width = code->width;
if(width < 45) {
return (width - 21)/ 4 + 1;
}
v1 = 0;
p = code->data + width * (width - 9) + 5;
for(x=0; x<6; x++) {
for(y=0; y<3; y++) {
v1 = v1 << 1;
v1 |= *(p - y * width - x) & 1;
}
}
v2 = 0;
p = code->data + width * 5 + width - 9;
for(y=0; y<6; y++) {
for(x=0; x<3; x++) {
v2 = v2 << 1;
v2 |= *(p - y * width - x) & 1;
}
}
if(v1 != v2) {
printf("Two verion patterns are different.\n");
return -1;
}
return v1 >> 12;
}
int QRcode_decodeFormat(QRcode *code, QRecLevel *level, int *mask)
{
unsigned int v1, v2;
int i, width;
unsigned char *p;
width = code->width;
v1 = 0;
p = code->data + width * 8;
for(i=0; i<8; i++) {
v1 = v1 << 1;
if(i < 6) {
v1 |= *(p + i) & 1;
} else {
v1 |= *(p + i + 1) & 1;
}
}
p = code->data + width * 7 + 8;
for(i=0; i<7; i++) {
v1 = v1 << 1;
if(i < 1) {
v1 |= *(p - width * i) & 1;
} else {
v1 |= *(p - width * (i + 1)) & 1;
}
}
v2 = 0;
p = code->data + width * (width - 1) + 8;
for(i=0; i<7; i++) {
v2 = v2 << 1;
v2 |= *(p - width * i) & 1;
}
p = code->data + width * 8 + width - 8;
for(i=0; i<8; i++) {
v2 = v2 << 1;
v2 |= *(p + i) & 1;
}
if(v1 != v2) {
printf("Two format infos are different.\n");
return -1;
}
v1 = (v1 ^ 0x5412) >> 10;
*mask = v1 & 7;
switch((v1 >> 3) & 3) {
case 1:
*level = QR_ECLEVEL_L;
break;
case 0:
*level = QR_ECLEVEL_M;
break;
case 3:
*level = QR_ECLEVEL_Q;
break;
case 2:
*level = QR_ECLEVEL_H;
break;
default:
break;
}
return 0;
}
static unsigned char *unmask(QRcode *code, QRecLevel level, int mask)
{
unsigned char *unmasked;
unmasked = Mask_makeMask(code->width, code->data, mask, level);
return unmasked;
}
unsigned char *QRcode_unmask(QRcode *code)
{
int ret, version, mask;
QRecLevel level;
version = QRcode_decodeVersion(code);
if(version < 1) return NULL;
ret = QRcode_decodeFormat(code, &level, &mask);
if(ret < 0) return NULL;
return unmask(code, level, mask);
}
typedef struct {
int width;
unsigned char *frame;
int x, y;
int dir;
int bit;
int mqr;
} FrameFiller;
static FrameFiller *FrameFiller_new(int width, unsigned char *frame, int mqr)
{
FrameFiller *filler;
filler = (FrameFiller *)malloc(sizeof(FrameFiller));
if(filler == NULL) return NULL;
filler->width = width;
filler->frame = frame;
filler->x = width - 1;
filler->y = width - 1;
filler->dir = -1;
filler->bit = -1;
filler->mqr = mqr;
return filler;
}
static unsigned char *FrameFiller_next(FrameFiller *filler)
{
unsigned char *p;
int x, y, w;
if(filler->bit == -1) {
filler->bit = 0;
return filler->frame + filler->y * filler->width + filler->x;
}
x = filler->x;
y = filler->y;
p = filler->frame;
w = filler->width;
if(filler->bit == 0) {
x--;
filler->bit++;
} else {
x++;
y += filler->dir;
filler->bit--;
}
if(filler->dir < 0) {
if(y < 0) {
y = 0;
x -= 2;
filler->dir = 1;
if(!filler->mqr && x == 6) {
x--;
y = 9;
}
}
} else {
if(y == w) {
y = w - 1;
x -= 2;
filler->dir = -1;
if(!filler->mqr && x == 6) {
x--;
y -= 8;
}
}
}
if(x < 0 || y < 0) return NULL;
filler->x = x;
filler->y = y;
if(p[y * w + x] & 0x80) {
// This tail recursion could be optimized.
return FrameFiller_next(filler);
}
return &p[y * w + x];
}
static unsigned char *extractBits(int width, unsigned char *frame, int spec[5])
{
unsigned char *bits, *p, *q;
FrameFiller *filler;
int i, j;
int col, row, d1, b1, blocks, idx, words;
blocks = QRspec_rsBlockNum(spec);
words = QRspec_rsDataLength(spec);
d1 = QRspec_rsDataCodes1(spec);
b1 = QRspec_rsBlockNum1(spec);
bits = (unsigned char *)malloc(words * 8);
/*
* 00 01 02 03 04 05 06 07 08 09
* 10 11 12 13 14 15 16 17 18 19
* 20 21 22 23 24 25 26 27 28 29 30
* 31 32 33 34 35 36 37 38 39 40 41
* 42 43 44 45 46 47 48 49 50 51 52
*/
row = col = 0;
filler = FrameFiller_new(width, frame, 0);
for(i=0; i<words; i++) {
col = i / blocks;
row = i % blocks + ((col >= d1)?b1:0);
idx = d1 * row + col + ((row > b1)?(row-b1):0);
q = bits + idx * 8;
for(j=0; j<8; j++) {
p = FrameFiller_next(filler);
q[j] = *p & 1;
}
}
free(filler);
return bits;
}
unsigned char *QRcode_extractBits(QRcode *code, int *length)
{
unsigned char *unmasked, *bits;
int spec[5];
int ret, version, mask;
QRecLevel level;
version = QRcode_decodeVersion(code);
if(version < 1) return NULL;
ret = QRcode_decodeFormat(code, &level, &mask);
if(ret < 0) return NULL;
QRspec_getEccSpec(version, level, spec);
*length = QRspec_rsDataLength(spec) * 8;
unmasked = unmask(code, level, mask);
if(unmasked == NULL) return NULL;
bits = extractBits(code->width, unmasked, spec);
free(unmasked);
return bits;
}
static void printBits(int length, unsigned char *bits)
{
int i;
for(i=0; i<length; i++) {
putchar((bits[i]&1)?'1':'0');
}
putchar('\n');
}
static int checkRemainderWords(int length, unsigned char *bits, int remainder)
{
int rbits, words;
unsigned char *p, v;
int i;
words = remainder / 8;
rbits = remainder - words * 8;
bits += (length - remainder);
for(i=0; i<rbits; i++) {
if((bits[i]&1) != 0) {
printf("Terminating code includes 1-bit.\n");
printBits(remainder, bits);
return -1;
}
}
p = bits + rbits;
for(i=0; i<words; i++) {
v = (unsigned char)bitToInt(p, 8);
if(v != ((i&1)?0x11:0xec)) {
printf("Remainder codewords wrong.\n");
printBits(remainder, bits);
return -1;
}
p += 8;
}
return 0;
}
QRdata *QRcode_decodeBits(QRcode *code)
{
unsigned char *unmasked, *bits;
int spec[5];
int ret, version, mask;
int length;
QRecLevel level;
QRdata *qrdata;
version = QRcode_decodeVersion(code);
if(version < 1) return NULL;
ret = QRcode_decodeFormat(code, &level, &mask);
if(ret < 0) return NULL;
QRspec_getEccSpec(version, level, spec);
length = QRspec_rsDataLength(spec) * 8;
unmasked = unmask(code, level, mask);
if(unmasked == NULL) return NULL;
bits = extractBits(code->width, unmasked, spec);
free(unmasked);
qrdata = QRdata_new();
qrdata->version = version;
qrdata->level = level;
ret = QRdata_decodeBits(qrdata, length, bits);
if(ret > 0) {
checkRemainderWords(length, bits, ret);
}
free(bits);
return qrdata;
}
QRdata *QRcode_decode(QRcode *code)
{
QRdata *qrdata;
qrdata = QRcode_decodeBits(code);
QRdata_concatChunks(qrdata);
return qrdata;
}
/*
* Micro QR Code decoder
*/
struct FormatInfo MQRformat[] = {
{1, QR_ECLEVEL_L},
{2, QR_ECLEVEL_L},
{2, QR_ECLEVEL_M},
{3, QR_ECLEVEL_L},
{3, QR_ECLEVEL_M},
{4, QR_ECLEVEL_L},
{4, QR_ECLEVEL_M},
{4, QR_ECLEVEL_Q}
};
int QRcode_decodeFormatMQR(QRcode *code, int *version, QRecLevel *level, int *mask)
{
unsigned int v, t;
int i, width;
unsigned char *p;
width = code->width;
v = 0;
p = code->data + width * 8 + 1;
for(i=0; i<8; i++) {
v = v << 1;
v |= p[i] & 1;
}
p = code->data + width * 7 + 8;
for(i=0; i<7; i++) {
v = v << 1;
v |= *(p - width * i) & 1;
}
v ^= 0x4445;
*mask = (v >> 10) & 3;
t = (v >> 12) & 7;
*version = MQRformat[t].version;
*level = MQRformat[t].level;
if(*version * 2 + 9 != width) {
printf("Decoded version number does not match to the size.\n");
return -1;
}
return 0;
}
static unsigned char *unmaskMQR(QRcode *code, QRecLevel level, int mask)
{
unsigned char *unmasked;
unmasked = MMask_makeMask(code->version, code->data, mask, level);
return unmasked;
}
unsigned char *QRcode_unmaskMQR(QRcode *code)
{
int ret, version, mask;
QRecLevel level;
ret = QRcode_decodeFormatMQR(code, &version, &level, &mask);
if(ret < 0) return NULL;
return unmaskMQR(code, level, mask);
}
static unsigned char *extractBitsMQR(int width, unsigned char *frame, int version, QRecLevel level)
{
unsigned char *bits;
FrameFiller *filler;
int i;
int size;
size = MQRspec_getDataLengthBit(version, level);
bits = (unsigned char *)malloc(size);
filler = FrameFiller_new(width, frame, 1);
for(i=0; i<size; i++) {
bits[i] = *(FrameFiller_next(filler)) & 1;
}
free(filler);
return bits;
}
unsigned char *MQRcode_extractBits(QRcode *code, int *length)
{
unsigned char *unmasked, *bits;
int ret, version, mask;
QRecLevel level;
ret = QRcode_decodeFormatMQR(code, &version, &level, &mask);
if(ret < 0) return NULL;
unmasked = unmaskMQR(code, level, mask);
if(unmasked == NULL) return NULL;
*length = MQRspec_getDataLengthBit(version, level);
bits = extractBitsMQR(code->width, unmasked, version, level);
free(unmasked);
return bits;
}
static int checkRemainderWordsMQR(int length, unsigned char *bits, int remainder, int version)
{
int rbits, words, paddings;
unsigned char *p, v;
int i, decoded;
decoded = length - remainder;
bits += decoded;
words = (decoded + 7) / 8;
rbits = words * 8 - decoded;
for(i=0; i<rbits; i++) {
if((bits[i]&1) != 0) {
printf("Terminating code includes 1-bit.\n");
printBits(remainder, bits);
return -1;
}
}
paddings = (length - words * 8) / 8;
p = bits + rbits;
for(i=0; i<paddings; i++) {
v = (unsigned char)bitToInt(p, 8);
if(v != ((i&1)?0x11:0xec)) {
printf("Remainder codewords wrong.\n");
printBits(remainder, bits);
return -1;
}
p += 8;
}
rbits = length - (paddings + words)* 8;
if(rbits > 0) {
if((version == 1 || version == 3) && rbits == 4) {
v = (unsigned char)bitToInt(p, 4);
if(v != 0) {
printf("Last padding bits include 1-bit.\n");
return -1;
}
} else {
printf("The length of the last padding bits is %d, not %d.\n", rbits, (version == 1 || version == 3)?4:0);
return -1;
}
}
return 0;
}
QRdata *QRcode_decodeBitsMQR(QRcode *code)
{
unsigned char *unmasked, *bits;
int ret, version, mask;
int length;
QRecLevel level;
QRdata *qrdata;
ret = QRcode_decodeFormatMQR(code, &version, &level, &mask);
if(ret < 0) return NULL;
unmasked = unmaskMQR(code, level, mask);
if(unmasked == NULL) return NULL;
length = MQRspec_getDataLengthBit(version, level);
bits = extractBitsMQR(code->width, unmasked, version, level);
free(unmasked);
qrdata = QRdata_newMQR();
qrdata->version = version;
qrdata->level = level;
ret = QRdata_decodeBits(qrdata, length, bits);
if(ret > 0) {
checkRemainderWordsMQR(length, bits, ret, version);
}
free(bits);
return qrdata;
}
QRdata *QRcode_decodeMQR(QRcode *code)
{
QRdata *qrdata;
qrdata = QRcode_decodeBitsMQR(code);
QRdata_concatChunks(qrdata);
return qrdata;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/decoder.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 7,360
|
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "../qrinput.h"
QRinput *gstream;
void test_numbit(void)
{
QRinput *stream;
char num[9]="01234567";
int bits;
testStart("Estimation of Numeric stream (8 digits)");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
bits = QRinput_estimateBitStreamSize(stream, 0);
testEndExp(bits == 41);
QRinput_append(gstream, QR_MODE_NUM, 8, (unsigned char *)num);
QRinput_free(stream);
}
void test_numbit2(void)
{
QRinput *stream;
char num[17]="0123456789012345";
int bits;
testStart("Estimation of Numeric stream (16 digits)");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num);
bits = QRinput_estimateBitStreamSize(stream, 0);
testEndExp(bits == 68);
QRinput_append(gstream, QR_MODE_NUM, 16, (unsigned char *)num);
QRinput_free(stream);
}
void test_numbit3(void)
{
QRinput *stream;
char *num;
int bits;
testStart("Estimation of Numeric stream (400 digits)");
stream = QRinput_new();
num = (char *)malloc(401);
memset(num, '1', 400);
num[400] = '\0';
QRinput_append(stream, QR_MODE_NUM, 400, (unsigned char *)num);
bits = QRinput_estimateBitStreamSize(stream, 0);
/* 4 + 10 + 133*10 + 4 = 1348 */
testEndExp(bits == 1348);
QRinput_append(gstream, QR_MODE_NUM, 400, (unsigned char *)num);
QRinput_free(stream);
free(num);
}
void test_an(void)
{
QRinput *stream;
char str[6]="AC-42";
int bits;
testStart("Estimation of Alphabet-Numeric stream (5 chars)");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str);
bits = QRinput_estimateBitStreamSize(stream, 0);
testEndExp(bits == 41);
QRinput_append(gstream, QR_MODE_AN, 5, (unsigned char *)str);
QRinput_free(stream);
}
void test_8(void)
{
QRinput *stream;
char str[9]="12345678";
int bits;
testStart("Estimation of 8 bit data stream (8 bytes)");
stream = QRinput_new();
QRinput_append(stream, QR_MODE_8, 8, (unsigned char *)str);
bits = QRinput_estimateBitStreamSize(stream, 0);
testEndExp(bits == 76);
QRinput_append(gstream, QR_MODE_8, 8, (unsigned char *)str);
QRinput_free(stream);
}
void test_structure(void)
{
QRinput *stream;
int bits;
testStart("Estimation of a structure-append header");
stream = QRinput_new();
QRinput_insertStructuredAppendHeader(stream, 10, 1, 0);
bits = QRinput_estimateBitStreamSize(stream, 1);
testEndExp(bits == 20);
QRinput_insertStructuredAppendHeader(gstream, 10, 1, 0);
QRinput_free(stream);
}
void test_kanji(void)
{
int res;
QRinput *stream;
unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa};
int bits;
testStart("Estimation of Kanji stream (2 chars)");
stream = QRinput_new();
res = QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str);
if(res < 0) {
printf("Failed to add.\n");
testEnd(1);
} else {
bits = QRinput_estimateBitStreamSize(stream, 0);
testEndExp(bits == 38);
QRinput_append(gstream, QR_MODE_KANJI, 4, (unsigned char *)str);
}
QRinput_free(stream);
}
void test_mix(void)
{
int bits;
testStart("Estimation of Mixed stream");
bits = QRinput_estimateBitStreamSize(gstream, 0);
testEndExp(bits == (41 + 68 + 1348 + 41 + 76 + 38 + 20));
QRinput_free(gstream);
}
int main(void)
{
gstream = QRinput_new();
test_numbit();
test_numbit2();
test_numbit3();
test_an();
test_8();
test_kanji();
test_structure();
test_mix();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_estimatebit.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,033
|
```c
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "../mqrspec.h"
unsigned char v4frame[] = {
0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,0x91,0x90,0x91,0x90,0x91,0x90,0x91,0x90,0x91,
0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xc1,0xc0,0xc1,0xc1,0xc1,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xc1,0xc0,0xc0,0xc0,0xc0,0xc0,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x91,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x91,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void test_newFrame(void)
{
int width, i, y;
unsigned char *frame;
testStart("Test empty frames");
for(i=1; i<MQRSPEC_VERSION_MAX; i++) {
frame = MQRspec_newFrame(i);
width = MQRspec_getWidth(i);
for(y=0; y<width; y++) {
assert_zero(memcmp(&frame[y * width], &v4frame[y * MQRSPEC_WIDTH_MAX], width), "Mismatch found in version %d, line %d.\n", i, y);
}
free(frame);
}
testFinish();
}
void test_newframe_invalid(void)
{
unsigned char *frame;
testStart("Checking MQRspec_newFrame with invalid version.");
frame = MQRspec_newFrame(0);
assert_null(frame, "MQRspec_newFrame(0) returns non-NULL.");
frame = MQRspec_newFrame(MQRSPEC_VERSION_MAX+1);
assert_null(frame, "MQRspec_newFrame(0) returns non-NULL.");
testFinish();
}
/* See Table 10 (pp.115) of Appendix 1, JIS X0510:2004 */
static unsigned int calcFormatInfo(int type, int mask)
{
unsigned int data, ecc, b, code;
int i, c;
data = (type << 12) | (mask << 10);
ecc = data;
b = 1 << 14;
for(i=0; b != 0; i++) {
if(ecc & b) break;
b = b >> 1;
}
c = 4 - i;
code = 0x537 << c ; //10100110111
b = 1 << (10 + c);
for(i=0; i<=c; i++) {
if(b & ecc) {
ecc ^= code;
}
code = code >> 1;
b = b >> 1;
}
return (data | ecc) ^ 0x4445;
}
/* See Table 10 of Appendix 1. (pp.115) */
static const int typeTable[4][3] = {
{ 0, -1, -1},
{ 1, 2, -1},
{ 3, 4, -1},
{ 5, 6, 7}
};
void test_format(void)
{
unsigned int format;
int version, l, mask;
int type;
int err = 0;
testStart("Format info test");
for(version=1; version<=4; version++) {
for(l=0; l<3; l++) {
for(mask=0; mask<4; mask++) {
format = MQRspec_getFormatInfo(mask, version, (QRecLevel)l);
type = typeTable[version - 1][l];
if(type == -1) {
if(format != 0) {
printf("Error in version %d, level %d, mask %d\n",
version, l, mask);
err++;
}
} else {
if(format != calcFormatInfo(type, mask)) {
printf("Error in version %d, level %d, mask %d\n",
version, l, mask);
err++;
}
}
}
}
}
testEnd(err);
}
void print_format(void)
{
unsigned int format;
int i, j;
for(i=0; i<4; i++) {
for(j=0; j<8; j++) {
format = calcFormatInfo(j, i);
printf("0x%04x, ", format);
}
printf("\n");
}
}
/**
* See Table 7 of Appendix 1.
*/
int datalen[4][3] = {
{ 20, 0, 0},
{ 40, 32, 0},
{ 84, 68, 0},
{128, 112, 80},
};
void test_dataLength(void)
{
int v, l;
int bits;
int err = 0;
testStart("Test dataLength");
for(v=0; v<4; v++) {
for(l=0; l<3; l++) {
bits = MQRspec_getDataLengthBit(v+1, (QRecLevel)l);
if(bits != datalen[v][l]) {
printf("Error in version %d, level %d.\n", v, l);
err++;
}
}
}
testEnd(err);
}
int main(void)
{
test_newFrame();
test_newframe_invalid();
//print_format();
test_format();
test_dataLength();
MQRspec_clearCache();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_mqrspec.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,228
|
```c
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "../mmask.h"
#include "../mqrspec.h"
char dot[2] = {'_', '#'};
static char *maskPatterns[4] = {
/* i mod 2 = 0 */
"######"
"______"
"######"
"______"
"######"
"______",
/* ((i div 2) + (j div 3)) mod 2 = 0 */
"###___"
"###___"
"___###"
"___###"
"###___"
"###___",
/* ((ij) mod 2 + (ij) mod 3) mod 2 = 0 */
"######"
"###___"
"##_##_"
"#_#_#_"
"#_##_#"
"#___##",
/* ((ij) mod 3 + (i+j) mod 2) mod 2 = 0 */
"#_#_#_"
"___###"
"#___##"
"_#_#_#"
"###___"
"_###__"
};
void print_mask(int mask)
{
const int w = 6;
unsigned char frame[w * w], *masked, *p;
int x, y;
memset(frame, 0, w * w);
masked = MMask_makeMaskedFrame(w, frame, mask);
p = masked;
for(y=0; y<w; y++) {
for(x=0; x<w; x++) {
putchar(dot[*p&1]);
p++;
}
printf("\n");
}
printf("\n");
free(masked);
}
void print_masks(void)
{
int i;
for(i=0; i<4; i++) {
print_mask(i);
}
}
int test_mask(int mask)
{
const int w = 6;
unsigned char frame[w * w], *masked, *p;
char *q;
int x, y;
int err = 0;
memset(frame, 0, w * w);
masked = MMask_makeMaskedFrame(w, frame, mask);
p = masked;
q = maskPatterns[mask];
for(y=0; y<w; y++) {
for(x=0; x<w; x++) {
if(dot[*p&1] != *q) {
err++;
}
p++;
q++;
}
}
free(masked);
return err;
}
void test_masks(void)
{
int i;
testStart("Mask pattern checks");
for(i=0; i<4; i++) {
assert_zero(test_mask(i), "Mask pattern %d incorrect.\n", i);
}
testFinish();
}
void test_maskEvaluation(void)
{
static const int w = 11;
unsigned char pattern[w*w];
int i, score;
memset(pattern, 0, w*w);
testStart("Test mask evaluation");
score = MMask_evaluateSymbol(w, pattern);
assert_equal(score, 0, "Mask score caluculation is incorrect. (score=%d (%d expected)\n", score, 0);
for(i=0; i<w; i++) {
pattern[(w-1) * w + i] = 1;
}
score = MMask_evaluateSymbol(w, pattern);
assert_equal(score, 16 + w - 1, "Mask score caluculation is incorrect. (score=%d) (%d expected)\n", score, 16 + w - 1);
for(i=0; i<w; i++) {
pattern[(w-1) * w + i] = 0;
pattern[i * w + w - 1] = 1;
}
score = MMask_evaluateSymbol(w, pattern);
assert_equal(score, 16 + w - 1, "Mask score caluculation is incorrect. (score=%d) (%d expected)\n", score, 16 + w - 1);
for(i=0; i<w; i++) {
pattern[(w-1) * w + i] = 1;
pattern[i * w + w - 1] = 1;
}
score = MMask_evaluateSymbol(w, pattern);
assert_equal(score, 16 * (w - 1) + w - 1, "Mask score caluculation is incorrect. (score=%d) (%d expected)\n", score, 16 * (w - 1) + w - 1);
testFinish();
}
int main(void)
{
//print_masks();
test_masks();
test_maskEvaluation();
report();
MQRspec_clearCache();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_mmask.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,003
|
```c
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include "../qrencode.h"
struct timeval tv;
void timerStart(const char *str)
{
printf("%s: START\n", str);
gettimeofday(&tv, NULL);
}
void timerStop(void)
{
struct timeval tc;
gettimeofday(&tc, NULL);
printf("STOP: %ld msec\n", (tc.tv_sec - tv.tv_sec) * 1000
+ (tc.tv_usec - tv.tv_usec) / 1000);
}
void prof_ver1to10(void)
{
QRcode *code;
int i;
int version;
static const char *data = "This is test.";
timerStart("Version 1 - 10 (500 symbols for each)");
for(i=0; i<500; i++) {
for(version = 0; version < 11; version++) {
code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
if(code == NULL) {
perror("Failed to encode:");
} else {
QRcode_free(code);
}
}
}
timerStop();
}
void prof_ver31to40(void)
{
QRcode *code;
int i;
int version;
static const char *data = "This is test.";
timerStart("Version 31 - 40 (50 symbols for each)");
for(i=0; i<50; i++) {
for(version = 31; version < 41; version++) {
code = QRcode_encodeString(data, version, QR_ECLEVEL_L, QR_MODE_8, 0);
if(code == NULL) {
perror("Failed to encode:");
} else {
QRcode_free(code);
}
}
}
timerStop();
}
int main(void)
{
prof_ver1to10();
prof_ver31to40();
QRcode_clearCache();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/prof_qrencode.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 426
|
```c
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "../qrspec.h"
#include "../qrencode_inner.h"
#include "decoder.h"
void print_eccTable(void)
{
int i, j;
int ecc;
int data;
int spec[5];
for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
printf("Version %2d\n", i);
for(j=0; j<4; j++) {
QRspec_getEccSpec(i, (QRecLevel)j, spec);
data = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec)
+ QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec);
ecc = QRspec_rsBlockNum1(spec) * QRspec_rsEccCodes1(spec)
+ QRspec_rsBlockNum2(spec) * QRspec_rsEccCodes2(spec);
printf("%3d\t", data);
printf("%3d\t", ecc);
printf("%2d\t", QRspec_rsBlockNum1(spec));
printf("(%3d, %3d, %3d)\n",
QRspec_rsDataCodes1(spec) + QRspec_rsEccCodes1(spec),
QRspec_rsDataCodes1(spec),
QRspec_rsEccCodes1(spec));
if(QRspec_rsBlockNum2(spec) > 0) {
printf("\t%2d\t", QRspec_rsBlockNum2(spec));
printf("(%3d, %3d, %3d)\n",
QRspec_rsDataCodes2(spec) + QRspec_rsEccCodes2(spec),
QRspec_rsDataCodes2(spec),
QRspec_rsEccCodes2(spec));
}
}
}
}
void test_eccTable(void)
{
int i, j;
int ecc;
int data;
int err = 0;
int spec[5];
testStart("Checking ECC table.");
for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
for(j=0; j<4; j++) {
QRspec_getEccSpec(i, (QRecLevel)j, spec);
data = QRspec_rsBlockNum1(spec) * QRspec_rsDataCodes1(spec)
+ QRspec_rsBlockNum2(spec) * QRspec_rsDataCodes2(spec);
ecc = QRspec_rsBlockNum1(spec) * QRspec_rsEccCodes1(spec)
+ QRspec_rsBlockNum2(spec) * QRspec_rsEccCodes2(spec);
if(data + ecc != QRspec_getDataLength(i, (QRecLevel)j) + QRspec_getECCLength(i, (QRecLevel)j)) {
printf("Error in version %d, level %d: invalid size\n", i, j);
printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[2]);
err++;
}
if(ecc != QRspec_getECCLength(i, (QRecLevel)j)) {
printf("Error in version %d, level %d: invalid data\n", i, j);
printf("%d %d %d %d %d %d\n", spec[0], spec[1], spec[2], spec[3], spec[4], spec[2]);
err++;
}
}
}
testEnd(err);
}
void test_eccTable2(void)
{
int i;
int spec[5];
const int correct[7][6] = {
{ 8, 1, 0, 2, 60, 38},
{ 8, 1, 1, 2, 61, 39},
{24, 2, 0, 11, 54, 24},
{24, 2, 1, 16, 55, 25},
{32, 0, 0, 17, 145, 115},
{40, 3, 0, 20, 45, 15},
{40, 3, 1, 61, 46, 16},
};
testStart("Checking ECC table(2)");
for(i=0; i<7; i++) {
QRspec_getEccSpec(correct[i][0], (QRecLevel)correct[i][1], spec);
if(correct[i][2] == 0) {
assert_equal(QRspec_rsBlockNum1(spec), correct[i][3],
"Error in version %d, level %d. rsBlockNum1 was %d, expected %d.\n",
correct[i][0], correct[i][1],
QRspec_rsBlockNum1(spec), correct[i][3]);
assert_equal(QRspec_rsDataCodes1(spec) + QRspec_rsEccCodes1(spec), correct[i][4],
"Error in version %d, level %d. rsDataCodes1 + rsEccCodes1 was %d, expected %d.\n",
correct[i][0], correct[i][1],
QRspec_rsDataCodes1(spec) + QRspec_rsEccCodes1(spec), correct[i][4]);
assert_equal(QRspec_rsDataCodes1(spec), correct[i][5],
"Error in version %d, level %d. rsDataCodes1 was %d, expected %d.\n",
correct[i][0], correct[i][1],
QRspec_rsDataCodes1(spec), correct[i][5]);
} else {
assert_equal(QRspec_rsBlockNum2(spec), correct[i][3],
"Error in version %d, level %d. rsBlockNum2 was %d, expected %d.\n",
correct[i][0], correct[i][1],
QRspec_rsBlockNum2(spec), correct[i][3]);
assert_equal(QRspec_rsDataCodes2(spec) + QRspec_rsEccCodes2(spec), correct[i][4],
"Error in version %d, level %d. rsDataCodes2 + rsEccCodes2 was %d, expected %d.\n",
correct[i][0], correct[i][1],
QRspec_rsDataCodes2(spec) + QRspec_rsEccCodes2(spec), correct[i][4]);
assert_equal(QRspec_rsDataCodes2(spec), correct[i][5],
"Error in version %d, level %d. rsDataCodes2 was %d, expected %d.\n",
correct[i][0], correct[i][1],
QRspec_rsDataCodes2(spec), correct[i][5]);
}
}
testFinish();
}
void test_newframe(void)
{
unsigned char buf[QRSPEC_WIDTH_MAX * QRSPEC_WIDTH_MAX];
int i, width;
size_t len;
FILE *fp;
unsigned char *frame;
QRcode *qrcode;
unsigned int version;
testStart("Checking newly created frame.");
fp = fopen("frame", "rb");
if(fp == NULL) {
perror("Failed to open \"frame\":");
abort();
}
for(i=1; i<=QRSPEC_VERSION_MAX; i++) {
frame = QRspec_newFrame(i);
width = QRspec_getWidth(i);
len = fread(buf, 1, width * width, fp);
if((int)len != width * width) {
perror("Failed to read the pattern file:");
abort();
}
assert_zero(memcmp(frame, buf, len), "frame pattern mismatch (version %d)\n", i);
qrcode = QRcode_new(i, width, frame);
version = QRcode_decodeVersion(qrcode);
assert_equal(version, i, "Decoded version number is wrong: %d, expected %d.\n", version, i);
QRcode_free(qrcode);
}
testFinish();
fclose(fp);
}
void test_newframe_invalid(void)
{
unsigned char *frame;
testStart("Checking QRspec_newFrame with invalid version.");
frame = QRspec_newFrame(0);
assert_null(frame, "QRspec_newFrame(0) returns non-NULL.");
frame = QRspec_newFrame(QRSPEC_VERSION_MAX+1);
assert_null(frame, "QRspec_newFrame(0) returns non-NULL.");
testFinish();
}
#if 0
/* This test is used to check positions of alignment pattern. See Appendix E
* (pp.71) of JIS X0510:2004 and compare to the output. Before comment out
* this test, change the value of the pattern marker's center dot from 0xa1
* to 0xb1 (QRspec_putAlignmentMarker() : finder).
*/
void test_alignment(void)
{
unsigned char *frame;
int i, x, y, width, c;
testStart("Checking alignment pattern.");
for(i=2; i<=QRSPEC_VERSION_MAX; i++) {
printf("%2d", i);
frame = QRspec_newFrame(i);
width = QRspec_getWidth(i);
c = 0;
for(x=0; x<width * width; x++) {
if(frame[x] == 0xb1) {
c++;
}
}
printf("|%2d| 6", c);
y = width - 7;
for(x=0; x < width; x++) {
if(frame[y * width + x] == 0xb1) {
printf(", %3d", x);
}
}
printf("\n");
free(frame);
}
testFinish();
}
#endif
void test_verpat(void)
{
int version;
unsigned int pattern;
int err = 0;
unsigned int data;
unsigned int code;
int i, c;
unsigned int mask;
for(version=7; version <= QRSPEC_VERSION_MAX; version++) {
pattern = QRspec_getVersionPattern(version);
if((pattern >> 12) != (unsigned int)version) {
printf("Error in version %d.\n", version);
err++;
continue;
}
mask = 0x40;
for(i=0; mask != 0; i++) {
if(version & mask) break;
mask = mask >> 1;
}
c = 6 - i;
data = version << 12;
code = 0x1f25 << c;
mask = 0x40000 >> (6 - c);
for(i=0; i<=c; i++) {
if(mask & data) {
data ^= code;
}
code = code >> 1;
mask = mask >> 1;
}
data = (version << 12) | (data & 0xfff);
if(data != pattern) {
printf("Error in version %d\n", version);
err++;
}
}
}
void print_newFrame(void)
{
int width;
int x, y;
unsigned char *frame;
frame = QRspec_newFrame(7);
width = QRspec_getWidth(7);
for(y=0; y<width; y++) {
for(x=0; x<width; x++) {
printf("%02x ", frame[y * width + x]);
}
printf("\n");
}
free(frame);
}
/* See Table 22 (pp.45) and Appendix C (pp. 65) of JIS X0510:2004 */
static unsigned int levelIndicator[4] = {1, 0, 3, 2};
static unsigned int calcFormatInfo(int mask, QRecLevel level)
{
unsigned int data, ecc, b, code;
int i, c;
data = (levelIndicator[level] << 13) | (mask << 10);
ecc = data;
b = 1 << 14;
for(i=0; b != 0; i++) {
if(ecc & b) break;
b = b >> 1;
}
c = 4 - i;
code = 0x537 << c ; //10100110111
b = 1 << (10 + c);
for(i=0; i<=c; i++) {
if(b & ecc) {
ecc ^= code;
}
code = code >> 1;
b = b >> 1;
}
return (data | ecc) ^ 0x5412;
}
void test_format(void)
{
unsigned int format;
int i, j;
int err = 0;
testStart("Format info test");
for(i=0; i<4; i++) {
for(j=0; j<8; j++) {
format = calcFormatInfo(j, (QRecLevel)i);
// printf("0x%04x, ", format);
if(format != QRspec_getFormatInfo(j, (QRecLevel)i)) {
printf("Level %d, mask %x\n", i, j);
err++;
}
}
// printf("\n");
}
testEnd(err);
}
int main(void)
{
test_eccTable();
test_eccTable2();
//print_eccTable();
test_newframe();
test_newframe_invalid();
//test_alignment();
test_verpat();
//print_newFrame();
test_format();
QRspec_clearCache();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_qrspec.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,904
|
```c
/*
* This tool creates a frame pattern data for debug purpose used by
* test_qrspec. test_qrspec and create_frame_pattern uses the same function
* of libqrencode. This means the test is meaningless if test_qrspec is run
* with a pattern data created by create_frame_pattern of the same version.
* In order to test it correctly, create a pattern data by the tool of the
* previous version, or use the frame data attached to the package.
*/
#include <stdio.h>
#include <string.h>
#include <png.h>
#include "common.h"
#include "../mqrspec.h"
void append_pattern(int version, FILE *fp)
{
int width;
unsigned char *frame;
frame = MQRspec_newFrame(version);
width = MQRspec_getWidth(version);
fwrite(frame, 1, width * width, fp);
free(frame);
}
static int writePNG(unsigned char *frame, int width, const char *outfile)
{
static FILE *fp;
png_structp png_ptr;
png_infop info_ptr;
unsigned char *row, *p, *q;
int x, y, xx, yy, bit;
int realwidth;
const int margin = 0;
const int size = 1;
realwidth = (width + margin * 2) * size;
row = (unsigned char *)malloc((realwidth + 7) / 8);
if(row == NULL) {
fprintf(stderr, "Failed to allocate memory.\n");
exit(EXIT_FAILURE);
}
if(outfile[0] == '-' && outfile[1] == '\0') {
fp = stdout;
} else {
fp = fopen(outfile, "wb");
if(fp == NULL) {
fprintf(stderr, "Failed to create file: %s\n", outfile);
perror(NULL);
exit(EXIT_FAILURE);
}
}
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(png_ptr == NULL) {
fclose(fp);
fprintf(stderr, "Failed to initialize PNG writer.\n");
exit(EXIT_FAILURE);
}
info_ptr = png_create_info_struct(png_ptr);
if(info_ptr == NULL) {
fclose(fp);
fprintf(stderr, "Failed to initialize PNG write.\n");
exit(EXIT_FAILURE);
}
if(setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
fprintf(stderr, "Failed to write PNG image.\n");
exit(EXIT_FAILURE);
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr,
realwidth, realwidth,
1,
PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr, info_ptr);
/* top margin */
memset(row, 0xff, (realwidth + 7) / 8);
for(y=0; y<margin * size; y++) {
png_write_row(png_ptr, row);
}
/* data */
p = frame;
for(y=0; y<width; y++) {
bit = 7;
memset(row, 0xff, (realwidth + 7) / 8);
q = row;
q += margin * size / 8;
bit = 7 - (margin * size % 8);
for(x=0; x<width; x++) {
for(xx=0; xx<size; xx++) {
*q ^= (*p & 1) << bit;
bit--;
if(bit < 0) {
q++;
bit = 7;
}
}
p++;
}
for(yy=0; yy<size; yy++) {
png_write_row(png_ptr, row);
}
}
/* bottom margin */
memset(row, 0xff, (realwidth + 7) / 8);
for(y=0; y<margin * size; y++) {
png_write_row(png_ptr, row);
}
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
free(row);
return 0;
}
void write_pattern_image(int version, const char *filename)
{
int width;
unsigned char *frame;
static char str[256];
frame = MQRspec_newFrame(version);
width = MQRspec_getWidth(version);
snprintf(str, 256, "%s-M%d.png", filename, version);
writePNG(frame, width, str);
free(frame);
}
void write_pattern(const char *filename)
{
FILE *fp;
int i;
fp = fopen(filename, "wb");
if(fp == NULL) {
perror("Failed to open a file to write:");
abort();
}
for(i=1; i<=MQRSPEC_VERSION_MAX; i++) {
append_pattern(i, fp);
write_pattern_image(i, filename);
}
fclose(fp);
}
int main(int argc, char **argv)
{
if(argc < 2) {
printf("Create empty frame patterns.\nUsage: %s FILENAME\n", argv[0]);
exit(0);
}
write_pattern(argv[1]);
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/create_mqr_frame_pattern.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,119
|
```c
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "../mask.h"
#include "../qrspec.h"
#include "decoder.h"
char dot[2] = {'_', '#'};
static char *maskPatterns[8] = {
/* (i + j) mod 2 = 0 */
"#_#_#_"
"_#_#_#"
"#_#_#_"
"_#_#_#"
"#_#_#_"
"_#_#_#",
/* i mod 2 = 0 */
"######"
"______"
"######"
"______"
"######"
"______",
/* j mod 3 = 0 */
"#__#__"
"#__#__"
"#__#__"
"#__#__"
"#__#__"
"#__#__",
/* (i + j) mod 3 = 0 */
"#__#__"
"__#__#"
"_#__#_"
"#__#__"
"__#__#"
"_#__#_",
/* ((i div 2) + (j div 3)) mod 2 = 0 */
"###___"
"###___"
"___###"
"___###"
"###___"
"###___",
/* (ij) mod 2 + (ij) mod 3 = 0 */
"######"
"#_____"
"#__#__"
"#_#_#_"
"#__#__"
"#_____",
/* ((ij) mod 2 + (ij) mod 3) mod 2 = 0 */
"######"
"###___"
"##_##_"
"#_#_#_"
"#_##_#"
"#___##",
/* ((ij) mod 3 + (i+j) mod 2) mod 2 = 0 */
"#_#_#_"
"___###"
"#___##"
"_#_#_#"
"###___"
"_###__"
};
void print_mask(int mask)
{
const int w = 6;
unsigned char frame[w * w], *masked, *p;
int x, y;
memset(frame, 0, w * w);
masked = Mask_makeMaskedFrame(w, frame, mask);
p = masked;
for(y=0; y<w; y++) {
for(x=0; x<w; x++) {
putchar(dot[*p&1]);
p++;
}
printf("\n");
}
printf("\n");
free(masked);
}
void print_masks(void)
{
int i;
for(i=0; i<8; i++) {
print_mask(i);
}
}
int test_mask(int mask)
{
const int w = 6;
unsigned char frame[w * w], *masked, *p;
char *q;
int x, y;
int err = 0;
memset(frame, 0, w * w);
masked = Mask_makeMaskedFrame(w, frame, mask);
p = masked;
q = maskPatterns[mask];
for(y=0; y<w; y++) {
for(x=0; x<w; x++) {
if(dot[*p&1] != *q) {
err++;
}
p++;
q++;
}
}
free(masked);
return err;
}
void test_masks(void)
{
int i;
testStart("Mask pattern checks");
for(i=0; i<8; i++) {
assert_zero(test_mask(i), "Mask pattern %d incorrect.\n", i);
}
testFinish();
}
#define N1 (3)
#define N2 (3)
#define N3 (40)
#define N4 (10)
void test_eval(void)
{
unsigned char *frame;
int w = 6;
int demerit;
frame = (unsigned char *)malloc(w * w);
testStart("Test mask evaluation (all white)");
memset(frame, 0, w * w);
demerit = Mask_evaluateSymbol(w, frame);
testEndExp(demerit == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1)));
testStart("Test mask evaluation (all black)");
memset(frame, 1, w * w);
demerit = Mask_evaluateSymbol(w, frame);
testEndExp(demerit == ((N1 + 1)*w*2 + N2 * (w - 1) * (w - 1)));
free(frame);
}
/* .#.#.#.#.#
* #.#.#.#.#.
* ..##..##..
* ##..##..##
* ...###...#
* ###...###.
* ....####..
* ####....##
* .....#####
* #####.....
*/
void test_eval2(void)
{
unsigned char *frame;
int w = 10;
int demerit;
int x;
frame = (unsigned char *)malloc(w * w);
testStart("Test mask evaluation (run length penalty check)");
for(x=0; x<w; x++) {
frame[ x] = x & 1;
frame[w + x] = (x & 1) ^ 1;
frame[w*2 + x] = (x / 2) & 1;
frame[w*3 + x] = ((x / 2) & 1) ^ 1;
frame[w*4 + x] = (x / 3) & 1;
frame[w*5 + x] = ((x / 3) & 1) ^ 1;
frame[w*6 + x] = (x / 4) & 1;
frame[w*7 + x] = ((x / 4) & 1) ^ 1;
frame[w*8 + x] = (x / 5) & 1;
frame[w*9 + x] = ((x / 5) & 1) ^ 1;
}
demerit = Mask_evaluateSymbol(w, frame);
testEndExp(demerit == N1 * 4 + N2 * 4);
free(frame);
}
void test_calcN2(void)
{
unsigned char frame[64];
int width;
int demerit;
int x, y;
testStart("Test mask evaluation (2x2 block check)");
width = 4;
for(y = 0; y < width; y++) {
for(x = 0; x < width; x++) {
frame[y * width + x] = ((x & 2) ^ (y & 2)) >> 1;
}
}
demerit = Mask_calcN2(width, frame);
assert_equal(demerit, N2 * 4, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 4);
width = 4;
for(y = 0; y < width; y++) {
for(x = 0; x < width; x++) {
frame[y * width + x] = (((x + 1) & 2) ^ (y & 2)) >> 1;
}
}
demerit = Mask_calcN2(width, frame);
assert_equal(demerit, N2 * 2, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 2);
width = 6;
for(y = 0; y < width; y++) {
for(x = 0; x < width; x++) {
frame[y * width + x] = (x / 3) ^ (y / 3);
}
}
demerit = Mask_calcN2(width, frame);
assert_equal(demerit, N2 * 16, "Calculation of N2 demerit is wrong: %d, expected %d", demerit, N2 * 16);
testFinish();
}
void test_eval3(void)
{
unsigned char *frame;
int w = 15;
int demerit;
int x, y;
static unsigned char pattern[7][15] = {
{0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0}, // N3x1
{1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1}, // N3x1
{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1}, // N3x1
{1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0}, // 0
{1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1}, // N3x2
{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0}, // N3 + (N1+1)
{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1} // (N1+1)
};
frame = (unsigned char *)malloc(w * w);
testStart("Test mask evaluation (1:1:3:1:1 check)");
for(y=0; y<5; y++) {
for(x=0; x<w; x++) {
frame[w*y*2 + x] = pattern[y][x];
frame[w*(y*2+1) + x] = pattern[y][x]^1;
}
}
for(x=0; x<w; x++) {
frame[w*10 + x] = x & 1;
}
for(y=5; y<7; y++) {
for(x=0; x<w; x++) {
frame[w*(y*2+1) + x] = pattern[y][x];
frame[w*(y*2+2) + x] = pattern[y][x]^1;
}
}
/*
for(y=0; y<w; y++) {
for(x=0; x<w; x++) {
printf("%s", frame[w*y+x]?"##":"..");
}
printf("\n");
}
*/
demerit = Mask_evaluateSymbol(w, frame);
testEndExp(demerit == N3 * 10 + (N1 + 1) * 4);
free(frame);
}
void test_format(void)
{
unsigned char *frame, *masked;
int version, mask, width, dmask;
QRecLevel level, dlevel;
QRcode *code;
int ret;
testStart("Checking format info.");
for(version=1; version<=QRSPEC_VERSION_MAX; version++) {
frame = QRspec_newFrame(version);
width = QRspec_getWidth(version);
for(level=0; level<4; level++) {
for(mask=0; mask<8; mask++) {
masked = Mask_makeMask(width, frame, mask, level);
code = QRcode_new(version, width, masked);
ret = QRcode_decodeFormat(code, &dlevel, &dmask);
assert_zero(ret, "Something wrong in format info.\n");
assert_equal(dlevel, level, "Decoded level is wrong: %d, expected %d", dlevel, level);
assert_equal(dmask, mask, "Decoded mask is wrong: %d, expected %d", dlevel, level);
QRcode_free(code);
}
}
free(frame);
}
testFinish();
}
void test_calcRunLength(void)
{
int width = 5;
unsigned char frame[width * width];
int runLength[width + 1];
int i, j;
int length;
static unsigned char pattern[6][5] = {
{0, 1, 0, 1, 0},
{1, 0, 1, 0, 1},
{0, 0, 0, 0, 0},
{1, 1, 1, 1, 1},
{0, 0, 1, 1, 1},
{1, 1, 0, 0, 0}
};
static int expected[6][7] = {
{ 1, 1, 1, 1, 1, 0, 5},
{-1, 1, 1, 1, 1, 1, 6},
{ 5, 0, 0, 0, 0, 0, 1},
{-1, 5, 0, 0, 0, 0, 2},
{ 2, 3, 0, 0, 0, 0, 2},
{-1, 2, 3, 0, 0, 0, 3}
};
testStart("Test runlength calc function");
for(i=0; i<6; i++) {
length = Mask_calcRunLength(width, pattern[i], 0, runLength);
assert_equal(expected[i][6], length, "Length incorrect: %d, expected %d.\n", length, expected[i][6]);
assert_zero(memcmp(runLength, expected[i], sizeof(int) * expected[i][6]), "Run length does not match: pattern %d, horizontal access.\n", i);
for(j=0; j<width; j++) {
frame[j * width] = pattern[i][j];
}
length = Mask_calcRunLength(width, frame, 1, runLength);
assert_equal(expected[i][6], length, "Length incorrect: %d, expected %d.\n", length, expected[i][6]);
assert_zero(memcmp(runLength, expected[i], sizeof(int) * expected[i][6]), "Run length does not match: pattern %d, vertical access.\n", i);
}
testFinish();
}
void test_calcN1N3(void)
{
int runLength[26];
int length;
int demerit;
int i;
static unsigned char pattern[][16] = {
{1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, N3},
{0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, N3},
{1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0},
{1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, N3},
{1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, N3},
{1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, N3 * 2},
};
static unsigned char pattern2[][19] = {
{1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, N3 + N1 + 1},
{0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, N3 + N1 + 1},
{1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, N1 + 1},
{1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, N3 + N1 + 1},
{1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, N3 + N1 + 1}
};
testStart("Test N3 penalty calculation");
for(i=0; i<6; i++) {
length = Mask_calcRunLength(15, pattern[i], 0, runLength);
demerit = Mask_calcN1N3(length, runLength);
assert_equal(pattern[i][15], demerit, "N3 penalty is wrong: %d, expected %d\n", demerit, pattern[i][15]);
}
for(i=0; i<5; i++) {
length = Mask_calcRunLength(18, pattern2[i], 0, runLength);
demerit = Mask_calcN1N3(length, runLength);
assert_equal(pattern2[i][18], demerit, "N3 penalty is wrong: %d, expected %d\n", demerit, pattern2[i][18]);
}
testFinish();
}
int main(void)
{
//print_masks();
test_masks();
test_eval();
test_eval2();
test_eval3();
test_format();
test_calcN2();
test_calcRunLength();
test_calcN1N3();
report();
QRspec_clearCache();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_mask.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 4,116
|
```c
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "../bitstream.h"
void test_null(void)
{
BitStream *bstream;
testStart("Empty stream");
bstream = BitStream_new();
assert_zero(BitStream_size(bstream), "Size of empty BitStream is not 0.\n");
assert_null(BitStream_toByte(bstream), "BitStream_toByte returned non-NULL.\n");
assert_nothing(BitStream_free(NULL), "Checking BitStream_free(NULL).\n");
testFinish();
BitStream_free(bstream);
}
void test_num(void)
{
BitStream *bstream;
unsigned int data = 0x13579bdf;
char correct[] = "0010011010101111001101111011111";
testStart("New from num");
bstream = BitStream_new();
BitStream_appendNum(bstream, 31, data);
testEnd(cmpBin(correct, bstream));
BitStream_free(bstream);
}
void test_bytes(void)
{
BitStream *bstream;
unsigned char data[1] = {0x3a};
char correct[] = "00111010";
testStart("New from bytes");
bstream = BitStream_new();
BitStream_appendBytes(bstream, 1, data);
testEnd(cmpBin(correct, bstream));
BitStream_free(bstream);
}
void test_appendNum(void)
{
BitStream *bstream;
char correct[] = "10001010 11111111 11111111 00010010001101000101011001111000";
testStart("Append Num");
bstream = BitStream_new();
BitStream_appendNum(bstream, 8, 0x0000008a);
assert_zero(ncmpBin(correct, bstream, 8), "Internal data is incorrect.\n");
BitStream_appendNum(bstream, 16, 0x0000ffff);
assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect.\n");
BitStream_appendNum(bstream, 32, 0x12345678);
assert_zero(cmpBin(correct, bstream), "Internal data is incorrect.\n");
testFinish();
BitStream_free(bstream);
}
void test_appendBytes(void)
{
BitStream *bstream;
unsigned char data[8];
char correct[] = "10001010111111111111111100010010001101000101011001111000";
testStart("Append Bytes");
bstream = BitStream_new();
data[0] = 0x8a;
BitStream_appendBytes(bstream, 1, data);
assert_zero(ncmpBin(correct, bstream, 8), "Internal data is incorrect.");
data[0] = 0xff;
data[1] = 0xff;
BitStream_appendBytes(bstream, 2, data);
assert_zero(ncmpBin(correct, bstream, 24), "Internal data is incorrect.\n");
data[0] = 0x12;
data[1] = 0x34;
data[2] = 0x56;
data[3] = 0x78;
BitStream_appendBytes(bstream, 4, data);
assert_zero(cmpBin(correct, bstream), "Internal data is incorrect.\n");
testFinish();
BitStream_free(bstream);
}
void test_toByte(void)
{
BitStream *bstream;
unsigned char correct[] = {
0x8a, 0xff, 0xff, 0x12, 0x34, 0x56, 0x78
};
unsigned char *result;
testStart("Convert to a byte array");
bstream = BitStream_new();
BitStream_appendBytes(bstream, 1, &correct[0]);
BitStream_appendBytes(bstream, 2, &correct[1]);
BitStream_appendBytes(bstream, 4, &correct[3]);
result = BitStream_toByte(bstream);
testEnd(memcmp(correct, result, 7));
BitStream_free(bstream);
free(result);
}
void test_toByte_4bitpadding(void)
{
BitStream *bstream;
unsigned char *result;
testStart("Convert to a byte array");
bstream = BitStream_new();
BitStream_appendNum(bstream, 4, 0xb);
result = BitStream_toByte(bstream);
assert_equal(result[0], 0xb, "incorrect paddings\n");
BitStream_free(bstream);
free(result);
bstream = BitStream_new();
BitStream_appendNum(bstream, 12, 0x335);
result = BitStream_toByte(bstream);
assert_equal(result[0], 0x33, "incorrect paddings\n");
assert_equal(result[1], 0x05, "incorrect paddings\n");
BitStream_free(bstream);
free(result);
testFinish();
}
void test_size(void)
{
BitStream *bstream;
testStart("size check");
bstream = BitStream_new();
assert_equal(BitStream_size(bstream), 0, "Initialized BitStream is not 0 length");
BitStream_appendNum(bstream, 1, 0);
assert_equal(BitStream_size(bstream), 1, "Size incorrect. (first append)");
BitStream_appendNum(bstream, 2, 0);
assert_equal(BitStream_size(bstream), 3, "Size incorrect. (second append)");
testFinish();
BitStream_free(bstream);
}
void test_append(void)
{
BitStream *bs1, *bs2;
char c1[] = "00";
char c2[] = "0011";
char c3[] = "01111111111111111";
char c4[] = "001101111111111111111";
char c5[] = "0011011111111111111111111111111111";
int ret;
testStart("Append two BitStreams");
bs1 = BitStream_new();
bs2 = BitStream_new();
ret = BitStream_appendNum(bs1, 1, 0);
ret = BitStream_appendNum(bs2, 1, 0);
ret = BitStream_append(bs1, bs2);
assert_zero(ret, "Failed to append.");
assert_zero(cmpBin(c1, bs1), "Internal data is incorrect.");
ret = BitStream_appendNum(bs1, 2, 3);
assert_zero(ret, "Failed to append.");
assert_zero(cmpBin(c2, bs1), "Internal data is incorrect.");
ret = BitStream_appendNum(bs2, 16, 65535);
assert_zero(ret, "Failed to append.");
assert_zero(cmpBin(c3, bs2), "Internal data is incorrect.");
ret = BitStream_append(bs1, bs2);
assert_zero(ret, "Failed to append.");
assert_zero(cmpBin(c4, bs1), "Internal data is incorrect.");
ret = BitStream_appendNum(bs1, 13, 16383);
assert_zero(ret, "Failed to append.");
assert_zero(cmpBin(c5, bs1), "Internal data is incorrect.");
testFinish();
BitStream_free(bs1);
BitStream_free(bs2);
}
int main(void)
{
test_null();
test_num();
test_bytes();
test_appendNum();
test_appendBytes();
test_toByte();
test_toByte_4bitpadding();
test_size();
test_append();
report();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_bitstream.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,544
|
```objective-c
/*
* common part of test units.
*/
#ifndef __COMMON_H__
#define __COMMON_H__
#include <stdlib.h>
#include "../config.h"
#include "../qrencode.h"
#include "../qrinput.h"
#include "../bitstream.h"
#include "../qrencode_inner.h"
#define testStart(__arg__) (testStartReal(__func__, __arg__))
#define testEndExp(__arg__) (testEnd(!(__arg__)))
static int tests = 0;
static int failed = 0;
static int assertionFailed = 0;
static int assertionNum = 0;
static const char *testName = NULL;
static const char *testFunc = NULL;
char levelChar[4] = {'L', 'M', 'Q', 'H'};
const char *modeStr[5] = {"nm", "an", "8", "kj", "st"};
void printQRinput(QRinput *input)
{
QRinput_List *list;
int i;
list = input->head;
while(list != NULL) {
for(i=0; i<list->size; i++) {
printf("0x%02x,", list->data[i]);
}
list = list->next;
}
printf("\n");
}
void printQRinputInfo(QRinput *input)
{
QRinput_List *list;
BitStream *b;
int i;
printf("QRinput info:\n");
printf(" version: %d\n", input->version);
printf(" level : %c\n", levelChar[input->level]);
list = input->head;
i = 0;
while(list != NULL) {
i++;
list = list->next;
}
printf(" chunks: %d\n", i);
b = QRinput_mergeBitStream(input);
if(b != NULL) {
printf(" bitstream-size: %d\n", BitStream_size(b));
BitStream_free(b);
}
list = input->head;
i = 0;
while(list != NULL) {
printf("\t#%d: mode = %s, size = %d\n", i, modeStr[list->mode], list->size);
i++;
list = list->next;
}
}
void printQRinputStruct(QRinput_Struct *s)
{
QRinput_InputList *list;
int i = 1;
printf("Struct size: %d\n", s->size);
printf("Struct parity: %08x\n", s->parity);
for(list = s->head; list != NULL; list = list->next) {
printf("Symbol %d - ", i);
printQRinputInfo(list->input);
i++;
}
}
void printFrame(int width, unsigned char *frame)
{
int x, y;
for(y=0; y<width; y++) {
for(x=0; x<width; x++) {
printf("%02x ", *frame++);
}
printf("\n");
}
}
void printQRcode(QRcode *code)
{
printFrame(code->width, code->data);
}
void testStartReal(const char *func, const char *name)
{
tests++;
testName = name;
testFunc = func;
assertionFailed = 0;
assertionNum = 0;
printf("_____%d: %s: %s...\n", tests, func, name);
}
void testEnd(int result)
{
printf(".....%d: %s: %s, ", tests, testFunc, testName);
if(result) {
puts("FAILED.");
failed++;
} else {
puts("PASSED.");
}
}
#define assert_exp(__exp__, ...) \
{assertionNum++;if(!(__exp__)) {assertionFailed++; printf(__VA_ARGS__);}}
#define assert_zero(__exp__, ...) assert_exp((__exp__) == 0, __VA_ARGS__)
#define assert_nonzero(__exp__, ...) assert_exp((__exp__) != 0, __VA_ARGS__)
#define assert_null(__ptr__, ...) assert_exp((__ptr__) == NULL, __VA_ARGS__)
#define assert_nonnull(__ptr__, ...) assert_exp((__ptr__) != NULL, __VA_ARGS__)
#define assert_equal(__e1__, __e2__, ...) assert_exp((__e1__) == (__e2__), __VA_ARGS__)
#define assert_notequal(__e1__, __e2__, ...) assert_exp((__e1__) != (__e2__), __VA_ARGS__)
#define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;}
void testFinish(void)
{
printf(".....%d: %s: %s, ", tests, testFunc, testName);
if(assertionFailed) {
printf("FAILED. (%d assertions failed.)\n", assertionFailed);
failed++;
} else {
printf("PASSED. (%d assertions passed.)\n", assertionNum);
}
}
void report()
{
printf("Total %d tests, %d fails.\n", tests, failed);
if(failed) exit(-1);
}
int ncmpBin(char *correct, BitStream *bstream, int len)
{
int i, bit;
char *p;
if(len != BitStream_size(bstream)) {
printf("Length is not match: %d, %d expected.\n", BitStream_size(bstream), len);
return -1;
}
p = correct;
i = 0;
while(*p != '\0') {
while(*p == ' ') {
p++;
}
bit = (*p == '1')?1:0;
if(bstream->data[i] != bit) return -1;
i++;
p++;
if(i == len) break;
}
return 0;
}
int cmpBin(char *correct, BitStream *bstream)
{
int len = 0;
char *p;
for(p = correct; *p != '\0'; p++) {
if(*p != ' ') len++;
}
return ncmpBin(correct, bstream, len);
}
void printBstream(BitStream *bstream)
{
int i, size;
size = BitStream_size(bstream);
for(i=0; i<size; i++) {
printf(bstream->data[i]?"1":"0");
}
printf("\n");
}
#endif /* __COMMON_H__ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/common.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,322
|
```shell
#!/bin/sh -e
./test_bitstream
./test_estimatebit
./test_qrencode
./test_qrinput
./test_qrspec
./test_rs
./test_split
./test_mask
./test_mqrspec
./test_mmask
./test_monkey
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_all.sh
|
shell
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 64
|
```c
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "common.h"
#include "../qrinput.h"
#include "../split.h"
#include "../qrspec.h"
#include "decoder.h"
#define MAX_LENGTH 7091
static unsigned char data[MAX_LENGTH];
static unsigned char check[MAX_LENGTH];
static const char *AN = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
#define drand(__scale__) ((__scale__) * (double)rand() / ((double)RAND_MAX + 1.0))
int fill8bitString(void)
{
int len, i;
len = 1 + (int)drand((MAX_LENGTH - 2));
for(i=0; i<len; i++) {
data[i] = (unsigned char)drand(255) + 1;
}
data[len] = '\0';
return len;
}
int fill8bitData(void)
{
int len, i;
len = 1 + (int)drand((MAX_LENGTH - 2));
for(i=0; i<len; i++) {
data[i] = (unsigned char)drand(256);
}
data[len] = '\0';
return len;
}
int fillANData(void)
{
int len, i;
len = 1 + (int)drand((MAX_LENGTH - 2));
for(i=0; i<len; i++) {
data[i] = AN[(int)drand(45)];
}
data[len] = '\0';
return len;
}
void test_encode_an(int num)
{
int ret;
int len;
len = fillANData();
QRcode *qrcode;
QRdata *qrdata;
FILE *fp;
char buf[256];
qrcode = QRcode_encodeString((char *)data, 0, num % 4, QR_MODE_8, num % 2);
if(qrcode == NULL) {
if(errno == ERANGE) return;
perror("test_encode_an aborted at QRcode_encodeString():");
printf("Length: %d\n", len);
printf("Level: %d\n", num % 4);
return;
}
qrdata = QRcode_decode(qrcode);
if(qrdata == NULL) {
printf("#%d: Failed to decode this code.\n", num);
QRcode_free(qrcode);
return;
}
if(qrdata->size != len) {
printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size);
}
ret = memcmp(qrdata->data, data, len);
if(ret != 0) {
unsigned char *frame, *p;
int x,y, c;
QRinput *input;
QRcode *origcode;
BitStream *bstream;
int spec[5];
printf("#%d: data mismatched.\n", num);
printf("Version: %d\n", qrcode->version);
QRspec_getEccSpec(qrcode->version, num%4, spec);
printf("DataLength: %d\n", QRspec_rsDataLength(spec));
printf("BlockNum1: %d\n", QRspec_rsBlockNum1(spec));
printf("BlockNum: %d\n", QRspec_rsBlockNum(spec));
printf("DataCodes1: %d\n", QRspec_rsDataCodes1(spec));
snprintf(buf, 256, "monkey-orig-%d.dat", num);
fp = fopen(buf, "w");
fputs((char *)data, fp);
fclose(fp);
snprintf(buf, 256, "monkey-result-%d.dat", num);
fp = fopen(buf, "w");
fputs((char *)qrdata->data, fp);
fclose(fp);
snprintf(buf, 256, "monkey-result-unmasked-%d.dat", num);
fp = fopen(buf, "w");
frame = QRcode_unmask(qrcode);
p = frame;
for(y=0; y<qrcode->width; y++) {
for(x=0; x<qrcode->width; x++) {
fputc((*p&1)?'1':'0', fp);
p++;
}
fputc('\n', fp);
}
fclose(fp);
free(frame);
snprintf(buf, 256, "monkey-orig-unmasked-%d.dat", num);
fp = fopen(buf, "w");
input = QRinput_new2(0, num % 4);
Split_splitStringToQRinput((char *)data, input, QR_MODE_8, num % 2);
origcode = QRcode_encodeMask(input, -2);
p = origcode->data;
for(y=0; y<origcode->width; y++) {
for(x=0; x<origcode->width; x++) {
fputc((*p&1)?'1':'0', fp);
p++;
}
fputc('\n', fp);
}
fclose(fp);
QRcode_free(origcode);
snprintf(buf, 256, "monkey-orig-bits-%d.dat", num);
fp = fopen(buf, "w");
bstream = QRinput_mergeBitStream(input);
c = 0;
for(x=0; x<bstream->length; x++) {
fputc((bstream->data[x]&1)?'1':'0', fp);
if((x & 7) == 7) {
fputc(' ', fp);
c++;
}
if((x & 63) == 63) {
fprintf(fp, "%d\n", c);
}
}
fclose(fp);
QRinput_free(input);
BitStream_free(bstream);
snprintf(buf, 256, "monkey-result-bits-%d.dat", num);
fp = fopen(buf, "w");
p = QRcode_extractBits(qrcode, &y);
c = 0;
for(x=0; x<y; x++) {
fputc((p[x]&1)?'1':'0', fp);
if((x & 7) == 7) {
fputc(' ', fp);
c++;
}
if((x & 63) == 63) {
fprintf(fp, "%d\n", c);
}
}
fclose(fp);
free(p);
}
QRdata_free(qrdata);
QRcode_free(qrcode);
}
void monkey_encode_an(int loop)
{
int i;
puts("Monkey test: QRcode_encodeString() - AlphaNumeric string.");
srand(0);
for(i=0; i<loop; i++) {
test_encode_an(i);
}
}
void test_split_an(int num)
{
QRinput *input;
QRinput_List *list;
int len, i, ret;
len = fillANData();
input = QRinput_new2(0, QR_ECLEVEL_L);
if(input == NULL) {
perror("test_split_an aborted at QRinput_new2():");
return;
}
ret = Split_splitStringToQRinput((char *)data, input, QR_MODE_8, 1);
if(ret < 0) {
perror("test_split_an aborted at Split_splitStringToQRinput():");
QRinput_free(input);
return;
}
list = input->head;
i = 0;
while(list != NULL) {
memcpy(check + i, list->data, list->size);
i += list->size;
list = list->next;
}
if(i != len) {
printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
}
check[i] = '\0';
ret = memcmp(data, check, len);
if(ret != 0) {
printf("#%d: data mismatched.\n", num);
list = input->head;
i = 0;
while(list != NULL) {
ret = memcmp(data + i, list->data, list->size);
printf("wrong chunk:\n");
printf(" position: %d\n", i);
printf(" mode : %d\n", list->mode);
printf(" size : %d\n", list->size);
printf(" data : %.*s\n", list->size, list->data);
i += list->size;
list = list->next;
}
exit(1);
}
QRinput_free(input);
}
void monkey_split_an(int loop)
{
int i;
puts("Monkey test: Split_splitStringToQRinput() - AlphaNumeric string.");
srand(0);
for(i=0; i<loop; i++) {
test_split_an(i);
}
}
void test_encode_8(int num)
{
QRcode *qrcode;
QRdata *qrdata;
int len, ret;
len = fill8bitData();
qrcode = QRcode_encodeData(len, data, 0, num % 4);
if(qrcode == NULL) {
if(errno == ERANGE) return;
perror("test_encdoe_8 aborted at QRcode_encodeData():");
return;
}
qrdata = QRcode_decode(qrcode);
if(qrdata == NULL) {
printf("#%d: Failed to decode this code.\n", num);
QRcode_free(qrcode);
return;
}
if(qrdata->size != len) {
printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size);
}
ret = memcmp(qrdata->data, data, len);
if(ret != 0) {
printf("#%d: data mismatched.\n", num);
}
QRdata_free(qrdata);
QRcode_free(qrcode);
}
void monkey_encode_8(int loop)
{
int i;
puts("Monkey test: QRcode_encodeData() - 8bit char string.");
srand(0);
for(i=0; i<loop; i++) {
test_encode_8(i);
}
}
void test_split_8(int num)
{
QRinput *input;
QRinput_List *list;
int len, i, ret;
len = fill8bitString();
input = QRinput_new2(0, QR_ECLEVEL_L);
if(input == NULL) {
perror("test_split_8 aborted at QRinput_new2():");
return;
}
ret = Split_splitStringToQRinput((char *)data, input, QR_MODE_8, 1);
if(ret < 0) {
perror("test_split_8 aborted at Split_splitStringToQRinput():");
QRinput_free(input);
return;
}
list = input->head;
i = 0;
while(list != NULL) {
memcpy(check + i, list->data, list->size);
i += list->size;
list = list->next;
}
if(i != len) {
printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
}
check[i] = '\0';
ret = memcmp(data, check, len);
if(ret != 0) {
printf("#%d: data mismatched.\n", num);
list = input->head;
i = 0;
while(list != NULL) {
ret = memcmp(data + i, list->data, list->size);
printf("wrong chunk:\n");
printf(" position: %d\n", i);
printf(" mode : %d\n", list->mode);
printf(" size : %d\n", list->size);
printf(" data : %.*s\n", list->size, list->data);
i += list->size;
list = list->next;
}
exit(1);
}
QRinput_free(input);
}
void monkey_split_8(int loop)
{
int i;
puts("Monkey test: Split_splitStringToQRinput() - 8bit char string.");
srand(0);
for(i=0; i<loop; i++) {
test_split_8(i);
}
}
void test_encode_kanji(int num)
{
QRcode *qrcode;
QRdata *qrdata;
int len, ret;
len = fill8bitString();
qrcode = QRcode_encodeString((char *)data, 0, num % 4, QR_MODE_8, 1);
if(qrcode == NULL) {
if(errno == ERANGE) return;
perror("test_encdoe_kanji aborted at QRcode_encodeString():");
return;
}
qrdata = QRcode_decode(qrcode);
if(qrdata == NULL) {
printf("#%d: Failed to decode this code.\n", num);
QRcode_free(qrcode);
return;
}
if(qrdata->size != len) {
printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size);
}
ret = memcmp(qrdata->data, data, len);
if(ret != 0) {
printf("#%d: data mismatched.\n", num);
}
QRdata_free(qrdata);
QRcode_free(qrcode);
}
void monkey_encode_kanji(int loop)
{
int i;
puts("Monkey test: QRcode_encodeString() - kanji string.");
srand(0);
for(i=0; i<loop; i++) {
test_encode_kanji(i);
}
}
void test_split_kanji(int num)
{
QRinput *input;
QRinput_List *list;
int len, i, ret;
len = fill8bitString();
input = QRinput_new2(0, QR_ECLEVEL_L);
if(input == NULL) {
perror("test_split_kanji aborted at QRinput_new2():");
return;
}
ret = Split_splitStringToQRinput((char *)data, input, QR_MODE_KANJI, 1);
if(ret < 0) {
perror("test_split_kanji aborted at Split_splitStringToQRinput():");
QRinput_free(input);
return;
}
list = input->head;
i = 0;
while(list != NULL) {
memcpy(check + i, list->data, list->size);
i += list->size;
list = list->next;
}
if(i != len) {
printf("#%d: length is not correct. (%d should be %d)\n", num, i, len);
}
check[i] = '\0';
ret = memcmp(data, check, len);
if(ret != 0) {
printf("#%d: data mismatched.\n", num);
list = input->head;
i = 0;
while(list != NULL) {
ret = memcmp(data + i, list->data, list->size);
printf("wrong chunk:\n");
printf(" position: %d\n", i);
printf(" mode : %d\n", list->mode);
printf(" size : %d\n", list->size);
printf(" data : %.*s\n", list->size, list->data);
i += list->size;
list = list->next;
}
exit(1);
}
QRinput_free(input);
}
void monkey_split_kanji(int loop)
{
int i;
puts("Monkey test: Split_splitStringToQRinput() - kanji string.");
srand(0);
for(i=0; i<loop; i++) {
test_split_kanji(i);
}
}
void test_split_structure(int num)
{
QRinput *input;
QRinput_Struct *s;
QRcode_List *codes, *list;
QRinput_InputList *il;
int version;
QRecLevel level;
int c, i, ret;
version = (int)drand(40) + 1;
level = (QRecLevel)drand(4);
fill8bitString();
input = QRinput_new2(version, level);
if(input == NULL) {
perror("test_split_structure aborted at QRinput_new2():");
return;
}
ret = Split_splitStringToQRinput((char *)data, input, QR_MODE_KANJI, 1);
if(ret < 0) {
perror("test_split_structure aborted at Split_splitStringToQRinput():");
QRinput_free(input);
return;
}
s = QRinput_splitQRinputToStruct(input);
if(s == NULL) {
if(errno != 0 && errno != ERANGE) {
perror("test_split_structure aborted at QRinput_splitQRinputToStruct():");
}
QRinput_free(input);
return;
}
il = s->head;
i = 0;
while(il != NULL) {
if(il->input->version != version) {
printf("Test: version %d, level %c\n", version, levelChar[level]);
printf("wrong version number.\n");
printQRinputInfo(il->input);
exit(1);
}
i++;
il = il->next;
}
codes = QRcode_encodeInputStructured(s);
if(codes == NULL) {
perror("test_split_structure aborted at QRcode_encodeInputStructured():");
QRinput_free(input);
QRinput_Struct_free(s);
return;
}
list = codes;
il = s->head;
c = 0;
while(list != NULL) {
if(list->code->version != version) {
printf("#%d: data mismatched.\n", num);
printf("Test: version %d, level %c\n", version, levelChar[level]);
printf("code #%d\n", c);
printf("Version mismatch: %d should be %d\n", list->code->version, version);
printf("max bits: %d\n", QRspec_getDataLength(version, level) * 8 - 20);
printQRinputInfo(il->input);
printQRinput(input);
exit(1);
}
list = list->next;
il = il->next;
c++;
}
QRinput_free(input);
QRinput_Struct_free(s);
QRcode_List_free(codes);
}
void monkey_split_structure(int loop)
{
int i;
puts("Monkey test: QRinput_splitQRinputToStruct.");
srand(0);
for(i=0; i<loop; i++) {
test_split_structure(i);
}
}
int main(int argc, char **argv)
{
int loop = 1000;
if(argc == 2) {
loop = atoi(argv[1]);
}
monkey_split_an(loop);
monkey_encode_an(loop);
monkey_split_8(loop);
monkey_encode_8(loop);
monkey_split_kanji(loop);
monkey_encode_kanji(loop);
monkey_split_structure(loop);
QRcode_clearCache();
return 0;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeWriter/qrencode/tests/test_monkey.c
|
c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 4,077
|
```c++
/*
This file is part of JQLibrary
Contact email: 188080501@qq.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
QZxing
path_to_url
*/
#include "JQQRCodeReader.h"
// Qt lib import
#include <QDebug>
#include <QImage>
#include <QMetaObject>
#include <QSemaphore>
#include <QThread>
// zxing lib import
#include "zxing/common/GlobalHistogramBinarizer.h"
#include "zxing/Binarizer.h"
#include "zxing/BinaryBitmap.h"
#include "zxing/MultiFormatReader.h"
#include "zxing/DecodeHints.h"
#include "zxing/LuminanceSource.h"
// ImageWrapper
class ImageWrapper: public zxing::LuminanceSource
{
Q_DISABLE_COPY( ImageWrapper )
public:
ImageWrapper(const QImage &sourceImage):
LuminanceSource( sourceImage.width(), sourceImage.height() ),
image_( sourceImage )
{ }
virtual ~ImageWrapper() = default;
// Callers take ownership of the returned memory and must call delete [] on it themselves.
zxing::ArrayRef< char > getRow(int y, zxing::ArrayRef< char > row) const
{
int width = getWidth();
if ( row->size() != width )
{
row.reset( zxing::ArrayRef< char >( width ) );
}
for ( int x = 0; x < width; ++x )
{
row[ x ] = static_cast< char >( qGray( image_.pixel( x,y ) ) );
}
return row;
}
zxing::ArrayRef< char > getMatrix() const
{
int width = image_.width();
int height = image_.height();
char *matrix = new char[ width * height ];
char *m = matrix;
for( int y = 0; y < height; ++y )
{
zxing::ArrayRef< char > tmpRow;
tmpRow = getRow( y, zxing::ArrayRef< char >( width ) );
#if __cplusplus > 199711L
memcpy( m, tmpRow->values().data(), width );
#else
memcpy( m, &tmpRow->values()[ 0 ], width );
#endif
m += width * sizeof( unsigned char );
//delete tmpRow;
}
zxing::ArrayRef< char > arr = zxing::ArrayRef< char >(matrix, width*height);
if( matrix )
{
delete[] matrix;
}
return arr;
}
private:
QImage image_;
};
// JQQRCodeReader
JQQRCodeReader::JQQRCodeReader():
decoder_( new zxing::MultiFormatReader ),
semaphore_( new QSemaphore( 1 ) )
{ }
JQQRCodeReader::~JQQRCodeReader()
{
semaphore_->acquire( 1 );
}
QString JQQRCodeReader::decodeImage(const QImage &image, const int &decodeType)
{
semaphore_->acquire( 1 );
zxing::Ref< zxing::Result > res;
QMetaObject::invokeMethod( this, "decodingStarted", Qt::QueuedConnection );
if( image.isNull() )
{
qDebug() << "JQQRCodeReader::decodeImage: error: image is null";
emit decodingFinished( false );
semaphore_->release( 1 );
return { };
}
auto ciw = new ImageWrapper( image );
zxing::Ref< zxing::LuminanceSource > imageRef( ciw );
zxing::GlobalHistogramBinarizer* binz = new zxing::GlobalHistogramBinarizer( imageRef );
zxing::Ref< zxing::Binarizer > bz( binz );
zxing::BinaryBitmap *bb = new zxing::BinaryBitmap( bz );
zxing::Ref< zxing::BinaryBitmap > ref( bb );
try
{
res = decoder_->decode( ref, static_cast< zxing::DecodeHints >( static_cast< unsigned int >( decodeType ) ) );
QString string = QString( res->getText()->getText().c_str() );
QMetaObject::invokeMethod( this, "tagFound", Qt::QueuedConnection, Q_ARG( QString, string ) );
QMetaObject::invokeMethod( this, "decodingFinished", Qt::QueuedConnection, Q_ARG( bool, true ) );
semaphore_->release( 1 );
return string;
}
catch ( zxing::Exception & )
{
QMetaObject::invokeMethod( this, "decodingFinished", Qt::QueuedConnection, Q_ARG( bool, false ) );
semaphore_->release( 1 );
}
return { };
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/JQQRCodeReader.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,240
|
```c++
/*
This file is part of JQLibrary
Contact email: 188080501@qq.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "JQQRCodeReaderForQml.h"
// Qt lib import
#include <QDebug>
#include <QImage>
#include <QSemaphore>
#include <QThreadPool>
#include <QtConcurrent>
#include <QQuickItem>
#include <QQuickItemGrabResult>
// ImagePreviewView
QPointer< ImagePreviewView > ImagePreviewView::object_;
QMutex ImagePreviewView::mutex_;
QImage ImagePreviewView::image_;
void ImagePreviewView::pushImage(const QImage &image)
{
if ( !object_ ) { return; }
mutex_.lock();
image_ = image;
mutex_.unlock();
QMetaObject::invokeMethod( object_, "update", Qt::QueuedConnection );
}
void ImagePreviewView::paint(QPainter *p)
{
if ( !object_ )
{
object_ = this;
}
if ( image_.isNull() ) { return; }
if ( QSize( static_cast< int >( this->width() ), static_cast< int >( this->height() ) ) != image_.size() )
{
this->setSize( QSizeF( image_.width(), image_.height() ) );
}
mutex_.lock();
p->drawImage( 0, 0, image_ );
mutex_.unlock();
}
// JQQRCodeReaderForQmlManage
JQQRCodeReaderForQmlManage::JQQRCodeReaderForQmlManage():
threadPool_( new QThreadPool ),
semaphore_( new QSemaphore )
{
threadPool_->setMaxThreadCount( std::max( QThread::idealThreadCount(), 3 ) );
semaphore_->release( threadPool_->maxThreadCount() );
}
JQQRCodeReaderForQmlManage::~JQQRCodeReaderForQmlManage()
{
threadPool_->waitForDone();
}
void JQQRCodeReaderForQmlManage::analysisItem(
QQuickItem *item,
const int &apertureX,
const int &apertureY,
const int &apertureWidth,
const int &apertureHeight
)
{
if ( !semaphore_->tryAcquire( 1 ) ) { return; }
const auto &&result = item->grabToImage();
const auto &&geometry = QRect( apertureX, apertureY, apertureWidth, apertureHeight );
QSharedPointer< QMetaObject::Connection > connection( new QMetaObject::Connection );
*connection = connect( result.data(), &QQuickItemGrabResult::ready, [ this, result, connection, geometry ]()
{
const auto image = result->image();
if ( image.isNull() )
{
qDebug( "JQQRCodeReaderForQmlManage::analysisItem: image is null" );
return;
}
qDebug() << QByteArray( (const char *)image.bits(), 10 ).toHex();
QtConcurrent::run( threadPool_.data(), [ this, image, geometry ]()
{
// QTime time;
// time.start();
QImage apertureImage = image.copy( geometry );
this->decodeImage( apertureImage, this->decodeQrCodeType_ );
const auto &&binarizationImage1 = this->binarization( apertureImage, defaultCorrectionValue_ );
this->decodeImage( binarizationImage1, this->decodeQrCodeType_ );
// ImagePreviewView::pushImage( binarizationResult1 );
const auto &&binarizationImage2 = this->binarization( apertureImage, defaultCorrectionValue_ + 0.3 );
this->decodeImage( binarizationImage2, this->decodeQrCodeType_ );
// ImagePreviewView::pushImage( binarizationResult2 );
const auto &&binarizationImage3 = this->binarization( apertureImage, defaultCorrectionValue_ - 0.3 );
this->decodeImage( binarizationImage3, this->decodeQrCodeType_ );
// ImagePreviewView::pushImage( binarizationResult3 );
semaphore_->release( 1 );
// qDebug() << time.elapsed();
} );
disconnect( *connection );
} );
}
QImage JQQRCodeReaderForQmlManage::binarization(const QImage &image, const qreal &correctionValue)
{
QImage result = image;
int reference1 = getReference( result, 0, 0, result.width() / 2, result.height() / 2, correctionValue );
int reference2 = getReference( result, result.width() / 2, 0, result.width(), result.height() / 2, correctionValue );
int reference3 = getReference( result, 0, result.height() / 2, result.width() / 2, result.height(), correctionValue );
int reference4 = getReference( result, result.width() / 2, result.height() / 2, result.width(), result.height(), correctionValue );
double referenceAvg = ( reference1 + reference2 + reference3 + reference4 ) / 4;
processImage( result, 0, 0, result.width() / 2, result.height() / 2, avgReference( referenceAvg, reference1 ), correctionValue );
processImage( result, result.width() / 2, 0, result.width(), result.height() / 2, avgReference( referenceAvg, reference2 ), correctionValue );
processImage( result, 0, result.height() / 2, result.width() / 2, result.height(), avgReference( referenceAvg, reference3 ), correctionValue );
processImage( result, result.width() / 2, result.height() / 2, result.width(), result.height(), avgReference( referenceAvg, reference4 ), correctionValue );
return result;
}
int JQQRCodeReaderForQmlManage::getReference(QImage &image, const int &xStart, const int &yStart, const int &xEnd, const int &yEnd, const qreal &correctionValue)
{
qint64 total = 0;
for ( auto y = yStart; y < yEnd; ++y )
{
for ( auto x = xStart; x < xEnd; ++x )
{
const auto &&color = image.pixelColor( x, y );
const auto &&value = color.red() + color.green() + color.blue();
total += value;
}
}
qint64 avg = total / ( ( xEnd - xStart ) * ( yEnd - yStart ) );
int reference = 0;
for ( auto y = yStart; y < yEnd; ++y )
{
for ( auto x = xStart; x < xEnd; ++x )
{
const auto &&color = image.pixelColor( x, y );
const auto &&value = color.red() + color.green() + color.blue();
if ( value > ( avg / correctionValue ) )
{
++reference;
}
}
}
return reference;
}
qreal JQQRCodeReaderForQmlManage::avgReference(const qreal &referenceAvg, const qreal ¤tReference)
{
if ( ( currentReference / referenceAvg ) > 1.15 ) { return 0.08 * 2; }
if ( ( currentReference / referenceAvg ) > 1.1 ) { return 0.04 * 2; }
if ( ( currentReference / referenceAvg ) > 1.05 ) { return 0.02 * 2; }
if ( ( currentReference / referenceAvg ) < 0.95 ) { return -0.02 * 2; }
if ( ( currentReference / referenceAvg ) < 0.9 ) { return -0.04 * 2; }
if ( ( currentReference / referenceAvg ) < 0.85 ) { return -0.08 * 2; }
return 0;
}
void JQQRCodeReaderForQmlManage::processImage(QImage &image, const int &xStart, const int &yStart, const int &xEnd, const int &yEnd, const qreal &offset, const qreal &correctionValue)
{
qint64 total = 0;
for ( auto y = yStart; y < yEnd; ++y )
{
for ( auto x = xStart; x < xEnd; ++x )
{
const auto &&color = image.pixelColor( x, y );
const auto &&value = color.red() + color.green() + color.blue();
total += value;
}
}
qint64 avg = total / ( ( xEnd - xStart ) * ( yEnd - yStart ) );
for ( auto y = yStart; y < yEnd; ++y )
{
for ( auto x = xStart; x < xEnd; ++x )
{
const auto &&color = image.pixelColor( x, y );
const auto &&value = color.red() + color.green() + color.blue();
if ( value > ( avg / ( correctionValue + offset ) ) )
{
image.setPixelColor( x, y, QColor( 255, 255, 255 ) );
}
else
{
image.setPixelColor( x, y, QColor( 0, 0, 0 ) );
}
}
}
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/JQQRCodeReaderForQml.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,241
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __BARCODE_FORMAT_H__
#define __BARCODE_FORMAT_H__
/*
* BarcodeFormat.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
namespace zxing {
class BarcodeFormat {
public:
// if you update the enum, update BarcodeFormat.cpp
enum Value {
NONE,
AZTEC,
CODABAR,
CODE_39,
CODE_93,
CODE_128,
DATA_MATRIX,
EAN_8,
EAN_13,
ITF,
MAXICODE,
PDF_417,
QR_CODE,
RSS_14,
RSS_EXPANDED,
UPC_A,
UPC_E,
UPC_EAN_EXTENSION
};
BarcodeFormat(Value v) : value(v) {}
const Value value;
operator Value () const {return value;}
static char const* barcodeFormatNames[];
};
}
#endif // __BARCODE_FORMAT_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/BarcodeFormat.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 247
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#ifndef __ZXING_H_
#define __ZXING_H_
#define ZXING_ARRAY_LEN(v) ((int)(sizeof(v)/sizeof(v[0])))
#define ZX_LOG_DIGITS(digits) \
((digits == 8) ? 3 : \
((digits == 16) ? 4 : \
((digits == 32) ? 5 : \
((digits == 64) ? 6 : \
((digits == 128) ? 7 : \
(-1))))))
#ifndef ZXING_DEBUG
#define ZXING_DEBUG 0
#endif
namespace zxing {
typedef char byte;
typedef bool boolean;
}
#include <limits>
#if defined(_WIN32) || defined(_WIN64)
#include <float.h>
namespace zxing {
inline bool isnan(float v) {return _isnan(v) != 0;}
inline bool isnan(double v) {return _isnan(v) != 0;}
inline float nan() {return std::numeric_limits<float>::quiet_NaN();}
}
#else
#include <cmath>
namespace zxing {
inline bool isnan(float v) {return std::isnan(v);}
inline bool isnan(double v) {return std::isnan(v);}
inline float nan() {return std::numeric_limits<float>::quiet_NaN();}
}
#endif
#if ZXING_DEBUG
#include <iostream>
#include <string>
using std::cout;
using std::cerr;
using std::endl;
using std::flush;
using std::string;
using std::ostream;
#if ZXING_DEBUG_TIMER
#include <sys/time.h>
namespace zxing {
class DebugTimer {
public:
DebugTimer(char const* string_) : chars(string_) {
gettimeofday(&start, 0);
}
DebugTimer(std::string const& string_) : chars(0), string(string_) {
gettimeofday(&start, 0);
}
void mark(char const* string) {
struct timeval end;
gettimeofday(&end, 0);
int diff =
(end.tv_sec - start.tv_sec)*1000*1000+(end.tv_usec - start.tv_usec);
cerr << diff << " " << string << '\n';
}
void mark(std::string string) {
mark(string.c_str());
}
~DebugTimer() {
if (chars) {
mark(chars);
} else {
mark(string.c_str());
}
}
private:
char const* const chars;
std::string string;
struct timeval start;
};
}
#define ZXING_TIME(string) DebugTimer __timer__ (string)
#define ZXING_TIME_MARK(string) __timer__.mark(string)
#endif
#endif // ZXING_DEBUG
#ifndef ZXING_TIME
#define ZXING_TIME(string) (void)0
#endif
#ifndef ZXING_TIME_MARK
#define ZXING_TIME_MARK(string) (void)0
#endif
#endif
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ZXing.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 651
|
```objective-c
#ifndef __RESULT_H__
#define __RESULT_H__
/*
* Result.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <string>
#include <zxing/common/Array.h>
#include <zxing/common/Counted.h>
#include <zxing/common/Str.h>
#include <zxing/ResultPoint.h>
#include <zxing/BarcodeFormat.h>
namespace zxing {
class Result : public Counted {
private:
Ref<String> text_;
ArrayRef<char> rawBytes_;
ArrayRef< Ref<ResultPoint> > resultPoints_;
BarcodeFormat format_;
public:
Result(Ref<String> text,
ArrayRef<char> rawBytes,
ArrayRef< Ref<ResultPoint> > resultPoints,
BarcodeFormat format);
~Result();
Ref<String> getText();
ArrayRef<char> getRawBytes();
ArrayRef< Ref<ResultPoint> > const& getResultPoints() const;
ArrayRef< Ref<ResultPoint> >& getResultPoints();
BarcodeFormat getBarcodeFormat() const;
friend std::ostream& operator<<(std::ostream &out, Result& result);
};
}
#endif // __RESULT_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Result.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 272
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __LUMINANCESOURCE_H__
#define __LUMINANCESOURCE_H__
/*
* LuminanceSource.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/common/Counted.h>
#include <zxing/common/Array.h>
#include <string.h>
namespace zxing {
class LuminanceSource : public Counted {
private:
const int width;
const int height;
public:
LuminanceSource(int width, int height);
virtual ~LuminanceSource();
int getWidth() const { return width; }
int getHeight() const { return height; }
// Callers take ownership of the returned memory and must call delete [] on it themselves.
virtual ArrayRef<char> getRow(int y, ArrayRef<char> row) const = 0;
virtual ArrayRef<char> getMatrix() const = 0;
virtual bool isCropSupported() const;
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
virtual bool isRotateSupported() const;
virtual Ref<LuminanceSource> invert() const;
virtual Ref<LuminanceSource> rotateCounterClockwise() const;
operator std::string () const;
};
}
#endif /* LUMINANCESOURCE_H_ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/LuminanceSource.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 328
|
```objective-c
#ifndef __READER_H__
#define __READER_H__
/*
* Reader.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/BinaryBitmap.h>
#include <zxing/Result.h>
#include <zxing/DecodeHints.h>
namespace zxing {
class Reader : public Counted {
protected:
Reader() {}
public:
virtual Ref<Result> decode(Ref<BinaryBitmap> image);
virtual Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints) = 0;
virtual ~Reader();
};
}
#endif // __READER_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Reader.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 160
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __DECODEHINTS_H_
#define __DECODEHINTS_H_
/*
* DecodeHintType.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/BarcodeFormat.h>
#include <zxing/ResultPointCallback.h>
namespace zxing {
typedef unsigned int DecodeHintType;
class DecodeHints;
DecodeHints operator | (DecodeHints const&, DecodeHints const&);
class DecodeHints {
private:
DecodeHintType hints;
Ref<ResultPointCallback> callback;
public:
static const DecodeHintType AZTEC_HINT = 1 << BarcodeFormat::AZTEC;
static const DecodeHintType CODABAR_HINT = 1 << BarcodeFormat::CODABAR;
static const DecodeHintType CODE_39_HINT = 1 << BarcodeFormat::CODE_39;
static const DecodeHintType CODE_93_HINT = 1 << BarcodeFormat::CODE_93;
static const DecodeHintType CODE_128_HINT = 1 << BarcodeFormat::CODE_128;
static const DecodeHintType DATA_MATRIX_HINT = 1 << BarcodeFormat::DATA_MATRIX;
static const DecodeHintType EAN_8_HINT = 1 << BarcodeFormat::EAN_8;
static const DecodeHintType EAN_13_HINT = 1 << BarcodeFormat::EAN_13;
static const DecodeHintType ITF_HINT = 1 << BarcodeFormat::ITF;
static const DecodeHintType MAXICODE_HINT = 1 << BarcodeFormat::MAXICODE;
static const DecodeHintType PDF_417_HINT = 1 << BarcodeFormat::PDF_417;
static const DecodeHintType QR_CODE_HINT = 1 << BarcodeFormat::QR_CODE;
static const DecodeHintType RSS_14_HINT = 1 << BarcodeFormat::RSS_14;
static const DecodeHintType RSS_EXPANDED_HINT = 1 << BarcodeFormat::RSS_EXPANDED;
static const DecodeHintType UPC_A_HINT = 1 << BarcodeFormat::UPC_A;
static const DecodeHintType UPC_E_HINT = 1 << BarcodeFormat::UPC_E;
static const DecodeHintType UPC_EAN_EXTENSION_HINT = 1 << BarcodeFormat::UPC_EAN_EXTENSION;
static const DecodeHintType TRYHARDER_HINT = 1 << 31;
static const DecodeHintType CHARACTER_SET = 1 << 30;
// static const DecodeHintType ALLOWED_LENGTHS = 1 << 29;
// static const DecodeHintType ASSUME_CODE_39_CHECK_DIGIT = 1 << 28;
static const DecodeHintType ASSUME_GS1 = 1 << 27;
// static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26;
static const DecodeHints PRODUCT_HINT;
static const DecodeHints ONED_HINT;
static const DecodeHints DEFAULT_HINT;
DecodeHints();
DecodeHints(DecodeHintType init);
void addFormat(BarcodeFormat toadd);
bool containsFormat(BarcodeFormat tocheck) const;
bool isEmpty() const {return (hints==0);}
void clear() {hints=0;}
void setTryHarder(bool toset);
bool getTryHarder() const;
void setResultPointCallback(Ref<ResultPointCallback> const&);
Ref<ResultPointCallback> getResultPointCallback() const;
friend DecodeHints operator | (DecodeHints const&, DecodeHints const&);
};
}
#endif
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/DecodeHints.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 772
|
```objective-c
#ifndef __BINARYBITMAP_H__
#define __BINARYBITMAP_H__
/*
* BinaryBitmap.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/common/Counted.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/BitArray.h>
#include <zxing/Binarizer.h>
namespace zxing {
class BinaryBitmap : public Counted {
private:
Ref<Binarizer> binarizer_;
public:
BinaryBitmap(Ref<Binarizer> binarizer);
virtual ~BinaryBitmap();
Ref<BitArray> getBlackRow(int y, Ref<BitArray> row);
Ref<BitMatrix> getBlackMatrix();
Ref<LuminanceSource> getLuminanceSource() const;
int getWidth() const;
int getHeight() const;
bool isRotateSupported() const;
Ref<BinaryBitmap> rotateCounterClockwise();
bool isCropSupported() const;
Ref<BinaryBitmap> crop(int left, int top, int width, int height);
};
}
#endif /* BINARYBITMAP_H_ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/BinaryBitmap.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 278
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* Exception.cpp
* ZXing
*
* Created by Christian Brunschen on 03/06/2008.
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ZXing.h>
#include <zxing/Exception.h>
#include <string.h>
using zxing::Exception;
void Exception::deleteMessage() {
delete [] message;
}
char const* Exception::copy(char const* msg) {
char* message = 0;
if (msg) {
int l = static_cast<int>(strlen(msg)+1);
if (l) {
message = new char[l];
strcpy(message, msg);
}
}
return message;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Exception.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 197
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __INVERTEDLUMINANCESOURCE_H__
#define __INVERTEDLUMINANCESOURCE_H__
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ZXing.h>
#include <zxing/LuminanceSource.h>
namespace zxing {
class InvertedLuminanceSource : public LuminanceSource {
private:
typedef LuminanceSource Super;
const Ref<LuminanceSource> delegate;
public:
InvertedLuminanceSource(Ref<LuminanceSource> const&);
ArrayRef<char> getRow(int y, ArrayRef<char> row) const;
ArrayRef<char> getMatrix() const;
boolean isCropSupported() const;
Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
boolean isRotateSupported() const;
virtual Ref<LuminanceSource> invert() const;
Ref<LuminanceSource> rotateCounterClockwise() const;
};
}
#endif /* INVERTEDLUMINANCESOURCE_H_ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/InvertedLuminanceSource.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 267
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* ChecksumException.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ChecksumException.h>
using zxing::ChecksumException;
ChecksumException::ChecksumException() throw() {}
ChecksumException::ChecksumException(const char *msg) throw() : ReaderException(msg) {}
ChecksumException::~ChecksumException() throw() {}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ChecksumException.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 143
|
```objective-c
#ifndef __RESULT_POINT_CALLBACK_H__
#define __RESULT_POINT_CALLBACK_H__
/*
* ResultPointCallback.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/common/Counted.h>
namespace zxing {
class ResultPoint;
class ResultPointCallback : public Counted {
protected:
ResultPointCallback() {}
public:
virtual void foundPossibleResultPoint(ResultPoint const& point) = 0;
virtual ~ResultPointCallback();
};
}
#endif // __RESULT_POINT_CALLBACK_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ResultPointCallback.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 138
|
```objective-c
#ifndef __MULTI_FORMAT_READER_H__
#define __MULTI_FORMAT_READER_H__
/*
* MultiFormatBarcodeReader.h
* ZXing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/Reader.h>
#include <zxing/common/BitArray.h>
#include <zxing/Result.h>
#include <zxing/DecodeHints.h>
namespace zxing {
class MultiFormatReader : public Reader {
private:
Ref<Result> decodeInternal(Ref<BinaryBitmap> image);
std::vector<Ref<Reader> > readers_;
DecodeHints hints_;
public:
MultiFormatReader();
Ref<Result> decode(Ref<BinaryBitmap> image);
Ref<Result> decode(Ref<BinaryBitmap> image, DecodeHints hints);
Ref<Result> decodeWithState(Ref<BinaryBitmap> image);
void setHints(DecodeHints hints);
~MultiFormatReader();
};
}
#endif
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/MultiFormatReader.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 230
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ZXing.h>
#include <zxing/MultiFormatReader.h>
#include <zxing/qrcode/QRCodeReader.h>
#include <zxing/datamatrix/DataMatrixReader.h>
#include <zxing/aztec/AztecReader.h>
#include <zxing/pdf417/PDF417Reader.h>
#include <zxing/oned/MultiFormatUPCEANReader.h>
#include <zxing/oned/MultiFormatOneDReader.h>
#include <zxing/ReaderException.h>
using zxing::Ref;
using zxing::Result;
using zxing::MultiFormatReader;
// VC++
using zxing::DecodeHints;
using zxing::BinaryBitmap;
MultiFormatReader::MultiFormatReader() {}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image) {
setHints(DecodeHints::DEFAULT_HINT);
return decodeInternal(image);
}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
setHints(hints);
return decodeInternal(image);
}
Ref<Result> MultiFormatReader::decodeWithState(Ref<BinaryBitmap> image) {
// Make sure to set up the default state so we don't crash
if (readers_.size() == 0) {
setHints(DecodeHints::DEFAULT_HINT);
}
return decodeInternal(image);
}
void MultiFormatReader::setHints(DecodeHints hints) {
hints_ = hints;
readers_.clear();
bool tryHarder = hints.getTryHarder();
bool addOneDReader = hints.containsFormat(BarcodeFormat::UPC_E) ||
hints.containsFormat(BarcodeFormat::UPC_A) ||
hints.containsFormat(BarcodeFormat::UPC_E) ||
hints.containsFormat(BarcodeFormat::EAN_13) ||
hints.containsFormat(BarcodeFormat::EAN_8) ||
hints.containsFormat(BarcodeFormat::CODABAR) ||
hints.containsFormat(BarcodeFormat::CODE_39) ||
hints.containsFormat(BarcodeFormat::CODE_93) ||
hints.containsFormat(BarcodeFormat::CODE_128) ||
hints.containsFormat(BarcodeFormat::ITF) ||
hints.containsFormat(BarcodeFormat::RSS_14) ||
hints.containsFormat(BarcodeFormat::RSS_EXPANDED);
if (addOneDReader && !tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
if (hints.containsFormat(BarcodeFormat::QR_CODE)) {
readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
}
if (hints.containsFormat(BarcodeFormat::DATA_MATRIX)) {
readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
}
if (hints.containsFormat(BarcodeFormat::AZTEC)) {
readers_.push_back(Ref<Reader>(new zxing::aztec::AztecReader()));
}
if (hints.containsFormat(BarcodeFormat::PDF_417)) {
readers_.push_back(Ref<Reader>(new zxing::pdf417::PDF417Reader()));
}
/*
if (hints.contains(BarcodeFormat.MAXICODE)) {
readers.add(new MaxiCodeReader());
}
*/
if (addOneDReader && tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
if (readers_.size() == 0) {
if (!tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
readers_.push_back(Ref<Reader>(new zxing::aztec::AztecReader()));
readers_.push_back(Ref<Reader>(new zxing::pdf417::PDF417Reader()));
// readers.add(new MaxiCodeReader());
if (tryHarder) {
readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
}
}
}
Ref<Result> MultiFormatReader::decodeInternal(Ref<BinaryBitmap> image) {
for (unsigned int i = 0; i < readers_.size(); i++) {
try {
return readers_[i]->decode(image, hints_);
} catch (ReaderException const& re) {
(void)re;
// continue
}
}
throw ReaderException("No code detected");
}
MultiFormatReader::~MultiFormatReader() {}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/MultiFormatReader.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,080
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __ILLEGAL_STATE_EXCEPTION_H__
#define __ILLEGAL_STATE_EXCEPTION_H__
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ReaderException.h>
namespace zxing {
class IllegalStateException : public ReaderException {
public:
IllegalStateException() throw() {}
IllegalStateException(const char *msg) throw() : ReaderException(msg) {}
~IllegalStateException() throw() {}
};
}
#endif // __ILLEGAL_STATE_EXCEPTION_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/IllegalStateException.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 139
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __READER_EXCEPTION_H__
#define __READER_EXCEPTION_H__
/*
* ReaderException.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/Exception.h>
namespace zxing {
class ReaderException : public Exception {
public:
ReaderException() throw() {}
ReaderException(char const* msg) throw() : Exception(msg) {}
~ReaderException() throw() {}
};
}
#endif // __READER_EXCEPTION_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ReaderException.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 148
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __RESULT_POINT_H__
#define __RESULT_POINT_H__
/*
* ResultPoint.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/common/Counted.h>
#include <vector>
namespace zxing {
class ResultPoint : public Counted {
protected:
const float posX_;
const float posY_;
public:
ResultPoint();
ResultPoint(float x, float y);
ResultPoint(int x, int y);
virtual ~ResultPoint();
virtual float getX() const;
virtual float getY() const;
bool equals(Ref<ResultPoint> other);
static void orderBestPatterns(std::vector<Ref<ResultPoint> > &patterns);
static float distance(Ref<ResultPoint> point1, Ref<ResultPoint> point2);
static float distance(float x1, float x2, float y1, float y2);
private:
static float crossProductZ(Ref<ResultPoint> pointA, Ref<ResultPoint> pointB, Ref<ResultPoint> pointC);
};
}
#endif // __RESULT_POINT_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ResultPoint.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 274
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/BinaryBitmap.h>
using zxing::Ref;
using zxing::BitArray;
using zxing::BitMatrix;
using zxing::LuminanceSource;
using zxing::BinaryBitmap;
// VC++
using zxing::Binarizer;
BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : binarizer_(binarizer) {
}
BinaryBitmap::~BinaryBitmap() {
}
Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
return binarizer_->getBlackRow(y, row);
}
Ref<BitMatrix> BinaryBitmap::getBlackMatrix() {
return binarizer_->getBlackMatrix();
}
int BinaryBitmap::getWidth() const {
return getLuminanceSource()->getWidth();
}
int BinaryBitmap::getHeight() const {
return getLuminanceSource()->getHeight();
}
Ref<LuminanceSource> BinaryBitmap::getLuminanceSource() const {
return binarizer_->getLuminanceSource();
}
bool BinaryBitmap::isCropSupported() const {
return getLuminanceSource()->isCropSupported();
}
Ref<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height) {
return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
}
bool BinaryBitmap::isRotateSupported() const {
return getLuminanceSource()->isRotateSupported();
}
Ref<BinaryBitmap> BinaryBitmap::rotateCounterClockwise() {
return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/BinaryBitmap.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 435
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* Result.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/Result.h>
using zxing::Result;
using zxing::Ref;
using zxing::ArrayRef;
using zxing::String;
using zxing::ResultPoint;
// VC++
using zxing::BarcodeFormat;
Result::Result(Ref<String> text,
ArrayRef<char> rawBytes,
ArrayRef< Ref<ResultPoint> > resultPoints,
BarcodeFormat format) :
text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format) {
}
Result::~Result() {
}
Ref<String> Result::getText() {
return text_;
}
ArrayRef<char> Result::getRawBytes() {
return rawBytes_;
}
ArrayRef< Ref<ResultPoint> > const& Result::getResultPoints() const {
return resultPoints_;
}
ArrayRef< Ref<ResultPoint> >& Result::getResultPoints() {
return resultPoints_;
}
zxing::BarcodeFormat Result::getBarcodeFormat() const {
return format_;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Result.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 294
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* Created by Christian Brunschen on 13/05/2008.
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/BarcodeFormat.h>
const char* zxing::BarcodeFormat::barcodeFormatNames[] = {
0,
"AZTEC",
"CODABAR",
"CODE_39",
"CODE_93",
"CODE_128",
"DATA_MATRIX",
"EAN_8",
"EAN_13",
"ITF",
"MAXICODE",
"PDF_417",
"QR_CODE",
"RSS_14",
"RSS_EXPANDED",
"UPC_A",
"UPC_E",
"UPC_EAN_EXTENSION"
};
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/BarcodeFormat.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 210
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __CHECKSUM_EXCEPTION_H__
#define __CHECKSUM_EXCEPTION_H__
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ReaderException.h>
namespace zxing {
class ChecksumException : public ReaderException {
typedef ReaderException Base;
public:
ChecksumException() throw();
ChecksumException(const char *msg) throw();
~ChecksumException() throw();
};
}
#endif // __CHECKSUM_EXCEPTION_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ChecksumException.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 143
|
```c++
/*
* Reader.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/Reader.h>
namespace zxing {
Reader::~Reader() { }
Ref<Result> Reader::decode(Ref<BinaryBitmap> image) {
return decode(image, DecodeHints::DEFAULT_HINT);
}
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Reader.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 114
|
```c++
/*
* ResultPointCallback.cpp
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ResultPointCallback.h>
namespace zxing {
ResultPointCallback::~ResultPointCallback() {}
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ResultPointCallback.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 77
|
```objective-c
#ifndef BINARIZER_H_
#define BINARIZER_H_
/*
* Binarizer.h
* zxing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/LuminanceSource.h>
#include <zxing/common/BitArray.h>
#include <zxing/common/BitMatrix.h>
#include <zxing/common/Counted.h>
namespace zxing {
class Binarizer : public Counted {
private:
Ref<LuminanceSource> source_;
public:
Binarizer(Ref<LuminanceSource> source);
virtual ~Binarizer();
virtual Ref<BitArray> getBlackRow(int y, Ref<BitArray> row) = 0;
virtual Ref<BitMatrix> getBlackMatrix() = 0;
Ref<LuminanceSource> getLuminanceSource() const ;
virtual Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source) = 0;
int getWidth() const;
int getHeight() const;
};
}
#endif /* BINARIZER_H_ */
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Binarizer.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 251
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
* ResultIO.cpp
* zxing
*
* Created by Christian Brunschen on 13/05/2008.
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/Result.h>
using zxing::Result;
using std::ostream;
ostream& zxing::operator<<(ostream &out, Result& result) {
if (result.text_ != 0) {
out << result.text_->getText();
} else {
out << "[" << result.rawBytes_->size() << " bytes]";
}
return out;
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/ResultIO.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 170
|
```c++
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <zxing/ZXing.h>
#include <zxing/InvertedLuminanceSource.h>
using zxing::boolean;
using zxing::Ref;
using zxing::ArrayRef;
using zxing::LuminanceSource;
using zxing::InvertedLuminanceSource;
InvertedLuminanceSource::InvertedLuminanceSource(Ref<LuminanceSource> const& delegate_)
: Super(delegate_->getWidth(), delegate_->getHeight()), delegate(delegate_) {}
ArrayRef<char> InvertedLuminanceSource::getRow(int y, ArrayRef<char> row) const {
row = delegate->getRow(y, row);
int width = getWidth();
for (int i = 0; i < width; i++) {
row[i] = (byte) (255 - (row[i] & 0xFF));
}
return row;
}
ArrayRef<char> InvertedLuminanceSource::getMatrix() const {
ArrayRef<char> matrix = delegate->getMatrix();
int length = getWidth() * getHeight();
ArrayRef<char> invertedMatrix(length);
for (int i = 0; i < length; i++) {
invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF));
}
return invertedMatrix;
}
zxing::boolean InvertedLuminanceSource::isCropSupported() const {
return delegate->isCropSupported();
}
Ref<LuminanceSource> InvertedLuminanceSource::crop(int left, int top, int width, int height) const {
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->crop(left, top, width, height)));
}
boolean InvertedLuminanceSource::isRotateSupported() const {
return delegate->isRotateSupported();
}
Ref<LuminanceSource> InvertedLuminanceSource::invert() const {
return delegate;
}
Ref<LuminanceSource> InvertedLuminanceSource::rotateCounterClockwise() const {
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->rotateCounterClockwise()));
}
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/InvertedLuminanceSource.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 504
|
```objective-c
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __EXCEPTION_H__
#define __EXCEPTION_H__
/*
* Exception.h
* ZXing
*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#include <string>
#include <exception>
namespace zxing {
class Exception : public std::exception {
private:
char const* const message;
public:
Exception() throw() : message(0) {}
Exception(const char* msg) throw() : message(copy(msg)) {}
Exception(Exception const& that) throw() : std::exception(that), message(copy(that.message)) {}
~Exception() throw() {
if(message) {
deleteMessage();
}
}
char const* what() const throw() {return message ? message : "";}
private:
static char const* copy(char const*);
void deleteMessage();
};
}
#endif // __EXCEPTION_H__
```
|
/content/code_sandbox/library/JQLibrary/src/JQQRCodeReader/zxing/zxing/Exception.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 224
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.