mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
Simplified inbox_list().
This commit is contained in:
parent
1a94d7c05b
commit
3642cd25e4
1 changed files with 7 additions and 15 deletions
22
data.c
22
data.c
|
@ -1725,13 +1725,9 @@ void inbox_add(const char *inbox)
|
||||||
xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5);
|
xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5);
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (strlen(inbox) < 256 && (f = fopen(fn, "w")) != NULL) {
|
if ((f = fopen(fn, "w")) != NULL) {
|
||||||
pthread_mutex_lock(&data_mutex);
|
|
||||||
|
|
||||||
fprintf(f, "%s\n", inbox);
|
fprintf(f, "%s\n", inbox);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
pthread_mutex_unlock(&data_mutex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1760,18 +1756,14 @@ xs_list *inbox_list(void)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((f = fopen(v, "r")) != NULL) {
|
if ((f = fopen(v, "r")) != NULL) {
|
||||||
char line[256];
|
xs *line = xs_readline(f);
|
||||||
|
|
||||||
if (fgets(line, sizeof(line), f)) {
|
if (line) {
|
||||||
fclose(f);
|
line = xs_strip_i(line);
|
||||||
|
ibl = xs_list_append(ibl, line);
|
||||||
int i = strlen(line);
|
|
||||||
|
|
||||||
if (i) {
|
|
||||||
line[i - 1] = '\0';
|
|
||||||
ibl = xs_list_append(ibl, line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue