blob: 4d7c6a40e518ca463a7a36afd9cb7eedbf676356 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "config.h"
#include <stdio.h>
#include <string.h>
/**
* lqueue - Simple, singly-linked-list queue implementation
*
* This code provides a simple implementation of the Queue abstract
* data type in terms of a singly linked (circular) list.
*
* License: BSD-MIT
* Author: David Gibson <david@gibson.dropbear.id.au>
*
* Example:
* #include <ccan/lqueue/lqueue.h>
*
* struct arg {
* const char *arg;
* struct lqueue_link ql;
* };
*
* int main(int argc, char *argv[])
* {
* int i;
* struct arg *a;
* LQUEUE(argq);
*
* for (i = 0; i < argc; i++) {
* a = malloc(sizeof(*a));
* a->arg = argv[i];
* lqueue_enqueue(&argq, a, ql);
* }
*
* printf("Command line arguments in order:\n");
*
* while (!lqueue_empty(&argq)) {
* a = lqueue_dequeue(&argq, struct arg, ql);
* printf("Argument: %s\n", a->arg);
* free(a);
* }
*
* return 0;
* }
*/
int main(int argc, char *argv[])
{
/* Expect exactly one argument */
if (argc != 2)
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/container_of\n");
return 0;
}
return 1;
}
|