File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ extern "C" {
9292
9393#include <3ds/applets/swkbd.h>
9494#include <3ds/applets/error.h>
95-
95+ #include <3ds/applets/browser.h>
9696#include <3ds/applets/miiselector.h>
9797
9898#include <3ds/archive.h>
Original file line number Diff line number Diff line change 1+ /**
2+ * @file browser.h
3+ * @brief Browser Applet
4+ */
5+
6+ #pragma once
7+
8+ /**
9+ * @brief Open the browser at a url
10+ * @param url The url to open at, max-length 1024 characters including the trailing zero. If invalid or null, just opens the browser.
11+ */
12+ void browserOpenUrl (const char * url );
Original file line number Diff line number Diff line change 1+ #include <3ds/types.h>
2+ #include <3ds/services/apt.h>
3+
4+ #include <3ds/applets/browser.h>
5+
6+ #include <stdlib.h>
7+ #include <string.h>
8+
9+ void browserOpenUrl (const char * url )
10+ {
11+ size_t url_len = url ? (strlen (url ) + 1 ) : 0 ;
12+ // check that we passed a url, it isn't too long and not too short (needs at least "http://")
13+ // if that is not the case, we just claim our buffer was 0 in size
14+ if (url_len > 0x400 || url_len < 8 ) url_len = 0 ;
15+ // Something (aptLaunchSystemApplet? webbrowser?) tries to write / trashes the buffer.
16+ // So, we copy the url onto the heap so that all still works out and our original argument remains const
17+ void * buffer = malloc (url_len );
18+ if (buffer ) memcpy (buffer , url , url_len );
19+ aptLaunchSystemApplet (APPID_WEB , buffer , url_len , 0 );
20+ if (buffer ) free (buffer );
21+ }
You can’t perform that action at this time.
0 commit comments