]> git.ozlabs.org Git - ccan/blob - ccan/lqueue/_info
lqueue: Linked list queue implementation
[ccan] / ccan / lqueue / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * lqueue - Simple, singly-linked-list queue implementation
7  *
8  * This code provides a simple implementation of the Queue abstract
9  * data type in terms of a singly linked (circular) list.
10  *
11  * License: BSD-MIT
12  * Author: David Gibson <david@gibson.dropbear.id.au>
13  *
14  * Example:
15  *      #include <ccan/lqueue/lqueue.h>
16  *
17  *      struct arg {
18  *              const char *arg;
19  *              struct lqueue_link ql;
20  *      };
21  *
22  *      int main(int argc, char *argv[])
23  *      {
24  *              int i;
25  *              struct arg *a;
26  *              LQUEUE(argq);
27  *
28  *              for (i = 0; i < argc; i++) {
29  *                      a = malloc(sizeof(*a));
30  *                      a->arg = argv[i];
31  *                      lqueue_enqueue(&argq, a, ql);
32  *              }
33  *
34  *              printf("Command line arguments in order:\n");
35  *
36  *              while (!lqueue_empty(&argq)) {
37  *                      a = lqueue_dequeue(&argq, struct arg, ql);
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/container_of\n");
53                 return 0;
54         }
55
56         return 1;
57 }