static CFHashCode __CFXMLNodeHash(CFTypeRef  cf) {
    CFXMLNodeRef node = (CFXMLNodeRef)cf;
    if (node->dataString) {
        return CFHash(node->dataString);
    }
    if (node->dataTypeID == kCFXMLNodeTypeDocument) {
        CFURLRef url = ((CFXMLDocumentInfo *)node->additionalData)->sourceURL;
        return url ? CFHash(url) : (CFHashCode)cf;
    } else {
        CFAssert2(false, __kCFLogAssertion, "%s(): Saw unexpected XML type code %d", __PRETTY_FUNCTION__, node->dataTypeID);
        return CFHash(cf);
    }
}
Esempio n. 2
0
STATIC CFHashCode
__EAPOLClientItemIDHash(CFTypeRef cf)
{
    EAPOLClientItemIDRef 	itemID = (EAPOLClientItemIDRef)cf;

    return (CFHash(itemID->u.ptr));
}
Esempio n. 3
0
static CFHashCode
__SCNetworkSetHash(CFTypeRef cf)
{
	SCNetworkSetPrivateRef	setPrivate	= (SCNetworkSetPrivateRef)cf;

	return CFHash(setPrivate->setID);
}
STATIC CFHashCode
__EAPOLClientProfileHash(CFTypeRef cf)
{
    EAPOLClientProfileRef 	profile = (EAPOLClientProfileRef)cf;

    return (CFHash(profile->uuid));
}
CFHashCode SecCode::hash()
{
	if (CFDataRef h = this->cdHash())
		return CFHash(h);
	else
		return this->staticCode()->hash();
}
Esempio n. 6
0
 CFHashCode Type::Hash( void ) const
 {
     if( this->GetCFObject() == NULL )
     {
         return static_cast< CFHashCode >( 0 );
     }
     
     return CFHash( this->GetCFObject() );
 }
void	HP_IOCycleTelemetry::Initialize(CFStringRef /*inName*/)
{
    //	get the device's UID
    CACFString theUID(mDevice->CopyDeviceUID());

    //	get the CFHash of the UID
    UInt32 theHashCode = ToUInt32(CFHash(theUID.GetCFString()));

    //	sum all the characters in the UID
    UInt64 theSum = 0;
    UInt32 theNumberCharacters = ToUInt32(CFStringGetLength(theUID.GetCFString()));
    for(UInt32 theCharacterIndex = 0; theCharacterIndex < theNumberCharacters; ++theCharacterIndex)
    {
        UniChar theCharacter = CFStringGetCharacterAtIndex(theUID.GetCFString(), theCharacterIndex);
        theSum += theCharacter;
    }

    //	build a string out of the hash code and character sum
    CFStringRef thePortName = CFStringCreateWithFormat(NULL, NULL, CFSTR(kHALIOCycleTelemetryServerPortNameFormat), CAProcess::GetPID(), theHashCode, theSum);

    //	initialize the super class (who releases the port name too)
    HP_TelemetryServer::Initialize(thePortName);
}
Esempio n. 8
0
/* CFError hash code is hash(domain) + code
 */
