A clone of btpd with my configuration changes.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "btcli.h"
  2. void
  3. usage_stop(void)
  4. {
  5. printf(
  6. "Stop torrents.\n"
  7. "\n"
  8. "Usage: stop -a\n"
  9. " stop torrent ...\n"
  10. "\n"
  11. "Options:\n"
  12. "-a\n"
  13. "\tStop all active torrents.\n"
  14. "\n"
  15. );
  16. exit(1);
  17. }
  18. static struct option stop_opts [] = {
  19. { "help", no_argument, NULL, 'H' },
  20. {NULL, 0, NULL, 0}
  21. };
  22. void
  23. cmd_stop(int argc, char **argv)
  24. {
  25. int ch, all = 0;
  26. struct ipc_torrent t;
  27. while ((ch = getopt_long(argc, argv, "a", stop_opts, NULL)) != -1) {
  28. switch (ch) {
  29. case 'a':
  30. all = 1;
  31. break;
  32. default:
  33. usage_stop();
  34. }
  35. }
  36. argc -= optind;
  37. argv += optind;
  38. if ((argc == 0 && !all) || (all && argc != 0))
  39. usage_stop();
  40. btpd_connect();
  41. if (all) {
  42. enum ipc_err code = btpd_stop_all(ipc);
  43. if (code != IPC_OK)
  44. errx(1, "%s", ipc_strerror(code));
  45. } else {
  46. for (int i = 0; i < argc; i++)
  47. if (torrent_spec(argv[i], &t))
  48. handle_ipc_res(btpd_stop(ipc, &t), "stop", argv[i]);
  49. }
  50. }