A clone of btpd with my configuration changes.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
861 B

  1. #include <sys/types.h>
  2. #include <err.h>
  3. #include <errno.h>
  4. #include <getopt.h>
  5. #include <inttypes.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include "metainfo.h"
  9. static void
  10. usage()
  11. {
  12. fprintf(stderr, "Usage: btinfo file ...\n\n");
  13. exit(1);
  14. }
  15. static struct option longopts[] = {
  16. { "help", no_argument, NULL, 1 },
  17. { NULL, 0, NULL, 0 }
  18. };
  19. int
  20. main(int argc, char **argv)
  21. {
  22. int ch;
  23. while ((ch = getopt_long(argc, argv, "", longopts, NULL)) != -1)
  24. usage();
  25. argc -= optind;
  26. argv += optind;
  27. if (argc < 1)
  28. usage();
  29. while (argc > 0) {
  30. struct metainfo *mi;
  31. if ((errno = load_metainfo(*argv, -1, 1, &mi)) != 0)
  32. err(1, "load_metainfo: %s", *argv);
  33. print_metainfo(mi);
  34. clear_metainfo(mi);
  35. free(mi);
  36. argc--;
  37. argv++;
  38. }
  39. return 0;
  40. }