当前位置: 首页>>代码示例>>C++>>正文


C++ CFDictionaryGetValue函数代码示例

本文整理汇总了C++中CFDictionaryGetValue函数的典型用法代码示例。如果您正苦于以下问题:C++ CFDictionaryGetValue函数的具体用法?C++ CFDictionaryGetValue怎么用?C++ CFDictionaryGetValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CFDictionaryGetValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: collect_drive_stats

static int
collect_drive_stats(io_registry_entry_t driver, long *stats)
{
    CFNumberRef     number;
    CFDictionaryRef properties;
    CFDictionaryRef statistics;
    long            value;
    kern_return_t   status;
    int             i;


    /*
     * If the drive goes away, we may not get any properties
     * for it.  So take some defaults. Nb: use memset ??
     */
    for (i = 0; i < kIDXLast; i++) {
	stats[i] = 0;
    }

    /* retrieve the properties */
    status = IORegistryEntryCreateCFProperties(driver, (CFMutableDictionaryRef *)&properties,
					       kCFAllocatorDefault, kNilOptions);
    if (status != KERN_SUCCESS) {
	snmp_log(LOG_ERR, "diskio: device has no properties\n");
/*	fprintf(stderr, "device has no properties\n"); */
	return (1);
    }

    /* retrieve statistics from properties */
    statistics = (CFDictionaryRef)CFDictionaryGetValue(properties,
						       CFSTR(kIOBlockStorageDriverStatisticsKey));
    if (statistics) {

	/* Now hand me the crystals. */
	if ((number = (CFNumberRef)CFDictionaryGetValue(statistics,
						 CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey)))) {
	    CFNumberGetValue(number, kCFNumberSInt32Type, &value);
	    stats[kIDXBytesRead] = value;
	}

	if ((number = (CFNumberRef)CFDictionaryGetValue(statistics,
						 CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey)))) {
	    CFNumberGetValue(number, kCFNumberSInt32Type, &value);
	    stats[kIDXBytesWritten] = value;
	}

	if ((number = (CFNumberRef)CFDictionaryGetValue(statistics,
						 CFSTR(kIOBlockStorageDriverStatisticsReadsKey)))) {
	    CFNumberGetValue(number, kCFNumberSInt32Type, &value);
	    stats[kIDXNumReads] = value;
	}
	if ((number = (CFNumberRef)CFDictionaryGetValue(statistics,
						 CFSTR(kIOBlockStorageDriverStatisticsWritesKey)))) {
	    CFNumberGetValue(number, kCFNumberSInt32Type, &value);
	    stats[kIDXNumWrites] = value;
	}
    }
    /* we're done with the properties, release them */
    CFRelease(properties);
    return (0);
}
开发者ID:OPSF,项目名称:uClinux,代码行数:61,代码来源:diskio.c

示例2: CFDictionaryGetValue

void wxHIDKeyboard::DoBuildCookies(CFArrayRef Array)
{
    //Now go through each possible cookie
    int i,
        nUsage;
//    bool bEOTriggered = false;
    for (i = 0; i < CFArrayGetCount(Array); ++i)
    {
        const void* ref = CFDictionaryGetValue(
                (CFDictionaryRef)CFArrayGetValueAtIndex(Array, i),
                CFSTR(kIOHIDElementKey)
                                              );

        if (ref != NULL)
        {
            DoBuildCookies((CFArrayRef) ref);
        }
        else
    {

            //
            // Get the usage #
            //
        CFNumberGetValue(
                (CFNumberRef)
                    CFDictionaryGetValue((CFDictionaryRef)
                        CFArrayGetValueAtIndex(Array, i),
                        CFSTR(kIOHIDElementUsageKey)
                                        ),
                              kCFNumberLongType,
                              &nUsage);

            //
            // Now translate the usage # into a wx keycode
            //

        //
        // OK, this is strange - basically this kind of strange -
        // Starting from 0xEO these elements (like shift) appear twice in
        // the array!  The ones at the end are bogus I guess - the funny part
        // is that besides the fact that the ones at the front have a Unit
        // and UnitExponent key with a value of 0 and a different cookie value,
        // there is no discernable difference between the two...
        //
        // Will the real shift please stand up?
        //
        // Something to spend a support request on, if I had one, LOL.
        //
        //if(nUsage == 0xE0)
        //{
        //    if(bEOTriggered)
        //       break;
        //    bEOTriggered = true;
        //}
        //Instead of that though we now just don't add duplicate keys

        if (nUsage >= kHIDUsage_KeyboardA && nUsage <= kHIDUsage_KeyboardZ)
            AddCookie(CFArrayGetValueAtIndex(Array, i), 'A' + (nUsage - kHIDUsage_KeyboardA) );
        else if (nUsage >= kHIDUsage_Keyboard1 && nUsage <= kHIDUsage_Keyboard9)
            AddCookie(CFArrayGetValueAtIndex(Array, i), '1' + (nUsage - kHIDUsage_Keyboard1) );
        else if (nUsage >= kHIDUsage_KeyboardF1 && nUsage <= kHIDUsage_KeyboardF12)
            AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_F1 + (nUsage - kHIDUsage_KeyboardF1) );
        else if (nUsage >= kHIDUsage_KeyboardF13 && nUsage <= kHIDUsage_KeyboardF24)
            AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_F13 + (nUsage - kHIDUsage_KeyboardF13) );
        else if (nUsage >= kHIDUsage_Keypad1 && nUsage <= kHIDUsage_Keypad9)
            AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_NUMPAD1 + (nUsage - kHIDUsage_Keypad1) );
        else switch (nUsage)
        {
            //0's (wx & ascii go 0-9, but HID goes 1-0)
            case kHIDUsage_Keyboard0:
                AddCookie(CFArrayGetValueAtIndex(Array, i), '0');
                break;
            case kHIDUsage_Keypad0:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_NUMPAD0);
                break;

            //Basic
            case kHIDUsage_KeyboardReturnOrEnter:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_RETURN);
                break;
            case kHIDUsage_KeyboardEscape:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_ESCAPE);
                break;
            case kHIDUsage_KeyboardDeleteOrBackspace:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_BACK);
                break;
            case kHIDUsage_KeyboardTab:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_TAB);
                break;
            case kHIDUsage_KeyboardSpacebar:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_SPACE);
                break;
            case kHIDUsage_KeyboardPageUp:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_PAGEUP);
                break;
            case kHIDUsage_KeyboardEnd:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_END);
                break;
            case kHIDUsage_KeyboardPageDown:
                AddCookie(CFArrayGetValueAtIndex(Array, i), WXK_PAGEDOWN);
