-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinters.c
70 lines (64 loc) · 1.08 KB
/
printers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "shell.h"
/**
*print_number - prints numbers to the stdout
*@n: number to print
*Return: nothing
*/
void print_number(int n)
{
unsigned int x = n;
if (n < 0)
{
_putchar('-');
x = -x;
}
if ((x / 10) > 0)
print_number(x / 10);
_putchar(x % 10 + '0');
}
/**
* prompt - Display Shell Prompt
*/
void prompt(void)
{
PRINTER("$ ");
}
/**
* print_error - Display Error Based on Command and How Many Time Shell Looped
* @input:User Input
* @counter:Simple Shell Count Loop
* @argv:Program Name
* Return: Void
*/
void print_error(char *input, int counter, char **argv)
{
char *er;
PRINTER(argv[0]);
PRINTER(": ");
er = _itoa(counter);
PRINTER(er);
free(er);
PRINTER(": ");
PRINTER(input);
PRINTER(": not found\n");
}
/**
* _prerror - Print Custome Error
* @argv:Program Name
* @c:Error Count
* @cmd:Command
* Return: Void
*/
void _prerror(char **argv, int c, char **cmd)
{
char *er = _itoa(c);
PRINTER(argv[0]);
PRINTER(": ");
PRINTER(er);
PRINTER(": ");
PRINTER(cmd[0]);
PRINTER(": Illegal number: ");
PRINTER(cmd[1]);
PRINTER("\n");
free(er);
}