static CFHashCode __CFErrorHash(CFTypeRef cf) {
    CFErrorRef err = (CFErrorRef)cf;
    return CFHash(err->domain) + err->code;
}
Esempio n. 9
0
static CFHashCode FavoriteSetItemHashCode( const void *value )
{
  // This function is called whenver the collection needs to calculate
  //  the so-called hash code of the item. A hash code is an integer
  //  number that makes comparing and searching for items much faster.
  // The number returned can be anything, but it must follow this rule:
  //  - Two items that are equal MUST return the same hash code
  //
  // The set is most efficient when any two items that are not equal
  //  return different numbers for their hash code. Since this is
  //  impossible (there are many more possible strings than possible
  //  hash code numbers), the idea is to create a hash code function
  //  that makes it unlikely that two different strings would return
  //  the same number. The more unlikely, the better the hash code,
  //  function, and the more efficient the set.
  
#if 1
  // Our implementation will add all of the character values of the
  //  string into a CFHashCode integer, shifting each successive
  //  character by one bit so the bits of each character get scattered
  //  around the bits of the larger integer. Step through this with
  //  the debugger to see how even slightly different strings return
  //  dramatically different numbers.
  CFHashCode code = 0;
  unsigned int bitShift = 0;
  const char* c = value;
  while ( *c != '\0' ) {
    // Note: the char value (*c) must be converted, via a typecast,
    //     to and CFHashCode sized integer *before* it gets bit
    //     shifted using the << operator. Without the explicit
    //     type conversion, the << operator would happily shift
    //     the bits of the char right into outerspace, since
    //     a char can only hold 8 bits. By converting it first,
    //     the bits of the char now occupy the lower bits of
    //     a much larger integer, and have someplace to go
    //     when shifted.
    code += ( ((CFHashCode)*c) << bitShift );
    
    // Increment bitShift so the next char gets shifted one more
    //  bit to the left. When bitShift gets so large that it
    //  would shift the char's bit off of the end of the CFHashCode
    //  integer, retart it at 0 again.
    if ( ++bitShift >= (sizeof(CFHashCode)-sizeof(char)) * 8 )
      bitShift = 0;
    
    // Advance to the next char in the string
    c++;
  }
#else
  // Alternative implementation:
  // This version, which you can compile and test by changing the
  //  #if 1 statement into an #if 0 statement, uses the Core
  //  Foundation library to calculate a hash value for us.
  // It's not as efficient--because it creates and destroys
  //  a CFString object every time it wants to calculate a hash
  //  code--but it's a lot less work.
  CFHashCode code;
  CFStringRef string;
  // Create a string object from our C string.
  string = CFStringCreateWithCString( NULL, value, kCFStringEncodingASCII );
  // Ask the string object for its hash code
  code = CFHash( string );
  // When you create or copy a Core Foundation object, you're responsible
  //  for destroying it again (much like alloc() and free()).
  CFRelease( string );
#endif
  
  return code;
}
Esempio n. 10
0
static long cf_hash(value v) {
  CAMLparam1(v);
  CAMLreturn((long)CFHash(cf_unwrap(v)));
}
Esempio n. 11
0
static CFHashCode __CFMessagePortHash(CFTypeRef cf) {
    CFMessagePortRef ms = (CFMessagePortRef)cf;
    return CFHash(ms->_port);
}
Esempio n. 12
0
static CFHashCode CGLayerHash (CFTypeRef cf)
{
	return CFHash (cf);
}
Esempio n. 13
0
static CFHashCode __CFLocaleHash(CFTypeRef cf) {
    CFLocaleRef locale = (CFLocaleRef)cf;
    return CFHash(locale->_identifier);
}
static Boolean
_auth_item_equal(CFTypeRef value1, CFTypeRef value2)
{
    return (CFHash(value1) == CFHash(value2));
}
Esempio n. 15
0
 HashCode Blob::hash() const
 {
     return CFHash(mData);
 }
CFHashCode digest_mapping_hash(struct digest_mapping *dm) {
	return CFHash(dm->digest_name) + dm->kclass + dm->digest_length;
}
Esempio n. 17
0
/* CFError hash code is hash(domain) + code
*/
static CFHashCode __CFErrorHash(CFTypeRef cf) {
    CFErrorRef err = (CFErrorRef)cf;
    /* !!! We do not need an assertion here, as this is called by the CFBase runtime only */
    return CFHash(err->domain) + err->code;
}
Esempio n. 18
0
static CFHashCode __DAFileSystemHash( CFTypeRef object )
{
    DAFileSystemRef filesystem = ( DAFileSystemRef ) object;

    return CFHash( filesystem->_id );
}
Esempio n. 19
0
static CFHashCode __CFCalendarHash(CFTypeRef cf) {
    CFCalendarRef calendar = (CFCalendarRef)cf;
    return CFHash(calendar->_identifier);
}
Esempio n. 20
0
static CFHashCode pairHash(const void* value)
{
    const SchedulePair* pair = static_cast<const SchedulePair*>(value);

    return (CFHashCode)pair->runLoop ^ CFHash(pair->mode);
}