include/: refactor header files more

This commit is contained in:
Johan Malm 2020-08-03 20:56:38 +01:00
parent 53266a0d5a
commit 4d1363dcae
32 changed files with 130 additions and 78 deletions

View file

@ -1,11 +1,11 @@
/*
* Very simple C buffer implementation
* Very simple C string buffer implementation
*
* Copyright Johan Malm 2020
*/
#ifndef BUF_H
#define BUF_H
#ifndef __LABWC_BUF_H
#define __LABWC_BUF_H
#include <stdio.h>
#include <stdlib.h>
@ -17,7 +17,18 @@ struct buf {
int len;
};
/*
* buf_init - allocate NULL-terminated C string buffer
* @s - buffer
* Note: use free(s->buf) to free it.
*/
void buf_init(struct buf *s);
/*
* buf_add - add data to C string buffer
* @s - buffer
* @data - data to be added
*/
void buf_add(struct buf *s, const char *data);
#endif /* BUF_H */
#endif /* __LABWC_BUF_H */

View file

@ -1,6 +1,10 @@
#ifndef __LABWC_BUG_ON_H
#define __LABWC_BUG_ON_H
/*
* BUG_ON - assert() without abort()
* @condition - expression to be evaluated
*/
#define BUG_ON(condition) \
do { \
if ((condition) != 0) { \
@ -9,5 +13,4 @@
} \
} while (0)
#endif /* __LABWC_BUT_ON_H */
#endif /* __LABWC_BUG_ON_H */

10
include/common/spawn.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef __LABWC_SPAWN_H
#define __LABWC_SPAWN_H
/**
* spawn_async_no_shell - execute asyncronously
* @command: command to be executed
*/
void spawn_async_no_shell(char const *command);
#endif /* __LABWC_SPAWN_H */

View file

@ -1,6 +1,6 @@
#ifndef CONFIG_DIR_H
#define CONFIG_DIR_H
#ifndef __LABWC_CONFIG_DIR_H
#define __LABWC_CONFIG_DIR_H
char *config_dir(void);
#endif /* CONFIG_DIR_H */
#endif /* __LABWC_CONFIG_DIR_H */

18
include/config/keybind.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef __LABWC_KEYBIND_H
#define __LABWC_KEYBIND_H
#include <wlr/types/wlr_keyboard.h>
#include <xkbcommon/xkbcommon.h>
struct keybind {
uint32_t modifiers;
xkb_keysym_t *keysyms;
size_t keysyms_len;
char *action;
char *command;
struct wl_list link;
};
struct keybind *keybind_add(const char *keybind);
#endif /* __LABWC_KEYBIND_H */

View file

@ -1,25 +1,12 @@
#ifndef RCXML_H
#define RCXML_H
#ifndef __LABWC_RCXML_H
#define __LABWC_RCXML_H
#include <stdio.h>
#include <stdbool.h>
#include <wlr/types/wlr_keyboard.h>
#include <wayland-server-core.h>
#include <xkbcommon/xkbcommon.h>
#include "common/buf.h"
struct keybind {
uint32_t modifiers;
xkb_keysym_t *keysyms;
size_t keysyms_len;
char *action;
char *command;
struct wl_list link;
};
struct keybind *keybind_add(const char *keybind);
struct rcxml {
bool client_side_decorations;
char *theme_name;
@ -34,4 +21,4 @@ void rcxml_parse_xml(struct buf *b);
void rcxml_read(const char *filename);
void rcxml_get_nodenames(struct buf *b);
#endif /* RCXML_H */
#endif /* __LABWC_RCXML_H */

View file

@ -1,5 +1,5 @@
#ifndef LABWC_H
#define LABWC_H
#ifndef __LABWC_H
#define __LABWC_H
#define _POSIX_C_SOURCE 200809L
#include <getopt.h>
@ -29,7 +29,8 @@
#include <wlr/xwayland.h>
#include <xkbcommon/xkbcommon.h>
#include "rcxml.h"
#include "config/rcxml.h"
#include "config/keybind.h"
#define XCURSOR_DEFAULT "left_ptr"
#define XCURSOR_SIZE 24
@ -185,4 +186,4 @@ void dbg_show_one_view(struct view *view);
void dbg_show_views(struct server *server);
void dbg_show_keybinds();
#endif /* LABWC_H */
#endif /* __LABWC_H */

View file

@ -1,6 +0,0 @@
#ifndef SPAWN_H
#define SPAWN_H
void spawn_async_no_shell(char const *command);
#endif /* SPAWN_H */

View file

@ -1,6 +1,6 @@
#ifndef THEME_DIR_H
#define THEME_DIR_H
#ifndef __LABWC_THEME_DIR_H
#define __LABWC_THEME_DIR_H
char *theme_dir(const char *theme_name);
#endif /* THEME_DIR_H */
#endif /* __LABWC_THEME_DIR_H */

View file

@ -4,8 +4,8 @@
* Copyright Johan Malm 2020
*/
#ifndef THEME_H
#define THEME_H
#ifndef __LABWC_THEME_H
#define __LABWC_THEME_H
#include <stdio.h>
#include <wlr/render/wlr_renderer.h>
@ -23,4 +23,4 @@ extern struct theme theme;
void theme_read(const char *theme_name);
#endif /* THEME_H */
#endif /* __LABWC_THEME_H */

View file

@ -4,8 +4,8 @@
* Copyright Johan Malm 2020
*/
#ifndef PARSE_H
#define PARSE_H
#ifndef __LABWC_PARSE_H
#define __LABWC_PARSE_H
#include <stdint.h>
#include "theme/xbm/tokenize.h"
@ -24,4 +24,4 @@ struct pixmap xbm_create_pixmap(struct token *tokens);
struct pixmap xbm_create_pixmap_builtin(const char *button);
#endif /* PARSE_H */
#endif /* __LABWC_PARSE_H */

View file

@ -4,8 +4,8 @@
* Copyright Johan Malm 2020
*/
#ifndef TOKENIZE_H
#define TOKENIZE_H
#ifndef __LABWC_TOKENIZE_H
#define __LABWC_TOKENIZE_H
enum token_type {
TOKEN_NONE = 0,
@ -37,4 +37,4 @@ struct token *xbm_tokenize(char *buffer);
*/
char *xbm_read_file(const char *filename);
#endif /* TOKENIZE_H */
#endif /* __LABWC_TOKENIZE_H */

View file

@ -1,9 +1,8 @@
#ifndef XBM_H
#define XBM_H
#ifndef __LABWC_XBM_H
#define __LABWC_XBM_H
#include <wlr/render/wlr_renderer.h>
#include "theme.h"
#include "theme/xbm/parse.h"
/**
@ -11,4 +10,4 @@
*/
void xbm_load(struct wlr_renderer *renderer);
#endif /* XBM_H */
#endif /* __LABWC_XBM_H */