Exemple #1
0
void flush_cache (enum cache cache_t)
{
	switch (cache_t) {
	case CACHE1:
		fwrite(cache1, cache1_off, 1, fp_out);
		break;
	case CACHE2:
		output_cache(CACHE1, cache2, cache2_off);
		cache2_off = 0;
		break;
	case CACHE3:
		output_cache(CACHE2, cache3, cache3_off);
		cache3_off = 0;
		break;
	}
}
Exemple #2
0
int parse_item_item()
{
	match_line(ITEM_ITEM_HEADER);
	match_line(ITEM_ITEM_FIELD);
	while(1) {
		switch (looknext) {
		case ITEM_ITEM_FIELD:
			match_line(ITEM_ITEM_FIELD);
			break;
		case ITEM_ITEM_ITEM_HEADER:
			parse_item_item_item();
		default:
			goto _end;
		}
	}
_end:
	output_cache(CACHE2, "\t\t};\n", 5);
	flush_cache(CACHE3);
	return 0;
}
Exemple #3
0
meta_signed_transaction_ptr database::store( const signed_transaction& trx, const pow_hash& block_id )
{
   auto tid = trx.calculate_id();
   auto itr = my->_trxs.find( tid );
   if( itr == my->_trxs.end() )
   {
      meta_signed_transaction_ptr mst = std::make_shared<meta_signed_transaction>();
      mst->trx = trx;
      mst->blk = block_id;
      my->_trxs[tid] = mst;

      // add all of the outputs
      for( uint32_t i = 0; i < trx.outputs.size(); ++i )
      {
          auto oid = output_cache( tid, i, trx.outputs[i] ).output_id;
          my->_outputs[oid] = std::make_shared<meta_output>( trx.outputs[i], tid );

      }
      return mst;
   }
   return itr->second;
}
Exemple #4
0
void export_line(enum token_line t)
{
	int count;
	char buf[MAXLINEBUF];
	char buf1[MAXLINEBUF];
	char cache[MAXLINEBUF];
	int len;

	switch (t) {
	case SECTION_HEADER:
		output("struct sect%s {\n", to_c(section, buf1, 0));
		break;
	case SECTION_NAME:
		output("\t%s\tname[%d];\n", to_c(type, buf1, 0), bytes);
		break;
	case SECTION_NUMBER:
		count = bytes / sizeof_type(type);
		if (count == 1) {
			output("\t%s\tnumber;\n", to_c(type, buf1, 0));
		} else {
			output("\t%s\tnumber[%d];\n", to_c(type, buf1, 0), count);
		}
		break;
	case ITEM_HEADER:
		output("\tstruct st%s *%s;\n", to_c(g_buf, buf, 1), to_c(g_buf, buf1, 0));
		rewind_cache(CACHE1);
		field1 = 0;

		len = sprintf(cache, "\tstruct st%s {\n", to_c(g_buf, buf, 1));
		output_cache(CACHE1, cache, len);
		break;
	case ITEM_FIELD:
		count = bytes / sizeof_type(type);
		if (count == 1) {
			len = sprintf(cache, "\t\t%s\tf%d_%s;\n", to_c(type, buf, 0), field1++, to_c(field, buf1, 0));
		} else {
			len = sprintf(cache, "\t\t%s\tf%d_%s[%d];\n", to_c(type, buf, 0), field1++, to_c(field, buf1, 0), count);
		}
		output_cache(CACHE1, cache, len);
		break;
	case ITEM_FIELD_BINARY:
		break;
	case ITEM_FIELD_BINARY_HEADER:
		break;
	case ITEM_FIELD_BINARY_BITFIELD:
		break;
	case ITEM_ITEM_HEADER:
		len = sprintf(cache, "\t\tstruct stt%s *%s;\n", to_c(g_buf, buf, 1), to_c(g_buf, buf1, 0));
		output_cache(CACHE1, cache, len);
		rewind_cache(CACHE2);
		field2 = 0;

		len = sprintf(cache, "\t\tstruct stt%s {\n", to_c(g_buf, buf, 1));
		output_cache(CACHE2, cache, len);
		break;
	case ITEM_ITEM_FIELD:
		count = bytes / sizeof_type(type);
		if (count == 1) {
			len = sprintf(cache, "\t\t\t%s\tf%d_%s;\n", to_c(type, buf, 0), field2++, to_c(field, buf1, 0));
		} else {
			len = sprintf(cache, "\t\t\t%s\tf%d_%s[%d];\n", to_c(type, buf, 0), field2++, to_c(field, buf1, 0), count);
		}
		output_cache(CACHE2, cache, len);
		break;
	case ITEM_ITEM_ITEM_HEADER:
		len = sprintf(cache, "\t\t\tstruct sttt%s *%s;\n", to_c(g_buf, buf, 1), to_c(g_buf, buf1, 0));
		output_cache(CACHE2, cache, len);
		rewind_cache(CACHE3);
		field3 = 0;

		len = sprintf(cache, "\t\t\tstruct sttt%s {\n", to_c(g_buf, buf, 1));
		output_cache(CACHE3, cache, len);
		break;
	case ITEM_ITEM_ITEM_FIELD:
		count = bytes / sizeof_type(type);
		if (count == 1) {
			len = sprintf(cache, "\t\t\t\t%s\tf%d_%s;\n", to_c(type, buf, 0), field3++, to_c(field, buf1, 0));
		} else {
			len = sprintf(cache, "\t\t\t\t%s\tf%d_%s[%d];\n", to_c(type, buf, 0), field3++, to_c(field, buf1, 0), count);
		}
		output_cache(CACHE3, cache, len);
		break;
	default:
		;
	}
}