]> git.ozlabs.org Git - ccan/blob - ccan/lstack/_info
crypto/shachain/tools: update to new rbuf API.
[ccan] / ccan / lstack / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * lstack - Simple, singly-linked-list stack implementation
7  *
8  * This code provides a simple implementation of the Stack abstract
9  * data type in terms of a singly linked list.
10  *
11  * License: BSD-MIT
12  * Author: David Gibson <david@gibson.dropbear.id.au>
13  *
14  * Example:
15  *      #include <ccan/lstack/lstack.h>
16  *
17  *      struct arg {
18  *              const char *arg;
19  *              struct lstack_link sl;
20  *      };
21  *
22  *      int main(int argc, char *argv[])
23  *      {
24  *              int i;
25  *              struct arg *a;
26  *              LSTACK(struct arg, sl) argstack;
27  *
28  *              for (i = 0; i < argc; i++) {
29  *                      a = malloc(sizeof(*a));
30  *                      a->arg = argv[i];
31  *                      lstack_push(&argstack, a);
32  *              }
33  *
34  *              printf("Command line arguments in reverse:\n");
35  *
36  *              while (!lstack_empty(&argstack)) {
37  *                      a = lstack_pop(&argstack);
38  *                      printf("Argument: %s\n", a->arg);
39  *                      free(a);
40  *              }
41  *
42  *              return 0;
43  *      }
44  */
45 int main(int argc, char *argv[])
46 {
47         /* Expect exactly one argument */
48         if (argc != 2)
49                 return 1;
50
51         if (strcmp(argv[1], "depends") == 0) {
52                 printf("ccan/tcon\n");
53                 return 0;
54         }
55
56         return 1;
57 }