1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include "version.h"
#include "sysinfo.h"
#include <string.h>
#include <stdio.h>
struct our_state {
int pretty_printing;
int custom_cpuinfo;
char cpuinfo_file[BUFSIZ];
};
struct our_state internal_state={1,0,"/proc/cpuinfo"};
char *get_sysinfo_version(char *version) {
snprintf(version,BUFSIZ,"%i.%i.%i",VERSION_MAJOR,VERSION_MINOR,VERSION_SUBMINOR);
return version;
}
int get_numeric_sysinfo_version(void) {
return (VERSION_MAJOR*10000)+(VERSION_MINOR*100)+VERSION_SUBMINOR;
}
int set_cpuinfo_file(char *filename) {
internal_state.custom_cpuinfo=1;
strncpy(internal_state.cpuinfo_file,filename,BUFSIZ);
return 0;
}
char *get_cpuinfo_file(void) {
return internal_state.cpuinfo_file;
}
void set_pretty_printing(int value) {
internal_state.pretty_printing=value;
}
int get_pretty_printing(void) {
return internal_state.pretty_printing;
}
|