Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Side by Side Diff: ports/gambc_ppapi/main.c

Issue 150413008: Initial support for gambit-scheme v4.7.0 Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Add gambc_ppapi Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ports/gambc_ppapi/index.html ('k') | ports/gambc_ppapi/manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2013 The Native Client Authors. All rights reserved. 1 /* Copyright (c) 2013 The Native Client Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */ 3 * found in the LICENSE file. */
4 4
5 #include <assert.h> 5 #include <assert.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <libtar.h>
8 #include <limits.h> 7 #include <limits.h>
9 #include <stdio.h> 8 #include <stdio.h>
10 #include <stdlib.h> 9 #include <stdlib.h>
11 #include <string.h> 10 #include <string.h>
12 #include <sys/mount.h> 11 #include <sys/mount.h>
13 #include <unistd.h> 12 #include <unistd.h>
14 13
15 #include "ppapi_simple/ps_main.h" 14 #include "ppapi_simple/ps_main.h"
16 15
17 int lua_main(int argc, char **argv); 16 int gambc_main(int argc, char **argv);
18 17
19 static int setup_unix_environment(const char* tarfile) { 18 static int setup_unix_environment() {
20 int ret = umount("/"); 19 int ret = umount("/");
21 if (ret) { 20 if (ret) {
22 printf("unmounting root fs failed\n"); 21 printf("unmounting root fs failed\n");
23 return 1; 22 return 1;
24 } 23 }
25 ret = mount("", "/", "memfs", 0, NULL); 24 ret = mount("", "/", "memfs", 0, NULL);
26 if (ret) { 25 if (ret) {
27 printf("mounting root fs failed\n"); 26 printf("mounting root fs failed\n");
28 return 1; 27 return 1;
29 } 28 }
30 29
31 mkdir("/home", 0777); 30 mkdir("/home", 0777);
32 mkdir("/tmp", 0777); 31 mkdir("/tmp", 0777);
33 mkdir("/bin", 0777); 32 mkdir("/bin", 0777);
34 mkdir("/etc", 0777); 33 mkdir("/etc", 0777);
35 mkdir("/mnt", 0777); 34 mkdir("/mnt", 0777);
36 mkdir("/mnt/http", 0777); 35 mkdir("/mnt/http", 0777);
37 mkdir("/mnt/html5", 0777); 36 mkdir("/mnt/html5", 0777);
38 37
39 const char* data_url = getenv("DATA_URL"); 38 ret = mount("http://mzh.im/gambit-in-nacl/scm", "/mnt/http", "httpfs", 0,
40 if (!data_url)
41 data_url = "./";
42
43 ret = mount(data_url, "/mnt/http", "httpfs", 0,
44 "allow_cross_origin_requests=true,allow_credentials=false"); 39 "allow_cross_origin_requests=true,allow_credentials=false");
45 if (ret) { 40 if (ret) {
46 printf("mounting http filesystem failed\n"); 41 printf("mounting http filesystem failed\n");
47 return 1; 42 return 1;
48 } 43 }
49 44
50 // Ignore failures from mounting html5fs. For example, it will always 45 // Ignore failures from mounting html5fs. For example, it will always
51 // fail in incognito mode. 46 // fail in incognito mode.
52 mount("/", "/mnt/html5", "html5fs", 0, ""); 47 mount("/", "/mnt/html5", "html5fs", 0, "");
53 48
54 // Extra tar achive from http filesystem.
55 if (tarfile) {
56 TAR* tar;
57 char filename[PATH_MAX];
58 strcpy(filename, "/mnt/http/");
59 strcat(filename, tarfile);
60 ret = tar_open(&tar, filename, NULL, O_RDONLY, 0, 0);
61 if (ret) {
62 printf("error opening: %s\n", filename);
63 return 1;
64 }
65
66 ret = tar_extract_all(tar, "/");
67 if (ret) {
68 printf("error extracting: %s\n", filename);
69 return 1;
70 }
71
72 ret = tar_close(tar);
73 assert(ret == 0);
74 }
75
76 // Setup environment 49 // Setup environment
77 setenv("HOME", "/home", 1); 50 setenv("HOME", "/home", 1);
78 setenv("PATH", "/bin", 1); 51 setenv("PATH", "/bin", 1);
79 setenv("USER", "user", 1); 52 setenv("USER", "user", 1);
80 setenv("LOGNAME", "user", 1); 53 setenv("LOGNAME", "user", 1);
81 return 0; 54 return 0;
82 } 55 }
83 56
84 int lua_ppapi_main(int argc, char **argv) { 57 int gambc_ppapi_main(int argc, char **argv) {
85 if (setup_unix_environment("luadata.tar")) 58 if (setup_unix_environment())
86 return 1; 59 return 1;
87 60
88 chdir("/lua-5.2.2-tests"); 61 return gambc_main(argc, argv);
89
90 return lua_main(argc, argv);
91 } 62 }
92 63
93 PPAPI_SIMPLE_REGISTER_MAIN(lua_ppapi_main) 64 PPAPI_SIMPLE_REGISTER_MAIN(gambc_ppapi_main)
OLDNEW
« no previous file with comments | « ports/gambc_ppapi/index.html ('k') | ports/gambc_ppapi/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698