aboutsummaryrefslogtreecommitdiffstats
path: root/src/list.h
blob: 33f4093898df22db800c692e46c14f17cf631e4b (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
/* 
 *  Matchbox Window Manager - A lightweight window manager not for the
 *                            desktop.
 *
 *  Authored By Matthew Allum <mallum@o-hand.com>
 *
 *  Copyright (c) 2002, 2004 OpenedHand Ltd - http://o-hand.com
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *
 */

#ifndef _MBLIST_H_
#define _MBLIST_H_

#include "structs.h"



struct list_item
{
  char* name;
  int   id;
  void* data;
  struct list_item* next;
};

#define list_enumerate(l,i) for((i)=(l);(i);(i)=(i)->next)

#define list_get_tail(l) while ((l)->next != NULL) (l)=(l)->next; 

struct list_item* list_new(int id, char *name, void *data);

void* list_add(struct list_item** head, char *name, int id, void *data);

void* list_find_by_id(struct list_item* head, int needed_id);

void* list_find_by_name(struct list_item* head, char *name);

void list_remove(struct list_item** head, void *data);

void list_destroy(struct list_item** head);

#endif