Skip to content

Commit 512332d

Browse files
committed
Initial commit
0 parents  commit 512332d

27 files changed

+959
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Source code for the webvm.io webpage.
2+
3+
Please use github.com/webvm/issues to signal any bug.
4+
5+
6+
This project depends on xterm.js (https://xtermjs.org/) and on its add-on xterm-addon-fit
7+
8+
To update the xterm-related files do:
9+
```
10+
mkdir build
11+
cd build
12+
npm install --save xterm
13+
npm install --save xterm-addon-fit
14+
cd ../xterm
15+
cp ../build/node_modules/xterm/lib/xterm.js .
16+
cp ../build/node_modules/xterm/css/xterm.css .
17+
cp ../build/node_modules/xterm-addon-fit/lib/xterm-addon-fit.js .
18+
cd ..
19+
rm -r build
20+
```

assets/webvm.jpeg

102 KB
Loading

examples/c/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
SRCS = $(wildcard *.c)
2+
3+
PROGS = $(patsubst %.c,%,$(SRCS))
4+
5+
all: $(PROGS)
6+
7+
%: %.c
8+
$(CC) $(CFLAGS) -o $@ $<
9+
10+
clean:
11+
rm -f $(PROGS)
12+
13+
.PHONY: all clean

examples/c/env.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdio.h>
2+
3+
// Most of the C compilers support a third parameter to main which
4+
// store all envorinment variables
5+
int main(int argc, char *argv[], char * envp[])
6+
{
7+
int i;
8+
for (i = 0; envp[i] != NULL; i++)
9+
printf("\n%s", envp[i]);
10+
getchar();
11+
return 0;
12+
}

examples/c/helloworld.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
printf("Hello, World!\n");
6+
}

examples/c/link.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <unistd.h>
2+
3+
int main()
4+
{
5+
link("env", "env3");
6+
return 0;
7+
}

examples/c/openat.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <fcntl.h>
2+
#include <stdio.h>
3+
#include <errno.h>
4+
5+
int main()
6+
{
7+
int ret = openat(AT_FDCWD, "/dev/tty", 0x88102, 0);
8+
printf("return value is %d and errno is %d\n", ret, errno);
9+
}
10+

examples/c/waitpid.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <sys/wait.h>
2+
#include <unistd.h>
3+
#include <errno.h>
4+
#include <stdio.h>
5+
6+
int main()
7+
{
8+
int status;
9+
10+
pid_t p = getpid();
11+
// waitpid takes a children's pid, not the current process one
12+
// if the pid is not a children of the current process, it returns -ECHILD
13+
pid_t res = waitpid(1001, &status, WNOHANG);
14+
15+
printf("res is %d, p is %d and errno is %d\n", res, p, errno);
16+
17+
}

examples/lua/fizzbuzz.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env luajit
2+
cfizz,cbuzz=0,0
3+
for i=1,20 do
4+
cfizz=cfizz+1
5+
cbuzz=cbuzz+1
6+
io.write(i .. ": ")
7+
if cfizz~=3 and cbuzz~=5 then
8+
io.write(i)
9+
else
10+
if cfizz==3 then
11+
io.write("Fizz")
12+
cfizz=0
13+
end
14+
if cbuzz==5 then
15+
io.write("Buzz")
16+
cbuzz=0
17+
end
18+
end
19+
io.write("\n")
20+
end

examples/lua/sorting.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fruits = {"banana","orange","apple","grapes"}
2+
3+
for k,v in ipairs(fruits) do
4+
print(k,v)
5+
end
6+
7+
table.sort(fruits)
8+
print("sorted table")
9+
10+
for k,v in ipairs(fruits) do
11+
print(k,v)
12+
end

0 commit comments

Comments
 (0)