KCMS Application Developer's Guide

Example: Using icSigNumTag and icSigListTag

Example 5-1shows you how to use icSigNumTag and icSigListTag.


Example 5-1 icSigNumTag and icSigListTag

#include <kcms/kcs.h>
 KcsAttributeValue					attrValue, *attrPtr;
 int					i;
 char					*tmp;

 /* Set the value of countSupplied */
 attrValue.base.countSupplied = 1;
 attrValue.base.type = KcsULong;

 /* Get the number of attributes in the profile */
 status = KcsGetAttribute(profile, icSigNumTag, &attrValue);
 if (status != KCS_SUCCESS) {
 	KcsFreeProfile(profile);
 	exit(1);
 }

 /* Make space to get a list of all tags */
 size = sizeof(KcsAttributeBase) + sizeof(long)*attrValue.val.uLongVal[0];
 if ((attrPtr = (KcsAttributeValue *)malloc(size)) == NULL) {
 	perror("malloc failed : ");
 	KcsFreeProfile(profile);
 	exit(1);
 }

 /* Get the list of tags */
 attrPtr->base.type = KcsULong;
 attrPtr->base.sizeOfType = sizeof(long);
 attrPtr->base.countSupplied = attrValue.val.uLongVal[0];
 status = KcsGetAttribute(profile, icSigListTag, attrPtr);
 if (status != KCS_SUCCESS) {
 	KcsFreeProfile(profile);
 	free (attrPtr);
 	exit(1);
 }

 /* Print the list */
 printf("Number of tags = %d\n", attrPtr->base.countSupplied);
 for (i=0; i<attrPtr->base.countSupplied; i++) {
 	tmp = (char *)&attrPtr->val.uLongVal[i];
 	printf("Tag # = %d, Tag Hex = 0x%x, Tag Ascii = %c%c%c%c\n", i,
 		attrPtr->val.uLongVal[i]; *tmp, *(tmp+1), *(tmp+2), *(tmp+3));
 }

 KcsFreeProfile(profile);
 free (attrPtr);