//.........这里部分代码省略.........
开发者ID:jonntd,项目名称:dynamica,代码行数:101,代码来源:hid.cpp

示例3: getProcessInfo

CFDictionaryRef getProcessInfo(CFStringRef targetCreator, CFStringRef targetName, CFStringRef targetIdentifier) {
	/* find an applicarion process specified by theSignature(creator type) from runnning process.
	if target application can be found, get information of the process and return as a result
	*/
	CFIndex nKey = 3;
	CFMutableArrayRef keyList = CFArrayCreateMutable(NULL,nKey,&kCFTypeArrayCallBacks);
	CFArrayAppendValue(keyList, CFSTR("FileCreator"));
	CFArrayAppendValue(keyList, CFSTR("CFBundleIdentifier"));
	CFArrayAppendValue(keyList, CFSTR("CFBundleName"));

	CFIndex firstKeyIndex;
	
	if (targetCreator != NULL) {
		firstKeyIndex = 0;
	}
	else if (targetIdentifier != NULL) {
		firstKeyIndex = 1;
	}
	else {
		firstKeyIndex = 2;
	}
	if (targetCreator == NULL) targetCreator = (CFStringRef)kCFNull;
	if (targetName == NULL) targetName = (CFStringRef)kCFNull;
	if (targetIdentifier == NULL) targetIdentifier = (CFStringRef)kCFNull;

	CFMutableArrayRef valueList = CFArrayCreateMutable(NULL, nKey,&kCFTypeArrayCallBacks);
	CFArrayAppendValue(valueList, targetCreator);
	CFArrayAppendValue(valueList, targetIdentifier);
	CFArrayAppendValue(valueList, targetName);
	
	CFStringRef dictKey = CFArrayGetValueAtIndex(keyList, firstKeyIndex);
	CFArrayRemoveValueAtIndex(keyList, firstKeyIndex);
	CFStringRef targetValue = CFArrayGetValueAtIndex(valueList, firstKeyIndex);
	CFArrayRemoveValueAtIndex(valueList, firstKeyIndex);
	
	Boolean isFound = false;
	ProcessSerialNumber psn = {kNoProcess, kNoProcess};
	CFDictionaryRef pDict = NULL;
	CFComparisonResult isSameStr;
	
	OSErr err = GetNextProcess(&psn);
	while( err == noErr) {
		pDict = ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask);
		CFStringRef dictValue = CFDictionaryGetValue(pDict, dictKey);
		if (dictValue != NULL) {
			isSameStr = CFStringCompare(dictValue,targetValue,0);

			if (isSameStr == kCFCompareEqualTo){
				isFound = true;
				for (CFIndex i=0; i < 2; i++) {
					CFStringRef secondValue = CFArrayGetValueAtIndex(valueList,i);
					if (secondValue != (CFStringRef)kCFNull) {
						CFStringRef nextKey = CFArrayGetValueAtIndex(keyList, i);
						dictValue = CFDictionaryGetValue(pDict,nextKey);
						isSameStr = CFStringCompare(dictValue,secondValue,0);
						if (isSameStr != kCFCompareEqualTo) {
							isFound = false;
							break;
						}
					}
				}
				
				if (isFound) break;
			}
		}
		
		CFRelease(pDict);
		err = GetNextProcess (&psn);
	}
	
	CFRelease(keyList);
	CFRelease(valueList);
	
	if (isFound) {
#if useLog	
		printf("getProcessInfo found PSN high:%d, low:%d \n", psn.highLongOfPSN, psn.lowLongOfPSN);
#endif
        CFMutableDictionaryRef p_dict_psn = CFDictionaryCreateMutableCopy (NULL, 0, pDict);
		CFDictionaryAddValue(p_dict_psn, CFSTR("PSNLow"), 
									CFNumberCreate(NULL, kCFNumberSInt32Type, &(psn.lowLongOfPSN)));
		CFDictionaryAddValue(p_dict_psn, CFSTR("PSNHigh"), 
									CFNumberCreate(NULL, kCFNumberSInt32Type, &(psn.highLongOfPSN)));
		CFRelease(pDict);
		return p_dict_psn;
	}
	else{
		return nil;
	}
}
开发者ID:tkurita,项目名称:SmartActivateLib,代码行数:89,代码来源:SmartActivate.c

