Merge branch 'master' into code-formatting

This commit is contained in:
2025-06-06 20:44:39 +02:00
13 changed files with 112 additions and 54 deletions

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);
@@ -64,7 +65,19 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
uint read;
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;
@@ -78,13 +91,17 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) {
} else {
free(value);
}
}
} else {
free(value);
}
free(key);
free(buf);
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++) {