echo.c (564B)
1 #include "linux.h" 2 3 static struct 4 { 5 unsigned short size; 6 char data[0x1000 - sizeof(unsigned short)]; 7 } buf; 8 9 static void putflush() 10 { 11 if (buf.size && write(1, buf.data, buf.size) != buf.size) 12 exit(1); 13 buf.size = 0; 14 } 15 16 static void putch(char c) 17 { 18 buf.data[buf.size++] = c; 19 if (c == '\n' || buf.size == sizeof buf.data) 20 putflush(); 21 } 22 23 static void putstr(char const* s) 24 { 25 while(*s) 26 putch(*s++); 27 } 28 29 int main(int argc, char* argv[]) 30 { 31 if (argc > 1) 32 putstr(argv[1]); 33 for (int i = 2; i < argc; ++i) 34 { 35 putch(' '); 36 putstr(argv[i]); 37 } 38 putch('\n'); 39 }