_info 2.0 KB

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