View Javadoc
1   /**
2    * Oshi (https://github.com/dblock/oshi)
3    * 
4    * Copyright (c) 2010 - 2015 The Oshi Project Team
5    * 
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of the Eclipse Public License v1.0
8    * which accompanies this distribution, and is available at
9    * http://www.eclipse.org/legal/epl-v10.html
10   * 
11   * Contributors:
12   * dblock[at]dblock[dot]org
13   * alessandro[at]perucchi[dot]org
14   * widdis[at]gmail[dot]com
15   * https://github.com/dblock/oshi/graphs/contributors
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   * CoreFoundation framework for power supply stats
27   * 
28   * @author widdis[at]gmail[dot]com
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  		// TODO Build this out
44  	}
45  
46  	public class CFArrayRef extends PointerType {
47  		// TODO Build this out
48  	}
49  
50  	public class CFDictionaryRef extends PointerType {
51  		// TODO Build this out
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  }