diff --git a/include/auth.h b/include/auth.h index b456227..8f7b850 100644 --- a/include/auth.h +++ b/include/auth.h @@ -6,6 +6,7 @@ #include "config.h" #include "sessions.h" -bool launch(char *user, char *passwd, struct session session, void (*cb)(void), struct behavior* behavior); +bool launch(char *user, char *passwd, struct session session, void (*cb)(void), + struct behavior *behavior); #endif diff --git a/include/ui.h b/include/ui.h index 023a947..5798850 100644 --- a/include/ui.h +++ b/include/ui.h @@ -5,7 +5,7 @@ #include "util.h" void setup(struct config); -int load(struct Vector * users, struct Vector * sessions); +int load(struct Vector *users, struct Vector *sessions); void print_err(const char *); void print_errno(const char *); diff --git a/include/util.h b/include/util.h index 96b1a5a..086afb8 100644 --- a/include/util.h +++ b/include/util.h @@ -14,18 +14,18 @@ void read_press(u_char *, char *); void strcln(char **dest, const char *source); struct Vector { - uint32_t length; - uint32_t alloc_len; - uint16_t alloc_size; - void** pages; + uint32_t length; + uint32_t alloc_len; + uint16_t alloc_size; + void **pages; }; struct Vector vec_new(); -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_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); #endif diff --git a/src/sessions.c b/src/sessions.c index c0ebbea..3087e91 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -89,7 +89,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) { // just add this to the list if (name_buf != NULL && exec_buf != NULL) { - struct session *session_i = malloc(sizeof (struct session)); + struct session *session_i = malloc(sizeof(struct session)); *session_i = __new_session(session_type, name_buf, exec_buf, tryexec_buf == NULL ? "" : tryexec_buf); vec_push(cb_sessions, session_i); diff --git a/src/ui.c b/src/ui.c index f711554..b05d0db 100644 --- a/src/ui.c +++ b/src/ui.c @@ -219,7 +219,7 @@ void ffield_cursor_focus() { struct user get_current_user() { if (of_user.current_opt != 0) - return *(struct user*)vec_get(gusers, of_user.current_opt - 1); + return *(struct user *)vec_get(gusers, of_user.current_opt - 1); else { struct user custom_user; custom_user.shell = "/usr/bin/bash"; @@ -239,7 +239,7 @@ struct session get_current_session() { shell_session.exec = shell_session.name = get_current_user().shell; return shell_session; } else - return *(struct session*)vec_get(gsessions, of_session.current_opt - 1); + return *(struct session *)vec_get(gsessions, of_session.current_opt - 1); } else { struct session custom_session; custom_session.type = SHELL; diff --git a/src/util.c b/src/util.c index 50a88a0..c23a12f 100644 --- a/src/util.c +++ b/src/util.c @@ -68,7 +68,6 @@ static int selret_magic() { return select(1, &set, NULL, NULL, &timeout); } - // Vector shii struct Vector vec_new() { struct Vector vec; @@ -76,7 +75,7 @@ struct Vector vec_new() { return vec; } -int vec_push(struct Vector* vec, void* item) { +int vec_push(struct Vector *vec, void *item) { if (vec->length >= vec->alloc_len) { uint32_t new_size = vec->alloc_len + vec->alloc_size; void **new_location = realloc(vec->pages, vec->alloc_size); @@ -93,33 +92,33 @@ int vec_push(struct Vector* vec, void* item) { return 0; } -void vec_free(struct Vector* vec) { - while(vec->length > 0) +void vec_free(struct Vector *vec) { + while (vec->length > 0) free(vec->pages[--vec->length]); vec_clear(vec); } -void vec_clear(struct Vector* vec) { +void vec_clear(struct Vector *vec) { free(vec->pages); vec_reset(vec); } -void vec_reset(struct Vector* vec) { +void vec_reset(struct Vector *vec) { vec->length = 0; vec->alloc_len = 0; vec->alloc_size = 4096; // 4KiB page size? vec->pages = NULL; } -void* vec_pop(struct Vector* vec) { +void *vec_pop(struct Vector *vec) { if (vec->length == 0) return NULL; return vec->pages[--vec->length]; } -void* vec_get(struct Vector* vec, size_t index) { +void *vec_get(struct Vector *vec, size_t index) { if (index >= vec->length) return NULL;