~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/skiboot/ccan/list/_info

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
#include "config.h"
 
4
 
 
5
/**
 
6
 * list - double linked list routines
 
7
 *
 
8
 * The list header contains routines for manipulating double linked lists.
 
9
 * It defines two types: struct list_head used for anchoring lists, and
 
10
 * struct list_node which is usually embedded in the structure which is placed
 
11
 * in the list.
 
12
 *
 
13
 * Example:
 
14
 *      #include <err.h>
 
15
 *      #include <stdio.h>
 
16
 *      #include <stdlib.h>
 
17
 *      #include <ccan/list/list.h>
 
18
 *
 
19
 *      struct parent {
 
20
 *              const char *name;
 
21
 *              struct list_head children;
 
22
 *              unsigned int num_children;
 
23
 *      };
 
24
 *
 
25
 *      struct child {
 
26
 *              const char *name;
 
27
 *              struct list_node list;
 
28
 *      };
 
29
 *
 
30
 *      int main(int argc, char *argv[])
 
31
 *      {
 
32
 *              struct parent p;
 
33
 *              struct child *c;
 
34
 *              unsigned int i;
 
35
 *
 
36
 *              if (argc < 2)
 
37
 *                      errx(1, "Usage: %s parent children...", argv[0]);
 
38
 *
 
39
 *              p.name = argv[1];
 
40
 *              list_head_init(&p.children);
 
41
 *              p.num_children = 0;
 
42
 *              for (i = 2; i < argc; i++) {
 
43
 *                      c = malloc(sizeof(*c));
 
44
 *                      c->name = argv[i];
 
45
 *                      list_add(&p.children, &c->list);
 
46
 *                      p.num_children++;
 
47
 *              }
 
48
 *
 
49
 *              printf("%s has %u children:", p.name, p.num_children);
 
50
 *              list_for_each(&p.children, c, list)
 
51
 *                      printf("%s ", c->name);
 
52
 *              printf("\n");
 
53
 *              return 0;
 
54
 *      }
 
55
 *
 
56
 * License: BSD-MIT
 
57
 * Author: Rusty Russell <rusty@rustcorp.com.au>
 
58
 */
 
59
int main(int argc, char *argv[])
 
60
{
 
61
        if (argc != 2)
 
62
                return 1;
 
63
 
 
64
        if (strcmp(argv[1], "depends") == 0) {
 
65
                printf("ccan/container_of\n");
 
66
                return 0;
 
67
        }
 
68
 
 
69
        return 1;
 
70
}