Summary
This article provides a sample application that returns all features using lc_feat_list including duplicates.Synopsis
Sample application that returns all features using lc_feat_list including duplicates.Discussion
/******************************************************************************
Copyright (c) 1988-2010 Flexera Software Inc. All Rights Reserved
This software has been provided pursuant to a License Agreement containing restrictions on its use. This software contains valuable trade secrets and proprietary information of Flexera Inc. and is protected by law. It may not be copied or distributed in any form or medium, disclosed to third parties, reverse engineered or used in any manner not provided for in said License Agreement except with the prior written authorization from Flexera Inc.
*****************************************************************************/
/*
*
* 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"
#ifdef PC
#define LICPATH "@localhost"
#else
#define LICPATH "@localhost:license.dat:."
#endif /* PC */
#define FEATURE "f1"
VENDORCODE code;
LM_HANDLE *lm_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;
char **feats;
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 node-locked functionality\n");
printf("Enter feature to checkout [default: \"%s\"]: ", FEATURE);
fgets(feature, MAX_FEATURE_LEN + 2, 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);
feats = lc_feat_list(lm_job, 0, NULL);
while (feats && *feats)
{/*do the following for every feature in license file*/
CONFIG *pos = NULL;
CONFIG *conf = NULL;
/* Go through all config structs of this feature */
for( pos = 0, conf = lc_next_conf(lm_job, *feats, &pos);
conf;
conf = lc_next_conf( lm_job, *feats, &pos ) )
{
printf ("Feature %s has %d count\n", conf->feature, conf->users );
}
feats++;
} /* end while (feats && *feats) */
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;
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 */
}Related Articles
How to Use lc_feat_list Only With Server Which Serves Features When You Have Multiple Licenses in Path? 7Number of Views Prevent FlexNet inventory agent AgentID collisions when cloning virtual machines 62Number of Views PowerShell script to return the name of the application process that is using a port 6Number of Views Sample Code/API To Get Content Of License File Which The License Server (lmgrd/ansyslmd) Is Using 11Number of Views Problem building FlexNet Publisher 11.6.1 csharp sample application 'out of the box' 4Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
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. | |
Revenera Assistant
Case id: 00001065
Activity: Status change: 2 hours ago