From 6a9fbbb13357ecd4296902532231e906c4e85c0c Mon Sep 17 00:00:00 2001 From: Firew0lf Date: Sat, 12 Mar 2016 19:57:59 +0100 Subject: [PATCH] Added ":addTrustedRootCA()" to the httpc contexts, close #8, Added some values in ctr. I didn't test :addTrustedRootCA(), but it's just a simple string-to-char+size function. --- Makefile | 4 +++- sdcard/3ds/ctruLua/examples/httpc/httpc.lua | 9 ++++----- source/ctr.c | 13 +++++++++++++ source/gfx.c | 2 +- source/httpc.c | 16 ++++++++++++++++ source/ir.c | 2 +- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index fede3ea..a766a60 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,8 @@ APP_TITLE := ctruLua APP_DESCRIPTION := Lua for the 3DS. Yes, it works. APP_AUTHOR := Reuh, Firew0lf and NegiAD ICON := icon.png +APP_VERSION := $(shell git describe --abbrev=0 --tags) +LASTCOMMIT := $(shell git rev-parse HEAD) #--------------------------------------------------------------------------------- # options for code generation @@ -48,7 +50,7 @@ CFLAGS := -g -Wall -O2 -mword-relocations -std=gnu11 \ -fomit-frame-pointer -ffast-math \ $(ARCH) -CFLAGS += $(INCLUDE) -DARM11 -D_3DS +CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DCTR_VERSION=\"$(APP_VERSION)\" -DCTR_BUILD=\"$(LASTCOMMIT)\" CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 diff --git a/sdcard/3ds/ctruLua/examples/httpc/httpc.lua b/sdcard/3ds/ctruLua/examples/httpc/httpc.lua index 7ff1ef5..2f45f22 100644 --- a/sdcard/3ds/ctruLua/examples/httpc/httpc.lua +++ b/sdcard/3ds/ctruLua/examples/httpc/httpc.lua @@ -25,19 +25,18 @@ while ctr.run() do dls = dls + 1 end - gfx.startFrame(gfx.TOP) + gfx.start(gfx.TOP) gfx.text(0, 0, data) gfx.text(0, 20, "Downloaded "..dls.." times.") - gfx.endFrame() + gfx.stop() - gfx.startFrame(gfx.BOTTOM) + gfx.start(gfx.BOTTOM) gfx.text(2, 2, "HTTP Contexts example") gfx.text(2, 20, "The data is downloaded from '"..addr.."'.") gfx.text(2, 30, "Press [B] to redownload.") - gfx.endFrame() + gfx.stop() gfx.render() end - context:close() diff --git a/source/ctr.c b/source/ctr.c index 64f55e5..c7adad4 100644 --- a/source/ctr.c +++ b/source/ctr.c @@ -189,6 +189,19 @@ int luaopen_ctr_lib(lua_State *L) { ctr_libs[i].load(L); lua_setfield(L, -2, ctr_libs[i].name); } + + /*** + Running version of ctrµLua. This string contains the exact name of the last (pre-)release tag. + @field version + */ + lua_pushstring(L, CTR_VERSION); + lua_setfield(L, -2, "version"); + /*** + Running build of ctrµLua. This string contains the last commit hash. + @field build + */ + lua_pushstring(L, CTR_BUILD); + lua_setfield(L, -2, "build"); return 1; } diff --git a/source/gfx.c b/source/gfx.c index 9ecd1a6..f356eaa 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -8,7 +8,7 @@ The `gfx` module. #include #include -#include <3ds/vram.h> +//#include <3ds/vram.h> //#include <3ds/services/gsp.h> #include diff --git a/source/httpc.c b/source/httpc.c index 1386880..5f15af7 100644 --- a/source/httpc.c +++ b/source/httpc.c @@ -218,6 +218,21 @@ static int httpc_getResponseHeader(lua_State *L) { return 1; } +/*** +Add a trusted RootCA cert to a context. +@function :addTrustedRootCA +@tparam string DER certificate +*/ +static int httpc_addTrustedRootCA(lua_State *L) { + httpcContext *context = lua_touserdata(L, 1); + u32 certsize; + u8* cert = (u8*)luaL_checklstring(L, 2, (size_t*)&certsize); + + httpcAddTrustedRootCA(context, cert, certsize); + + return 0; +} + // object static const struct luaL_Reg httpc_methods[] = { {"open", httpc_open }, @@ -229,6 +244,7 @@ static const struct luaL_Reg httpc_methods[] = { {"close", httpc_close }, {"addPostData", httpc_addPostData }, {"getResponseHeader", httpc_getResponseHeader }, + {"addTrustedRootCA", httpc_addTrustedRootCA }, {NULL, NULL} }; diff --git a/source/ir.c b/source/ir.c index 5c5864e..86d85fe 100644 --- a/source/ir.c +++ b/source/ir.c @@ -5,7 +5,7 @@ The `ir` module. */ #include <3ds/types.h> #include <3ds/services/ir.h> -#include <3ds/linear.h> +//#include <3ds/linear.h> #include #include