| 1827 | }; |
| 1828 | |
| 1829 | static const char *init(struct plugin *p, const char *b, const jsmntok_t *t) |
| 1830 | { |
| 1831 | /* Switch to bookkeeper-dir, if specified */ |
| 1832 | if (datadir && chdir(datadir) != 0) { |
| 1833 | if (mkdir(datadir, 0700) != 0 && errno != EEXIST) |
| 1834 | plugin_err(p, |
| 1835 | "Unable to create 'bookkeeper-dir'=%s", |
| 1836 | datadir); |
| 1837 | if (chdir(datadir) != 0) |
| 1838 | plugin_err(p, |
| 1839 | "Unable to switch to 'bookkeeper-dir'=%s", |
| 1840 | datadir); |
| 1841 | } |
| 1842 | |
| 1843 | /* No user suppled db_dsn, set one up here */ |
| 1844 | if (!db_dsn) |
| 1845 | db_dsn = tal_fmt(NULL, "sqlite3://accounts.sqlite3"); |
| 1846 | |
| 1847 | plugin_log(p, LOG_DBG, "Setting up database at %s", db_dsn); |
| 1848 | /* Final flag tells us What's New, Pussycat. */ |
| 1849 | db = notleak(db_setup(p, p, db_dsn, &tom_jones)); |
| 1850 | db_dsn = tal_free(db_dsn); |
| 1851 | |
| 1852 | return NULL; |
| 1853 | } |
| 1854 | |
| 1855 | int main(int argc, char *argv[]) |
| 1856 | { |
nothing calls this directly
no test coverage detected