summaryrefslogtreecommitdiff
path: root/Source/Applications
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-11-08 12:58:27 +0100
committerAlexis211 <alexis211@gmail.com>2009-11-08 12:58:27 +0100
commitec6a6922d074da4b64976282333e308deb39aeec (patch)
tree60d5e4a63095af75fc3ddae38021fa4c92ffd361 /Source/Applications
parent962b8e892ce060b9690a35b0bcf6bae9a882c330 (diff)
downloadMelon-ec6a6922d074da4b64976282333e308deb39aeec.tar.gz
Melon-ec6a6922d074da4b64976282333e308deb39aeec.zip
Introduced PaperWork : our init/login manager.
Login with user=root;pass=admin or user=alexis211;pass=iamgod
Diffstat (limited to 'Source/Applications')
-rw-r--r--Source/Applications/PaperWork/Makefile31
-rw-r--r--Source/Applications/PaperWork/main.cpp52
-rw-r--r--Source/Applications/Shell/Shell-fs.ns.cpp2
3 files changed, 84 insertions, 1 deletions
diff --git a/Source/Applications/PaperWork/Makefile b/Source/Applications/PaperWork/Makefile
new file mode 100644
index 0000000..fe8d564
--- /dev/null
+++ b/Source/Applications/PaperWork/Makefile
@@ -0,0 +1,31 @@
+.PHONY: clean, mrproper
+
+CXX = g++
+CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND
+
+LD = ld
+LDFLAGS = -T ../../Library/Link.ld -L ../../Library
+
+Objects = main.o
+OutFile = PaperWork
+
+all: $(OutFile)
+ echo "* Done with $(OutFile)."
+
+rebuild: mrproper all
+
+$(OutFile): $(Objects)
+ echo "* Linking $@..."
+ $(LD) $(LDFLAGS) $^ -o $@
+
+%.o: %.cpp
+ echo "* Compiling $<..."
+ $(CXX) $(CXXFLAGS) -c $< -o $@
+
+clean:
+ echo "* Removing object files..."
+ rm -rf *.o
+
+mrproper: clean
+ echo "* Removing applications..."
+ rm -rf $(OutFile)
diff --git a/Source/Applications/PaperWork/main.cpp b/Source/Applications/PaperWork/main.cpp
new file mode 100644
index 0000000..0ec6512
--- /dev/null
+++ b/Source/Applications/PaperWork/main.cpp
@@ -0,0 +1,52 @@
+#include <Binding/Process.class.h>
+#include <String.class.h>
+
+int main(Vector<String> args) {
+ String act = "init";
+ if (args.size() == 2) {
+ if (args[1] == "login") {
+ act = "login";
+ } else if (args[1] == "init") {
+ act = "init";
+ }
+ }
+
+ if (act == "init") {
+ while (1) {
+ Process p = Process::run("/System/Applications/PaperWork.app");
+ if (p.valid()) {
+ p.setInVT(invt);
+ p.setOutVT(outvt);
+ p.pushArg("login");
+ p.start();
+ p.wait();
+ } else {
+ return 1;
+ }
+ }
+ } else if (act == "login") {
+ outvt << "Logging in to Melon\n";
+ String user, pw;
+ while (1) {
+ outvt << "Username : ";
+ user = invt.readLine();
+ outvt << "Password : ";
+ pw = invt.readLine(false);
+ if (!Process::get().authenticatePW(user, pw)) {
+ outvt << "Authentication failed.\n\n";
+ continue;
+ }
+ Process p = Process::run("/Applications/Shell/Shell.app");
+ if (p.valid()) {
+ p.setInVT(invt);
+ p.setOutVT(outvt);
+ p.start();
+ p.wait();
+ outvt << "\n\n";
+ } else {
+ return 1;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/Source/Applications/Shell/Shell-fs.ns.cpp b/Source/Applications/Shell/Shell-fs.ns.cpp
index cd9de8a..0b51299 100644
--- a/Source/Applications/Shell/Shell-fs.ns.cpp
+++ b/Source/Applications/Shell/Shell-fs.ns.cpp
@@ -27,7 +27,7 @@ void ls(Vector<String>& args) {
String perm = "rwxrwxrwx";
u32int p = n.getPerm();
for (u32int i = 0; i < 9; i++) {
- if (((p >> i) & 1) == 0) perm[9 - i] = "-";
+ if (((p >> i) & 1) == 0) perm[8 - i] = "-";
}
if (n.type() == NT_FILE) {
outvt << " FILE " << perm << " " << n.getName();