Last active
September 1, 2018 18:57
-
-
Save su8/2cdb401ba39c1fd00562c022337074cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/sysctl.h> | |
int main(void) { | |
u_int val[3] = {0}; | |
char buf[256] = {""}; | |
size_t len = sizeof(val); | |
size_t len2 = sizeof(buf); | |
if (0 != (sysctlbyname("dev.cpu.0.temperature", &val, &len, NULL, 0))) { | |
if (0 != (sysctlbyname("dev.aibs.0.%desc", buf, &len2, NULL, 0))) { | |
puts("failed!"); | |
return EXIT_FAILURE; | |
} | |
} | |
if (0 != (strcmp(buf, ""))) | |
printf("%s\n", buf); | |
else | |
printf("%lu\n", (unsigned long)val[0]); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment