blob: b8e5bbe01ea4c51f67a7c01865e9160a9023d5ea (
plain)
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
|
#include <string.h>
#include <unistd.h>
#include <sys/uio.h>
int main(int argc, char **argv)
{
if (argc <= 1)
return 0;
struct iovec iov[2 * argc - 2];
int iovcnt = 0;
for (int i = 1; i < argc; i++) {
iov[iovcnt].iov_base = argv[i];
iov[iovcnt].iov_len = strlen(argv[i]);
iovcnt++;
if (i < argc - 1) {
iov[iovcnt].iov_base = " ";
iov[iovcnt].iov_len = 1;
iovcnt++;
}
}
iov[iovcnt].iov_base = "\n";
iov[iovcnt].iov_len = 1;
iovcnt++;
return writev(STDOUT_FILENO, iov, iovcnt) < 0 ? 1 : 0;
}
|