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.

start.c 1.2 KiB

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