summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/main.c b/main.c
index 8e3dbd2..a109192 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,7 @@ int usage(void)
16 printf("Commands:\n"); 16 printf("Commands:\n");
17 printf("\n"); 17 printf("\n");
18 printf("init [{basedir}] Initializes the database\n"); 18 printf("init [{basedir}] Initializes the database\n");
19 printf("upgrade {basedir} Upgrade to a new version\n");
19 printf("adduser {basedir} [{uid}] Adds a new user\n"); 20 printf("adduser {basedir} [{uid}] Adds a new user\n");
20 printf("httpd {basedir} Starts the HTTPD daemon\n"); 21 printf("httpd {basedir} Starts the HTTPD daemon\n");
21 printf("purge {basedir} Purges old data\n"); 22 printf("purge {basedir} Purges old data\n");
@@ -76,6 +77,19 @@ int main(int argc, char *argv[])
76 return initdb(basedir); 77 return initdb(basedir);
77 } 78 }
78 79
80 if (strcmp(cmd, "upgrade") == 0) {
81 int ret;
82
83 /* database upgrade */
84 if ((basedir = GET_ARGV()) == NULL)
85 return usage();
86
87 if ((ret = srv_open(basedir, 1)) == 1)
88 srv_log(xs_dup("OK"));
89
90 return ret;
91 }
92
79 if (strcmp(cmd, "markdown") == 0) { 93 if (strcmp(cmd, "markdown") == 0) {
80 /* undocumented, for testing only */ 94 /* undocumented, for testing only */
81 xs *c = xs_readall(stdin); 95 xs *c = xs_readall(stdin);
@@ -88,7 +102,7 @@ int main(int argc, char *argv[])
88 if ((basedir = GET_ARGV()) == NULL) 102 if ((basedir = GET_ARGV()) == NULL)
89 return usage(); 103 return usage();
90 104
91 if (!srv_open(basedir)) { 105 if (!srv_open(basedir, 0)) {
92 srv_log(xs_fmt("error opening database at %s", basedir)); 106 srv_log(xs_fmt("error opening database at %s", basedir));
93 return 1; 107 return 1;
94 } 108 }
@@ -142,12 +156,21 @@ int main(int argc, char *argv[])
142 } 156 }
143 157
144 if (strcmp(cmd, "timeline") == 0) { 158 if (strcmp(cmd, "timeline") == 0) {
145 xs *list = local_list(&snac, 0xfffffff); 159#if 0
160 xs *list = local_list(&snac, XS_ALL);
146 xs *body = html_timeline(&snac, list, 1); 161 xs *body = html_timeline(&snac, list, 1);
147 162
148 printf("%s\n", body); 163 printf("%s\n", body);
149 user_free(&snac); 164 user_free(&snac);
150 srv_free(); 165 srv_free();
166#endif
167
168 xs *idx = xs_fmt("%s/private.idx", snac.basedir);
169 xs *list = index_list_desc(idx, 256);
170 xs *tl = timeline_top_level(&snac, list);
171
172 xs *j = xs_json_dumps_pp(tl, 4);
173 printf("%s\n", j);
151 174
152 return 0; 175 return 0;
153 } 176 }