Mirror of CollapseOS
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

27 Zeilen
559B

  1. #include <stdlib.h>
  2. #include <unistd.h>
  3. void sendcmd(int fd, char *cmd)
  4. {
  5. char junk[2];
  6. while (*cmd) {
  7. write(fd, cmd, 1);
  8. read(fd, &junk, 1);
  9. cmd++;
  10. // The other side is sometimes much slower than us and if we don't let
  11. // it breathe, it can choke.
  12. usleep(1000);
  13. }
  14. write(fd, "\n", 1);
  15. read(fd, &junk, 2); // sends back \r\n
  16. usleep(1000);
  17. }
  18. // Send a cmd and also read the "> " prompt
  19. void sendcmdp(int fd, char *cmd)
  20. {
  21. char junk[2];
  22. sendcmd(fd, cmd);
  23. read(fd, &junk, 2);
  24. }