add blerg_init to blerg.a consumers
[blerg.git] / cgi / cgi_blerg.c
index cfe8031..373c353 100644 (file)
@@ -100,6 +100,9 @@ int main(int argc, char *argv[]) {
        struct url_info info;
        char *data;
 
+       if (!blerg_init())
+               exit(1);
+
        if (cgi_init() != CGIERR_NONE)
                exit(0);
 
@@ -376,6 +379,10 @@ int main(int argc, char *argv[]) {
                } else {
                        respond_blergref_list(feedlist, recs);
                }
+
+               struct blerg *b = blerg_open(username);
+               blerg_set_subscription_mark(b);
+               blerg_close(b);
        } else if (strncmp(path, "/feedinfo", 9) == 0) {
                const char *username = cgi_getentrystr("username");
                if (!check_auth(username))
@@ -409,6 +416,23 @@ int main(int argc, char *argv[]) {
                fwrite(ybuf, len, 1, stdout);
 
                yajl_gen_free(g);
+       } else if (strncmp(path, "/passwd", 7) == 0) {
+               const char *username = cgi_getentrystr("username");
+               if (!check_auth(username))
+                       exit(0);
+
+               const char *password = cgi_getentrystr("password");
+               const char *new_password = cgi_getentrystr("new_password");
+               if (password == NULL || new_password == NULL) {
+                       respond_JSON_Failure();
+               } else {
+                       if (auth_check_password(username, password)) {
+                               auth_set_password(username, new_password);
+                               respond_JSON_Success();
+                       } else {
+                               respond_JSON_Failure();
+                       }
+               }
        } else {
                respond_404();
                exit(0);