2023-11-16 04:38:29 +01:00
|
|
|
#ifndef SIGNAL_HANDLER_H
|
|
|
|
#define SIGNAL_HANDLER_H
|
2023-10-24 05:14:31 +02:00
|
|
|
|
2023-11-22 12:59:59 +01:00
|
|
|
#include <signal.h>
|
2023-10-24 05:14:31 +02:00
|
|
|
|
2023-10-25 16:30:08 +02:00
|
|
|
#include "block.h"
|
2023-10-24 05:14:31 +02:00
|
|
|
#include "timer.h"
|
|
|
|
|
|
|
|
typedef sigset_t signal_set;
|
2023-10-25 16:30:08 +02:00
|
|
|
typedef int (*signal_refresh_callback)(block* const blocks,
|
|
|
|
const unsigned short block_count);
|
|
|
|
typedef int (*signal_timer_callback)(block* const blocks,
|
|
|
|
const unsigned short block_code,
|
|
|
|
timer* const timer);
|
2023-10-24 05:14:31 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int fd;
|
|
|
|
const signal_refresh_callback refresh_callback;
|
|
|
|
const signal_timer_callback timer_callback;
|
2023-10-25 16:30:08 +02:00
|
|
|
|
|
|
|
block* const blocks;
|
|
|
|
const unsigned short block_count;
|
2023-10-24 05:14:31 +02:00
|
|
|
} signal_handler;
|
|
|
|
|
|
|
|
signal_handler signal_handler_new(
|
2023-10-25 16:30:08 +02:00
|
|
|
block* const blocks, const unsigned short block_count,
|
2023-10-24 05:14:31 +02:00
|
|
|
const signal_refresh_callback refresh_callback,
|
|
|
|
const signal_timer_callback timer_callback);
|
|
|
|
int signal_handler_init(signal_handler* const handler);
|
|
|
|
int signal_handler_deinit(signal_handler* const handler);
|
|
|
|
int signal_handler_process(signal_handler* const handler, timer* const timer);
|
2023-11-16 04:38:29 +01:00
|
|
|
|
|
|
|
#endif // SIGNAL_HANDLER_H
|