diff --git a/perl/main.pl b/perl/main.pl index 8c02b21..a9072b3 100644 --- a/perl/main.pl +++ b/perl/main.pl @@ -1,9 +1,10 @@ use strict; use warnings; -sub square +sub base_page { + 2 * 2; } -print "Hello treebird" . square; +print "Hello from Perl\n"; diff --git a/src/main.c b/src/main.c index 7fbc59a..9939e37 100644 --- a/src/main.c +++ b/src/main.c @@ -225,7 +225,6 @@ int main(int argc, char **argv, char **env) // Hell, let's not sit around here either cgi_start(&api); - free_instance_info_cache(); mastodont_cleanup(&api); diff --git a/src/session.c b/src/session.c index ac4e546..44f1f3d 100644 --- a/src/session.c +++ b/src/session.c @@ -29,3 +29,54 @@ const char* const get_token(struct session* ssn) { return keystr(ssn->cookies.access_token); } + +static HV* perlify_post_values(struct post_values* post) +{ +} + +static HV* perlify_get_values(struct get_values* get) +{ +} + +static HV* perlify_config(struct local_config* config) +{ + HV* ssn_config_hv = newHV(); + + hv_stores(ssn_config_hv, "logged_in", newSVpv(config->logged_in, 0)); + hv_stores(ssn_config_hv, "theme", newSVpv(config->theme, 0)); + hv_stores(ssn_config_hv, "background_url", newSVpv(config->background_url, 0)); + hv_stores(ssn_config_hv, "lang", newSViv(config->lang)); + hv_stores(ssn_config_hv, "themeclr", newSViv(config->themeclr)); + hv_stores(ssn_config_hv, "jsactions", newSViv(config->jsactions)); + hv_stores(ssn_config_hv, "jslive", newSViv(config->jslive)); + hv_stores(ssn_config_hv, "js", newSViv(config->js)); + hv_stores(ssn_config_hv, "interact_img", newSViv(config->interact_img)); + hv_stores(ssn_config_hv, "stat_attachments", newSViv(config->stat_attachments)); + hv_stores(ssn_config_hv, "stat_greentexts", newSViv(config->stat_greentexts)); + hv_stores(ssn_config_hv, "stat_dope", newSViv(config->stat_dope)); + hv_stores(ssn_config_hv, "stat_oneclicksoftware", newSViv(config->stat_oneclicksoftware)); + hv_stores(ssn_config_hv, "stat_emojo_likes", newSViv(config->stat_emojo_likes)); + hv_stores(ssn_config_hv, "stat_hide_muted", newSViv(config->stat_hide_muted)); + hv_stores(ssn_config_hv, "instance_show_shoutbox", newSViv(config->instance_show_shoutbox)); + hv_stores(ssn_config_hv, "instance_panel", newSViv(config->instance_panel)); + hv_stores(ssn_config_hv, "notif_embed", newSViv(config->notif_embed)); + hv_stores(ssn_config_hv, "sidebar_opacity", newSViv(config->sidebar_opacity)); + + return ssn_config_hv; +} + +HV* perlify_session(struct session* ssn) +{ + HV* ssn_hv = newHV(); + hv_stores(ssn_hv, "logged_in", newSVuv(ssn->logged_in)); +// HV* ssn_post_values = perlify_post_values(&(ssn->post)); +// HV* ssn_get_values = perlify_get_values(&(ssn->query)); +// HV* ssn_get_values = perlify_cookie_values(&(ssn->query)) + // Config + HV* ssn_config = perlify_config(&(ssn->config)); + hv_stores(ssn_hv, "config", newRV_inc((SV*)ssn_config)); + + + return ssn_hv; +} + diff --git a/src/session.h b/src/session.h index 6d9a23a..5c4f968 100644 --- a/src/session.h +++ b/src/session.h @@ -19,6 +19,7 @@ #ifndef SESSION_H #define SESSION_H #include +#include "global_perl.h" #include "query.h" #include "local_config.h" #include "cookie.h" @@ -36,5 +37,6 @@ struct session const char* const get_instance(struct session* ssn); const char* const get_token(struct session* ssn); +HV* perlify_session(struct session* ssn); #endif // SESSION_H