_info 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * list - double linked list routines
  6. *
  7. * The list header contains routines for manipulating double linked lists.
  8. * It defines two types: struct list_head used for anchoring lists, and
  9. * struct list_node which is usually embedded in the structure which is placed
  10. * in the list.
  11. *
  12. * Example:
  13. * #include <err.h>
  14. * #include <stdio.h>
  15. * #include <stdlib.h>
  16. * #include <ccan/list/list.h>
  17. *
  18. * struct parent {
  19. * const char *name;
  20. * struct list_head children;
  21. * unsigned int num_children;
  22. * };
  23. *
  24. * struct child {
  25. * const char *name;
  26. * struct list_node list;
  27. * };
  28. *
  29. * int main(int argc, char *argv[])
  30. * {
  31. * struct parent p;
  32. * struct child *c;
  33. * unsigned int i;
  34. *
  35. * if (argc < 2)
  36. * errx(1, "Usage: %s parent children...", argv[0]);
  37. *
  38. * p.name = argv[1];
  39. * list_head_init(&p.children);
  40. * p.num_children = 0;
  41. * for (i = 2; i < argc; i++) {
  42. * c = malloc(sizeof(*c));
  43. * c->name = argv[i];
  44. * list_add(&p.children, &c->list);
  45. * p.num_children++;
  46. * }
  47. *
  48. * printf("%s has %u children:", p.name, p.num_children);
  49. * list_for_each(&p.children, c, list)
  50. * printf("%s ", c->name);
  51. * printf("\n");
  52. * return 0;
  53. * }
  54. *
  55. * License: BSD-MIT
  56. * Author: Rusty Russell <rusty@rustcorp.com.au>
  57. */
  58. int main(int argc, char *argv[])
  59. {
  60. if (argc != 2)
  61. return 1;
  62. if (strcmp(argv[1], "depends") == 0) {
  63. printf("ccan/container_of\n");
  64. return 0;
  65. }
  66. return 1;
  67. }