LCOV - code coverage report
Current view: top level - src - console.c (source / functions) Hit Total Coverage
Test: report.info Lines: 13 21 61.9 %
Date: 2024-01-02 12:43:31 Functions: 2 3 66.7 %

          Line data    Source code
       1             : #include "console.h"
       2             : 
       3           0 : void print_perror(const char *format, ...)
       4             : {
       5             :     va_list args;
       6           0 :     va_start(args, format);
       7             : 
       8           0 :     vfprintf(stderr, format, args);
       9           0 :     perror("");
      10             : 
      11           0 :     va_end(args);
      12           0 : }
      13             : 
      14           1 : void print_info(const char *text, ...)
      15             : {
      16           1 :     printf(BLUE);
      17             :     va_list args;
      18           1 :     va_start(args, text);
      19           1 :     vprintf(text, args);
      20           1 :     va_end(args);
      21           1 :     printf(RESET "\n");
      22           1 : }
      23             : 
      24          20 : void print_prompt()
      25             : {
      26          20 :     char *username = getenv("USER");
      27          20 :     if (username == NULL)
      28           0 :         username = "";
      29             : 
      30             :     char cwd[MAX_INPUT_LENGTH];
      31          20 :     if (getcwd(cwd, sizeof(cwd)) == NULL)
      32             :     {
      33           0 :         cwd[0] = '\0';
      34             :     }
      35             : 
      36             :     // Use this if you want to print the hostname
      37             :     // char hostname[1024];
      38             :     // gethostname(hostname, 1024);
      39             :     // if(username == NULL)
      40             :     //     username = "hostname";
      41             : 
      42          20 :     printf(YELLOW "%s" RESET "@" BLUE "livl-shell" GREEN ":~%s" RESET "$ ", username, cwd);
      43          20 : }

Generated by: LCOV version 1.14