Mirror of CollapseOS
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

27 lignes
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. }