A clone of btpd with my configuration changes.
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.

61 lignes
1.2 KiB

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