47 const std::string S_ToolName =
"gettingstartedsample";
48 const std::string S_ToolVersion =
"1.0";
55 "<dca-redist-folder> <ticket> <product>\n"
56 " dca-redist-folder - the folder where the DCA is installed to\n"
57 " ticket - a valid ticket\n"
58 " product - the product associated with your ticket\n\n"
66 # define DCA_BINDIR "bin/Win32"
68 # define DCA_BINDIR "bin/linux"
75 #define DCA_INITDIR "init"
80 #define DCA_LOGDIR "./logs"
88 std::cout <<
"IBM DCA Sample: " << S_ToolName <<
" (" << S_ToolVersion <<
99 std::cout << name <<
" usage:" << std::endl;
110 int main(
int argc,
char *argv[] )
122 std::string myRedistFolder = argv[ 1 ];
123 const std::string myTicket = argv[ 2 ];
124 const std::string myProduct = argv[ 3 ];
126 if( myRedistFolder.empty() || myTicket.empty() || myProduct.empty() ) {
132 const char c = myRedistFolder[ myRedistFolder.length() - 1 ];
133 if( c !=
'/' && c !=
'\\' )
134 myRedistFolder +=
"/";
137 std::cout <<
"Initializing 3rd party libraries "
138 "libcurl and libOpenSSL." << std::endl;
154 std::cout <<
"Successfully created DcaInstance by using:" <<
156 std::cout <<
" Binary directory:" << myInitData.
binDir <<
158 std::cout <<
" Init directory:" << myInitData.
initDir <<
160 std::cout <<
" Logging directory:" << myInitData.
logDir <<
165 myLicenseData.
ticket = myTicket;
166 myLicenseData.
product = myProduct;
168 std::cout <<
"Create License by using:" <<
170 std::cout <<
" Ticket:" << myLicenseData.
ticket <<
172 std::cout <<
" Product:" << myLicenseData.
product <<
183 std::cout <<
"DCA is not licensed." << std::endl;
184 std::cout <<
"Last message:" <<
193 std::cout <<
"License Info:" << std::endl;
194 std::cout <<
" DCA is licensed." << std::endl;
195 std::cout <<
" MaxUsers:" << myLicense.
getMaxUsers() <<
199 std::cout <<
" Ticket:" << myLicense.
getTicket() <<
201 std::cout <<
" Session:" << myLicense.
getSession() <<
205 std::cout <<
" Expiration Date:" << ctime(&expirationDate) <<
213 catch(
const ExDca& ex ) {
214 std::cerr <<
"DCA Exception occured. Details: " << ex.
getDescription() <<
218 catch(
const std::exception& s ) {
219 std::cerr <<
"std::exception occured. Details: " << s.what() <<
"." << std::endl;
223 std::cerr <<
"Unknown exception caught." << std::endl;
231 std::cout <<
"Deinitializing 3rd party libraries "
232 "libcurl and libOpenSSL." << std::endl;
233 std::cout <<
"Exiting sample with rc=" << rc << std::endl;
Is used to create a License object. A license first must be created with DcaInstance::createLicense t...
Exception class used in the DCA.
void InitCUrl()
Initializes libcurl. Do not use any DCA function before initializing libcurl.
std::string initDir
the directory in which the DCA init files are stored
int getMaxSessions() const
Returns the maximum allowed sessions associated with your ticket/license.
time_t getExpirationDate() const
Returns the expiration date of the license in UTC.
std::string getDescription() const
Returns a description of the error.
std::string binDir
the directory in which the DCA binary (*.dca) files are stored
This header includes initialization/deinitialization support functions for the 3rd party libraries us...
void SetOpenSslCallbacks()
Initializes the required callbacks for OpenSSL when using HTTPS or SSL connections in a multi-threade...
void UnsetOpenSslCallbacks()
Unsets the openssl callbacks. Do not call any DCA function after you have called this function.
int getMaxUsers() const
Returns the maximum allowed users associated with your ticket/license.
void DeinitCUrl()
Deinitializes libcurl. Do not call any DCA function after you have called this function.
#define DCA_LOGDIR
Relative directory for logfile(s).
#define DCA_INITDIR
DCA subdirectory of the DCA initialization data.
DCA_RESULT_TYPE getReturnCode() const
Gets the code of the error.
static void PrintToolHeader()
Prints out the name and the version of this sample.
Use a License to initialize a classification package or a toolbox package.
bool isLicensed(DCA_MODULE_ID_TYPE id=0, bool force=false) const
Checks whether the given License is valid for the given module id.
std::string ticket
The ticket as provided in the license.
This header includes all header files of the DCA Base Package.
Encapsulates the init and deinit of the DCA API.
std::string product
The product code used with the license.
std::string logDir
the directory in which the DCA log file should be created
static void PrintUsage(const char *name)
Prints out the syntax of the sample.
std::string getLastMessage() const
Returns the last message received from our license server or if none available the last available mes...
std::string getTicket() const
Returns the ticket of the license as string.
#define DCA_BINDIR
DCA subdirectory of the DCA binaries.
std::string getSession() const
Returns the session of the license as string.
const std::string S_UsageString
Usage string, displayed if a parameter is missing.
This structure is used to initialize the DcaInstance.
static DcaInstance create(const InitData &initData)
Creates a DcaInstance, starts up the DCA API and initializes the required main module.
License createLicense(const LicenseData &licData, const ProxySettings &proxySettings=ProxySettings(), LogLevel aLogLevel=LOG_Initial) const
Creates a License object using the given LicenseData.
int main(int argc, char *argv[])
The main routine.