示例4: copy_display_modes

/***********************************************************************
 *              copy_display_modes
 *
 * Wrapper around CGDisplayCopyAllDisplayModes() to include additional
 * modes on Retina-capable systems, but filter those which would confuse
 * Windows apps (basically duplicates at different DPIs).
 *
 * For example, some Retina Macs support a 1920x1200 mode, but it's not
 * returned from CGDisplayCopyAllDisplayModes() without special options.
 * This is especially bad if that's the user's default mode, since then
 * no "available" mode matches the initial settings.
 */
static CFArrayRef copy_display_modes(CGDirectDisplayID display)
{
    CFArrayRef modes = NULL;

#if defined(MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
    if (&kCGDisplayShowDuplicateLowResolutionModes != NULL &&
        CGDisplayModeGetPixelWidth != NULL && CGDisplayModeGetPixelHeight != NULL)
    {
        CFDictionaryRef options;
        struct display_mode_descriptor* desc;
        CFMutableDictionaryRef modes_by_size;
        CFIndex i, count;
        CGDisplayModeRef* mode_array;

        options = CFDictionaryCreate(NULL, (const void**)&kCGDisplayShowDuplicateLowResolutionModes,
                                     (const void**)&kCFBooleanTrue, 1, &kCFTypeDictionaryKeyCallBacks,
                                     &kCFTypeDictionaryValueCallBacks);

        modes = CGDisplayCopyAllDisplayModes(display, options);
        if (options)
            CFRelease(options);
        if (!modes)
            return NULL;

        desc = create_original_display_mode_descriptor(display);

        modes_by_size = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
        count = CFArrayGetCount(modes);
        for (i = 0; i < count; i++)
        {
            BOOL better = TRUE;
            CGDisplayModeRef new_mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
            BOOL new_is_original = display_mode_matches_descriptor(new_mode, desc);
            CFDictionaryRef key = create_mode_dict(new_mode, new_is_original);

            /* If a given mode is the user's default, then always list it in preference to any similar
               modes that may exist. */
            if (new_is_original)
                better = TRUE;
            else
            {
                CFStringRef pixel_encoding = CGDisplayModeCopyPixelEncoding(new_mode);
                CGDisplayModeRef old_mode;

                if (pixel_encoding)
                {
                    BOOL bpp30 = CFEqual(pixel_encoding, CFSTR(kIO30BitDirectPixels));
                    CFRelease(pixel_encoding);
                    if (bpp30)
                    {
                        /* This is an odd pixel encoding.  It seems it's only returned
                           when using kCGDisplayShowDuplicateLowResolutionModes.  It's
                           32bpp in terms of the actual raster layout, but it's 10
                           bits per component.  I think that no Windows program is
                           likely to need it and they will probably be confused by it.
                           Skip it. */
                        CFRelease(key);
                        continue;
                    }
                }

                old_mode = (CGDisplayModeRef)CFDictionaryGetValue(modes_by_size, key);
                if (old_mode)
                {
                    BOOL old_is_original = display_mode_matches_descriptor(old_mode, desc);

                    if (old_is_original)
                        better = FALSE;
                    else
                    {
                        /* Otherwise, prefer a mode whose pixel size equals its point size over one which
                           is scaled. */
                        size_t width_points = CGDisplayModeGetWidth(new_mode);
                        size_t height_points = CGDisplayModeGetHeight(new_mode);
                        size_t new_width_pixels = CGDisplayModeGetPixelWidth(new_mode);
                        size_t new_height_pixels = CGDisplayModeGetPixelHeight(new_mode);
                        size_t old_width_pixels = CGDisplayModeGetPixelWidth(old_mode);
                        size_t old_height_pixels = CGDisplayModeGetPixelHeight(old_mode);
                        BOOL new_size_same = (new_width_pixels == width_points && new_height_pixels == height_points);
                        BOOL old_size_same = (old_width_pixels == width_points && old_height_pixels == height_points);

                        if (new_size_same && !old_size_same)
                            better = TRUE;
                        else if (!new_size_same && old_size_same)
                            better = FALSE;
                        else
                        {
                            /* Otherwise, prefer the mode with the smaller pixel size. */
//.........这里部分代码省略.........
开发者ID:AmesianX,项目名称:wine,代码行数:101,代码来源:display.c

示例5: HIDGetDeviceProduct

/*
 * Gets the device's product name.
 */
static int
HIDGetDeviceProduct(io_service_t dev, char *name)
{
    CFMutableDictionaryRef hidProperties, usbProperties;
    io_registry_entry_t parent1, parent2;
    kern_return_t ret;

    hidProperties = usbProperties = 0;

    ret = IORegistryEntryCreateCFProperties(dev, &hidProperties,
                                            kCFAllocatorDefault, kNilOptions);
    if ((ret != KERN_SUCCESS) || !hidProperties) {
        SDL_SetError("Haptic: Unable to create CFProperties.");
        return -1;
    }

    /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also
     * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties
     */
    if ((KERN_SUCCESS ==
         IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1))
        && (KERN_SUCCESS ==
            IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2))
        && (KERN_SUCCESS ==
            IORegistryEntryCreateCFProperties(parent2, &usbProperties,
                                              kCFAllocatorDefault,
                                              kNilOptions))) {
        if (usbProperties) {
            CFTypeRef refCF = 0;
            /* get device info
             * try hid dictionary first, if fail then go to usb dictionary
             */


            /* Get product name */
            refCF =
                CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey));
            if (!refCF)
                refCF =
                    CFDictionaryGetValue(usbProperties,
                                         CFSTR("USB Product Name"));
            if (refCF) {
                if (!CFStringGetCString(refCF, name, 256,
                                        CFStringGetSystemEncoding())) {
                    SDL_SetError
                        ("Haptic: CFStringGetCString error retrieving pDevice->product.");
                    return -1;
                }
            }

            CFRelease(usbProperties);
        } else {
            SDL_SetError
                ("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties.");
            return -1;
        }

        /* Release stuff. */
        if (kIOReturnSuccess != IOObjectRelease(parent2)) {
            SDL_SetError("Haptic: IOObjectRelease error with parent2.");
        }
        if (kIOReturnSuccess != IOObjectRelease(parent1)) {
            SDL_SetError("Haptic: IOObjectRelease error with parent1.");
        }
    } else {
        SDL_SetError("Haptic: Error getting registry entries.");
        return -1;
    }

    return 0;
}
开发者ID:DAOWAce,项目名称:pcsxr,代码行数:74,代码来源:SDL_syshaptic.c

示例6: reportDrive

// This function is much inspired by record_device() and devstats() from
// http://opensource.apple.com/source/system_cmds/system_cmds-230/iostat.tproj/iostat.c
static void reportDrive(dynamic_accumulator_t *ioLoad, io_registry_entry_t drive) {
  io_registry_entry_t parent;
  CFStringRef name;
  kern_return_t status;
  
  // get drive's parent
  status = IORegistryEntryGetParentEntry(drive,
                                         kIOServicePlane, &parent);
  if (status != KERN_SUCCESS) {
    return;
  }
  if (!IOObjectConformsTo(parent, "IOBlockStorageDriver")) {
    IOObjectRelease(parent);
    return;
  }

  // get drive properties
  CFDictionaryRef driveProperties;
  status = IORegistryEntryCreateCFProperties(drive,
                                             (CFMutableDictionaryRef *)&driveProperties,
                                             kCFAllocatorDefault,
                                             kNilOptions);
  if (status != KERN_SUCCESS) {
    return;
  }
  
  // get name from properties
  name = (CFStringRef)CFDictionaryGetValue(driveProperties,
                                           CFSTR(kIOBSDNameKey));
  char cname[100];
  CFStringGetCString(name, cname, sizeof(cname), CFStringGetSystemEncoding());
  CFRelease(driveProperties);
  
  // get parent properties
  CFDictionaryRef parentProperties;
  status = IORegistryEntryCreateCFProperties(parent,
                                             (CFMutableDictionaryRef *)&parentProperties,
                                             kCFAllocatorDefault,
                                             kNilOptions);
  IOObjectRelease(parent);
  if (status != KERN_SUCCESS) {
    CFRelease(driveProperties);
    return;
  }
  
  CFDictionaryRef statistics;
  statistics = (CFDictionaryRef)CFDictionaryGetValue(parentProperties,
                                                     CFSTR(kIOBlockStorageDriverStatisticsKey));
  if (!statistics) {
    CFRelease(parentProperties);
    return;
  }
  
  u_int64_t bytesRead = 0;
  u_int64_t bytesWritten = 0;
  CFNumberRef number;
  if ((number = (CFNumberRef)CFDictionaryGetValue(statistics,
                                                  CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey)))) {
    CFNumberGetValue(number, kCFNumberSInt64Type, &bytesRead);
  }
  if ((number = (CFNumberRef)CFDictionaryGetValue(statistics,
                                                  CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey)))) {
    CFNumberGetValue(number, kCFNumberSInt64Type, &bytesWritten);
  }

  CFRelease(parentProperties);
  
  dynamic_accumulator_report(ioLoad, cname, bytesRead, bytesWritten);
}
开发者ID:hdfssk,项目名称:bubblemon,代码行数:71,代码来源:osx-meter.c

示例7: CFDictionaryGetValue

void wxHIDJoystick::MakeCookies(CFArrayRef Array)
{
    int i, nUsage, nPage;

    for (i = 0; i < CFArrayGetCount(Array); ++i)
    {
        const void* ref = CFDictionaryGetValue(
                              (CFDictionaryRef)CFArrayGetValueAtIndex(Array, i),
                              CFSTR(kIOHIDElementKey)
                          );

        if (ref != NULL)
        {
            MakeCookies((CFArrayRef) ref);
        }
        else
        {
            CFNumberGetValue(
                (CFNumberRef)
                CFDictionaryGetValue(
                    (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
                    CFSTR(kIOHIDElementUsageKey)
                ),
                kCFNumberIntType,
                &nUsage    );

            CFNumberGetValue(
                (CFNumberRef)
                CFDictionaryGetValue(
                    (CFDictionaryRef) CFArrayGetValueAtIndex(Array, i),
                    CFSTR(kIOHIDElementUsagePageKey)
                ),
                kCFNumberIntType,
                &nPage     );

#if 0
            wxLogSysError(wxT("[%i][%i]"), nUsage, nPage);
#endif
            if (nPage == kHIDPage_Button && nUsage <= 40)
                AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), nUsage-1 );
            else if (nPage == kHIDPage_GenericDesktop)
            {
                //axis...
                switch(nUsage)
                {
                case kHIDUsage_GD_X:
                    AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_X);
                    wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                             CFSTR(kIOHIDElementMaxKey),
                                             &m_nXMax);
                    wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                             CFSTR(kIOHIDElementMinKey),
                                             &m_nXMin);
                    break;
                case kHIDUsage_GD_Y:
                    AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Y);
                    wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                             CFSTR(kIOHIDElementMaxKey),
                                             &m_nYMax);
                    wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                             CFSTR(kIOHIDElementMinKey),
                                             &m_nYMin);
                    break;
                case kHIDUsage_GD_Z:
                    AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_Z);
                    wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                             CFSTR(kIOHIDElementMaxKey),
                                             &m_nZMax);
                    wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                             CFSTR(kIOHIDElementMinKey),
                                             &m_nZMin);
                    break;
                default:
                    break;
                }
            }
            else if (nPage == kHIDPage_Simulation && nUsage == kHIDUsage_Sim_Rudder)
            {
                //rudder...
                AddCookieInQueue(CFArrayGetValueAtIndex(Array, i), wxJS_AXIS_RUDDER );
                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                         CFSTR(kIOHIDElementMaxKey),
                                         &m_nRudderMax);
                wxGetIntFromCFDictionary(CFArrayGetValueAtIndex(Array, i),
                                         CFSTR(kIOHIDElementMinKey),
                                         &m_nRudderMin);
            }
        }
    }
}
开发者ID:hajuuk,项目名称:R7000,代码行数:90,代码来源:hidjoystick.cpp

