/************************************************************************************************** * NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE: * * Copyright (c) 1997-2014 Flexera Software LLC. All Rights Reserved. * * This computer program is the property of Flexera Software LLC of * Schaumburg, Illinois, U.S.A. Any use, copy, publication, distribution, display, modification, or * transmission of this computer program in whole or in part in any form or by any means without * the prior express written permission of Flexera Software LLC is * strictly prohibited. * * Except when expressly provided by Flexera Software LLC in writing, * possession of this computer program shall not be construed to confer any license or rights under * any of Flexera Software LLC's intellectual property rights, whether by * estoppel, implication, or otherwise. * * ALL COPIES OF THIS PROGRAM MUST DISPLAY THIS NOTICE OF COPYRIGHT AND OWNERSHIP IN FULL. **************************************************************************************************/ /* * * Description: This is a sample application program, to illustrate * the use of the Flexible License Manager. * */ #include "lmclient.h" #include #include #include #include #include "lm_attr.h" #ifdef PC #define LICPATH "@localhost" #else #define LICPATH "@localhost:license.dat:." #endif /* PC */ #define FEATURE "f1" VENDORCODE code; LM_HANDLE *job; static void init(struct flexinit_property_handle **); static void cleanup(struct flexinit_property_handle *); int main(int argc, char * argv[]) { char feature[MAX_FEATURE_LEN * 2] = {'\0'}; char * output = NULL; struct flexinit_property_handle *initHandle; int stat; int nlic = 1; init(&initHandle); if (argc > 1) { nlic = atoi(argv[1]); } if (lc_new_job(0, lc_new_job_arg2, &code, &job)) { lc_perror(job, "lc_new_job failed"); cleanup(initHandle); exit(lc_get_errno(job)); } (void)lc_set_attr(job, LM_A_LICENSE_DEFAULT, (LM_A_VAL_TYPE) "@localhost"); { int flexStat = 0; int nIndex = 0; char *retStr = NULL; retStr = lc_vsend(job, "DUMMY STRING"); if (!retStr) { printf(" LS not up\n\n"); } else { printf (" LS is up\n\n"); // loop to get all the CONFIG structs const char** featList; featList = (const char**)lc_feat_list(job, LM_FLIST_ALL_FILES | LM_FILTERLIST_ALL_FILES, NULL); if(!featList) { printf("Error in Getting Feature List \n\n", lc_errstring(job)); } for(nIndex = 0; featList[nIndex]; nIndex++) { CONFIG *conf = NULL; CONFIG *nextPosition = NULL; const char* feature = featList[nIndex]; if(!feature) { printf("FEATURE IS NULL \n\n"); } printf("\n\t\t Feature Name is %s", feature); while ( conf = lc_next_conf(job, (LM_CHAR_PTR)feature , &nextPosition) ) { LM_VD_FEATURE_INFO featInfo; featInfo.feat = conf; if ( ( flexStat = lc_get_attr(job, LM_A_VD_FEATURE_INFO, (short *)&featInfo)) != 0) { printf("\n\n\tError %d getting the feature info", lc_get_errno(job)); /* the server told us there is no feature info for this CONFIG. * This is ok because the server pools licenses and will only * return success once for all the CONFIGs in a pool. */ } else { printf("\n\n Got some config information"); printf("\n\t\t Feature Name is %s", featInfo.feat->feature); printf("\n\t\t Exp date is %s", featInfo.feat->date); printf("\n\t\t Version is %s", featInfo.feat->version); printf("\n\t\t Total number of licenses is %d", featInfo.num_lic); printf("\n\t\t Number of licenses in use is %d", featInfo.tot_lic_in_use); printf("\n\t\t vendor String is %s", featInfo.feat->lc_vendor_def); } } // we don't want any partial information. If we have glitches just dispose all the data flexStat = lc_get_errno(job); if (flexStat) { if (LM_NOFEATURE==flexStat) { printf("\n\t ERROR: No licenses for the PLD. Skipping it\n"); } else { printf("\n\t ERROR: Error %d while getting the config structures\n", flexStat); } } } } exit: lc_free_job(job); return ( 0 ); } } static void init(struct flexinit_property_handle **handle) { #ifndef NO_ACTIVATION_SUPPORT struct flexinit_property_handle *ourHandle; int stat; if (stat = lc_flexinit_property_handle_create(&ourHandle)) { fprintf(stderr, "lc_flexinit_property_handle_create() failed: %d\n", stat); exit(1); } if (stat = lc_flexinit_property_handle_set(ourHandle, (FLEXINIT_PROPERTY_TYPE)FLEXINIT_PROPERTY_USE_TRUSTED_STORAGE, (FLEXINIT_VALUE_TYPE)1)) { fprintf(stderr, "lc_flexinit_property_handle_set failed: %d\n", stat); exit(1); } if (stat = lc_flexinit(ourHandle)) { fprintf(stderr, "lc_flexinit failed: %d\n", stat); exit(1); } *handle = ourHandle; #endif /* NO_ACTIVATION_SUPPORT */ } static void cleanup(struct flexinit_property_handle *initHandle) { #ifndef NO_ACTIVATION_SUPPORT int stat; if (stat = lc_flexinit_cleanup(initHandle)) { fprintf(stderr, "lc_flexinit_cleanup failed: %d\n", stat); } if (stat = lc_flexinit_property_handle_free(initHandle)) { fprintf(stderr, "lc_flexinit_property_handle_free failed: %d\n", stat); } #endif /* NO_ACTIVATION_SUPPORT */ }