summaryrefslogtreecommitdiff
path: root/Source/Library/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library/Userland')
-rw-r--r--Source/Library/Userland/App/ShellApp.proto.cpp23
-rw-r--r--Source/Library/Userland/Binding/Process.class.h4
-rw-r--r--Source/Library/Userland/Binding/VirtualTerminal.class.h6
-rw-r--r--Source/Library/Userland/Syscall/RessourceCaller.class.h4
4 files changed, 25 insertions, 12 deletions
diff --git a/Source/Library/Userland/App/ShellApp.proto.cpp b/Source/Library/Userland/App/ShellApp.proto.cpp
index a3d9737..f2233bc 100644
--- a/Source/Library/Userland/App/ShellApp.proto.cpp
+++ b/Source/Library/Userland/App/ShellApp.proto.cpp
@@ -14,6 +14,7 @@ void ShellApp::init() {
u32int argc = pr.argc();
for (u32int i = 0; i < argc; i++) {
String arg = pr.argv(i);
+ if (arg.empty()) continue;
if (arg == "-") {
i++;
if (i == argc) {
@@ -26,13 +27,13 @@ void ShellApp::init() {
bool found = false;
for (u32int i = 0; i < flags.size(); i++) {
if (flags[i].type == FT_BOOL) {
- if (arg == String("--no-") + flags[i].lName) {
+ if (arg == (String("--no-") += flags[i].lName)) {
flags[i].boolVal = false;
found = true;
}
}
}
- if (!found) outvt << "Unknown option : " << arg << "\n";
+ if (!found) outvt << "Unknown option : " << arg << ENDL;
} else if (arg.substr(0, 2) == "--") {
bool found = false;
for (u32int i = 0; i < flags.size(); i++) {
@@ -49,21 +50,29 @@ void ShellApp::init() {
}
}
}
- if (!found) outvt << "Unknown option : " << arg << "\n";
+ if (!found) outvt << "Unknown option : " << arg << ENDL;
} else {
for (u32int j = 1; j < arg.size(); j++) {
bool found = false;
for (u32int k = 0; k < flags.size(); k++) {
if (flags[k].sName == arg[j]) {
found = true;
- if (flags[k].type == FT_BOOL) flags[k].boolVal = true;
- if (flags[k].type == FT_INT) flags[k].intVal = pr.argv(++i).toInt();
- if (flags[k].type == FT_STR) flags[k].strVal = pr.argv(++i);
+ if (flags[k].type == FT_BOOL) {
+ flags[k].boolVal = true;
+ } else {
+ i++;
+ if (i >= argc) {
+ outvt << "Missing argument for flag : -" << String(arg[j], 1) << ENDL;
+ } else {
+ flags[k].strVal = pr.argv(i);
+ if (flags[k].type == FT_INT) flags[k].intVal = flags[k].strVal.toInt();
+ }
+ }
break;
}
}
if (!found) {
- outvt << "Unknown option : -" << String(arg[j]) << "\n";
+ outvt << "Unknown option : -" << String(arg[j], 1) << ENDL;
exit(-1);
}
}
diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h
index 2200f59..e94084b 100644
--- a/Source/Library/Userland/Binding/Process.class.h
+++ b/Source/Library/Userland/Binding/Process.class.h
@@ -54,10 +54,10 @@ class Process : public RessourceCaller {
void pushArg(const String& arg) {
doCall(PRIF_PUSHARG, (u32int)&arg);
}
- void setInVT(VirtualTerminal vt) {
+ void setInVT(const VirtualTerminal& vt) {
doCall(PRIF_SETINVT, vt.resId());
}
- void setOutVT(VirtualTerminal vt) {
+ void setOutVT(const VirtualTerminal& vt) {
doCall(PRIF_SETOUTVT, vt.resId());
}
bool authenticatePW(String user, String pw) {
diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h
index df44124..6576c1c 100644
--- a/Source/Library/Userland/Binding/VirtualTerminal.class.h
+++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h
@@ -7,9 +7,10 @@
#include <Kbd.iface.h>
#include <OStream.proto.h>
+#include <IStream.proto.h>
#include <WChar.class.h>
-class VirtualTerminal : public RessourceCaller, public OStream {
+class VirtualTerminal : public RessourceCaller, public OStream, public IStream {
public:
static VirtualTerminal getIn() {
u32int id = RessourceCaller::sCall(VTIF_OBJTYPE, VTIF_SGETPRINVT);
@@ -30,6 +31,9 @@ class VirtualTerminal : public RessourceCaller, public OStream {
void write(const String &s) {
doCall(VTIF_WRITE, (u32int)&s);
}
+ String read() {
+ return String::unserialize(doCall(VTIF_READLINE, 1)) += "\n";
+ }
keypress_t getKeypress(bool show = true, bool block = true) {
keypress_t* ptr = (keypress_t*)doCall(VTIF_GETKEYPRESS, (show ? 1 : 0) | (block ? 2 : 0));
return *ptr;
diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.h b/Source/Library/Userland/Syscall/RessourceCaller.class.h
index f26216d..39091ed 100644
--- a/Source/Library/Userland/Syscall/RessourceCaller.class.h
+++ b/Source/Library/Userland/Syscall/RessourceCaller.class.h
@@ -28,8 +28,8 @@ class RessourceCaller {
public:
static u32int sCall(u32int type, u8int wat, u32int a = 0, u32int b = 0, u32int c = 0, u32int d = 0);
- u32int resId() { return m_id; }
- u32int resType() { return m_type; }
+ u32int resId() const { return m_id; }
+ u32int resType() const { return m_type; }
bool valid() { return m_type != 0; }
};