示例8: pango_core_text_face_from_ct_font_descriptor

static inline PangoCoreTextFace *
pango_core_text_face_from_ct_font_descriptor (CTFontDescriptorRef desc)
{
  int font_traits;
  char *buffer;
  CFStringRef str;
  CFNumberRef number;
  CGFloat value;
  CFDictionaryRef dict;
  CFCharacterSetRef charset;
  PangoCoreTextFace *face = g_object_new (PANGO_TYPE_CORE_TEXT_FACE,
                                          NULL);

  face->synthetic_italic = FALSE;

  /* Get font name */
  str = CTFontDescriptorCopyAttribute (desc, kCTFontNameAttribute);
  buffer = gchar_from_cf_string (str);

  /* We strdup again to save space. */
  face->postscript_name = g_strdup (buffer);

  CFRelease (str);
  g_free (buffer);

  /* Get style name */
  str = CTFontDescriptorCopyAttribute (desc, kCTFontStyleNameAttribute);
  buffer = gchar_from_cf_string (str);

  face->style_name = g_strdup (buffer);

  CFRelease (str);
  g_free (buffer);

  /* Get font traits, symbolic traits */
  dict = CTFontDescriptorCopyAttribute (desc, kCTFontTraitsAttribute);
  number = (CFNumberRef)CFDictionaryGetValue (dict,
                                              kCTFontWeightTrait);
  if (CFNumberGetValue (number, kCFNumberCGFloatType, &value))
    {
      if (value < ct_weight_min || value > ct_weight_max)
	{
	  face->weight = PANGO_WEIGHT_NORMAL; /* This is really an error */
	}
      else
	{
	  guint i;
	  for (i = 0; i < G_N_ELEMENTS(ct_weight_limits); i++)
	    if (value < ct_weight_limits[i].bound)
	      {
		face->weight = ct_weight_limits[i].weight;
		break;
	      }
	}
    }
  else
    face->weight = PANGO_WEIGHT_NORMAL;

  number = (CFNumberRef)CFDictionaryGetValue (dict, kCTFontSymbolicTrait);
  if (CFNumberGetValue (number, kCFNumberIntType, &font_traits))
    {
      face->traits = font_traits;
    }
  CFRelease (dict);

  /* Get font coverage */
  charset = CTFontDescriptorCopyAttribute (desc,
                                           kCTFontCharacterSetAttribute);
  face->coverage = pango_coverage_from_cf_charset (charset);
  CFRelease (charset);

  return face;
}
开发者ID:alexp-sssup,项目名称:pango,代码行数:73,代码来源:pangocoretext-fontmap.c

