CByteArray APL_Certifs::getXML(bool bNoHeader) { /* <certificates count=��> <certificate> </certificate> </certificates> */ char buffer[50]; CByteArray xml; if(!bNoHeader) xml+="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; xml+="<certificates count=\""; sprintf_s(buffer,sizeof(buffer),"%ld",countAll(true)); xml+=buffer; xml+="\">\n"; for(unsigned long i=0;i<countAll(true);i++) { xml+=getCert(i,true)->getXML(true); } xml+="</certificates>\n"; return xml; }
int process(GlobalArgs* globalArgs) { char currentFileName[MAX_PATH_LENGTH]; int buildOrNot = 0; FILE *fp; //we are going to rebuild the keyword index if it does not exist snprintf(currentFileName, MAX_PATH_LENGTH, "%s_%d-mers_KWTREE_INFO", globalArgs->patternFileName, globalArgs->k); if(!(fp= fopen ( currentFileName , "rb" ))) buildOrNot=1; else fclose(fp); if(buildOrNot) { if(buildPatternIndex(globalArgs)!=0) { printf("Error building keyword tree for the pattern set\n"); return 1; } } //if -c option is specified we are going to iterate over files in globalArgs.inputFiles and produce counts if(globalArgs->countOrNot==1) { if(countAll(globalArgs)!=0) { printf("Error counting\n"); return 1; } } return 0; }
CByteArray APL_Certifs::getCSV() { /* certificatescount;certificate1;certificate2;... */ char buffer[50]; CByteArray csv; sprintf_s(buffer,sizeof(buffer),"%ld",countAll(true)); csv+=buffer; csv+=CSV_SEPARATOR; for(unsigned long i=0;i<countAll(true);i++) { csv+=getCert(i,true)->getCSV(); } return csv; }
int KDPropertyModel::Private::countAll( KDPropertyGroupInterface* root ) const { int res = 0; for( int i = 0; i < root->propertyCount(); ++i ) { KDPropertyInterface* prop = root->propertyAt(i); if( prop->isCategory() ) { res += countAll(static_cast<KDPropertyGroupInterface*>(prop)); } else { ++res; } } return res; }
CByteArray APL_Certifs::getTLV() { //First we add all the certs in a tlv CTLVBuffer tlvNested; CByteArray baCount; baCount.AppendLong(countAll(true)); tlvNested.SetTagData(0x00,baCount.GetBytes(),baCount.Size()); //Tag 0x00 contain the number of certificates unsigned char j=1; for(unsigned long i=0;i<countAll(true);i++) { APL_Certif *cert=getCert(i,true); CByteArray baCert=cert->getTLV(); tlvNested.SetTagData(j++,baCert.GetBytes(),baCert.Size()); } unsigned long ulLen=tlvNested.GetLengthNeeded(); unsigned char *pucData= new unsigned char[ulLen]; tlvNested.Extract(pucData,ulLen); CByteArray baCerts(pucData,ulLen); delete[] pucData; //We nest the tlv into the enclosing tlv CTLVBuffer tlv; tlv.SetTagData(BEID_TLV_TAG_FILE_CERTS,baCerts.GetBytes(),baCerts.Size()); ulLen=tlv.GetLengthNeeded(); pucData= new unsigned char[ulLen]; tlv.Extract(pucData,ulLen); CByteArray ba(pucData,ulLen); delete[] pucData; return ba; }