tiny-shell 0.2
A mini shell project aiming to gain knowledge about Win32 and Linux API
Loading...
Searching...
No Matches
utils.c File Reference
#include "utils.h"
#include "../os/operations.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

bool is_number (const char *c)
 
bool support_color ()
 

Function Documentation

◆ is_number()

bool is_number ( const char * c)

Definition at line 8 of file utils.c.

8 {
9 if(c == NULL || c[0] == '\0')
10 return false;
11 const unsigned int length = strlen(c);
12 static const unsigned int MAX_INT_DIGITS = 10;
13 if(length > MAX_INT_DIGITS)
14 return false;
15 for(int i = 0; i < length; ++i) {
16 if(c[i] < '0' || c[i] > '9')
17 return false;
18 }
19 return true;
20}

Referenced by cmd_init_from_str().

Here is the caller graph for this function:

◆ support_color()

bool support_color ( )

Definition at line 58 of file utils.c.

58 {
59 static bool res = false;
60 static bool checked = false;
61
62 if(!checked) {
63 res = priv_support_color();
64 checked = true;
65 }
66
67 return res;
68}

Referenced by format_error(), format_output(), format_success(), format_usage(), and prompt_input().

Here is the caller graph for this function: