Remove ansi_colors.h from the programs. Add the volatile keyword to the memset operations.
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
/// @file ansi_colors.h
|
||||
/// @brief Macros for ANSI colors.
|
||||
/// @copyright (c) 2014-2023 This file is distributed under the MIT License.
|
||||
/// See LICENSE.md for details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FG_RESET "\033[0m" ///< ANSI code for resetting.
|
||||
|
||||
#define FG_BLACK "\033[30m" ///< ANSI code for setting a BLACK foreground.
|
||||
#define FG_RED "\033[31m" ///< ANSI code for setting a RED foreground.
|
||||
#define FG_GREEN "\033[32m" ///< ANSI code for setting a GREEN foreground.
|
||||
#define FG_YELLOW "\033[33m" ///< ANSI code for setting a YELLOW foreground.
|
||||
#define FG_BLUE "\033[34m" ///< ANSI code for setting a BLUE foreground.
|
||||
#define FG_MAGENTA "\033[35m" ///< ANSI code for setting a MAGENTA foreground.
|
||||
#define FG_CYAN "\033[36m" ///< ANSI code for setting a CYAN foreground.
|
||||
#define FG_WHITE "\033[37m" ///< ANSI code for setting a WHITE foreground.
|
||||
|
||||
#define FG_BLACK_BOLD "\033[1;30m" ///< ANSI code for setting a BLACK foreground.
|
||||
#define FG_RED_BOLD "\033[1;31m" ///< ANSI code for setting a RED foreground.
|
||||
#define FG_GREEN_BOLD "\033[1;32m" ///< ANSI code for setting a GREEN foreground.
|
||||
#define FG_YELLOW_BOLD "\033[1;33m" ///< ANSI code for setting a YELLOW foreground.
|
||||
#define FG_BLUE_BOLD "\033[1;34m" ///< ANSI code for setting a BLUE foreground.
|
||||
#define FG_MAGENTA_BOLD "\033[1;35m" ///< ANSI code for setting a MAGENTA foreground.
|
||||
#define FG_CYAN_BOLD "\033[1;36m" ///< ANSI code for setting a CYAN foreground.
|
||||
#define FG_WHITE_BOLD "\033[1;37m" ///< ANSI code for setting a WHITE foreground.
|
||||
|
||||
#define FG_BLACK_BRIGHT "\033[90m" ///< ANSI code for setting a BRIGHT_BLACK foreground.
|
||||
#define FG_RED_BRIGHT "\033[91m" ///< ANSI code for setting a BRIGHT_RED foreground.
|
||||
#define FG_GREEN_BRIGHT "\033[92m" ///< ANSI code for setting a BRIGHT_GREEN foreground.
|
||||
#define FG_YELLOW_BRIGHT "\033[93m" ///< ANSI code for setting a BRIGHT_YELLOW foreground.
|
||||
#define FG_BLUE_BRIGHT "\033[94m" ///< ANSI code for setting a BRIGHT_BLUE foreground.
|
||||
#define FG_MAGENTA_BRIGHT "\033[95m" ///< ANSI code for setting a BRIGHT_MAGENTA foreground.
|
||||
#define FG_CYAN_BRIGHT "\033[96m" ///< ANSI code for setting a BRIGHT_CYAN foreground.
|
||||
#define FG_WHITE_BRIGHT "\033[97m" ///< ANSI code for setting a BRIGHT_WHITE foreground.
|
||||
|
||||
#define FG_BLACK_BRIGHT_BOLD "\033[1;90m" ///< ANSI code for setting a BRIGHT_BLACK foreground.
|
||||
#define FG_RED_BRIGHT_BOLD "\033[1;91m" ///< ANSI code for setting a BRIGHT_RED foreground.
|
||||
#define FG_GREEN_BRIGHT_BOLD "\033[1;92m" ///< ANSI code for setting a BRIGHT_GREEN foreground.
|
||||
#define FG_YELLOW_BRIGHT_BOLD "\033[1;93m" ///< ANSI code for setting a BRIGHT_YELLOW foreground.
|
||||
#define FG_BLUE_BRIGHT_BOLD "\033[1;94m" ///< ANSI code for setting a BRIGHT_BLUE foreground.
|
||||
#define FG_MAGENTA_BRIGHT_BOLD "\033[1;95m" ///< ANSI code for setting a BRIGHT_MAGENTA foreground.
|
||||
#define FG_CYAN_BRIGHT_BOLD "\033[1;96m" ///< ANSI code for setting a BRIGHT_CYAN foreground.
|
||||
#define FG_WHITE_BRIGHT_BOLD "\033[1;97m" ///< ANSI code for setting a BRIGHT_WHITE foreground.
|
||||
|
||||
#define BG_BLACK "\033[40m" ///< ANSI code for setting a BLACK background.
|
||||
#define BG_RED "\033[41m" ///< ANSI code for setting a RED background.
|
||||
#define BG_GREEN "\033[42m" ///< ANSI code for setting a GREEN background.
|
||||
#define BG_YELLOW "\033[43m" ///< ANSI code for setting a YELLOW background.
|
||||
#define BG_BLUE "\033[44m" ///< ANSI code for setting a BLUE background.
|
||||
#define BG_MAGENTA "\033[45m" ///< ANSI code for setting a MAGENTA background.
|
||||
#define BG_CYAN "\033[46m" ///< ANSI code for setting a CYAN background.
|
||||
#define BG_WHITE "\033[47m" ///< ANSI code for setting a WHITE background.
|
||||
|
||||
#define BG_BRIGHT_BLACK "\033[100m" ///< ANSI code for setting a BRIGHT_BLACK background.
|
||||
#define BG_BRIGHT_RED "\033[101m" ///< ANSI code for setting a BRIGHT_RED background.
|
||||
#define BG_BRIGHT_GREEN "\033[102m" ///< ANSI code for setting a BRIGHT_GREEN background.
|
||||
#define BG_BRIGHT_YELLOW "\033[103m" ///< ANSI code for setting a BRIGHT_YELLOW background.
|
||||
#define BG_BRIGHT_BLUE "\033[104m" ///< ANSI code for setting a BRIGHT_BLUE background.
|
||||
#define BG_BRIGHT_MAGENTA "\033[105m" ///< ANSI code for setting a BRIGHT_MAGENTA background.
|
||||
#define BG_BRIGHT_CYAN "\033[106m" ///< ANSI code for setting a BRIGHT_CYAN background.
|
||||
#define BG_BRIGHT_WHITE "\033[107m" ///< ANSI code for setting a BRIGHT_WHITE background.
|
||||
+4
-5
@@ -15,8 +15,7 @@
|
||||
#include <strerror.h>
|
||||
#include <stdlib.h>
|
||||
#include <io/debug.h>
|
||||
|
||||
#include "ansi_colors.h"
|
||||
#include <io/ansi_colors.h>
|
||||
|
||||
/// Maximum length of credentials.
|
||||
#define CREDENTIALS_LENGTH 50
|
||||
@@ -52,7 +51,7 @@ static inline void __set_io_flags(unsigned flag, bool_t active)
|
||||
tcsetattr(STDIN_FILENO, 0, &_termios);
|
||||
}
|
||||
|
||||
static inline void __print_message_file(const char * file)
|
||||
static inline void __print_message_file(const char *file)
|
||||
{
|
||||
char buffer[256];
|
||||
ssize_t nbytes, total = 0;
|
||||
@@ -159,12 +158,12 @@ int main(int argc, char **argv)
|
||||
// Get the username.
|
||||
do {
|
||||
printf("Username :");
|
||||
} while (!__get_input(username, CREDENTIALS_LENGTH, false));
|
||||
} while (!__get_input(username, sizeof(username), false));
|
||||
|
||||
// Get the password.
|
||||
do {
|
||||
printf("Password :");
|
||||
} while (!__get_input(password, CREDENTIALS_LENGTH, true));
|
||||
} while (!__get_input(password, sizeof(password), true));
|
||||
|
||||
// Check if we can find the user.
|
||||
if ((pwd = getpwnam(username)) == NULL) {
|
||||
|
||||
+11
-11
@@ -10,18 +10,18 @@
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <io/debug.h>
|
||||
#include <io/ansi_colors.h>
|
||||
#include <sys/bitops.h>
|
||||
#include "stdbool.h"
|
||||
#include "stddef.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "strerror.h"
|
||||
#include "termios.h"
|
||||
#include "limits.h"
|
||||
#include "sys/utsname.h"
|
||||
#include "ctype.h"
|
||||
#include "ansi_colors.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strerror.h>
|
||||
#include <termios.h>
|
||||
#include <limits.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/// Maximum length of commands.
|
||||
#define CMD_LEN 32
|
||||
|
||||
Reference in New Issue
Block a user