Refactor header inclusions and add main.h; implement searchPersonByUUID and addTimeEvent functions in users.c

This commit is contained in:
2025-04-24 19:53:52 +02:00
parent d60fcba0c8
commit e23ed280d8
9 changed files with 84 additions and 5 deletions
+1
View File
@@ -12,6 +12,7 @@
#include "tui.h"
#include "rfid_handler.h"
#include "file_operations.h"
#include "main.h"
int main(int argc, char const **argv)
{
+1
View File
@@ -1,5 +1,6 @@
#include "rfid_handler.h"
#include "users.h"
#include "main.h"
#include <stdio.h>
#include <stdlib.h>
+2
View File
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "main.h"
void uartDialog(char *uart_adress, int terminal_x, int terminal_y)
{
+44
View File
@@ -1,4 +1,6 @@
#include "users.h"
#include "main.h"
#include <stdio.h>
#include <stdlib.h>
@@ -31,6 +33,24 @@ uint16_t generateUUID
return uuid;
}
node_t *searchPersonByUUID
(
node_t *_head,
uint16_t _uuid
)
{
node_t *current = _head;
while (current != NULL)
{
if (current->user.uuid == _uuid)
{
return current;
}
current = current->next;
}
return NULL;
};
int addPersonToList
(
node_t **_head,
@@ -67,6 +87,7 @@ int addPersonToList
new_node->user.department = _department;
new_node->user.last_time_event = -255;
new_node->user.total = 0;
new_node->user.available = FALSE;
new_node->next = NULL;
@@ -83,5 +104,28 @@ int addPersonToList
}
current->next = new_node;
return 1;
}
int addTimeEvent
(
node_t *_person
)
{
time_t current_time = time(0);
if (_person == NULL)
{
return 0;
}
if (_person->user.available)
{
_person->user.total += (current_time - _person->user.last_time_event);
}
_person->user.available = !_person->user.available;
_person->user.last_time_event = current_time;
return 1;
}