mirror of
https://github.com/javalsai/lidm.git
synced 2025-08-30 18:08:00 +02:00
lint: fix code for clang-tidy
This commit is contained in:
128
include/config.h
128
include/config.h
@@ -14,7 +14,7 @@ enum introspection_type {
|
||||
KEY,
|
||||
STRING_ARRAY,
|
||||
};
|
||||
static const char* NNULLABLE const intros_tys_names[] = {
|
||||
static const char* NNULLABLE const INTROS_TYS_NAMES[] = {
|
||||
[STRING] = "STRING",
|
||||
[BOOL] = "BOOL",
|
||||
[KEY] = "KEY",
|
||||
@@ -43,70 +43,70 @@ struct introspection_item {
|
||||
struct table_##table { \
|
||||
TABLE(STRUCT_BUILDER, table) \
|
||||
}
|
||||
#define BUILD_DEFAULT(table, TABLE) \
|
||||
static const struct table_##table default_table_##table = { \
|
||||
#define BUILD_DEFAULT(utable, table, TABLE) \
|
||||
static const struct table_##table DEFAULT_TABLE_##utable = { \
|
||||
TABLE(DEFAULT_BUILDER, table)}
|
||||
#define BUILD_INTROS(table, TABLE) \
|
||||
static const struct introspection_item intros_table_##table[] = { \
|
||||
#define BUILD_INTROS(utable, table, TABLE) \
|
||||
static const struct introspection_item INTROS_TABLE_##utable[] = { \
|
||||
TABLE(INTROS_BUILDER, table)}
|
||||
|
||||
#define BUILD(table, TABLE) \
|
||||
BUILD_TABLE(table, TABLE); \
|
||||
BUILD_DEFAULT(table, TABLE); \
|
||||
BUILD_INTROS(table, TABLE);
|
||||
#define BUILD(table, utable, TABLE) \
|
||||
BUILD_TABLE(table, TABLE); \
|
||||
BUILD_DEFAULT(utable, table, TABLE); \
|
||||
BUILD_INTROS(utable, table, TABLE);
|
||||
|
||||
// should be ansi escape codes under \x1b[...m
|
||||
// if not prepared accordingly, it might break
|
||||
#define TABLE_COLORS(F, name) \
|
||||
F(char*, bg, STRING, "48;2;38;28;28", name) \
|
||||
F(char*, fg, STRING, "22;24;38;2;245;245;245", name) \
|
||||
F(char*, err, STRING, "1;31", name) \
|
||||
F(char*, s_wayland, STRING, "38;2;255;174;66", name) \
|
||||
F(char*, s_xorg, STRING, "38;2;37;175;255", name) \
|
||||
F(char*, s_shell, STRING, "38;2;34;140;34", name) \
|
||||
F(char*, e_hostname, STRING, "38;2;255;64;64", name) \
|
||||
F(char*, e_date, STRING, "38;2;144;144;144", name) \
|
||||
F(char*, e_box, STRING, "38;2;122;122;122", name) \
|
||||
F(char*, e_header, STRING, "4;38;2;0;255;0", name) \
|
||||
F(char*, e_user, STRING, "36", name) \
|
||||
F(char*, e_passwd, STRING, "4;38;2;245;245;205", name) \
|
||||
F(char*, e_badpasswd, STRING, "3;4;31", name) \
|
||||
F(char*, e_key, STRING, "38;2;255;174;66", name)
|
||||
#define TABLE_COLORS(F, name) \
|
||||
F(char* NNULLABLE, bg, STRING, "48;2;38;28;28", name) \
|
||||
F(char* NNULLABLE, fg, STRING, "22;24;38;2;245;245;245", name) \
|
||||
F(char* NNULLABLE, err, STRING, "1;31", name) \
|
||||
F(char* NNULLABLE, s_wayland, STRING, "38;2;255;174;66", name) \
|
||||
F(char* NNULLABLE, s_xorg, STRING, "38;2;37;175;255", name) \
|
||||
F(char* NNULLABLE, s_shell, STRING, "38;2;34;140;34", name) \
|
||||
F(char* NNULLABLE, e_hostname, STRING, "38;2;255;64;64", name) \
|
||||
F(char* NNULLABLE, e_date, STRING, "38;2;144;144;144", name) \
|
||||
F(char* NNULLABLE, e_box, STRING, "38;2;122;122;122", name) \
|
||||
F(char* NNULLABLE, e_header, STRING, "4;38;2;0;255;0", name) \
|
||||
F(char* NNULLABLE, e_user, STRING, "36", name) \
|
||||
F(char* NNULLABLE, e_passwd, STRING, "4;38;2;245;245;205", name) \
|
||||
F(char* NNULLABLE, e_badpasswd, STRING, "3;4;31", name) \
|
||||
F(char* NNULLABLE, e_key, STRING, "38;2;255;174;66", name)
|
||||
|
||||
BUILD(colors, TABLE_COLORS);
|
||||
BUILD(colors, COLORS, TABLE_COLORS);
|
||||
|
||||
// even if they're multiple bytes long
|
||||
// they should only take up 1 char size on display
|
||||
#define TABLE_CHARS(F, name) \
|
||||
F(char*, hb, STRING, "─", name) \
|
||||
F(char*, vb, STRING, "│", name) \
|
||||
F(char*, ctl, STRING, "┌", name) \
|
||||
F(char*, ctr, STRING, "┐", name) \
|
||||
F(char*, cbl, STRING, "└", name) \
|
||||
F(char*, cbr, STRING, "┘", name)
|
||||
#define TABLE_CHARS(F, name) \
|
||||
F(char* NNULLABLE, hb, STRING, "─", name) \
|
||||
F(char* NNULLABLE, vb, STRING, "│", name) \
|
||||
F(char* NNULLABLE, ctl, STRING, "┌", name) \
|
||||
F(char* NNULLABLE, ctr, STRING, "┐", name) \
|
||||
F(char* NNULLABLE, cbl, STRING, "└", name) \
|
||||
F(char* NNULLABLE, cbr, STRING, "┘", name)
|
||||
|
||||
BUILD(chars, TABLE_CHARS);
|
||||
BUILD(chars, CHARS, TABLE_CHARS);
|
||||
|
||||
#define TABLE_FUNCTIONS(F, name) \
|
||||
F(enum keys, poweroff, KEY, F1, name) \
|
||||
F(enum keys, reboot, KEY, F2, name) \
|
||||
F(enum keys, refresh, KEY, F5, name)
|
||||
|
||||
BUILD(functions, TABLE_FUNCTIONS);
|
||||
BUILD(functions, FUNCTIONS, TABLE_FUNCTIONS);
|
||||
|
||||
#define TABLE_STRINGS(F, name) \
|
||||
F(char*, f_poweroff, STRING, "poweroff", name) \
|
||||
F(char*, f_reboot, STRING, "reboot", name) \
|
||||
F(char*, f_refresh, STRING, "refresh", name) \
|
||||
F(char*, e_user, STRING, "user", name) \
|
||||
F(char*, e_passwd, STRING, "password", name) \
|
||||
F(char*, s_wayland, STRING, "wayland", name) \
|
||||
F(char*, s_xorg, STRING, "xorg", name) \
|
||||
F(char*, s_shell, STRING, "shell", name) \
|
||||
F(char*, opts_pre, STRING, "< ", name) \
|
||||
F(char*, opts_post, STRING, " >", name)
|
||||
#define TABLE_STRINGS(F, name) \
|
||||
F(char* NNULLABLE, f_poweroff, STRING, "poweroff", name) \
|
||||
F(char* NNULLABLE, f_reboot, STRING, "reboot", name) \
|
||||
F(char* NNULLABLE, f_refresh, STRING, "refresh", name) \
|
||||
F(char* NNULLABLE, e_user, STRING, "user", name) \
|
||||
F(char* NNULLABLE, e_passwd, STRING, "password", name) \
|
||||
F(char* NNULLABLE, s_wayland, STRING, "wayland", name) \
|
||||
F(char* NNULLABLE, s_xorg, STRING, "xorg", name) \
|
||||
F(char* NNULLABLE, s_shell, STRING, "shell", name) \
|
||||
F(char* NNULLABLE, opts_pre, STRING, "< ", name) \
|
||||
F(char* NNULLABLE, opts_post, STRING, " >", name)
|
||||
|
||||
BUILD(strings, TABLE_STRINGS);
|
||||
BUILD(strings, STRINGS, TABLE_STRINGS);
|
||||
|
||||
#define NULL_VEC \
|
||||
(struct Vector) { \
|
||||
@@ -117,7 +117,7 @@ BUILD(strings, TABLE_STRINGS);
|
||||
F(struct Vector, source, STRING_ARRAY, NULL_VEC, name) \
|
||||
F(struct Vector, user_source, STRING_ARRAY, NULL_VEC, name)
|
||||
|
||||
BUILD(behavior, TABLE_BEHAVIOR);
|
||||
BUILD(behavior, BEHAVIOR, TABLE_BEHAVIOR);
|
||||
|
||||
//// CONFIG
|
||||
struct config {
|
||||
@@ -128,12 +128,12 @@ struct config {
|
||||
struct table_behavior behavior;
|
||||
};
|
||||
|
||||
static const struct config default_config = {
|
||||
.colors = default_table_colors,
|
||||
.chars = default_table_chars,
|
||||
.functions = default_table_functions,
|
||||
.strings = default_table_strings,
|
||||
.behavior = default_table_behavior,
|
||||
static const struct config DEFAULT_CONFIG = {
|
||||
.colors = DEFAULT_TABLE_COLORS,
|
||||
.chars = DEFAULT_TABLE_CHARS,
|
||||
.functions = DEFAULT_TABLE_FUNCTIONS,
|
||||
.strings = DEFAULT_TABLE_STRINGS,
|
||||
.behavior = DEFAULT_TABLE_BEHAVIOR,
|
||||
};
|
||||
|
||||
struct introspection_table {
|
||||
@@ -143,17 +143,17 @@ struct introspection_table {
|
||||
size_t len;
|
||||
};
|
||||
|
||||
static const struct introspection_table config_instrospection[] = {
|
||||
{"colors", offsetof(struct config, colors), intros_table_colors,
|
||||
sizeof(intros_table_colors) / sizeof(intros_table_colors[0])},
|
||||
{"chars", offsetof(struct config, chars), intros_table_chars,
|
||||
sizeof(intros_table_chars) / sizeof(intros_table_chars[0])},
|
||||
{"functions", offsetof(struct config, functions), intros_table_functions,
|
||||
sizeof(intros_table_functions) / sizeof(intros_table_functions[0])},
|
||||
{"strings", offsetof(struct config, strings), intros_table_strings,
|
||||
sizeof(intros_table_strings) / sizeof(intros_table_strings[0])},
|
||||
{"behavior", offsetof(struct config, behavior), intros_table_behavior,
|
||||
sizeof(intros_table_behavior) / sizeof(intros_table_behavior[0])},
|
||||
static const struct introspection_table CONFIG_INSTROSPECTION[] = {
|
||||
{"colors", offsetof(struct config, colors), INTROS_TABLE_COLORS,
|
||||
sizeof(INTROS_TABLE_COLORS) / sizeof(INTROS_TABLE_COLORS[0])},
|
||||
{"chars", offsetof(struct config, chars), INTROS_TABLE_CHARS,
|
||||
sizeof(INTROS_TABLE_CHARS) / sizeof(INTROS_TABLE_CHARS[0])},
|
||||
{"functions", offsetof(struct config, functions), INTROS_TABLE_FUNCTIONS,
|
||||
sizeof(INTROS_TABLE_FUNCTIONS) / sizeof(INTROS_TABLE_FUNCTIONS[0])},
|
||||
{"strings", offsetof(struct config, strings), INTROS_TABLE_STRINGS,
|
||||
sizeof(INTROS_TABLE_STRINGS) / sizeof(INTROS_TABLE_STRINGS[0])},
|
||||
{"behavior", offsetof(struct config, behavior), INTROS_TABLE_BEHAVIOR,
|
||||
sizeof(INTROS_TABLE_BEHAVIOR) / sizeof(INTROS_TABLE_BEHAVIOR[0])},
|
||||
};
|
||||
|
||||
//// FUNCTIONS
|
||||
|
@@ -34,7 +34,7 @@ enum keys {
|
||||
PAGE_DOWN,
|
||||
};
|
||||
|
||||
static const char* const key_names[] = {
|
||||
static const char* const KEY_NAMES[] = {
|
||||
[ESC] = "ESC",
|
||||
[F1] = "F1",
|
||||
[F2] = "F2",
|
||||
@@ -70,7 +70,7 @@ struct key_mapping {
|
||||
const char* sequences[3];
|
||||
};
|
||||
|
||||
static const struct key_mapping key_mappings[] = {
|
||||
static const struct key_mapping KEY_MAPPINGS[] = {
|
||||
{ESC, {"\x1b", NULL}},
|
||||
{F1, {"\x1bOP", "\x1b[[A", NULL}},
|
||||
{F2, {"\x1bOQ", "\x1b[[B", NULL}},
|
||||
|
@@ -40,12 +40,12 @@
|
||||
#define VALUE_MAXLEN (BOX_WIDTH - VALUES_COL + 1 - BOX_HMARGIN - 2)
|
||||
|
||||
enum input { SESSION, USER, PASSWD };
|
||||
extern const u_char inputs_n;
|
||||
extern const u_char INPUTS_N;
|
||||
|
||||
void setup(struct config* config);
|
||||
int load(struct Vector* users, struct Vector* sessions);
|
||||
void print_err(const char*);
|
||||
void print_errno(const char*);
|
||||
void print_err(const char* /*msg*/);
|
||||
void print_errno(const char* /*descr*/);
|
||||
|
||||
void ui_update_field(enum input focused_input);
|
||||
void ui_update_ffield();
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "macros.h"
|
||||
#include "ui.h"
|
||||
|
||||
extern enum input focused_input;
|
||||
@@ -11,8 +12,8 @@ extern struct opts_field of_session;
|
||||
extern struct opts_field of_user;
|
||||
extern struct opts_field of_passwd;
|
||||
|
||||
extern struct Vector* gusers;
|
||||
extern struct Vector* gsessions;
|
||||
extern struct Vector* UNULLABLE gusers;
|
||||
extern struct Vector* UNULLABLE gsessions;
|
||||
|
||||
struct opts_field* NNULLABLE get_opts_field(enum input from);
|
||||
struct opts_field* NNULLABLE get_opts_ffield();
|
||||
@@ -23,6 +24,6 @@ struct session st_session(bool include_defshell);
|
||||
void st_ch_focus(char direction);
|
||||
void st_ch_of_opts(char direction);
|
||||
void st_ch_ef_col(char direction);
|
||||
void st_kbd_type(char* text, bool cfg_include_defshell);
|
||||
void st_kbd_type(char* NNULLABLE text, bool cfg_include_defshell);
|
||||
|
||||
#endif
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#include "keys.h"
|
||||
|
||||
int find_keyname(enum keys* at, const char* name);
|
||||
enum keys find_ansi(const char*);
|
||||
void read_press(u_char*, char*);
|
||||
enum keys find_ansi(const char* seq);
|
||||
void read_press(u_char* length, char* out);
|
||||
|
||||
bool utf8_iscont(char byte);
|
||||
size_t utf8len(const char* str);
|
||||
@@ -27,14 +27,14 @@ struct Vector {
|
||||
};
|
||||
|
||||
extern const struct Vector VEC_NEW;
|
||||
int vec_resize(struct Vector*, size_t size);
|
||||
int vec_reserve(struct Vector*, size_t size);
|
||||
int vec_reserve_exact(struct Vector*, size_t size);
|
||||
int vec_push(struct Vector*, void* item);
|
||||
void vec_free(struct Vector*);
|
||||
void vec_clear(struct Vector*);
|
||||
void vec_reset(struct Vector*);
|
||||
void* vec_pop(struct Vector*); // won't free it, nor shrink vec list space
|
||||
void* vec_get(struct Vector*, size_t index);
|
||||
int vec_resize(struct Vector* self, size_t size);
|
||||
int vec_reserve(struct Vector* self, size_t size);
|
||||
int vec_reserve_exact(struct Vector* self, size_t size);
|
||||
int vec_push(struct Vector* self, void* item);
|
||||
void vec_free(struct Vector* self);
|
||||
void vec_clear(struct Vector* self);
|
||||
void vec_reset(struct Vector* self);
|
||||
void* vec_pop(struct Vector* self); // won't free it, nor shrink vec list space
|
||||
void* vec_get(struct Vector* self, size_t index);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user