예제 #1
0
파일: xml.cpp 프로젝트: kreshano/hiphop-php
xmlDocPtr soap_xmlParseFile(const char *filename) {
  String cache_key("HPHP.SOAP.WSDL.");
  cache_key += filename;

  Variant content = f_apc_fetch(cache_key);
  if (same(content, false)) {
    Variant stream = File::Open(filename, "rb", CREATE_MAP1
                                ("http", CREATE_MAP1("timeout", 1000)));
    if (!same(stream, false)) {
      content = f_stream_get_contents(stream);
      if (!same(content, false)) {
        f_apc_store(cache_key, content);
      }
    }
  }

  if (!same(content, false)) {
    String scontent = content.toString();
    return soap_xmlParseMemory(scontent.data(), scontent.size());
  }
  return NULL;
}
예제 #2
0
파일: tcsps.c 프로젝트: wy461132/repository
/*
 * disk store format:
 *
 * TrouSerS 0.2.0 and before:
 * Version 0:                  cached?
 * [UINT32   num_keys_on_disk]
 * [TSS_UUID uuid0           ] yes
 * [TSS_UUID uuid_parent0    ] yes
 * [UINT16   pub_data_size0  ] yes
 * [UINT16   blob_size0      ] yes
 * [UINT16   cache_flags0    ] yes
 * [BYTE[]   pub_data0       ]
 * [BYTE[]   blob0           ]
 * [...]
 *
 * TrouSerS 0.2.1+
 * Version 1:                  cached?
 * [BYTE     PS version = '\1']
 * [UINT32   num_keys_on_disk ]
 * [TSS_UUID uuid0            ] yes
 * [TSS_UUID uuid_parent0     ] yes
 * [UINT16   pub_data_size0   ] yes
 * [UINT16   blob_size0       ] yes
 * [UINT32   vendor_data_size0] yes
 * [UINT16   cache_flags0     ] yes
 * [BYTE[]   pub_data0        ]
 * [BYTE[]   blob0            ]
 * [BYTE[]   vendor_data0     ]
 * [...]
 *
 */