示例9: fetchVolatileValue

static CFTypeRef  fetchVolatileValue(CFTypeRef  context, void *domain, CFStringRef  key) {
    CFTypeRef  result = CFDictionaryGetValue((CFMutableDictionaryRef  )domain, key);
    if (result) CFRetain(result);
    return result;
}
开发者ID:Apple-FOSS-Mirror,项目名称:CF,代码行数:5,代码来源:CFPreferences.c

示例10: getenv

void CDarwinStorageProvider::GetLocalDrives(VECSOURCES &localDrives)
{
  CMediaSource share;

  // User home folder
  share.strPath = getenv("HOME");
  share.strName = g_localizeStrings.Get(21440);
  share.m_ignore = true;
  localDrives.push_back(share);

  // User desktop folder
  share.strPath = getenv("HOME");
  share.strPath += "/Desktop";
  share.strName = "Desktop";
  share.m_ignore = true;
  localDrives.push_back(share);

  // Volumes (all mounts are present here)
  share.strPath = "/Volumes";
  share.strName = "Volumes";
  share.m_ignore = true;
  localDrives.push_back(share);

  // This will pick up all local non-removable disks including the Root Disk.
  DASessionRef session = DASessionCreate(kCFAllocatorDefault);
  if (session)
  {
    unsigned i, count = 0;
    struct statfs *buf = NULL;
    CStdString mountpoint, devicepath;

    count = getmntinfo(&buf, 0);
    for (i=0; i<count; i++)
    {
      mountpoint = buf[i].f_mntonname;
      devicepath = buf[i].f_mntfromname;

      DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, session, devicepath.c_str());
      if (disk)
      {
        CFDictionaryRef details = DADiskCopyDescription(disk);
        if (details)
        {
          if (kCFBooleanFalse == CFDictionaryGetValue(details, kDADiskDescriptionMediaRemovableKey))
          {
            CMediaSource share;

            share.strPath = mountpoint;
            Cocoa_GetVolumeNameFromMountPoint(mountpoint, share.strName);
            share.m_ignore = true;
            localDrives.push_back(share);
          }
          CFRelease(details);
        }
        CFRelease(disk);
      }
    }

    CFRelease(session);
  }
}
开发者ID:mbolhuis,项目名称:xbmc,代码行数:61,代码来源:DarwinStorageProvider.cpp

