Verify bittorrent .torrent metainfo files.
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.

57 lignes
1.6KB

  1. #include "opts.h"
  2. #include <unistd.h>
  3. #include <string.h>
  4. int opt_silent = 0;
  5. int opt_showinfo = 0;
  6. int opt_help = 0;
  7. int opt_no_use_dir = 0;
  8. int opt_pretty_progress = 0;
  9. int opt_scriptformat_info = OPT_SCRIPTFORMAT_NONE;
  10. char* opt_data_path = NULL;
  11. int opts_parse(int argc, char** argv) {
  12. int opt;
  13. while ((opt = getopt(argc, argv, "pnihsv:f:")) != -1) {
  14. switch (opt) {
  15. case 'i':
  16. opt_showinfo = 1;
  17. break;
  18. case 'h':
  19. opt_help = 1;
  20. break;
  21. case 's':
  22. opt_silent = 1;
  23. break;
  24. case 'n':
  25. opt_no_use_dir = 1;
  26. break;
  27. case 'p':
  28. opt_pretty_progress = 1;
  29. break;
  30. case 'v':
  31. opt_data_path = optarg;
  32. break;
  33. case 'f':
  34. if (strlen(optarg) != 1)
  35. return -1;
  36. char info_char = optarg[0];
  37. opt_scriptformat_info = OPT_SCRIPTFORMAT_INVALID;
  38. for (int i = 0; i < OPT_SCRIPTFORMAT_MAPPING_LEN; i++) {
  39. const opt_scriptformat_mapping_t* curr = &OPT_SCRIPTFORMAT_MAPPING[i];
  40. if (info_char == curr->info_char) {
  41. opt_scriptformat_info = curr->info;
  42. break;
  43. }
  44. }
  45. if (opt_scriptformat_info == OPT_SCRIPTFORMAT_INVALID)
  46. return -1;
  47. break;
  48. default:
  49. return -1;
  50. }
  51. }
  52. return 0;
  53. }