_info 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <string.h>
  2. #include "config.h"
  3. /**
  4. * tal/path - routines to manipulate paths
  5. *
  6. * This code helps manage paths.
  7. *
  8. * License: BSD-MIT
  9. * Author: Rusty Russell <rusty@rustcorp.com.au>
  10. *
  11. * Example:
  12. * // Program to print out full path names, recursively.
  13. * #include <ccan/tal/path/path.h>
  14. * #include <sys/types.h>
  15. * #include <dirent.h>
  16. * #include <stdio.h>
  17. * #include <ccan/err/err.h>
  18. *
  19. * static void dump(const char *dir)
  20. * {
  21. * struct dirent *di;
  22. * DIR *d = opendir(dir);
  23. * if (!d) {
  24. * warn("Failed to open %s", dir);
  25. * return;
  26. * }
  27. * printf("%s\n", dir);
  28. * while ((di = readdir(d)) != NULL) {
  29. * char *path;
  30. * if (streq(di->d_name, ".") || streq(di->d_name, ".."))
  31. * continue;
  32. * path = path_join(NULL, dir, di->d_name);
  33. * if (path_is_dir(path))
  34. * dump(path);
  35. * tal_free(path);
  36. * }
  37. * closedir(d);
  38. * }
  39. *
  40. * int main(void)
  41. * {
  42. * dump(path_cwd(NULL));
  43. * return 0;
  44. * }
  45. */
  46. int main(int argc, char *argv[])
  47. {
  48. /* Expect exactly one argument */
  49. if (argc != 2)
  50. return 1;
  51. if (strcmp(argv[1], "depends") == 0) {
  52. printf("ccan/str\n");
  53. printf("ccan/take\n");
  54. printf("ccan/tal\n");
  55. printf("ccan/tal/str\n");
  56. return 0;
  57. }
  58. return 1;
  59. }