示例11: SCREENReadNormalizedGammaTable

PsychError SCREENReadNormalizedGammaTable(void)
{
    int		i, screenNumber, numEntries, reallutsize, physicalDisplay, outputId;
    float 	*redTable, *greenTable, *blueTable;
    double	*gammaTable;	

    //all subfunctions should have these two lines
    PsychPushHelp(useString, synopsisString, seeAlsoString);
    if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    PsychErrorExit(PsychCapNumOutputArgs(3));
    PsychErrorExit(PsychCapNumInputArgs(2));

    // Get optional physicalDisplay argument - It defaults to zero:
    physicalDisplay = -1;
    PsychCopyInIntegerArg(2, FALSE, &physicalDisplay);

    // Read in the screen number:
    // On OS/X we also accept screen indices for physical displays (as opposed to active dispays).
    // This only makes a difference in mirror-mode, where there is only 1 active display, but that
    // corresponds to two physical displays which can have different gamma setting requirements:
    if ((PSYCH_SYSTEM == PSYCH_OSX) && (physicalDisplay > 0)) {
        PsychCopyInIntegerArg(1, TRUE, &screenNumber);
	if (screenNumber < 1) PsychErrorExitMsg(PsychError_user, "A 'screenNumber' that is smaller than one provided, although 'physicalDisplay' flag set. This is not allowed!");

	// Invert screenNumber as a sign its a physical display, not an active display:
	screenNumber = -1 * screenNumber;
    }
    else {
        PsychCopyInScreenNumberArg(1, TRUE, &screenNumber);
    }

    if ((PSYCH_SYSTEM == PSYCH_LINUX) && (physicalDisplay > -1)) {
        // Affect one specific display output for given screen:
        outputId = physicalDisplay;
    }
    else {
        // Other OS'es, and Linux with default setting: Affect all outputs
        // for a screen.
        outputId = -1;
    }

    // Retrieve gamma table:
    PsychReadNormalizedGammaTable(screenNumber, outputId, &numEntries, &redTable, &greenTable, &blueTable);
	
    // Copy it out to runtime:
    PsychAllocOutDoubleMatArg(1, FALSE, numEntries, 3, 0, &gammaTable);

    for(i=0;i<numEntries;i++){
        gammaTable[PsychIndexElementFrom3DArray(numEntries, 3, 0, i, 0, 0)]=(double)redTable[i];
        gammaTable[PsychIndexElementFrom3DArray(numEntries, 3, 0, i, 1, 0)]=(double)greenTable[i];
        gammaTable[PsychIndexElementFrom3DArray(numEntries, 3, 0, i, 2, 0)]=(double)blueTable[i];
    }

    // Copy out optional DAC resolution value:
    PsychCopyOutDoubleArg(2, FALSE, (double) PsychGetDacBitsFromDisplay(screenNumber));
	
    // We default to the assumption that the real size of the hardware LUT is identical to
    // the size of the returned LUT:
    reallutsize = numEntries;
	
    #if PSYCH_SYSTEM == PSYCH_OSX
		// On OS-X we query the real LUT size from the OS and return that value:
		CGDirectDisplayID	displayID;
		CFMutableDictionaryRef properties;
		CFNumberRef cfGammaLength;
		SInt32 lutslotcount;
		io_service_t displayService;
		kern_return_t kr;
		CFMutableArrayRef framebufferTimings0 = 0;
		CFDataRef framebufferTimings1 = 0;
		IODetailedTimingInformationV2 *framebufferTiming = NULL;
		
		// Retrieve display handle for screen:
		PsychGetCGDisplayIDFromScreenNumber(&displayID, screenNumber);
		
		// Retrieve low-level IOKit service port for this display:
		displayService = CGDisplayIOServicePort(displayID);
				
		// Obtain the properties from that service
		kr = IORegistryEntryCreateCFProperties(displayService, &properties, NULL, 0);
		if((kr == kIOReturnSuccess) && ((cfGammaLength = (CFNumberRef) CFDictionaryGetValue(properties, CFSTR(kIOFBGammaCountKey)))!=NULL))
		{
			CFNumberGetValue(cfGammaLength, kCFNumberSInt32Type, &lutslotcount);
			CFRelease(properties);
			reallutsize = (int) lutslotcount;
		}
		else {
			// Failed!
			if (PsychPrefStateGet_Verbosity()>1) printf("PTB-WARNING: Failed to query real size of video LUT for screen %i! Will return safe default of %i slots.\n", screenNumber, reallutsize);
		}	

		if (PsychPrefStateGet_Verbosity()>9) {			
			CGDisplayModeRef currentMode;
			CFNumberRef n;
			int modeId;
			currentMode = CGDisplayCopyDisplayMode(displayID);
            modeId = (int) CGDisplayModeGetIODisplayModeID(currentMode);
            CGDisplayModeRelease(currentMode);
            
//.........这里部分代码省略.........
开发者ID:AlanFreeman,项目名称:Psychtoolbox-3,代码行数:101,代码来源:SCREENReadNormalizedGammaTable.c

示例12: remote_aes

CFDictionaryRef remote_aes(int socket, CFDictionaryRef dict)
{
    uint8_t* input2 = NULL;
    uint32_t len = 0;
    uint8_t* iv2 = NULL;
    uint32_t keyMask = 0;
    uint32_t mode = 0;
    uint32_t bits = 0;
    
    CFNumberRef km =  CFDictionaryGetValue(dict, CFSTR("keyMask"));
    if(km == NULL || CFGetTypeID(km) != CFNumberGetTypeID())
        return NULL;
    CFNumberGetValue(km, kCFNumberIntType, &keyMask);
    
    CFNumberRef m =  CFDictionaryGetValue(dict, CFSTR("mode"));
    if(m == NULL || CFGetTypeID(m) != CFNumberGetTypeID())
        return NULL;
    CFNumberGetValue(m, kCFNumberIntType, &mode);
    
    CFNumberRef b =  CFDictionaryGetValue(dict, CFSTR("bits"));
    if(b == NULL || CFGetTypeID(b) != CFNumberGetTypeID())
        return NULL;
    CFNumberGetValue(b, kCFNumberIntType, &bits);
    
    CFDataRef input = CFDictionaryGetValue(dict, CFSTR("input"));
    if(input == NULL || CFGetTypeID(input) != CFDataGetTypeID())
        return NULL;

    CFDataRef iv = CFDictionaryGetValue(dict, CFSTR("iv"));
    if(iv != NULL)
    {
        if (CFGetTypeID(iv) != CFDataGetTypeID())
            return NULL;
        iv2 = (uint8_t*) CFDataGetBytePtr(iv);
    }
    len = CFDataGetLength(input);
    if (len % 16 != 0)
    {
        return NULL;
    }
    input2 = malloc(len);
    if (input2 == NULL)
    {
        return NULL;
    }

    memcpy(input2, CFDataGetBytePtr(input), len);
    
    uint32_t ret = doAES(input2, input2, len, keyMask, NULL, iv2, mode, bits);

    CFMutableDictionaryRef out  = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);	
    
    CFNumberRef retCode = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ret);
    CFDictionaryAddValue(out, CFSTR("returnCode"), retCode);
    CFRelease(retCode);
 
    if (ret == 0)
    {
        CFDataRef dd = CFDataCreate(kCFAllocatorDefault, input2, len);
        CFDictionaryAddValue(out, CFSTR("data"), dd);
        CFRelease(dd);
    }
    free(input2);

    return out;
}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:66,代码来源:remote_functions.c

