1 #include "../../lib/include/stringptr.h"
9 puts("prog name_of_file");
10 puts("writes stdin to supplied filename, in the fashion of the > shell operator.");
14 int main(int argc
, char** argv
) {
18 if(argc
!= 2) return syntax();
20 int fd
= open(argv
[1], O_WRONLY
| O_CREAT
| O_TRUNC
, S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IROTH
);
22 perror("file access");
26 while(line
= read_stdin_line(buf
, sizeof(buf
), 0), line
.ptr
) {
27 write(fd
, line
.ptr
, line
.size
);