_info 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * opt - simple command line parsing
  6. *
  7. * Simple but powerful command line parsing.
  8. *
  9. * Example:
  10. * #include <ccan/opt/opt.h>
  11. * #include <stdio.h>
  12. * #include <stdlib.h>
  13. *
  14. * static bool someflag;
  15. * static int verbose;
  16. * static char *somestring;
  17. *
  18. * static struct opt_table opts[] = {
  19. * OPT_WITHOUT_ARG("--verbose|-v", opt_inc_intval, &verbose,
  20. * "Verbose mode (can be specified more than once)"),
  21. * OPT_WITHOUT_ARG("--someflag", opt_set_bool, &someflag,
  22. * "Set someflag"),
  23. * OPT_WITH_ARG("--somefile=<filename>", opt_set_charp, opt_show_charp,
  24. * &somestring, "Set somefile to <filename>"),
  25. * OPT_WITHOUT_ARG("--usage|--help|-h", opt_usage_and_exit,
  26. * "args...\nA silly test program.",
  27. * "Print this message."),
  28. * OPT_ENDTABLE
  29. * };
  30. *
  31. * int main(int argc, char *argv[])
  32. * {
  33. * int i;
  34. *
  35. * opt_register_table(opts, NULL);
  36. * // For fun, register an extra one.
  37. * opt_register_noarg("--no-someflag", opt_set_invbool, &someflag,
  38. * "Unset someflag");
  39. * if (!opt_parse(&argc, argv, opt_log_stderr))
  40. * exit(1);
  41. *
  42. * printf("someflag = %i, verbose = %i, somestring = %s\n",
  43. * someflag, verbose, somestring);
  44. * printf("%u args left over:", argc - 1);
  45. * for (i = 1; i < argc; i++)
  46. * printf(" %s", argv[i]);
  47. * printf("\n");
  48. * return 0;
  49. * }
  50. *
  51. * License: GPL (2 or any later version)
  52. * Author: Rusty Russell <rusty@rustcorp.com.au>
  53. */
  54. int main(int argc, char *argv[])
  55. {
  56. if (argc != 2)
  57. return 1;
  58. if (strcmp(argv[1], "depends") == 0) {
  59. printf("ccan/typesafe_cb\n");
  60. printf("ccan/compiler\n");
  61. return 0;
  62. }
  63. return 1;
  64. }