示例13: __deviceCallback

static void __deviceCallback(void * context, IOReturn result, void * sender, IOHIDDeviceRef device)
{
    boolean_t   terminated  = context == 0;
    CFStringRef debugString = CFCopyDescription(device);
    char * c_debug_string = NULL;
    
    if( debugString ){
        // DG: Bluetooth "Product" strings have Unicode encoding and no nul terminator and CFStringGetCStringPtr returns NULL
        // Need to manually copy to C string
        CFIndex length = CFStringGetLength(debugString);
        CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, CFStringGetSystemEncoding()) + 1;
        c_debug_string = (char *)malloc(maxSize);
        CFStringGetCString(debugString, c_debug_string, maxSize, CFStringGetSystemEncoding());
        CFRelease(debugString);
    }
    
    static CFMutableDictionaryRef s_timers = NULL;
    
    if ( !s_timers )
        s_timers = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    
    uint64_t uuid = 0;
    CFNumberRef temp = IOHIDDeviceGetProperty( device, CFSTR(kIOHIDUniqueIDKey) );
    if ( temp && CFGetTypeID(temp)  == CFNumberGetTypeID() ) CFNumberGetValue( temp, kCFNumberLongLongType, &uuid );
    CFNumberGetValue( IOHIDDeviceGetProperty( device, CFSTR(kIOHIDUniqueIDKey) ), kCFNumberLongLongType, &uuid );
    
    printf("%-10.10s: %s UniqueID %llu\n", terminated ? "terminated" : "matched", c_debug_string ? c_debug_string : "", uuid );
    
    if ( c_debug_string )
        free(c_debug_string);
    
    if ( terminated ) {
        CFDictionaryRemoveValue(gOutputElements, device);
        
        
        CFRunLoopTimerRef timer = (CFRunLoopTimerRef)CFDictionaryGetValue(s_timers, device);
        if ( timer ) {
            CFRunLoopRemoveTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
        }
        CFDictionaryRemoveValue(s_timers, device);
        
    } else {
        CFArrayRef              outputElements  = NULL;
        CFMutableDictionaryRef  matching        = NULL;
        
        if ( gPrintDescriptor ) {
            CFDataRef descriptor = NULL;
            
            descriptor = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDReportDescriptorKey));
            if ( descriptor ) {
                PrintHIDDescriptor(CFDataGetBytePtr(descriptor), CFDataGetLength(descriptor));
            }
        }
        
        if ( gPollInterval != 0.0 ) {
            CFRunLoopTimerContext   context = {.info=device};
            CFRunLoopTimerRef       timer   = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), gPollInterval, 0, 0, __timerCallback, &context);
            
            CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
            
            CFDictionaryAddValue(s_timers, device, timer);
            CFRelease(timer);
            
            printf("Adding polling timer @ %4.6f s\n", gPollInterval);
        }
        
        matching = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
        if ( matching ) {
            uint32_t    value   = kIOHIDElementTypeOutput;
            CFNumberRef number  = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
            
            if ( number ) {
                CFDictionarySetValue(matching, CFSTR(kIOHIDElementTypeKey), number);
                
                outputElements = IOHIDDeviceCopyMatchingElements(device, matching, 0);
                if ( outputElements ) {
                    CFDictionarySetValue(gOutputElements, device, outputElements);
                    CFRelease(outputElements);
                }
                
                CFRelease(number);
            }
            CFRelease(matching);
        }
    }
