Implement CSV loading and saving functionality; refactor user list management; update UUID generation and search functions; enhance signal handling in main application.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @brief Provizorni modul pro praci se seznamy uzivatelu. Priprava pro implementaci uziti PostgreSQL
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DB_HANDLER_H__
|
||||
#define __DB_HANDLER_H__
|
||||
|
||||
#include "main.h"
|
||||
#include "users.h"
|
||||
#include <libpq-fe.h>
|
||||
|
||||
int loadListFromCSV(char* _filename, list_t * _list);
|
||||
|
||||
int saveListToCSV(char* _filename, list_t * _list);
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,7 @@ typedef struct
|
||||
// UART handler thread
|
||||
void *uartListener(void *arg);
|
||||
|
||||
void parseIncommingPacket(list_t *_head, BYTE *_packet);
|
||||
uint16_t parseIncommingPacket(BYTE *_packet);
|
||||
|
||||
void sendPacketToDevice(BYTE * _packet);
|
||||
|
||||
|
||||
+3
-1
@@ -5,8 +5,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "main.h"
|
||||
|
||||
#include "users.h"
|
||||
|
||||
void uartDialog(char *uart_adress, int terminal_x, int terminal_y);
|
||||
|
||||
void mainMenu(list_t * person_list, int terminal_x, int terminal_y);
|
||||
|
||||
#endif
|
||||
+9
-6
@@ -45,7 +45,7 @@ typedef struct list
|
||||
* @param _head Pointer to the head node of the linked list.
|
||||
* @return A 16-bit unsigned integer representing the generated UUID.
|
||||
*/
|
||||
uint16_t generateUUID(node_t *_head);
|
||||
uint16_t generateUUID(list_t *_list);
|
||||
|
||||
/**
|
||||
* @brief Searches for a UUID associated with a user by their name and surname.
|
||||
@@ -59,7 +59,7 @@ uint16_t generateUUID(node_t *_head);
|
||||
* @param _surname Pointer to a string containing the user's surname.
|
||||
* @return Pointer to the UUID of the user if found, or 0 if no match is found.
|
||||
*/
|
||||
uint16_t *searchUUIDByName(node_t *_head, char *_name, char *_surname);
|
||||
uint16_t *searchUUIDByName(list_t *_list, char *_name, char *_surname);
|
||||
|
||||
/**
|
||||
* @brief Searches for a person in a linked list by their UUID.
|
||||
@@ -72,7 +72,7 @@ uint16_t *searchUUIDByName(node_t *_head, char *_name, char *_surname);
|
||||
* @return Pointer to the node containing the person with the matching UUID,
|
||||
* or NULL if no such person is found.
|
||||
*/
|
||||
node_t *searchPersonByUUID(node_t *_head, uint16_t _uuid);
|
||||
node_t *searchPersonByUUID(list_t *_list, uint16_t _uuid);
|
||||
|
||||
/**
|
||||
* @brief Adds a new person to the linked list.
|
||||
@@ -101,7 +101,9 @@ node_t *searchPersonByUUID(node_t *_head, uint16_t _uuid);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
int addPersonToList(node_t **_head, char *_name, char *_surname, uint32_t _department);
|
||||
int addPersonToList(list_t *_list, char *_name, char *_surname, uint32_t _department);
|
||||
|
||||
int loadPersonToList(list_t *_list, uint16_t _uuid, char *_name, char *_surname, uint32_t _department, time_t _last_event, time_t _total, BYTE _available);
|
||||
|
||||
/**
|
||||
* @brief Adds a time event to the specified person's event list.
|
||||
@@ -114,7 +116,7 @@ int addPersonToList(node_t **_head, char *_name, char *_surname, uint32_t _depar
|
||||
* @return An integer indicating the success or failure of the operation.
|
||||
* Typically, 1 for success and a 0 for failure.
|
||||
*/
|
||||
int addTimeEvent(node_t *_person);
|
||||
int addTimeEvent(node_t *_person, list_t *_list);
|
||||
|
||||
/**
|
||||
* @brief Removes a person node from a linked list.
|
||||
@@ -127,5 +129,6 @@ int addTimeEvent(node_t *_person);
|
||||
* @param _person Double pointer to the node representing the person to remove.
|
||||
* @return int Returns 0 on success, or a negative value on failure.
|
||||
*/
|
||||
int removePersonFromList(node_t **_head, node_t **_person);
|
||||
int removePersonFromList(list_t *_list, node_t **_person);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user