PatchworkOS
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
#include <
errno.h
>
2
#include <
stdbool.h
>
3
#include <
stdio.h
>
4
#include <
stdlib.h
>
5
#include <
string.h
>
6
#include <
sys/io.h
>
7
8
int
main
(
int
argc,
char
** argv)
9
{
10
for
(
int
i = 1; i < argc; i++)
11
{
12
fd_t
fd =
open
(argv[i]);
13
if
(fd ==
ERR
)
14
{
15
printf
(
"open: failed to open %s (%s)\n"
, argv[i],
strerror
(
errno
));
16
return
EXIT_FAILURE
;
17
}
18
19
close
(fd);
20
}
21
22
return
EXIT_SUCCESS
;
23
}
errno.h
errno
#define errno
Error number variable.
Definition
errno.h:27
open
fd_t open(const char *path)
System call for opening files.
Definition
open.c:9
close
uint64_t close(fd_t fd)
System call for closing files.
Definition
close.c:9
fd_t
__UINT64_TYPE__ fd_t
A file descriptor.
Definition
fd_t.h:12
io.h
ERR
#define ERR
Definition
main.c:44
main
int main()
Definition
main.c:97
stdbool.h
stdio.h
printf
_PUBLIC int printf(const char *_RESTRICT format,...)
Definition
printf.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
touch
main.c
Generated by
1.9.8