-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.c
60 lines (53 loc) · 822 Bytes
/
output.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
#include "main.h"
/**
* _putchar - print a character to the standard input
* @c: character
*
* Return: void
*/
int _putchar(char c)
{
return (write(1, &c, 1));
}
/**
* prompt - display shell interactive prompt
*
* Return: void
*/
void prompt(void)
{
signal(SIGINT, SIG_IGN);
signal(SIGINT, signal_handr);
print("($) ");
}
/**
* signal_handr - handle signals
*
* @signum: Signal value
*/
void signal_handr(int signum)
{
(void)(signum);
print("\n($) ");
fflush(stdout);
}
/**
* print - print a string to standard output
* @s: pointer to a string
*
* Return: void
*/
void print(char *s)
{
write(STDERR_FILENO, s, _strlen(s));
}
/**
* _printf - print a string to standard error
* @s: pointer to a string
*
* Return: void
*/
void _printf(char *s)
{
write(STDOUT_FILENO, s, _strlen(s));
}