Sample Code to get the expiration date of borrowed license
/**************************************************************************************************
* Copyright (c) 1997-2018 Flexera. All Rights Reserved.
**************************************************************************************************/
/*
*
* Description: This is a sample application program, to illustrate
* the use of the Flexible License Manager.
*
*/
#include "lmclient.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "lm_attr.h"
#include "lm_redir_std.h"
#ifdef PC
#define LICPATH "@localhost"
#else
#define LICPATH "@localhost:license.dat:."
#endif /* PC */
#define FEATURE "f1"
VENDORCODE code;
LM_HANDLE *lm_job;
LM_BORROW_STAT *s;
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'};
struct flexinit_property_handle *initHandle = NULL;
int nlic = 1;
char expiration_date[100];
struct tm *tm;
init(&initHandle);
if (argc > 1)
{
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));
}
printf("Enter \"f1\" to demo floating functionality\n");
printf("Enter \"f2\" to demo node-locked functionality\n");
printf("Enter feature to checkout [default: \"%s\"]: ", FEATURE);
fgets(feature, MAX_FEATURE_LEN + 2, 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);
lc_get_attr(lm_job, LM_A_BORROW_STAT, &s);
for(; s; s = s->next)
{
printf("Borrowed Feature is %s\n", s->feature);
tm = localtime(&s->end);
sprintf(expiration_date, "%d-%s-%02d %02d:%02d",
tm->tm_mday,
tm->tm_mon == 0 ? "Jan" :
tm->tm_mon == 1 ? "Feb" :
tm->tm_mon == 2 ? "Mar" :
tm->tm_mon == 3 ? "Apr" :
tm->tm_mon == 4 ? "May" :
tm->tm_mon == 5 ? "Jun" :
tm->tm_mon == 6 ? "Jul" :
tm->tm_mon == 7 ? "Aug" :
tm->tm_mon == 8 ? "Sep" :
tm->tm_mon == 9 ? "Oct" :
tm->tm_mon == 10 ? "Nov" : "Dec",
(tm->tm_year + 1900) % 2000,
tm->tm_hour, tm->tm_min);
printf("Expiration Date is %s\n",expiration_date);
getchar();
break;
}
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));
}
printf("%s checked out...", feature);
printf("press return to exit...");
/*
* Wait till user hits return
*/
getchar();
lc_checkin(lm_job, feature, 0);
lc_free_job(lm_job);
cleanup(initHandle);
return 0;
}
static void init(struct flexinit_property_handle **handle)
{
#ifndef NO_ACTIVATION_SUPPORT
struct flexinit_property_handle *ourHandle = NULL;
int stat;
if ((stat = lc_flexinit_property_handle_create(&ourHandle)))
{
fprintf(lm_flex_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(lm_flex_stderr(), "lc_flexinit_property_handle_set failed: %d\n", stat);
exit(1);
}
if ((stat = lc_flexinit(ourHandle)))
{
fprintf(lm_flex_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(lm_flex_stderr(), "lc_flexinit_cleanup failed: %d\n", stat);
}
if ((stat = lc_flexinit_property_handle_free(initHandle)))
{
fprintf(lm_flex_stderr(), "lc_flexinit_property_handle_free failed: %d\n", stat);
}
#endif /* NO_ACTIVATION_SUPPORT */
}
Was this helpful?
Related Articles
Best Practice: Handling SSL Certificate Changes for Cloud License Server Instances 21Number of Views How to Enable or Reset Producer User and Password for CLS 17Number of Views Clock Windback Detection doesn't Work With Get Feature Information 6Number of Views License Server System does not Support this Feature. (-18,327) 10Number of Views VM_UUID Detection Mechanism in Azure 11Number of Views
Revenera Assistant
Online
Hi, I am Reva - Ask me anything.
Updates
No new updates
Chat
Home
Updates
/**/
Thanks for the feedback!
Your feedback has been saved.Rate this response:
1
2
3
4
5
Add Additional feedback ( Optional )
0/240
English
English
Language changed successfully
Something went wrong
Email sent successfully
Something went wrong
Case create successfully
Are you sure you want to cancel
the case creation?
Please select a product to submit the case.
Please select a product version to submit the case.
0/255
Upload Attachment
File Upload
Maximum file
size allowed is 3 MB.
File type
not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Are you sure you want to cancel the case creation?
Case closed successfully
File Upload
Maximum file size allowed is 3 MB.
File type not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
File Upload
Maximum file
size allowed is 3 MB.
File type
not supported.
Supported file types:
Documents (.txt, .doc, .docx, .pdf), Images (.jpg, .png), Comma Separated Files
(.csv) Speadsheets (.xlsx, .xls)
Revenera Assistant
© 2026 Flexera Software. All Rights Reserved.
Case id: 00001065
Activity: Status change: 2 hours ago