PatchworkOS
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
#include <
errno.h
>
2
#include <
stdbool.h
>
3
#include <
stdint.h
>
4
#include <
stdio.h
>
5
#include <
stdlib.h
>
6
#include <
string.h
>
7
#include <
sys/io.h
>
8
9
int
main
(
int
argc,
char
** argv)
10
{
11
for
(
int
i = 1; i < argc; i++)
12
{
13
if
(
writef
(
STDOUT_FILENO
, argv[i]) ==
ERR
)
14
{
15
fprintf
(
stderr
,
"echo: %s\n"
,
strerror
(
errno
));
16
return
EXIT_FAILURE
;
17
}
18
19
if
(i != argc - 1)
20
{
21
if
(
writef
(
STDOUT_FILENO
,
" "
) ==
ERR
)
22
{
23
fprintf
(
stderr
,
"echo: %s\n"
,
strerror
(
errno
));
24
return
EXIT_FAILURE
;
25
}
26
}
27
}
28
return
EXIT_SUCCESS
;
29
}
errno.h
errno
#define errno
Error number variable.
Definition
errno.h:27
writef
uint64_t writef(fd_t fd, const char *_RESTRICT format,...)
Wrapper for writing a formatted string to a file.
Definition
writef.c:9
STDOUT_FILENO
#define STDOUT_FILENO
Definition
io.h:45
io.h
ERR
#define ERR
Definition
main.c:44
main
int main()
Definition
main.c:97
stdbool.h
stdint.h
stdio.h
stderr
FILE * stderr
Definition
std_streams.c:18
fprintf
_PUBLIC int fprintf(FILE *_RESTRICT stream, const char *_RESTRICT format,...)
Definition
fprintf.c:5
stdlib.h
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition
stdlib.h:46
EXIT_FAILURE
#define EXIT_FAILURE
Definition
stdlib.h:47
string.h
strerror
_PUBLIC char * strerror(int errnum)
Definition
strerror.c:6
src
programs
echo
main.c
Generated by
1.9.8