本文整理汇总了C++中IORegistryEntryCreateCFProperties函数的典型用法代码示例。如果您正苦于以下问题:C++ IORegistryEntryCreateCFProperties函数的具体用法?C++ IORegistryEntryCreateCFProperties怎么用?C++ IORegistryEntryCreateCFProperties使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IORegistryEntryCreateCFProperties函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_drive
/*
* Check whether an IORegistryEntry refers to a valid
* I/O device, and if so, collect the information.
*/
static int
handle_drive(io_registry_entry_t drive, struct drivestats * dstat)
{
io_registry_entry_t parent;
CFMutableDictionaryRef properties;
CFStringRef name;
CFNumberRef number;
kern_return_t status;
/* get drive's parent */
status = IORegistryEntryGetParentEntry(drive, kIOServicePlane, &parent);
if (status != KERN_SUCCESS) {
snmp_log(LOG_ERR, "diskio: device has no parent\n");
/* fprintf(stderr, "device has no parent\n"); */
return(1);
}
if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) {
/* get drive properties */
status = IORegistryEntryCreateCFProperties(drive, &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);
}
/* get BSD name and unitnumber from properties */
name = (CFStringRef)CFDictionaryGetValue(properties,
CFSTR(kIOBSDNameKey));
number = (CFNumberRef)CFDictionaryGetValue(properties,
CFSTR(kIOBSDUnitKey));
/* Collect stats and if succesful store them with the name and unitnumber */
if (name && number && !collect_drive_stats(parent, dstat->stats)) {
CFStringGetCString(name, dstat->name, MAXDRIVENAME, CFStringGetSystemEncoding());
CFNumberGetValue(number, kCFNumberSInt32Type, &dstat->bsd_unit_number);
num_drives++;
}
/* clean up, return success */
CFRelease(properties);
return(0);
}
/* failed, don't keep parent */
IOObjectRelease(parent);
return(1);
}
示例2: myIORegistryEntryBSDNameMatchingCopyValue
CFDictionaryRef
myIORegistryEntryBSDNameMatchingCopyValue(const char * devname, Boolean parent)
{
kern_return_t status;
CFMutableDictionaryRef properties = NULL;
io_registry_entry_t service;
service
= IOServiceGetMatchingService(kIOMasterPortDefault,
IOBSDNameMatching(kIOMasterPortDefault, 0, devname));
if (service == MACH_PORT_NULL) {
return (NULL);
}
if (parent) {
io_registry_entry_t parent_service;
status = IORegistryEntryGetParentEntry(service, kIOServicePlane,
&parent_service);
if (status == KERN_SUCCESS) {
status = IORegistryEntryCreateCFProperties(parent_service,
&properties,
kCFAllocatorDefault,
kNilOptions);
IOObjectRelease(parent_service);
}
}
else {
status = IORegistryEntryCreateCFProperties(service,
&properties,
kCFAllocatorDefault,
kNilOptions);
}
if (status != KERN_SUCCESS) {
properties = NULL;
}
IOObjectRelease(service);
return (properties);
}
示例3: IOMasterPort
int IdlePlatform::secondsIdle()
{
mach_port_t masterPort;
io_iterator_t iter;
io_registry_entry_t curObj;
IOMasterPort(MACH_PORT_NULL, &masterPort);
IOServiceGetMatchingServices(masterPort, IOServiceMatching("IOHIDSystem"), &iter);
if (iter == 0)
return -1;
curObj = IOIteratorNext(iter);
if (curObj == 0)
return -1;
CFMutableDictionaryRef properties = 0;
CFTypeRef obj;
int result = -1;
if (IORegistryEntryCreateCFProperties(curObj, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS && properties != NULL) {
obj = CFDictionaryGetValue(properties, CFSTR("HIDIdleTime"));
CFRetain(obj);
} else
obj = NULL;
if (obj) {
uint64_t tHandle;
CFTypeID type = CFGetTypeID(obj);
if (type == CFDataGetTypeID())
CFDataGetBytes((CFDataRef) obj, CFRangeMake(0, sizeof(tHandle)), (UInt8*) &tHandle);
else if (type == CFNumberGetTypeID())
CFNumberGetValue((CFNumberRef)obj, kCFNumberSInt64Type, &tHandle);
else
return -1;
CFRelease(obj);
// essentially divides by 10^9
tHandle >>= 30;
result = tHandle;
}
/* Release our resources */
IOObjectRelease(curObj);
IOObjectRelease(iter);
CFRelease((CFTypeRef)properties);
return result;
}
示例4: getProperties
// gets all properties from an entry into a QMap
static QMap<QString, QVariant> getProperties(const io_registry_entry_t &entry)
{
CFMutableDictionaryRef propertyDict = 0;
if (IORegistryEntryCreateCFProperties(entry, &propertyDict, kCFAllocatorDefault, kNilOptions) != KERN_SUCCESS) {
return QMap<QString, QVariant>();
}
QMap<QString, QVariant> result = q_toVariantMap(propertyDict);
CFRelease(propertyDict);
return result;
}
示例5: OSX_ReadCDTOC
void OSX_ReadCDTOC(io_object_t cdobject) {
CFMutableDictionaryRef cd_props = 0;
CFDataRef cdTOCdata = NULL;
char* cdTOCrawdata = NULL;
if (IORegistryEntryCreateCFProperties(cdobject, &cd_props, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess) return;
cdTOCdata = (CFDataRef)CFDictionaryGetValue(cd_props, CFSTR (kIOCDMediaTOCKey));
if (cdTOCdata != NULL) {
Extract_cdTOCrawdata(cdTOCdata, cdTOCrawdata);
}
CFRelease(cd_props);
cd_props = NULL;
return;
}
示例6: PRINT
IOReturn
SATSMARTClient::Probe ( CFDictionaryRef propertyTable,
io_service_t inService,
SInt32 * order )
{
CFMutableDictionaryRef dict = NULL;
IOReturn status = kIOReturnBadArgument;
PRINT ( ( "SATSMARTClient::Probe called\n" ) );
// Sanity check
if ( inService == 0 )
{
goto Exit;
}
status = IORegistryEntryCreateCFProperties ( inService, &dict, NULL, 0 );
if ( status != kIOReturnSuccess )
{
goto Exit;
}
if ( !CFDictionaryContainsKey ( dict, CFSTR ( "IOCFPlugInTypes" ) ) )
{
goto Exit;
}
status = kIOReturnSuccess;
Exit:
if ( dict != NULL )
{
CFRelease ( dict );
dict = NULL;
}
PRINT ( ( "SATSMARTClient::Probe called %x\n",status ) );
return status;
}
示例7: genPCIDevice
void genPCIDevice(const io_service_t& device, QueryData& results) {
Row r;
// Get the device details
CFMutableDictionaryRef details;
IORegistryEntryCreateCFProperties(
device, &details, kCFAllocatorDefault, kNilOptions);
r["pci_slot"] = getIOKitProperty(details, "pcidebug");
std::vector<std::string> properties;
auto compatible = getIOKitProperty(details, "compatible");
boost::trim(compatible);
boost::split(properties, compatible, boost::is_any_of(" "));
if (properties.size() < 2) {
VLOG(1) << "Error parsing IOKit compatible properties";
return;
}
size_t prop_index = 0;
if (properties[1].find("pci") == 0 && properties[1].find("pciclass") != 0) {
// There are two sets of PCI definitions.
prop_index = 1;
} else if (properties[0].find("pci") != 0) {
VLOG(1) << "No vendor/model found";
return;
}
std::vector<std::string> vendor;
boost::split(vendor, properties[prop_index++], boost::is_any_of(","));
r["vendor_id"] = vendor[0].substr(3);
r["model_id"] = (vendor[1].size() == 3) ? "0" + vendor[1] : vendor[1];
if (properties[prop_index].find("pciclass") == 0) {
// There is a class definition.
r["pci_class"] = properties[prop_index++].substr(9);
}
if (properties.size() > prop_index) {
// There is a driver/ID.
r["driver"] = properties[prop_index];
}
results.push_back(r);
CFRelease(details);
}
示例8: record_device
/*
* Determine whether an IORegistryEntry refers to a valid
* I/O device, and if so, record it.
*/
static int
record_device(io_registry_entry_t drive)
{
io_registry_entry_t parent;
CFDictionaryRef properties;
CFStringRef name;
CFNumberRef number;
kern_return_t status;
/* get drive's parent */
status = IORegistryEntryGetParentEntry(drive,
kIOServicePlane, &parent);
if (status != KERN_SUCCESS)
errx(1, "device has no parent");
if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) {
drivestat[num_devices].driver = parent;
/* get drive properties */
status = IORegistryEntryCreateCFProperties(drive,
(CFMutableDictionaryRef *)&properties,
kCFAllocatorDefault,
kNilOptions);
if (status != KERN_SUCCESS)
errx(1, "device has no properties");
/* get name from properties */
name = (CFStringRef)CFDictionaryGetValue(properties,
CFSTR(kIOBSDNameKey));
CFStringGetCString(name, drivestat[num_devices].name,
MAXDRIVENAME, CFStringGetSystemEncoding());
/* get blocksize from properties */
number = (CFNumberRef)CFDictionaryGetValue(properties,
CFSTR(kIOMediaPreferredBlockSizeKey));
CFNumberGetValue(number, kCFNumberSInt64Type,
&drivestat[num_devices].blocksize);
/* clean up, return success */
CFRelease(properties);
num_devices++;
return(0);
}
/* failed, don't keep parent */
IOObjectRelease(parent);
return(1);
}
示例9: genFDEStatusForBSDName
void genFDEStatusForBSDName(const std::string& bsd_name,
const std::string& uuid,
QueryData& results) {
auto matching_dict =
IOBSDNameMatching(kIOMasterPortDefault, kNilOptions, bsd_name.c_str());
if (matching_dict == nullptr) {
return;
}
auto service =
IOServiceGetMatchingService(kIOMasterPortDefault, matching_dict);
if (!service) {
return;
}
CFMutableDictionaryRef properties;
if (IORegistryEntryCreateCFProperties(
service, &properties, kCFAllocatorDefault, kNilOptions) !=
KERN_SUCCESS) {
IOObjectRelease(service);
return;
}
Row r;
r["name"] = kDeviceNamePrefix + bsd_name;
r["uuid"] = uuid;
auto encrypted = getIOKitProperty(properties, kCoreStorageIsEncryptedKey_);
if (encrypted.empty()) {
r["encrypted"] = "0";
} else {
r["encrypted"] = encrypted;
id_t uid;
uuid_string_t uuid_string = {0};
if (genUid(uid, uuid_string).ok()) {
r["uid"] = BIGINT(uid);
r["user_uuid"] = TEXT(uuid_string);
}
}
r["type"] = (r.at("encrypted") == "1") ? kEncryptionType : std::string();
results.push_back(r);
CFRelease(properties);
IOObjectRelease(service);
}
示例10: idleTime
long idleTime() {
long idlesecs;
#ifdef LINUX
bool _idleDetectionPossible;
XScreenSaverInfo *_mit_info;
int event_base, error_base;
if(XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base))
_idleDetectionPossible = true;
else
_idleDetectionPossible = false;
_mit_info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), _mit_info);
idlesecs = (_mit_info->idle/1000);
#endif
#ifdef WINDOWS
LASTINPUTINFO lif;
lif.cbSize = sizeof(LASTINPUTINFO);
GetLastInputInfo(&lif);
DWORD tickCount = GetTickCount();
idlesecs = (tickCount - lif.dwTime) / 1000;
#endif
#ifdef MAC
idlesecs = -1;//int64_t
io_iterator_t iter = 0;
if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"), &iter) == KERN_SUCCESS) {
io_registry_entry_t entry = IOIteratorNext(iter);
if (entry) {
CFMutableDictionaryRef dict = NULL;
if (IORegistryEntryCreateCFProperties(entry, &dict, kCFAllocatorDefault, 0) == KERN_SUCCESS) {
CFNumberRef obj = (CFNumberRef)CFDictionaryGetValue(dict, CFSTR("HIDIdleTime"));
if (obj) {
int64_t nanoseconds = 0;
if (CFNumberGetValue(obj, kCFNumberSInt64Type, &nanoseconds)) {
idlesecs = (nanoseconds >> 30); // Divide by 10^9 to convert from nanoseconds to seconds.
}
}
CFRelease(dict);
}
示例11: genPCIDevice
void genPCIDevice(const io_service_t& device, QueryData& results) {
Row r;
// Get the device details
CFMutableDictionaryRef details;
IORegistryEntryCreateCFProperties(
device, &details, kCFAllocatorDefault, kNilOptions);
r["pci_slot"] = getIOKitProperty(details, "pcidebug");
auto compatible = getIOKitProperty(details, "compatible");
auto properties = IOKitPCIProperties(compatible);
r["vendor_id"] = properties.vendor_id;
r["model_id"] = properties.model_id;
r["pci_class"] = properties.pci_class;
r["driver"] = properties.driver;
results.push_back(r);
CFRelease(details);
}
示例12: myIORegistryEntryCopyValue
CFDictionaryRef
myIORegistryEntryCopyValue(const char * path)
{
io_registry_entry_t service;
kern_return_t status;
CFMutableDictionaryRef properties = NULL;
service = IORegistryEntryFromPath(kIOMasterPortDefault, path);
if (service == MACH_PORT_NULL) {
return (NULL);
}
status = IORegistryEntryCreateCFProperties(service,
&properties,
kCFAllocatorDefault,
kNilOptions);
if (status != KERN_SUCCESS) {
properties = NULL;
}
IOObjectRelease(service);
return (properties);
}
示例13: PrintSpeedForDisc
static IOReturn
PrintSpeedForDisc ( io_object_t opticalMedia )
{
IOReturn error = kIOReturnError;
CFMutableDictionaryRef properties = NULL;
CFStringRef bsdNode = NULL;
const char * bsdName = NULL;
error = IORegistryEntryCreateCFProperties ( opticalMedia,
&properties,
kCFAllocatorDefault,
kNilOptions );
require ( ( error == kIOReturnSuccess ), ErrorExit );
bsdNode = ( CFStringRef ) CFDictionaryGetValue ( properties, CFSTR ( kIOBSDNameKey ) );
require ( ( bsdNode != NULL ), ReleaseProperties );
bsdName = CFStringGetCStringPtr ( bsdNode, CFStringGetSystemEncoding ( ) );
require ( ( bsdName != NULL ), ReleaseProperties );
error = PrintSpeedForBSDNode ( bsdName );
require ( ( error == kIOReturnSuccess ), ReleaseProperties );
ReleaseProperties:
require_quiet ( ( properties != NULL ), ErrorExit );
CFRelease ( properties );
properties = NULL;
ErrorExit:
return error;
}
开发者ID:unofficial-opensource-apple,项目名称:IOSCSIArchitectureModelFamily,代码行数:39,代码来源:OpticalMediaSpeed.c
示例14: genUSBDevice
void genUSBDevice(const io_service_t& device, QueryData& results) {
Row r;
// Get the device details
CFMutableDictionaryRef details;
IORegistryEntryCreateCFProperties(
device, &details, kCFAllocatorDefault, kNilOptions);
r["usb_address"] = getUSBProperty(details, "USB Address");
r["usb_port"] = getUSBProperty(details, "PortNum");
r["model"] = getUSBProperty(details, "USB Product Name");
r["model_id"] = getUSBProperty(details, "idProduct");
r["vendor"] = getUSBProperty(details, "USB Vendor Name");
r["vendor_id"] = getUSBProperty(details, "idVendor");
r["serial"] = getUSBProperty(details, "iSerialNumber");
auto non_removable = getUSBProperty(details, "non-removable");
r["removable"] = (non_removable == "yes") ? "0" : "1";
results.push_back(r);
CFRelease(details);
}
示例15: main
int main(int argc, char **argv)
{
mach_port_t masterPort;
io_registry_entry_t root;
CFDictionaryRef props;
kern_return_t status;
// Obtain the I/O Kit communication handle.
status = IOMasterPort(bootstrap_port, &masterPort);
assert(status == KERN_SUCCESS);
// Obtain the registry root entry.
root = IORegistryGetRootEntry(masterPort);
assert(root);
status = IORegistryEntryCreateCFProperties(root,
(CFTypeRef *) &props,
kCFAllocatorDefault, kNilOptions );
assert( KERN_SUCCESS == status );
assert( CFDictionaryGetTypeID() == CFGetTypeID(props));
props = (CFDictionaryRef)
CFDictionaryGetValue( props, CFSTR(kIOKitDiagnosticsKey));
assert( props );
assert( CFDictionaryGetTypeID() == CFGetTypeID(props));
printNumber(props, CFSTR("Instance allocation"));
printNumber(props, CFSTR("Container allocation"));
printNumber(props, CFSTR("IOMalloc allocation"));
CFRelease(props);
IOObjectRelease(root);
exit(0);
}