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