diff options
author | Alexis211 <alexis211@gmail.com> | 2009-12-20 20:03:22 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-12-20 20:03:22 +0100 |
commit | 09353da6e91a0968ae24d4b4d97ed434520e6217 (patch) | |
tree | 016694d12e9dfebc773cef629eb56556d0024b22 /Source/Applications/Shell | |
parent | 247070cc7e5ae117fd0d1b551fafdf5c13f0dd6b (diff) | |
parent | 18454dc8be12827a84c2ebc58aa5d31bb44e1e6a (diff) | |
download | Melon-09353da6e91a0968ae24d4b4d97ed434520e6217.tar.gz Melon-09353da6e91a0968ae24d4b4d97ed434520e6217.zip |
Merge branch 'framework'
Conflicts:
.gitignore
Diffstat (limited to 'Source/Applications/Shell')
-rwxr-xr-x | Source/Applications/Shell/Applets/rot13 | bin | 0 -> 73404 bytes | |||
-rw-r--r-- | Source/Applications/Shell/Applets/rot13.cpp | 30 | ||||
-rw-r--r-- | Source/Applications/Shell/Makefile | 8 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell-fs.class.cpp | 4 | ||||
-rw-r--r-- | Source/Applications/Shell/Shell.class.cpp | 5 | ||||
-rw-r--r-- | Source/Applications/Shell/main.cpp | 5 |
6 files changed, 42 insertions, 10 deletions
diff --git a/Source/Applications/Shell/Applets/rot13 b/Source/Applications/Shell/Applets/rot13 Binary files differnew file mode 100755 index 0000000..0399a6f --- /dev/null +++ b/Source/Applications/Shell/Applets/rot13 diff --git a/Source/Applications/Shell/Applets/rot13.cpp b/Source/Applications/Shell/Applets/rot13.cpp new file mode 100644 index 0000000..e5638b8 --- /dev/null +++ b/Source/Applications/Shell/Applets/rot13.cpp @@ -0,0 +1,30 @@ +#include <App/StreamApp.proto.h> + +class rot13 : public StreamApp { + public: + rot13() : StreamApp("rot13", "Cat a file, but ROT13 it") {} + int run(); +}; + +APP(rot13); + +int rot13::run() { + while (!in->eof()) { + String s = in->get(); + if (in->eof() && s.empty()) break; + for (u32int i = 0; i < s.size(); i++) { + WChar &c = s[i]; + if (c >= WChar('A') and c <= WChar('Z')) { + c += 13; + if (c > WChar('Z')) c -= 26; + } + if (c >= WChar('a') and c <= WChar('z')) { + c += 13; + if (c > WChar('z')) c -= 26; + } + } + *out << s << ENDL; + } + return 0; +} + diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile index d546a15..e972dfb 100644 --- a/Source/Applications/Shell/Makefile +++ b/Source/Applications/Shell/Makefile @@ -10,7 +10,9 @@ Objects = Shell.class.o \ Shell-fs.class.o OutFile = Shell -all: $(OutFile) +Applets = Applets/rot13 + +all: $(OutFile) $(Applets) echo "* Done with $(OutFile)." rebuild: mrproper all @@ -19,6 +21,10 @@ $(OutFile): $(Objects) echo "* Linking $@..." $(LD) $(LDFLAGS) $^ -o $@ +Applets/%: Applets/%.o + echo "* Linking $@..." + $(LD) $(LDFLAGS) $^ -o $@ -Map $@.map + %.o: %.cpp echo "* Compiling $<..." $(CXX) $(CXXFLAGS) -c $< -o $@ diff --git a/Source/Applications/Shell/Shell-fs.class.cpp b/Source/Applications/Shell/Shell-fs.class.cpp index 150b877..30faaf7 100644 --- a/Source/Applications/Shell/Shell-fs.class.cpp +++ b/Source/Applications/Shell/Shell-fs.class.cpp @@ -28,11 +28,11 @@ void Shell::ls(Vector<String>& args) { if (((p >> i) & 1) == 0) perm[8 - i] = "-"; } if (n.type() == NT_FILE) { - outvt << " FILE " << perm << " " << n.getName(); + outvt << " FILE " << perm << " " << n.getName() << FLUSH; outvt.setCsrCol(30); outvt << (s32int)n.getLength() << " bytes.\n"; } else if (n.type() == NT_DIRECTORY) { - outvt << " DIR " << perm << " " << n.getName() << "/"; + outvt << " DIR " << perm << " " << n.getName() << "/" << FLUSH; outvt.setCsrCol(30); outvt << (s32int)n.getLength() << " items.\n"; } diff --git a/Source/Applications/Shell/Shell.class.cpp b/Source/Applications/Shell/Shell.class.cpp index 3d406c8..4283b30 100644 --- a/Source/Applications/Shell/Shell.class.cpp +++ b/Source/Applications/Shell/Shell.class.cpp @@ -25,8 +25,9 @@ int Shell::run() { cwd = FS::cwdNode(); while (1) { - outvt << "{" << cwd.getName() << "}: "; - String s = invt.readLine(); + outvt << "{" << cwd.getName() << "}: " << FLUSH; + String s = invt.get(); + if (s.contains(EOF)) return 0; if (s.empty()) continue; while (s[0] == WChar(" ") or s[0] == WChar("\t")) { s = s.substr(1, s.size() - 1); diff --git a/Source/Applications/Shell/main.cpp b/Source/Applications/Shell/main.cpp deleted file mode 100644 index 66c4269..0000000 --- a/Source/Applications/Shell/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "Shell.ns.h" - -int main(const Vector<String>& args) { - return Shell::run(); -} |