summaryrefslogtreecommitdiff
path: root/Source/Applications/Shell/Applets
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-12-20 20:03:22 +0100
committerAlexis211 <alexis211@gmail.com>2009-12-20 20:03:22 +0100
commit09353da6e91a0968ae24d4b4d97ed434520e6217 (patch)
tree016694d12e9dfebc773cef629eb56556d0024b22 /Source/Applications/Shell/Applets
parent247070cc7e5ae117fd0d1b551fafdf5c13f0dd6b (diff)
parent18454dc8be12827a84c2ebc58aa5d31bb44e1e6a (diff)
downloadMelon-09353da6e91a0968ae24d4b4d97ed434520e6217.tar.gz
Melon-09353da6e91a0968ae24d4b4d97ed434520e6217.zip
Merge branch 'framework'
Conflicts: .gitignore
Diffstat (limited to 'Source/Applications/Shell/Applets')
-rwxr-xr-xSource/Applications/Shell/Applets/rot13bin0 -> 73404 bytes
-rw-r--r--Source/Applications/Shell/Applets/rot13.cpp30
2 files changed, 30 insertions, 0 deletions
diff --git a/Source/Applications/Shell/Applets/rot13 b/Source/Applications/Shell/Applets/rot13
new file mode 100755
index 0000000..0399a6f
--- /dev/null
+++ b/Source/Applications/Shell/Applets/rot13
Binary files differ
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;
+}
+