forked from external/yambar
tllist: use tllist from external git repository
This commit is contained in:
parent
736e07b15e
commit
0550d2799d
14 changed files with 22 additions and 171 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -2,3 +2,6 @@
|
||||||
path = external/wlr-protocols
|
path = external/wlr-protocols
|
||||||
url = https://github.com/swaywm/wlr-protocols.git
|
url = https://github.com/swaywm/wlr-protocols.git
|
||||||
branch = master
|
branch = master
|
||||||
|
[submodule "subprojects/tllist"]
|
||||||
|
path = subprojects/tllist
|
||||||
|
url = https://gitlab.com/dnkl/tllist.git
|
||||||
|
|
|
@ -36,7 +36,7 @@ if backend_wayland
|
||||||
|
|
||||||
bar_wayland = declare_dependency(
|
bar_wayland = declare_dependency(
|
||||||
sources: ['wayland.c', 'wayland.h'] + wl_proto_src + wl_proto_headers,
|
sources: ['wayland.c', 'wayland.h'] + wl_proto_src + wl_proto_headers,
|
||||||
dependencies: [wayland_client, wayland_cursor])
|
dependencies: [wayland_client, wayland_cursor, tllist])
|
||||||
|
|
||||||
bar_backends += [bar_wayland]
|
bar_backends += [bar_wayland]
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
|
|
||||||
|
#include <tllist.h>
|
||||||
#include <xdg-output-unstable-v1.h>
|
#include <xdg-output-unstable-v1.h>
|
||||||
#include <wlr-layer-shell-unstable-v1.h>
|
#include <wlr-layer-shell-unstable-v1.h>
|
||||||
|
|
||||||
#define LOG_MODULE "bar:wayland"
|
#define LOG_MODULE "bar:wayland"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include "../tllist.h"
|
|
||||||
#include "../stride.h"
|
#include "../stride.h"
|
||||||
|
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <tllist.h>
|
||||||
|
|
||||||
#define LOG_MODULE "config:verify"
|
#define LOG_MODULE "config:verify"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "tllist.h"
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
conf_err_prefix(const keychain_t *chain, const struct yml_node *node)
|
conf_err_prefix(const keychain_t *chain, const struct yml_node *node)
|
||||||
|
|
|
@ -57,6 +57,8 @@ if backend_x11
|
||||||
install_headers('xcb.h', subdir: 'yambar')
|
install_headers('xcb.h', subdir: 'yambar')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
tllist = subproject('tllist').get_variable('tllist')
|
||||||
|
|
||||||
subdir('completions')
|
subdir('completions')
|
||||||
subdir('doc')
|
subdir('doc')
|
||||||
subdir('bar')
|
subdir('bar')
|
||||||
|
@ -84,10 +86,9 @@ yambar = executable(
|
||||||
'particle.c', 'particle.h',
|
'particle.c', 'particle.h',
|
||||||
'plugin.c', 'plugin.h',
|
'plugin.c', 'plugin.h',
|
||||||
'tag.c', 'tag.h',
|
'tag.c', 'tag.h',
|
||||||
'tllist.h',
|
|
||||||
'yml.c', 'yml.h',
|
'yml.c', 'yml.h',
|
||||||
version,
|
version,
|
||||||
dependencies: [bar, freetype, fontconfig, pixman, yaml, threads, dl] +
|
dependencies: [bar, freetype, fontconfig, pixman, yaml, threads, dl, tllist] +
|
||||||
decorations + particles + modules,
|
decorations + particles + modules,
|
||||||
build_rpath: '$ORIGIN/modules:$ORIGIN/decorations:$ORIGIN/particles',
|
build_rpath: '$ORIGIN/modules:$ORIGIN/decorations:$ORIGIN/particles',
|
||||||
export_dynamic: true,
|
export_dynamic: true,
|
||||||
|
@ -109,7 +110,6 @@ install_headers(
|
||||||
'particle.h',
|
'particle.h',
|
||||||
'stride.h',
|
'stride.h',
|
||||||
'tag.h',
|
'tag.h',
|
||||||
'tllist.h',
|
|
||||||
'yml.h',
|
'yml.h',
|
||||||
subdir: 'yambar')
|
subdir: 'yambar')
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
|
#include <tllist.h>
|
||||||
|
|
||||||
#define LOG_MODULE "alsa"
|
#define LOG_MODULE "alsa"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
@ -10,7 +12,6 @@
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
#include "../tllist.h"
|
|
||||||
|
|
||||||
struct private {
|
struct private {
|
||||||
char *card;
|
char *card;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module_sdk = declare_dependency(dependencies: [freetype, pixman, threads])
|
module_sdk = declare_dependency(dependencies: [freetype, pixman, threads, tllist])
|
||||||
|
|
||||||
modules = []
|
modules = []
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
|
|
||||||
|
#include <tllist.h>
|
||||||
|
|
||||||
#define LOG_MODULE "network"
|
#define LOG_MODULE "network"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
@ -21,7 +23,6 @@
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../module.h"
|
#include "../module.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
#include "../tllist.h"
|
|
||||||
|
|
||||||
struct af_addr {
|
struct af_addr {
|
||||||
int family;
|
int family;
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
|
|
||||||
|
#include <tllist.h>
|
||||||
|
|
||||||
#define LOG_MODULE "removables"
|
#define LOG_MODULE "removables"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
@ -20,7 +22,6 @@
|
||||||
#include "../config-verify.h"
|
#include "../config-verify.h"
|
||||||
#include "../particles/dynlist.h"
|
#include "../particles/dynlist.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
#include "../tllist.h"
|
|
||||||
|
|
||||||
typedef tll(char *) mount_point_list_t;
|
typedef tll(char *) mount_point_list_t;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
particle_sdk = declare_dependency(dependencies: [freetype, fontconfig, pixman])
|
particle_sdk = declare_dependency(dependencies: [freetype, fontconfig, pixman, tllist])
|
||||||
|
|
||||||
particles = []
|
particles = []
|
||||||
foreach particle : ['empty', 'list', 'map', 'progress-bar', 'ramp', 'string']
|
foreach particle : ['empty', 'list', 'map', 'progress-bar', 'ramp', 'string']
|
||||||
|
|
3
plugin.c
3
plugin.c
|
@ -3,11 +3,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include <tllist.h>
|
||||||
|
|
||||||
#define LOG_MODULE "plugin"
|
#define LOG_MODULE "plugin"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "tllist.h"
|
|
||||||
|
|
||||||
#if !defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
|
#if !defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
|
||||||
|
|
||||||
|
|
1
subprojects/tllist
Submodule
1
subprojects/tllist
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 20928f2952b88d915da3b77217cdde69f6ab4ae4
|
157
tllist.h
157
tllist.h
|
@ -1,157 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#define TLL_PASTE2( a, b) a##b
|
|
||||||
#define TLL_PASTE( a, b) TLL_PASTE2( a, b)
|
|
||||||
|
|
||||||
/* Utility macro to generate a list element struct with a unique struct tag */
|
|
||||||
#define TLL_UNIQUE_INNER_STRUCT(TYPE, ID) \
|
|
||||||
struct TLL_PASTE(__tllist_ , ID) { \
|
|
||||||
TYPE item; \
|
|
||||||
struct TLL_PASTE(__tllist_, ID) *prev; \
|
|
||||||
struct TLL_PASTE(__tllist_, ID) *next; \
|
|
||||||
} *head, *tail;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defines a new typed-list type, or directly instantiate a typed-list variable
|
|
||||||
*
|
|
||||||
* Example a, declare a variable (list of integers):
|
|
||||||
* tll(int) my_list;
|
|
||||||
*
|
|
||||||
* Example b, declare a type, and then use the type:
|
|
||||||
* tll(int, my_list_type);
|
|
||||||
* struct my_list_type my_list;
|
|
||||||
*/
|
|
||||||
#define tll(TYPE, ...) \
|
|
||||||
struct __VA_ARGS__ { \
|
|
||||||
TLL_UNIQUE_INNER_STRUCT(TYPE, __COUNTER__) \
|
|
||||||
size_t length; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initializer: tll(int) my_list = tll_init(); */
|
|
||||||
#define tll_init() {.head = NULL, .tail = NULL, .length = 0}
|
|
||||||
|
|
||||||
/* Length/size of list: printf("size: %zu\n", tll_length(my_list)); */
|
|
||||||
#define tll_length(list) (list).length
|
|
||||||
|
|
||||||
/* Adds a new item to the back of the list */
|
|
||||||
#define tll_push_back(list, new_item) \
|
|
||||||
do { \
|
|
||||||
__typeof__((list).head) __e = malloc(sizeof(*__e)); \
|
|
||||||
__e->item = (new_item); \
|
|
||||||
__e->prev = (list).tail; \
|
|
||||||
__e->next = NULL; \
|
|
||||||
if ((list).head == NULL) \
|
|
||||||
(list).head = (list).tail = __e; \
|
|
||||||
else { \
|
|
||||||
(list).tail->next = __e; \
|
|
||||||
(list).tail = __e; \
|
|
||||||
} \
|
|
||||||
(list).length++; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* Adds a new item to the front of the list */
|
|
||||||
#define tll_push_front(list, new_item) \
|
|
||||||
do { \
|
|
||||||
__typeof__((list).head) __e = malloc(sizeof(*__e)); \
|
|
||||||
__e->item = (new_item); \
|
|
||||||
__e->prev = NULL; \
|
|
||||||
__e->next = (list).head; \
|
|
||||||
if ((list).head == NULL) \
|
|
||||||
(list).head = (list).tail = __e; \
|
|
||||||
else { \
|
|
||||||
(list).head->prev = __e; \
|
|
||||||
(list).head = __e; \
|
|
||||||
} \
|
|
||||||
(list).length++; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Iterates the list. <it> is an iterator pointer. You can access the
|
|
||||||
* list item with ->item:
|
|
||||||
*
|
|
||||||
* tll(int) my_list = vinit();
|
|
||||||
* tll_push_back(my_list, 5);
|
|
||||||
*
|
|
||||||
* tll_foreach(my_list i) {
|
|
||||||
* printf("%d\n", i->item);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
#define tll_foreach(list, it) \
|
|
||||||
for (__typeof__(*(list).head) *it = (list).head, \
|
|
||||||
*it_next = it != NULL ? it->next : NULL; \
|
|
||||||
it != NULL; \
|
|
||||||
it = it_next, \
|
|
||||||
it_next = it_next != NULL ? it_next->next : NULL)
|
|
||||||
|
|
||||||
/* Same as tll_foreach(), but iterates backwards */
|
|
||||||
#define tll_rforeach(list, it) \
|
|
||||||
for (__typeof__(*(list).tail) *it = (list).tail, \
|
|
||||||
*it_prev = it != NULL ? it->prev : NULL; \
|
|
||||||
it != NULL; \
|
|
||||||
it = it_prev, \
|
|
||||||
it_prev = it_prev != NULL ? it_prev->prev : NULL)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Removes an entry from the list. <it> is an iterator. I.e. you can
|
|
||||||
* only call this from inside a tll_foreach() or tll_rforeach() loop.
|
|
||||||
*/
|
|
||||||
#define tll_remove(list, it) \
|
|
||||||
do { \
|
|
||||||
assert((list).length > 0); \
|
|
||||||
__typeof__((list).head) __prev = it->prev; \
|
|
||||||
__typeof__((list).head) __next = it->next; \
|
|
||||||
if (__prev != NULL) \
|
|
||||||
__prev->next = __next; \
|
|
||||||
else \
|
|
||||||
(list).head = __next; \
|
|
||||||
if (__next != NULL) \
|
|
||||||
__next->prev = __prev; \
|
|
||||||
else \
|
|
||||||
(list).tail = __prev; \
|
|
||||||
free(it); \
|
|
||||||
(list).length--; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* Same as tll_remove(), but calls free_callback(it->item) */
|
|
||||||
#define tll_remove_and_free(list, it, free_callback) \
|
|
||||||
do { \
|
|
||||||
free_callback((it)->item); \
|
|
||||||
tll_remove((list), (it)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define tll_front(list) (list).head->item
|
|
||||||
#define tll_back(list) (list).tail->item
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Removes the first element from the list, and returns it (note:
|
|
||||||
* returns the *actual* item, not an iterator.
|
|
||||||
*/
|
|
||||||
#define tll_pop_front(list) \
|
|
||||||
({__typeof__((list).head) it = (list).head; \
|
|
||||||
__typeof__((list).head->item) __ret = it->item; \
|
|
||||||
tll_remove((list), it); \
|
|
||||||
__ret; \
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Same as tll_pop_front(), but returns/removes the *last* element */
|
|
||||||
#define tll_pop_back(list) \
|
|
||||||
({__typeof__((list).tail) it = (list).tail; \
|
|
||||||
__typeof__((list).tail->item) __ret = it->item; \
|
|
||||||
tll_remove((list), it); \
|
|
||||||
__ret; \
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Frees the list. This call is *not* needed if the list is already empty. */
|
|
||||||
#define tll_free(list) \
|
|
||||||
tll_foreach(list, __it) \
|
|
||||||
tll_remove(list, __it)
|
|
||||||
|
|
||||||
/* Same as tll_free(), but also calls free_callback(item) for every item */
|
|
||||||
#define tll_free_and_free(list, free_callback) \
|
|
||||||
tll_foreach(list, __it) \
|
|
||||||
tll_remove_and_free(list, __it, free_callback)
|
|
3
yml.c
3
yml.c
|
@ -7,8 +7,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <yaml.h>
|
#include <yaml.h>
|
||||||
|
#include <tllist.h>
|
||||||
#include "tllist.h"
|
|
||||||
|
|
||||||
enum yml_error {
|
enum yml_error {
|
||||||
YML_ERR_NONE,
|
YML_ERR_NONE,
|
||||||
|
|
Loading…
Add table
Reference in a new issue