示例#1
0
void HashGPDDNode::Print() const {
	cout << "HashGPDDNode Infomation:" << endl;
	cout << "Key Number: " << KeyNum() << " Node Number: " << NodeNum() << endl;
	cout << "Hit Time: " << TimesOfHit() << " Crash Time: " << TimesOfCrash() << endl;
	HashTable::const_iterator it = hTable.begin();
	HashNode* tmp;
	while(it != hTable.end()) {
		tmp = (*it).second;
		while(tmp) {
			cout << "Key Value: " << (*it).first << endl;
			cout << "Symbol: " << tmp->NodeInfo->sym->name << endl;
			tmp = tmp->next;
		}
		++it;
	}
}
示例#2
0
// загрузка таблицы управления ВМ из файла (VCR)
// вызывает:
// KeyNum()
// возвращает:
// 0 - успешно
int VCR::LoadVCR (char *fname)
{
#ifdef DEBUG_IRCOUT
	printf ("LoadVCR: %s", fname);
	printf (" open");
#endif
	// open file
#ifdef UNIX
	int handle = open (fname, O_RDONLY);
#else
	int handle = open (fname, O_RDONLY | O_BINARY);
#endif
	if (handle < 0)
	 {
	  errinf (EOPEN, "LoadVCR: Error open file\n");
	  return (EOPEN);
	 }

	if (!svcr)
	 {
	  // выделим место под таблицу
//	  svcr = (u_char *)malloc(0x996);
	  svcr = (vcrfile *)malloc(sizeof(vcrfile));
	 }

	// считываем таблицу
#ifdef DEBUG_IRCOUT
	printf (" read");
//	if (read (handle, svcr, 0x996) != 0x996) {
#endif
	if (read (handle, svcr, sizeof(vcrfile)) != sizeof(vcrfile))
	 {
	  errinf (EREAD, "LoadVCR: Read error file\n");
	  free (svcr);
	  svcr = NULL;
	  return (EREAD);
	 }

	close (handle);
//	fvcr = 1;
#ifdef DEBUG_IRCOUT
	printf ("CRC: %X\n", svcr->tstsum);
//	printf ("%s\n", svcr->kname[0]);
#endif
	keynums = KeyNum ();
	return (0);
};