diff options
author | default <nobody@localhost> | 2023-07-10 18:04:59 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-07-10 18:04:59 +0200 |
commit | 3642cd25e4eedbe2c3c2981eac03422b26a8eda0 (patch) | |
tree | 2a3245523568b2ef27bbba975d7000605087f6d0 /data.c | |
parent | 1a94d7c05bfbc69be14d3e4fd53d8e95972ff007 (diff) |
Simplified inbox_list().
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 22 |
1 files changed, 7 insertions, 15 deletions
@@ -1725,13 +1725,9 @@ void inbox_add(const char *inbox) xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5); FILE *f; - if (strlen(inbox) < 256 && (f = fopen(fn, "w")) != NULL) { - pthread_mutex_lock(&data_mutex); - + if ((f = fopen(fn, "w")) != NULL) { fprintf(f, "%s\n", inbox); fclose(f); - - pthread_mutex_unlock(&data_mutex); } } @@ -1760,18 +1756,14 @@ xs_list *inbox_list(void) FILE *f; if ((f = fopen(v, "r")) != NULL) { - char line[256]; - - if (fgets(line, sizeof(line), f)) { - fclose(f); + xs *line = xs_readline(f); - int i = strlen(line); - - if (i) { - line[i - 1] = '\0'; - ibl = xs_list_append(ibl, line); - } + if (line) { + line = xs_strip_i(line); + ibl = xs_list_append(ibl, line); } + + fclose(f); } } |