shallot v0.0.3 from taswebqlseworuhc.onion.
[shallot/rransom.git] / src / linux.c
blob22d1ff85a0df47878d0cab28cbdd12ced8351da4
1 // linux specific stuff for shallot
3 #include "linux.h"
5 #ifdef LINUX_PORT
7 #include "defines.h"
8 #include <string.h>
10 // Linux specific stuff (damn this is ugly code. blame linus.)
11 uint8_t parse_cpuinfo(char *buf, uint16_t avail, uint16_t *used) {
12 uint16_t x = 0;
13 char procsfound = 0;
14 static uint8_t skip = 0;
16 if(!skip) {
17 if(memcmp(&CPUINFO_PROC_STR, buf, CPUINFO_PROC_STR_LEN) == 0)
18 procsfound++;
21 while((buf[x] != 0) && (x < avail)) {
22 if(x) {
23 if(buf[x - 1] == '\n') {
24 break;
27 x++;
30 *used = x;
32 if(!x)
33 return 0; // prevent the next if statement from causing a buffer overflow
35 if((x == avail) && (buf[x - 1] != '\n'))
36 skip = 1;
37 else
38 skip = 0;
40 return procsfound;
43 #endif