/************************************************************************************************** * Copyright (c) 1997-2018, 2020-2022 Flexera. All Rights Reserved. **************************************************************************************************/ /* * * Description: This is a sample application program, to illustrate * the use of the Flexible License Manager. * */ /* Uncomment the following line to run the original batch prototype */ /* #define BATCH_PROTO */ #include "lmclient.h" #include #include #include #include #ifdef PC #include #else #include #endif #include "lm_attr.h" #include "lm_redir_std.h" #ifdef PC #define LICPATH "@localhost" #else #define LICPATH "@localhost:license.dat:." #include #endif /* PC */ #define FEATURE "f1" #define FEATURE_DELIM "," VENDORCODE code; LM_HANDLE *lm_job; static int nlic = 1; static int secure_comms = 0; static struct flexinit_property_handle *initHandle = NULL; static void init(struct flexinit_property_handle **); static void cleanup(struct flexinit_property_handle *); static const char* s_errs[] = { #include "lmerrors.h" }; void exit_err(const char* msg, int err) { if( err ) { fprintf(stderr,"%s failed, status: %d\n",msg,err); exit(1); } } void doBatch(char** f_list, int f_count) { int i; LM_TXN txn = LM_TXN_NULL; #ifndef PC struct timeval tStart,tEnd; float latency; #endif /* * Create the batch checkout */ exit_err("lc_txn_create", lc_txn_create(lm_job, &txn)); for(i=0; i 2) { co = atoi(argv[2]); nlic = atoi(argv[1]); } if (lc_new_job(0, lc_new_job_arg2, &code, &lm_job)) { lc_perror(lm_job, "lc_new_job failed"); cleanup(initHandle); exit(lc_get_errno(lm_job)); } //yashwanth printf("\n Choose: \n 1 for lc_checkout and 2 for lc_transfer_lic "); printf("\n Enter \"f1\" to demo floating functionality\n"); printf("Enter \"f2\" to demo node-locked functionality\n"); printf("Enter feature to checkout [default: \"%s\"]: ", FEATURE); (void)fgets(feature, sizeof(feature), lm_flex_stdin()); /* add 2 for \n and \0 */ feature[strlen(feature) - 1] = '\0'; if(!*feature) strcpy(feature, FEATURE); (void)lc_set_attr(lm_job, LM_A_LICENSE_DEFAULT, (LM_A_VAL_TYPE)LICPATH); if( secure_comms ) { if ( lc_set_attr(lm_job, LM_A_SECURE_COMMS, (LM_A_VAL_TYPE)1) != LM_NOERROR ) { lc_perror(lm_job, "Failed to enable secure comms"); cleanup(initHandle); exit (lc_get_errno(lm_job)); } } if( !strstr(feature, FEATURE_DELIM) ) { /* * Single feature checkout */ #ifndef PC gettimeofday(&tStart, NULL); #endif //yashwanth switch(co) { case 1: printf("\n lc_checkout"); if(lc_checkout(lm_job, feature, "1.0", nlic, LM_CO_NOWAIT, &code, LM_DUP_NONE)) { lc_perror(lm_job, "checkout failed"); cleanup(initHandle); exit (lc_get_errno(lm_job)); } break; case 2: printf("\n lc_transfer_lic"); if(lc_transfer_lic(lm_job, feature, "1.0", nlic, &code)) { lc_perror(lm_job, "license transfer failed"); cleanup(initHandle); exit (lc_get_errno(lm_job)); } break; default: printf("\n Not selected any option of some error"); } //yashwanth #ifndef PC gettimeofday(&tEnd, NULL); latency = (tEnd.tv_sec - tStart.tv_sec)*1000.0 + (tEnd.tv_usec - tStart.tv_usec)/1000.0; #endif printf("\n %s checked out...", feature); printf("\n"); #ifndef PC printf("latency=%.1fms\n",latency); #endif printf("press return to exit..."); /* * Wait till user hits return */ getchar(); lc_checkin(lm_job, feature, 0); } else { /* * Batch feature checkout */ int f_count=1; /* We know there's at least one feature, plus 1 for each ',' */ int i; char** f_list; char* f; /* * Setup the list iof features */ for( f=feature; *f; f++ ) { if( *f == *FEATURE_DELIM ) ++f_count; } f_list = calloc(f_count, sizeof(*f_list)); f=strtok(feature, FEATURE_DELIM); for(i=0; i