Ejemplo n.º 1
0
static BOOL __RSProcessInfoUpdateVersion(RSProcessInfoRef processInfo, RSStringRef key /*__RSProcessInfoOperatingSystemVersion*/) {
    BOOL result = NO;
    if (__RSProcessInfoObjectForKey(processInfo, key)) return result = YES;
    RSMutableArrayRef keys = RSArrayCreateMutable(RSAllocatorSystemDefault, 0);
    RSMutableArrayRef descriptions = RSArrayCreateMutable(RSAllocatorSystemDefault, 0);
    RSRetain(key);
    RSArrayAddObject(keys, __RSProcessInfo_kern_ostype);
    RSArrayAddObject(descriptions, __RSProcessInfoKernelType);
    
    RSArrayAddObject(keys, __RSProcessInfo_kern_osversion);
    RSArrayAddObject(descriptions, __RSProcessInfoKernelVersion);
    
    RSArrayAddObject(keys, __RSProcessInfo_kern_osrelease);
    RSArrayAddObject(descriptions, __RSProcessInfoKernelRelease);
    
    RSArrayAddObject(keys, __RSProcessInfo_kern_uuid);
    RSArrayAddObject(descriptions, __RSProcessInfoKernelUUID);
    
    result = __RSProcessInfoUpdateKeys(processInfo, keys, descriptions, key);
    RSMutableDictionaryRef dict = (RSMutableDictionaryRef)__RSProcessInfoObjectForKey(processInfo, key);
    __RSRuntimeSetInstanceSpecial(dict, YES);
    
    RS_CONST_STRING_DECL(__RSSystemVersionInfoPlistPath, "/System/Library/CoreServices/SystemVersion.plist");
    RSDictionaryRef sysVer = RSDictionaryCreateWithContentOfPath(RSAllocatorSystemDefault, __RSSystemVersionInfoPlistPath);
    RS_CONST_STRING_DECL(ProductUserVisibleVersion, "ProductUserVisibleVersion");
    RSStringRef userVisibleVersion = RSDictionaryGetValue(sysVer, ProductUserVisibleVersion);
    RSDictionarySetValue(dict, __RSProcessInfoHumenReadableOperatingSystemVersion, userVisibleVersion);
    RSRelease(sysVer);
    
    RSRelease(key);
    RSRelease(descriptions);
    RSRelease(keys);
    return result;
}
Ejemplo n.º 2
0
static BOOL __RSProcessInfoUpdateMachineType(RSProcessInfoRef processInfo, RSStringRef key /*__RSProcessInfoMachine*/) {
    BOOL result = NO;
    if (__RSProcessInfoObjectForKey(processInfo, key)) return result = YES;
    RSMutableArrayRef keys = RSArrayCreateMutable(RSAllocatorSystemDefault, 0);
    RSMutableArrayRef descriptions = RSArrayCreateMutable(RSAllocatorSystemDefault, 0);
    RSRetain(key);
    RSArrayAddObject(keys, __RSProcessInfo_hw_model);
    RSArrayAddObject(descriptions, __RSProcessInfoMachineType);
    
//    RSArrayAddObject(keys, nil);
//    RSArrayAddObject(descriptions, __RSProcessInfoMachineSerinalNumber);
    
    result = __RSProcessInfoUpdateKeys(processInfo, keys, descriptions, key);
    RSMutableDictionaryRef dict = (RSMutableDictionaryRef)__RSProcessInfoObjectForKey(processInfo, key);
    __RSRuntimeSetInstanceSpecial(dict, YES);
    // machine Serinal Number
    
    void *handle = __RSProcessInfoGetHandle(processInfo);
    if (handle)
    {
        void *func = _RSGetImplementAddress(handle, "__RSProcessInfoGetSerinalNumber");
        RSStringRef serinal = func ? ((RSStringRef (*)(void))func)() : RSSTR("Null");
        RSDictionarySetValue(dict, __RSProcessInfoMachineSerinalNumber, serinal);
        RSRelease(serinal);
    }
    
    RSRelease(key);
    RSRelease(descriptions);
    RSRelease(keys);
    return result;
}
Ejemplo n.º 3
0
static BOOL __RSProcessInfoUpdate(RSMutableDictionaryRef processInfo, RSStringRef lookupKey, RSStringRef key) {
    RSStringRef value = nil;
    value = ___RSProcessInfoCreateUpdate(lookupKey);
    if (value)
    {
        RSDictionarySetValue(processInfo, key, value);
        RSRelease(value);
    }
    return value ? YES : NO;
}
Ejemplo n.º 4
0
RSExport void RSErrorSetCallBackForDomain(RSStringRef domainName, RSErrorUserInfoKeyCallBack callBack)
{
    if (!__RSErrorCallBackTable) __RSErrorInitUserInfoKeyCallBackTable();
    RSSpinLockLock(&__RSErrorCallBackTableSpinlock);
    if (callBack) {
        RSDictionarySetValue(__RSErrorCallBackTable, domainName, (void *)callBack);
    } else {
        RSDictionaryRemoveValue(__RSErrorCallBackTable, domainName);
    }
    RSSpinLockUnlock(&__RSErrorCallBackTableSpinlock);
}
Ejemplo n.º 5
0
RSInline void __RSDictionaryAddEnvWithCString(RSMutableDictionaryRef dict, const char *key) {
    const char *value = __RSGetEnvironment(key);
    if (dict && key && value)
    {
        RSStringRef k = RSStringCreateWithCString(RSAllocatorSystemDefault, key, RSStringEncodingUTF8);
        RSStringRef v = RSStringCreateWithCString(RSAllocatorSystemDefault, value, RSStringEncodingUTF8);
        RSDictionarySetValue(dict, k, v);
        RSRelease(k);
        RSRelease(v);
    }
}
RSExport void RSDictionarySetValueForKeys(RSMutableDictionaryRef dictionary, RSArrayRef keys, RSTypeRef value) {
    if (nil == dictionary || nil == keys || !RSArrayGetCount(keys)) return;
    RSClassRef dictClass = RSClassGetWithUTF8String("RSDictionary");
    RSUInteger cnt = RSArrayGetCount(keys);
    if (cnt < 2) {
        return RSDictionarySetValue(dictionary, RSArrayObjectAtIndex(keys, 0), value);
    }
    cnt --;
    RSMutableDictionaryRef tmp = dictionary, tmp1 = tmp;
    for (RSUInteger idx = 0; idx < cnt; idx++) {
        if (RSInstanceIsMemberOfClass(tmp, dictClass)) {
            tmp1 = (RSMutableDictionaryRef)RSDictionaryGetValue(tmp, RSArrayObjectAtIndex(keys, idx));
            if (!tmp1) {
                tmp1 = RSDictionaryCreateMutable(RSAllocatorSystemDefault, 0, RSDictionaryRSTypeContext);
                RSDictionarySetValue(tmp, RSArrayObjectAtIndex(keys, idx), tmp1);
                RSRelease(tmp1);
            }
            tmp = tmp1;
        } else {
            return ;
        }
    }
    return RSDictionarySetValue(tmp, RSArrayLastObject(keys), value);
}
Ejemplo n.º 7
0
RSInline void __RSProcessInfoSetObjectForKey(RSProcessInfoRef processInfo, RSStringRef key, RSTypeRef value) {
    return RSDictionarySetValue(processInfo->_info, key, value);
}