Crinit -- Configurable Rootfs Init
Loading...
Searching...
No Matches
timer.h File Reference

(/usr/bin/git)

#include <bits/types/struct_itimerspec.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
Include dependency graph for timer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  crinitTimerDef
 
struct  crinitTimer
 

Macros

#define CO_RANGE(start, test, end)   (((start) <= (test)) && ((test) < (end)))
 
#define CC_RANGE(start, test, end)   (((start) <= (test)) && ((test) <= (end)))
 
#define OC_RANGE(start, test, end)   (((start) < (test)) && ((test) <= (end)))
 
#define OO_RANGE(start, test, end)   (((start) < (test)) && ((test) < (end)))
 

Typedefs

typedef struct crinitTimerDef crinitTimerDef_t
 
typedef struct crinitTimer crinitTimer_t
 

Functions

void crinitTimerSetDefault (crinitTimerDef_t *td)
 
bool crinitCheckTimerDef (crinitTimerDef_t *td)
 
int crinitSPrintTimerDef (char *s, crinitTimerDef_t *td)
 
void crinitPrintTimerDef (crinitTimerDef_t *td)
 
bool crinitTimerParse (char *s, crinitTimerDef_t *td)
 
struct timespec crinitTimerNextTime (struct timespec *last, crinitTimerDef_t *td)
 
struct tm * crinitZonedTimeR (const time_t *time, int8_t timezone[2], struct tm *restrict result)
 
bool crinitCheckTimerTime (struct timespec ts, crinitTimerDef_t *td)
 

Macro Definition Documentation

◆ CC_RANGE

#define CC_RANGE (   start,
  test,
  end 
)    (((start) <= (test)) && ((test) <= (end)))

Check if a value is in a closed-closed range (test in [start, end] ) ie start <= test <= end.

Parameters
startthe lower end of the range to check
testthe value to check if it's in range
endthe upper end of the range to check
Returns
true if test is higher or equal to start and lower or equal to end

◆ CO_RANGE

#define CO_RANGE (   start,
  test,
  end 
)    (((start) <= (test)) && ((test) < (end)))

Check if a value is in a closed-open range (test in [start, end) ) ie start <= test < end.

Parameters
startthe lower end of the range to check
testthe value to check if it's in range
endthe upper end of the range to check
Returns
true if test is higher or equal to start and lower then end

◆ OC_RANGE

#define OC_RANGE (   start,
  test,
  end 
)    (((start) < (test)) && ((test) <= (end)))

Check if a value is in a open-closed range (test in (start, end] ) ie start < test <= end.

Parameters
startthe lower end of the range to check
testthe value to check if it's in range
endthe upper end of the range to check
Returns
true if test is higher then start and lower or equal to end

◆ OO_RANGE

#define OO_RANGE (   start,
  test,
  end 
)    (((start) < (test)) && ((test) < (end)))

Check if a value is in a open-open range (test in (start, end) ) ie start < test < end.

Parameters
startthe lower end of the range to check
testthe value to check if it's in range
endthe upper end of the range to check
Returns
true if test is higher then start and lower then end

Typedef Documentation

◆ crinitTimer_t

typedef struct crinitTimer crinitTimer_t

The type of a crinit timer object.

◆ crinitTimerDef_t

The type of a timer definition.

Function Documentation

◆ crinitCheckTimerDef()

bool crinitCheckTimerDef ( crinitTimerDef_t td)

Check if a timer definition gives a valid timer ie. month between 1 and 12, day in 1 to 31, hours 0 to 23, ...

Parameters
tdthe timer definition to set check
Returns
true if the timer definition is valid, and false if not

◆ crinitCheckTimerTime()

bool crinitCheckTimerTime ( struct timespec  ts,
crinitTimerDef_t td 
)

Check if a timerstamp is valid for a timer

Parameters
tsthe timestamp to check.
tdthe crinit timer definition to check against
Returns
true if the timer should trigger at that timestamp, false otherwise

◆ crinitPrintTimerDef()

void crinitPrintTimerDef ( crinitTimerDef_t td)

print a crinitTimerDef_t as crinitInfoPrint message

Parameters
tdthe crinitTimerDef_t to print

◆ crinitSPrintTimerDef()

int crinitSPrintTimerDef ( char *  s,
crinitTimerDef_t td 
)

print a crinitTimerDef_t into a string

Parameters
sthe string to print to
tdthe crinitTimerDef_t to print
Returns
the number of bytes written to s excluding the terminating 0 byte

◆ crinitTimerNextTime()

struct timespec crinitTimerNextTime ( struct timespec *  last,
crinitTimerDef_t td 
)

Calculate the next time the timer should trigger.

Parameters
lastthe last timestamp to calculate the next from
tdthe timer definition to calculate the next time from
Returns
the timestamp the timer is fullfiled next

◆ crinitTimerParse()

bool crinitTimerParse ( char *  s,
crinitTimerDef_t td 
)

Parses a timer definition from a string

Parameters
sthe string to parse from
tdthe crinitTimerDef_t to set
Returns
true on success, false otherwise

◆ crinitTimerSetDefault()

void crinitTimerSetDefault ( crinitTimerDef_t td)

Set a timer to the default value: Mon..Sun-0000..65535-01..12-01..31-00:00:00+0000

Parameters
tdthe crinitTimerDef_t to set to default

◆ crinitZonedTimeR()

struct tm * crinitZonedTimeR ( const time_t *  time,
int8_t  timezone[2],
struct tm *restrict  result 
)

Get a struct tm similar to gmtime_r with a specific timezone.

Parameters
timethe timestamp to transform into a tm
timezonethe timezone with hour and minute
resultthe resulting tm struct
Returns
a tm representation in the specyfied timezone