开发者ID:wzw19890321,项目名称:IOHIDFamily,代码行数:85,代码来源:IOHIDReportTest.c

示例14: main

int main( int argc, char * argv[] )
{
    mach_port_t   		masterPort;
    io_iterator_t 		iter;
    io_service_t 		service;
    kern_return_t		kr;
    CFMutableDictionaryRef	properties;
    CFStringRef			cfStr;

    kr = IOMasterPort( MACH_PORT_NULL, &masterPort);
    assert( KERN_SUCCESS == kr );

    // Look up the object we wish to open. This example uses simple class
    // matching (IOServiceMatching()) to look up the object that is the
    // AppleSamplePCI driver class instantiated by the kext.

    kr = IOServiceGetMatchingServices( masterPort,
                        IOServiceMatching( kAppleSamplePCIClassName ), &iter);
    assert( KERN_SUCCESS == kr );

    for( ;
      (service = IOIteratorNext(iter));
      IOObjectRelease(service)) {

        io_string_t path;
        kr = IORegistryEntryGetPath(service, kIOServicePlane, path);
        assert( KERN_SUCCESS == kr );
        printf("Found a device of class "kAppleSamplePCIClassName": %s\n", path);

        // print the value of kIONameMatchedKey property, as an example of 
	// getting properties from the registry. Property based access
	// doesn't require a user client connection.

        // grab a copy of the properties
        kr = IORegistryEntryCreateCFProperties( service, &properties,
                    kCFAllocatorDefault, kNilOptions );
        assert( KERN_SUCCESS == kr );
	
        cfStr = CFDictionaryGetValue( properties, CFSTR(kIONameMatchedKey) );
        if( cfStr) {
            const char * c = NULL;
            char * buffer = NULL;
            c = CFStringGetCStringPtr(cfStr, kCFStringEncodingMacRoman);
            if(!c) {
                CFIndex bufferSize = CFStringGetLength(cfStr) + 1;
                buffer = malloc(bufferSize);
                if(buffer) {
                    if(CFStringGetCString(cfStr, buffer, bufferSize, kCFStringEncodingMacRoman))
                        c = buffer;
                }
            }
            if(c)
                printf("it matched on name \"%s\"\n", c);
            if(buffer)
                free(buffer);
        }
        CFRelease( properties );

        // test out the user client
        Test( masterPort, service );
    }
    IOObjectRelease(iter);

    exit(0);
    return(0);
}
开发者ID:fruitsamples,项目名称:IOKit,代码行数:66,代码来源:AppleSamplePCIClient.c

示例15: CFMutableDictionaryRef

void PolicyEngine::addToAuthority(CFMutableDictionaryRef parent, CFStringRef key, CFTypeRef value)
{
	CFMutableDictionaryRef authority = CFMutableDictionaryRef(CFDictionaryGetValue(parent, kSecAssessmentAssessmentAuthority));
	assert(authority);
	CFDictionaryAddValue(authority, key, value);
}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:6,代码来源:policyengine.cpp


注:本文中的CFDictionaryGetValue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。