src/lib/BasicASN1Reader.h
branchv_0
changeset 35 bf2c546f49d1
parent 34 c15dc8762bdb
child 36 caed9146f72f
equal deleted inserted replaced
34:c15dc8762bdb 35:bf2c546f49d1
   251 			}
   251 			}
   252 
   252 
   253 		} else {
   253 		} else {
   254 			// TODO: do not skip, parse
   254 			// TODO: do not skip, parse
   255 			// TODO: check available bytes before allocating buffer
   255 			// TODO: check available bytes before allocating buffer
   256 			std::vector<uint8_t> temp(typeHeader.length, 0);
   256 			std::string s;
   257 			read(temp.data(), typeHeader.length);
   257 			s.resize(typeHeader.length);
   258 			// TODO: recover transaction?
   258 			read((uint8_t*) s.data(), typeHeader.length);
   259 
   259 			handlers->writeSpecific(typeHeader, s);
   260 			std::stringstream description;
       
   261 			description << "UNKNOWN:"
       
   262 					<< " tag = " << typeHeader.tag
       
   263 					<< " tagClass = " << (int) typeHeader.tagClass
       
   264 					<< " pc = " << (int) typeHeader.pc
       
   265 					<< " length = " << typeHeader.length
       
   266 					<< " definite = " << (typeHeader.definiteLength ? "true" : "false")
       
   267 					<< " hex = ";
       
   268 			description << std::hex << std::setfill('0');
       
   269 			for (uint8_t b : temp) description << std::setw(2) << (int) b;
       
   270 			description << " ascii = ";
       
   271 			for (uint8_t b : temp) description << (b >= 32 && b < 127 ? (char) b : '.');
       
   272 			// TODO: special event for unparsed? (instead of a text string)
       
   273 			handlers->writeTextString(typeHeader, description.str());
       
   274 		}
   260 		}
   275 
   261 
   276 		commit();
   262 		commit();
   277 	}
   263 	}
   278 
   264