CrimsonCare
CrimsonCare is a C project designed to provide a robust solution for blood management.
 
Loading...
Searching...
No Matches
misc.c File Reference

Misc source file. More...

#include "../include/misc.h"

Go to the source code of this file.

Functions

displayWelcomeMessage

Display welcome message

This function displays the welcome message by reading from the file resources/assets/misc/cc.txt.

Note
The file resources/assets/misc/cc.txt is a text file that contains the welcome message.
Precondition
The file resources/assets/misc/cc.txt exists.
Postcondition
The welcome message is displayed.
void displayWelcomeMessage (void)
 
displayUserMenu

Display user menu

This function displays the user menu.

Postcondition
The user menu is displayed.
void displayUserMenu (void)
 
displayAdminMenu

Display admin menu

This function displays the admin menu.

Postcondition
The admin menu is displayed.
void displayAdminMenu (void)
 
clearInputBuffer

Clear input buffer

This function clears the input buffer by reading until a newline character is encountered.

Postcondition
The input buffer is cleared.
void clearInputBuffer (void)
 
checkUsername

Check if username is valid

This function checks if a username is valid.

Parameters
[in]strUsername to check
Returns
True if username is valid, False otherwise
Note
Username can only contain lowercase letters and digits.
Precondition
str is not empty
Postcondition
If the str is valid, the function returns true. Otherwise, it returns false.
bool checkUsername (const char *str)
 
containsPipe

Check if string contains pipe

This function checks if a string contains a pipe character.

Parameters
[in]strString to check
Returns
True if string contains pipe, False otherwise
Precondition
str is not empty
Postcondition
If the str contains a pipe character, the function returns true. Otherwise, it returns false.
bool containsPipe (const char *str)
 
getPassword

Get password

This function gets the password from the user by reading from the standard input.

Parameters
[in,out]passwordPassword
[in]sizePassword size
Postcondition
Updates the password with the user's input through the pointer password.
void getPassword (char *password, size_t size)
 
isLeapYear

Check if year is leap year

This function checks if a year is a leap year.

Parameters
[in]yearYear to check
Returns
True if year is leap year, False otherwise
bool isLeapYear (int year)
 
isValidDate

Check if date is valid

This function checks if a date is valid.

Parameters
[in]dateDate to check
Returns
True if date is valid, False otherwise
Precondition
date is not empty
Postcondition
If the date is valid, the function returns true. Otherwise, it returns false.
Exceptions
Ifthe date is empty, an error message is displayed.
Ifthe date is invalid, an error message is displayed.
bool isValidDate (const char *date)
 
formatDate

Format date to yyyy-mm-dd

This function formats a date string to the format yyyy-mm-dd.

Parameters
[in,out]dateDate to format
Precondition
date is not empty
Postcondition
The date is formatted to the format yyyy-mm-dd and updates the date through the pointer date.
Exceptions
Ifthe date is empty, an error message is displayed.
Ifthe date is invalid, an error message is displayed.
void formatDate (char *date)
 

Detailed Description

Misc source file.

This file contains the implementation of the functions for the misc module.

Author
CrimsonCare Team
Date
2025-01-22

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file misc.c.

Function Documentation

◆ checkUsername()

bool checkUsername ( const char * str)

Definition at line 127 of file misc.c.

◆ clearInputBuffer()

void clearInputBuffer ( void )

Definition at line 107 of file misc.c.

◆ containsPipe()

bool containsPipe ( const char * str)

Definition at line 150 of file misc.c.

◆ displayAdminMenu()

void displayAdminMenu ( void )

Definition at line 82 of file misc.c.

◆ displayUserMenu()

void displayUserMenu ( void )

Definition at line 65 of file misc.c.

◆ displayWelcomeMessage()

void displayWelcomeMessage ( void )

Definition at line 46 of file misc.c.

◆ formatDate()

void formatDate ( char * date)

Definition at line 294 of file misc.c.

◆ getPassword()

void getPassword ( char * password,
size_t size )

Definition at line 172 of file misc.c.

◆ isLeapYear()

bool isLeapYear ( int year)

Definition at line 228 of file misc.c.

◆ isValidDate()

bool isValidDate ( const char * date)

Definition at line 248 of file misc.c.