#include "ppport.h"
-#include "const-c.inc"
-
+#include "config.h"
#include "database/database.h"
#include "database/blergref.h"
#include "database/tags.h"
#include "database/subscription.h"
#include "database/util.h"
+#include "common/auth.h"
+
+#include "const-c.inc"
HV * blergref_to_perl_hash(struct blergref *list) {
HV *tmp;
OUTPUT:
RETVAL
-int _store(struct blerg *ptr, const char *data, int length(data))
+const char * _store(struct blerg *ptr, const char *data, int length(data))
PROTOTYPE: $$
- CODE:
- RETVAL = blerg_store(ptr, data, XSauto_length_of_data);
- OUTPUT:
- RETVAL
+ INIT:
+ uint64_t record;
+ char buf[21];
+ int n;
+ PPCODE:
+ record = blerg_store(ptr, data, XSauto_length_of_data);
+ n = snprintf(buf, 21, "%llu", record);
+ XPUSHs(sv_2mortal(newSVpv(buf, n)));
-const char * _fetch(struct blerg *ptr, int record)
+const char * _fetch(struct blerg *ptr, const char *str_record)
INIT:
+ uint64_t record;
char *buf;
int buflen;
int n;
PPCODE:
+ record = strtoull(str_record, NULL, 0);
n = blerg_fetch(ptr, record, &buf, &buflen);
if (!n) {
XSRETURN_UNDEF;
n = snprintf(buf, 21, "%llu", count);
XPUSHs(sv_2mortal(newSVpv(buf, n)));
-time_t _get_timestamp(struct blerg *ptr, int record)
+time_t _get_timestamp(struct blerg *ptr, const char *str_record)
+ INIT:
+ uint64_t record;
CODE:
+ record = strtoull(str_record, NULL, 0);
RETVAL = blerg_get_timestamp(ptr, record);
OUTPUT:
RETVAL
OUTPUT:
RETVAL
-void _tag_list(const char *tag, const char *str_offset, int direction)
+void tag_list(const char *tag, const char *str_offset, int direction)
INIT:
HV * tmp;
struct blergref *list;
int count, i;
PPCODE:
offset = strtoull(str_offset, NULL, 0);
+ count = 50;
list = tag_list(tag, offset, &count, direction);
if (list == NULL) {
- XSRETURN_UNDEF;
+ XSRETURN_EMPTY;
}
i = count - 1;
free(list);
int subscription_add(const char *from, const char *to)
- CODE:
- RETVAL = subscription_add(from, to);
- OUTPUT:
- RETVAL
int subscription_remove(const char *from, const char *to)
- CODE:
- RETVAL = subscription_remove(from, to);
- OUTPUT:
- RETVAL
-void subscription_list(const char *author, const char *str_offset, int direction)
+void _subscription_list(const char *author, const char *str_offset, int direction)
INIT:
HV *tmp;
struct blergref *list;
int count, i;
PPCODE:
offset = strtoull(str_offset, NULL, 0);
+ count = 50;
list = subscription_list(author, offset, &count, direction);
if (list == NULL) {
- XSRETURN_UNDEF;
+ XSRETURN_EMPTY;
}
i = count - 1;
int valid_tag_name(const char *name)
int valid_name(const char *name)
+
+int auth_set_password(const char *username, const char *password)
+
+int auth_check_password(const char *username, const char *password)
+
+char * auth_login(const char *username, const char *password)
+ INIT:
+ char *token;
+ PPCODE:
+ token = auth_login(username, password);
+ if (token != NULL) {
+ XPUSHs(sv_2mortal(newSVpv(token, TOKEN_SIZE * 2)));
+ } else {
+ XSRETURN_UNDEF;
+ }
+ free(token);
+
+int auth_logout(const char *username, const char *token)
+
+int auth_check_token(const char *username, const char *given_token)