summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2023-07-10 18:04:59 +0200
committerGravatar default2023-07-10 18:04:59 +0200
commit3642cd25e4eedbe2c3c2981eac03422b26a8eda0 (patch)
tree2a3245523568b2ef27bbba975d7000605087f6d0 /data.c
parentRevert "New server config array "webfinger_domains"." (diff)
downloadsnac2-3642cd25e4eedbe2c3c2981eac03422b26a8eda0.tar.gz
snac2-3642cd25e4eedbe2c3c2981eac03422b26a8eda0.tar.xz
snac2-3642cd25e4eedbe2c3c2981eac03422b26a8eda0.zip
Simplified inbox_list().
Diffstat (limited to 'data.c')
-rw-r--r--data.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/data.c b/data.c
index 1d6bfd1..2c2ff8b 100644
--- a/data.c
+++ b/data.c
@@ -1725,13 +1725,9 @@ void inbox_add(const char *inbox)
1725 xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5); 1725 xs *fn = xs_fmt("%s/inbox/%s", srv_basedir, md5);
1726 FILE *f; 1726 FILE *f;
1727 1727
1728 if (strlen(inbox) < 256 && (f = fopen(fn, "w")) != NULL) { 1728 if ((f = fopen(fn, "w")) != NULL) {
1729 pthread_mutex_lock(&data_mutex);
1730
1731 fprintf(f, "%s\n", inbox); 1729 fprintf(f, "%s\n", inbox);
1732 fclose(f); 1730 fclose(f);
1733
1734 pthread_mutex_unlock(&data_mutex);
1735 } 1731 }
1736} 1732}
1737 1733
@@ -1760,18 +1756,14 @@ xs_list *inbox_list(void)
1760 FILE *f; 1756 FILE *f;
1761 1757
1762 if ((f = fopen(v, "r")) != NULL) { 1758 if ((f = fopen(v, "r")) != NULL) {
1763 char line[256]; 1759 xs *line = xs_readline(f);
1764
1765 if (fgets(line, sizeof(line), f)) {
1766 fclose(f);
1767 1760
1768 int i = strlen(line); 1761 if (line) {
1769 1762 line = xs_strip_i(line);
1770 if (i) { 1763 ibl = xs_list_append(ibl, line);
1771 line[i - 1] = '\0';
1772 ibl = xs_list_append(ibl, line);
1773 }
1774 } 1764 }
1765
1766 fclose(f);
1775 } 1767 }
1776 } 1768 }
1777 1769