diff options
| author | 2024-04-29 09:26:37 +0200 | |
|---|---|---|
| committer | 2024-04-29 09:26:37 +0200 | |
| commit | 29fb43079761796e34209611ec93bd651b871cab (patch) | |
| tree | 92032b2b28cf51dcc534124334b6ff8561724441 /data.c | |
| parent | More work in lists. (diff) | |
| download | snac2-29fb43079761796e34209611ec93bd651b871cab.tar.gz snac2-29fb43079761796e34209611ec93bd651b871cab.tar.xz snac2-29fb43079761796e34209611ec93bd651b871cab.zip | |
More work in lists.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 38 |
1 files changed, 36 insertions, 2 deletions
| @@ -1732,6 +1732,7 @@ xs_list *tag_search(char *tag, int skip, int show) | |||
| 1732 | /** lists **/ | 1732 | /** lists **/ |
| 1733 | 1733 | ||
| 1734 | xs_val *list_maint(snac *user, const char *list, int op) | 1734 | xs_val *list_maint(snac *user, const char *list, int op) |
| 1735 | /* list maintenance */ | ||
| 1735 | { | 1736 | { |
| 1736 | xs_val *l = NULL; | 1737 | xs_val *l = NULL; |
| 1737 | 1738 | ||
| @@ -1810,15 +1811,48 @@ xs_val *list_maint(snac *user, const char *list, int op) | |||
| 1810 | fn = xs_replace_i(fn, ".id", ".lst"); | 1811 | fn = xs_replace_i(fn, ".id", ".lst"); |
| 1811 | unlink(fn); | 1812 | unlink(fn); |
| 1812 | 1813 | ||
| 1813 | fn = xs_replace_i(fn, ".list", ".idx"); | 1814 | fn = xs_replace_i(fn, ".lst", ".idx"); |
| 1814 | unlink(fn); | 1815 | unlink(fn); |
| 1815 | } | 1816 | } |
| 1816 | } | 1817 | } |
| 1817 | 1818 | ||
| 1818 | break; | 1819 | break; |
| 1820 | } | ||
| 1821 | |||
| 1822 | return l; | ||
| 1823 | } | ||
| 1824 | |||
| 1825 | |||
| 1826 | xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op) | ||
| 1827 | /* list content management */ | ||
| 1828 | { | ||
| 1829 | xs_val *l = NULL; | ||
| 1830 | |||
| 1831 | if (!xs_is_hex(list)) | ||
| 1832 | return NULL; | ||
| 1833 | |||
| 1834 | if (actor_md5 != NULL && !xs_is_hex(actor_md5)) | ||
| 1835 | return NULL; | ||
| 1836 | |||
| 1837 | xs *fn = xs_fmt("%s/list/%s.lst", user->basedir, list); | ||
| 1838 | |||
| 1839 | switch (op) { | ||
| 1840 | case 0: /** list content **/ | ||
| 1841 | l = index_list(fn, XS_ALL); | ||
| 1819 | 1842 | ||
| 1820 | case 3: /** list content (list is the id) **/ | ||
| 1821 | break; | 1843 | break; |
| 1844 | |||
| 1845 | case 1: /** append actor to list **/ | ||
| 1846 | if (actor_md5 != NULL) { | ||
| 1847 | if (!index_in(fn, actor_md5)) | ||
| 1848 | index_add_md5(fn, actor_md5); | ||
| 1849 | } | ||
| 1850 | |||
| 1851 | break; | ||
| 1852 | |||
| 1853 | case 2: /** delete actor from list **/ | ||
| 1854 | if (actor_md5 != NULL) | ||
| 1855 | index_del_md5(fn, actor_md5); | ||
| 1822 | } | 1856 | } |
| 1823 | 1857 | ||
| 1824 | return l; | 1858 | return l; |