11 Commits

Author SHA1 Message Date
b22ae6b2cc fix: memory leaks 2025-06-06 19:40:38 +02:00
04a102a7bb perf: better and efficient vec impl 2025-06-06 19:39:44 +02:00
dc6424979e fix: address mem issues 2025-06-06 18:12:45 +02:00
82e92df95c fix(aur): v0.2.1 checksums on the srcfile (again x2) 2025-06-06 17:05:14 +02:00
f2dbeb0236 Merge pull request #34 from AliensInc/master
Fixes the first two lines in the sha256sum

> *Why dont the checks runnnnnnnnnnnn*
2025-06-06 16:58:48 +02:00
Basher52
d72643c030 Fixes the first two lines in the sha256sum 2025-05-27 21:35:05 +02:00
f7139b16b5 Merge pull request #32 from rmntgx/memory-fixes
fix: memory leaks and memory access errors
2025-05-20 17:02:24 +02:00
rmntgx
ee6565d5b4 fix: memory leaks and memory access errors 2025-05-20 19:42:24 +05:00
620d861d8c fix(aur): lidm-bin@0.2.1 checksums 2025-03-22 18:27:15 +01:00
e879561cbd Merge pull request #28 from javalsai/actions/update-aur-0.2.1
[AUR update]: Bump to 0.2.1
2025-03-22 18:01:24 +01:00
GitHub Actions
eecfd7ac4c Update AUR pkgs to v0.2.1 2025-03-22 16:54:29 +00:00
11 changed files with 138 additions and 72 deletions

View File

@@ -1,17 +1,17 @@
pkgbase = lidm-bin
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
pkgver = 0.2.0
pkgrel = 1
pkgver = 0.2.1
pkgrel = 2
url = https://github.com/javalsai/lidm
arch = x86_64
license = GPL
depends = pam
provides = lidm
conflicts = lidm
source = lidm::https://github.com/javalsai/lidm/releases/download/v0.2.0/lidm-amd64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/themes/default.ini
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/assets/man/lidm.1
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.2.0/assets/man/lidm-config.5
source = lidm::https://github.com/javalsai/lidm/releases/download/v0.2.1/lidm-amd64
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v0.2.1/themes/default.ini
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v0.2.1/assets/man/lidm.1
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v0.2.1/assets/man/lidm-config.5
sha256sums = 65b42f4f7acd970b167fe84d1fa75450b54e01a6f0edddb9d8dd487058a20850
sha256sums = 68662430a6d262b35cc54d9f0e164ed935b7f7f4497a87cc94946c558bbe8a91
sha256sums = a6807a55ff72ec5a5678583156b3efd0d367f0bcb79854094132771f0cb86bce

View File

@@ -1,8 +1,8 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-bin
pkgver=0.2.0
pkgrel=1
pkgver=0.2.1
pkgrel=2
depends=('pam')
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
arch=('x86_64')

View File

@@ -1,7 +1,7 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm-git
pkgver=0.2.0.r2.g255256b
pkgver=0.2.1.r0.ge2014f4
pkgrel=1
depends=('pam')
makedepends=('git' 'make' 'gcc')

View File

@@ -1,6 +1,6 @@
pkgbase = lidm
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
pkgver = 0.2.0
pkgver = 0.2.1
pkgrel = 1
url = https://github.com/javalsai/lidm
arch = any
@@ -8,7 +8,7 @@ pkgbase = lidm
makedepends = git
makedepends = gcc
depends = pam
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v0.2.0.tar.gz
sha256sums = 6d397cf75cafdcb95e5a2623d70f2e07bbb085a07b7c3b743caac06454ed7b16
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v0.2.1.tar.gz
sha256sums = 56aaf8025fac16f5deef3058274635198fc3bf3f7eadc1de5c6539614f03d84b
pkgname = lidm

View File

@@ -1,7 +1,7 @@
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
# Maintainer: javalsai <javalsai@proton.me>
pkgname=lidm
pkgver=0.2.0
pkgver=0.2.1
pkgrel=1
depends=('pam')
makedepends=('git' 'gcc')
@@ -10,7 +10,7 @@ arch=('any')
url="https://github.com/javalsai/lidm"
license=('GPL')
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('6d397cf75cafdcb95e5a2623d70f2e07bbb085a07b7c3b743caac06454ed7b16')
sha256sums=('56aaf8025fac16f5deef3058274635198fc3bf3f7eadc1de5c6539614f03d84b')
build() {
tar -xzf "tarball.tar.gz"

View File

@@ -14,18 +14,20 @@ 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 capacity;
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_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);
#endif

