From 3eea7a245a7ed49127a222628543f9509a6ff2b6 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Thu, 16 Dec 2021 17:11:12 +0100 Subject: Switched most buffers to wide chars, added general ref class, now clear mpd errors, added track and command completion --- list.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 list.h (limited to 'list.h') diff --git a/list.h b/list.h new file mode 100644 index 0000000..738c6ce --- /dev/null +++ b/list.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +#define OFFSET(type, attr) ((size_t) &((type *)0)->attr) +#define UPCAST(ptr, type) ({ \ + const typeof( ((type *)0)->link ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - OFFSET(type, link) ); }) + +#define LIST_HEAD ((struct link) { .prev = NULL, .next = NULL }) +#define LINK_EMPTY ((struct link) { 0 }) + +#define LINK(p) (&(p)->link) + +struct link { + struct link *prev; + struct link *next; +}; + +/* list_XXX functions operate on the list head */ + +int list_len(struct link *head); +int list_ffind(struct link *head, struct link *link); + +struct link *link_back(struct link *list); +void link_prepend(struct link *list, struct link *link); +void link_append(struct link *list, struct link *link); +struct link *link_pop(struct link *link); + +struct link *link_iter(struct link *link, int n); + +void list_push_back(struct link *list, struct link *link); + -- cgit v1.2.3-71-gd317