summaryrefslogtreecommitdiff
path: root/src/utils.h
blob: 01e0c33f8f5ed399670ea759bbdf43f9e0f711a9 (plain)
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
#pragma once

#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

#define MIN_INTERVAL 30

#define INA260_SYSFS "/sys/kernel/ina260"
#define INA260_POWER_REGISTER "registers/power"

#define STR(symbol) #symbol
#define STRINGIFY(symbol) STR(symbol)

#define TIMESTAMP() (time(NULL))

#define INTERVAL(duration)\
    ((TIMESTAMP()) - ((TIMESTAMP())%(duration)))

#define INTERVAL_LAST(duration)\
    (INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))

#define FILE_EXISTS(path) (access((path), F_OK) == 0)

void mkdirp(char *path);