View File

@@ -4,6 +4,14 @@
#include "config.h"
#include "util.h"
// Alr so ima explain the bitfield returned by `cb` a bit
// 4 bits:
// 0b0001: break out of parsing (returning true)
// 0b0010: free the value
// 0b0100: free the key
// 0b1000: break out of parsing (returning false)
//
// This would return true if everything goes fine, false otherwise (malloc error, broke parsing, etc)
bool line_parser(FILE *fd, ssize_t *blksize,
u_char (*cb)(char *key, char *value)) {
size_t opt_size = 4096;
@@ -27,23 +35,34 @@ bool line_parser(FILE *fd, ssize_t *blksize,
free(buf);
return false;
}
if ((read = sscanf(buf, "%[^ ] = %[^\n]\n", key, buf)) != 0) {
u_char ret = cb(key, buf);
char *value = malloc(read_size);
if (value == NULL) {
free(buf);
return false;
}
if ((read = sscanf(buf, "%[^ ] = %[^\n]\n", key, value)) != 0) {
u_char ret = cb(key, value);
if (ret & 0b0100)
free(key);
if (ret & 0b0010)
free(value);
if (ret & 0b1000) {
free(buf);
if (ret & 0b1000)
return false;
if (ret & 0b0001)
}
if (ret & 0b0001) {
free(buf);
break;
}
}
free(buf);
}
return true;
}
struct config *__config;
// Yanderedev code (wanna fix this with a table or smth)
u_char config_line_handler(char *k, char *v) {
if (strcmp(k, "colors.bg") == 0)
__config->theme.colors.bg = v;
@@ -85,13 +104,16 @@ u_char config_line_handler(char *k, char *v) {
__config->theme.chars.cbl = v;
else if (strcmp(k, "chars.cbr") == 0)
__config->theme.chars.cbr = v;
else if (strcmp(k, "functions.poweroff") == 0)
else if (strcmp(k, "functions.poweroff") == 0) {
__config->functions.poweroff = find_keyname(v);
else if (strcmp(k, "functions.reboot") == 0)
return 0b0110;
} else if (strcmp(k, "functions.reboot") == 0) {
__config->functions.reboot = find_keyname(v);
else if (strcmp(k, "functions.refresh") == 0)
return 0b0110;
} else if (strcmp(k, "functions.refresh") == 0) {
__config->functions.refresh = find_keyname(v);
else if (strcmp(k, "strings.f_poweroff") == 0)
return 0b0110;
} else if (strcmp(k, "strings.f_poweroff") == 0)
__config->strings.f_poweroff = v;
else if (strcmp(k, "strings.f_reboot") == 0)
__config->strings.f_reboot = v;
@@ -107,16 +129,17 @@ u_char config_line_handler(char *k, char *v) {
__config->strings.s_xorg = v;
else if (strcmp(k, "strings.s_shell") == 0)
__config->strings.s_shell = v;
else if (strcmp(k, "behavior.include_defshell") == 0)
else if (strcmp(k, "behavior.include_defshell") == 0) {
__config->behavior.include_defshell = strcmp(v, "true") == 0;
else if (strcmp(k, "behavior.source") == 0)
return 0b0110;
} else if (strcmp(k, "behavior.source") == 0)
vec_push(&__config->behavior.source, v);
else if (strcmp(k, "behavior.user_source") == 0)
vec_push(&__config->behavior.user_source, v);
else
return 0b1111;
return 0b100;
return 0b0100;
}
struct config *parse_config(char *path) {

View File

@@ -54,6 +54,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
char *exec_buf = NULL;
char *tryexec_buf = NULL;
// This should be made a specific function
// Emm, if anything goes wrong just free the inner loop and `break;` fd and the rest is handled after
while (true) {
char *buf = malloc(sb->st_blksize);
ssize_t read_size = getline(&buf, &alloc_size, fd);
@@ -63,28 +64,44 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
}
uint read;
char *key = malloc(read_size);
if ((read = sscanf(buf, "%[^=]=%[^\n]\n", key, buf)) != 0) {
char *key = malloc(read_size + sizeof(char));
if(key == NULL) {
free(buf);
// TODO: more sophisticated error handling??
break;
}
char *value = malloc(read_size + sizeof(char));
if(value == NULL) {
free(buf);
free(key);
// TODO: more sophisticated error handling??
break;
}
value[0] = '\0'; // I'm not sure if sscanf would null this string out
if ((read = sscanf(buf, "%[^=]=%[^\n]\n", key, value)) != 0) {
if (strcmp(key, "Name") == 0) {
found &= 0b001;
name_buf = realloc(buf, read);
name_buf = realloc(value, strlen(value) + sizeof(char));
} else if (strcmp(key, "Exec") == 0) {
found &= 0b010;
exec_buf = realloc(buf, read);
exec_buf = realloc(value, strlen(value) + sizeof(char));
} else if (strcmp(key, "TryExec") == 0) {
found &= 0b100;
tryexec_buf = realloc(buf, read);
} else
free(buf);
} else
free(buf);
tryexec_buf = realloc(value, strlen(value) + sizeof(char));
} else {
free(value);
}
} else {
free(value);
}
free(key);
if (found == 0b111)
break;
free(buf);
if (found == 0b111) break;
}
/*printf("\nend parsing...\n");*/
// Generic handling of exit
fclose(fd);
// just add this to the list
@@ -108,6 +125,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
// This code is designed to be run purely single threaded
struct Vector get_avaliable_sessions() {
struct Vector sessions = vec_new();
vec_reserve(&sessions, 8);
cb_sessions = &sessions;
for (size_t i = 0; i < (sizeof(sources) / sizeof(sources[0])); i++) {

View File

@@ -322,6 +322,7 @@ void ffield_type(char *text) {
print_ffield();
}
static char* unknown_str = "unknown";
int load(struct Vector *users, struct Vector *sessions) {
/// SETUP
gusers = users;
@@ -331,9 +332,9 @@ int load(struct Vector *users, struct Vector *sessions) {
char *hostname = malloc(16);
if (gethostname(hostname, 16) != 0) {
free(hostname);
hostname = "unknown";
hostname = unknown_str;
} else {
hostname = realloc(hostname, strlen(hostname) + 1);
hostname[15] = '\0';
}
of_session = ofield_new(sessions->length + behavior.include_defshell);
@@ -350,12 +351,14 @@ int load(struct Vector *users, struct Vector *sessions) {
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", boxstart.y + 2,
boxstart.x + 12 - (uint)strlen(hostname), theme.colors.e_hostname,
hostname, theme.colors.fg);
if(hostname != unknown_str) free(hostname);
// put date
char *fmtd_time = fmt_time();
printf("\x1b[%d;%dH\x1b[%sm%s\x1b[%sm", boxstart.y + 2,
boxstart.x + boxw - 3 - (uint)strlen(fmtd_time), theme.colors.e_date,
fmtd_time, theme.colors.fg);
free(fmtd_time);
print_field(SESSION);
print_field(USER);

View File

@@ -23,6 +23,7 @@ static struct user __new_user(struct passwd *p) {
// This code is designed to be run purely single threaded
struct Vector get_human_users() {
struct Vector users = vec_new();
vec_reserve(&users, 4);
struct passwd *pwd;
while ((pwd = getpwent()) != NULL) {

View File

@@ -68,58 +68,77 @@ static int selret_magic() {
return select(1, &set, NULL, NULL, &timeout);
}
// Vector shii
struct Vector vec_new() {
struct Vector vec;
vec_clear(&vec);
vec_reset(&vec);
return vec;
}
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);
if (new_location != NULL) {
vec->alloc_size = new_size;
vec->pages = new_location;
} else {
return -1;
}
int vec_resize(struct Vector *vec, size_t size) {
void **new_location = realloc(vec->pages, size * sizeof(void*));
if (new_location != NULL) {
if (vec->length > size)
vec->length = size;
vec->capacity = size;
vec->pages = new_location;
} else {
return -1;
}
vec->pages[vec->length] = item;
vec->length++;
return 0;
}
void vec_free(struct Vector* vec) {
while(vec->length > 0)
int vec_reserve(struct Vector *vec, size_t size) {
uint32_t new_capacity = vec->capacity;
while (vec->length + size > new_capacity) {
new_capacity = new_capacity + (new_capacity >> 1) + 1; // cap * 1.5 + 1; 0 1 2 4 7 11...
}
return vec_resize(vec, new_capacity);
}
int vec_reserve_exact(struct Vector *vec, size_t size) {
uint32_t needed_capacity = vec->length + size;
if (vec->capacity < needed_capacity) {
return vec_resize(vec, needed_capacity);
} else {
return 0;
}
}
int vec_push(struct Vector *vec, void *item) {
int res_ret = vec_reserve(vec, 1);
if(res_ret != 0) return res_ret;
vec->pages[vec->length++] = item;
return 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->capacity = 0;
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;