1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package oshi.software.os.mac.local;
18
19 import com.sun.jna.Library;
20 import com.sun.jna.Native;
21 import com.sun.jna.NativeLong;
22 import com.sun.jna.Pointer;
23 import com.sun.jna.PointerType;
24
25
26
27
28
29
30 public interface CoreFoundation extends Library {
31 CoreFoundation INSTANCE = (CoreFoundation) Native.loadLibrary(
32 "CoreFoundation", CoreFoundation.class);
33
34 public static final int UTF_8 = 0x08000100;
35
36 int CFArrayGetCount(CFArrayRef array);
37
38 CFTypeRef CFArrayGetValueAtIndex(CFArrayRef array, int index);
39
40 void CFRelease(CFTypeRef blob);
41
42 public class CFTypeRef extends PointerType {
43
44 }
45
46 public class CFArrayRef extends PointerType {
47
48 }
49
50 public class CFDictionaryRef extends PointerType {
51
52 }
53
54 public class CFStringRef extends PointerType {
55 public static CFStringRef toCFString(String s) {
56 final char[] chars = s.toCharArray();
57 int length = chars.length;
58 return CoreFoundation.INSTANCE.CFStringCreateWithCharacters(null,
59 chars, new NativeLong(length));
60 }
61 }
62
63 CFStringRef CFStringCreateWithCharacters(Object object, char[] chars,
64 NativeLong length);
65
66 boolean CFDictionaryGetValueIfPresent(CFDictionaryRef dictionary,
67 CFStringRef key, PointerType value);
68
69 Pointer CFDictionaryGetValue(CFDictionaryRef dictionary, CFStringRef key);
70
71 boolean CFStringGetCString(Pointer foo, Pointer buffer, long maxSize,
72 int encoding);
73
74 long CFStringGetLength(Pointer str);
75
76 long CFStringGetMaximumSizeForEncoding(long length, int encoding);
77
78 boolean CFBooleanGetValue(Pointer booleanRef);
79
80 }