TSS_RESULT
psfile_write_key(int fd,
		TSS_UUID *uuid,
		TSS_UUID *parent_uuid,
		UINT32 *parent_ps,
		BYTE *vendor_data,
		UINT32 vendor_size,
		BYTE *key_blob,
		UINT16 key_blob_size)
{
	TSS_KEY key;
	UINT16 pub_key_size, cache_flags = CACHE_FLAG_VALID;
	UINT64 offset;
	int rc = 0;

	/* leaving the cache flag for parent ps type as 0 implies TSS_PS_TYPE_USER */
	if (*parent_ps == TSS_PS_TYPE_SYSTEM)
		cache_flags |= CACHE_FLAG_PARENT_PS_SYSTEM;

	/* Unload the blob to get the public key */
	offset = 0;
	if ((rc = UnloadBlob_TSS_KEY(&offset, key_blob, &key)))
		return rc;

	pub_key_size = key.pubKey.keyLength;

        if ((rc = write_key_init(fd, pub_key_size, key_blob_size, vendor_size)) < 0)
                goto done;

	/* offset now holds the number of bytes from the beginning of the file
	 * the key will be stored at
	 */
	offset = rc;

#ifdef TSS_DEBUG
	if (offset == 0)
		LogDebug("ERROR: key being written with offset 0!!");
#endif

	/* [TSS_UUID uuid0           ] yes */
        if ((rc = write_data(fd, (void *)uuid, sizeof(TSS_UUID)))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [TSS_UUID uuid_parent0    ] yes */
        if ((rc = write_data(fd, (void *)parent_uuid, sizeof(TSS_UUID)))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [UINT16   pub_data_size0  ] yes */
        if ((rc = write_data(fd, &pub_key_size, sizeof(UINT16)))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [UINT16   blob_size0      ] yes */
        if ((rc = write_data(fd, &key_blob_size, sizeof(UINT16)))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [UINT32   vendor_data_size0 ] yes */
        if ((rc = write_data(fd, &vendor_size, sizeof(UINT32)))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [UINT16   cache_flags0    ] yes */
        if ((rc = write_data(fd, &cache_flags, sizeof(UINT16)))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [BYTE[]   pub_data0       ] no */
        if ((rc = write_data(fd, (void *)key.pubKey.key, pub_key_size))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [BYTE[]   blob0           ] no */
        if ((rc = write_data(fd, (void *)key_blob, key_blob_size))) {
		LogError("%s", __FUNCTION__);
                goto done;
	}

	/* [BYTE[]   vendor_data0    ] no */
	if (vendor_size > 0) {
		if ((rc = write_data(fd, (void *)vendor_data, vendor_size))) {
			LogError("%s", __FUNCTION__);
			goto done;
		}
	}

	if ((rc = cache_key((UINT32)offset, cache_flags, uuid, parent_uuid, pub_key_size,
					key_blob_size, vendor_size)))
                goto done;
done:
	destroy_key_refs(&key);

        return rc;
}
예제 #3
0
string method_properties::impl2::get_property( int num_opt, 
					       const string& prop_name ) const
{
  pair< int, string > cache_key( num_opt, prop_name );

  {
    // Is it in the cache?
    map< pair< int, string >, string >::const_iterator cacheval
      = cache.find( cache_key );
    if ( cacheval != cache.end() )
      return cacheval->second;
  }

  make_string os;

  // Generate the value
  if ( prop_name.size() == 1 )
    {
      switch ( prop_name[0] ) 
	{
	case 'L':
	  os << setw(num_opt) << m.size();
	  break;
	  
	case 'l': 
	  os << m.lh();
	  break;

	case 'p': 
	  os << m.format( method::M_UCROSS | method::M_DOTS | 
			  method::M_EXTERNAL );
	  break;

	case 'q': 
	  os << m.format( method::M_DASH | method::M_FULL_SYMMETRY );
	  break;

	case 'Q': 
	  os << m.format( method::M_DASH | method::M_SYMMETRY |
                          method::M_OMIT_LH );
	  break;

	case 'r': {
	  // TODO:  Should we cache all rows at same time?
	  row r( m.bells() );
	  int n( num_opt );
	  for ( method::const_iterator 
		  i( m.begin() ), e( m.begin() + num_opt );
		n && i != e; ++i, --n ) 
	    r *= *i;
	  if ( n )
	    throw runtime_error( "Format specifies row after end of method" );
	  os << r;
	} break;

	case 'h': 
	  try { 
            os << m.at( num_opt-1 ); 
          } catch ( out_of_range const& ) {
            // This should only happen if we're filtering with -U0 and no -n.
            os << expr_error_string;
          }
	  break;

	case 'b': 
	  os << setw(num_opt) << m.maxblows();
	  break;

	case 'o': 
	  os << setw(num_opt) << m.leads();
	  break;

	case 'u': 
	  os << setw(num_opt) << m.huntbells(); 
	  break;

	case 'B': 
	  os << setw(num_opt) << m.bells(); 
	  break;

	case 'd': 
	  os << m.lhcode(); 
	  break;

	case 'D':
	  os << old_lhcode(formats_in_unicode, m);
	  break;

	case 'y':
	  os << method_symmetry_string( m );
	  break;

	case 'n':
	  os << base_name();
	  break;

	case 'N':
	  os << name();
	  break;

	case 'C': 
	  os << method::classname( m.methclass() ); 
	  break;

	case 'S': 
	  os << method::stagename( m.bells() );
	  break;

	case 'M': 
	  os << setw(num_opt) << musical_analysis::analyse(m);
	  break;

	case 'F': 
	  os << falseness_group_codes(m);
	  break;

	case 'P': {
	  bell b(num_opt-1); os << b;
	  for ( method::const_iterator i( m.begin() ), e( m.end() ); 
		i != e; ++i ) os << (b *= *i);
	} break;

	case 'O': 
	  os << tenors_together_coursing_order(m);
	  break;

        case 's':
          os << setw(num_opt) << staticity(m);
          break;

	case '#': {
	  static RINGING_ULLONG n=0;
	  os << setw(num_opt) << ++n;
	} break;
 
        case 'i': {
          library_entry const& e = method_libraries::instance().find(m);
          if ( !e.null() && e.has_facet<cc_collection_id>() )
            os << setw(num_opt) << e.get_facet<cc_collection_id>();
          else 
            os << string( num_opt, ' ' );
        } break;

        case 'T': {
          char buf[16]; time_t t = time(NULL);
          // This use of the internal libc struct tm may not be thread safe.
          strftime(buf, sizeof(buf), "%H:%M:%S", localtime(&t));
          os << buf;
        } break;

        case 'a': 
          os << payload;
          break;
 
        case '?':
          // Return it to avoid caching it
          return os << setw(num_opt) << get_last_exec_status(); 

	default:
	  throw logic_error( "Unknown variable requested" );
	}
    }
  else
    {
      throw logic_error( "Unknown variable requested" );
    }

  return cache[ cache_key ] = os;
}
            mesh_name = attachment_name;
            break;
          }
        }
        if (!mesh_name.empty())
          set_field("mesh_uri", db_->parameters().at("root").get_str() + std::string("/")
                + db_->parameters().at("collection").get_str() + "/" + mesh_id
                + "/" + mesh_name);
      }
      break;
    default:
      for (; iter != end; ++iter) {
        if ((*iter).has_field("mesh_uri")) {
          set_field("mesh_uri", (*iter).get_field<std::string>("mesh_uri"));
          break;
        } else if ((*iter).has_attachment("mesh")) {
          std::stringstream stream;
          (*iter).get_attachment_stream("mesh", stream);
          set_attachment_stream("mesh", stream);
          break;
        }
      }
      break;
  }

      // Cache all the results
      cached_name_mesh_id_[cache_key()] = *this;
    }
  }
}