_info 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * tlist - typesafe double linked list routines
  6. *
  7. * The list header contains routines for manipulating double linked lists;
  8. * this extends it so you can create list head types which only accomodate
  9. * a specific entry type.
  10. *
  11. * Example:
  12. * #include <err.h>
  13. * #include <stdio.h>
  14. * #include <stdlib.h>
  15. * #include <ccan/tlist/tlist.h>
  16. *
  17. * // We could use TLIST_TYPE(children, struct child) to define this.
  18. * struct tlist_children {
  19. * struct list_head raw;
  20. * TCON(struct child *canary);
  21. * };
  22. * struct parent {
  23. * const char *name;
  24. * struct tlist_children children;
  25. * unsigned int num_children;
  26. * };
  27. *
  28. * struct child {
  29. * const char *name;
  30. * struct list_node list;
  31. * };
  32. *
  33. * int main(int argc, char *argv[])
  34. * {
  35. * struct parent p;
  36. * struct child *c;
  37. * unsigned int i;
  38. *
  39. * if (argc < 2)
  40. * errx(1, "Usage: %s parent children...", argv[0]);
  41. *
  42. * p.name = argv[1];
  43. * tlist_init(&p.children);
  44. * for (i = 2; i < argc; i++) {
  45. * c = malloc(sizeof(*c));
  46. * c->name = argv[i];
  47. * tlist_add(&p.children, c, list);
  48. * p.num_children++;
  49. * }
  50. *
  51. * printf("%s has %u children:", p.name, p.num_children);
  52. * tlist_for_each(&p.children, c, list)
  53. * printf("%s ", c->name);
  54. * printf("\n");
  55. * return 0;
  56. * }
  57. *
  58. * License: LGPL
  59. * Author: Rusty Russell <rusty@rustcorp.com.au>
  60. */
  61. int main(int argc, char *argv[])
  62. {
  63. if (argc != 2)
  64. return 1;
  65. if (strcmp(argv[1], "depends") == 0) {
  66. printf("ccan/list\n");
  67. printf("ccan/tcon\n");
  68. return 0;
  69. }
  70. return 1;
  71. }