diff options
author | Alexis211 <alexis211@gmail.com> | 2009-10-23 17:28:25 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-10-23 17:28:25 +0200 |
commit | f0556ed7f051fb101dc68752526696365bf79a11 (patch) | |
tree | 61345fbadbf76c6f12b36b48a9dfadd744f6cbbd /Source/Library | |
parent | df179c18baab4b5d85a283924fb23dfee7ea7fdb (diff) | |
download | Melon-f0556ed7f051fb101dc68752526696365bf79a11.tar.gz Melon-f0556ed7f051fb101dc68752526696365bf79a11.zip |
More work on syscalls and shell
Diffstat (limited to 'Source/Library')
-rw-r--r-- | Source/Library/Common/BasicString.class.cpp | 8 | ||||
-rw-r--r-- | Source/Library/Common/BasicString.class.h | 1 | ||||
-rw-r--r-- | Source/Library/Common/SimpleList.class.h | 1 | ||||
-rw-r--r-- | Source/Library/Common/WChar.class.h | 2 | ||||
-rw-r--r-- | Source/Library/Interface/FSNode.iface.h | 11 | ||||
-rw-r--r-- | Source/Library/Interface/Sys.iface.h | 9 | ||||
-rw-r--r-- | Source/Library/Makefile | 1 | ||||
-rw-r--r-- | Source/Library/Userland/Binding/FSNode.class.h | 12 | ||||
-rw-r--r-- | Source/Library/Userland/Binding/Sys.ns.cpp | 15 | ||||
-rw-r--r-- | Source/Library/Userland/Binding/Sys.ns.h | 9 | ||||
-rw-r--r-- | Source/Library/Userland/Syscall/RessourceCaller.class.h | 2 |
11 files changed, 69 insertions, 2 deletions
diff --git a/Source/Library/Common/BasicString.class.cpp b/Source/Library/Common/BasicString.class.cpp index b8f7eea..f3a6164 100644 --- a/Source/Library/Common/BasicString.class.cpp +++ b/Source/Library/Common/BasicString.class.cpp @@ -151,6 +151,14 @@ void BasicString<T>::clear() { } template <typename T> +bool BasicString<T>::contains(const T& chr) const { + for (u32int i = 0; i < m_length; i++) { + if (m_string[i] == chr) return true; + } + return false; +} + +template <typename T> Vector< BasicString<T> > BasicString<T>::split(T sep) const { Vector< BasicString<T> > ret; ret.push(BasicString<T>()); diff --git a/Source/Library/Common/BasicString.class.h b/Source/Library/Common/BasicString.class.h index 17055e8..21041e8 100644 --- a/Source/Library/Common/BasicString.class.h +++ b/Source/Library/Common/BasicString.class.h @@ -43,6 +43,7 @@ class BasicString { u32int size() const { return m_length; } void clear(); bool empty() const { return m_length == 0; } + bool contains(const T& chr) const; Vector< BasicString<T> > split(T sep) const; BasicString<T> substr(s32int start, u32int size); diff --git a/Source/Library/Common/SimpleList.class.h b/Source/Library/Common/SimpleList.class.h index 7b731db..8fcd834 100644 --- a/Source/Library/Common/SimpleList.class.h +++ b/Source/Library/Common/SimpleList.class.h @@ -48,6 +48,7 @@ class SimpleList { } SimpleList<T>* removeOnce(const T& value) { + if (this == 0) return 0; if (value == m_value) return delThis(); for (SimpleList<T> *iter = this; iter->next() != 0; iter = iter->next()) { if (iter->next()->v() == value) { diff --git a/Source/Library/Common/WChar.class.h b/Source/Library/Common/WChar.class.h index 3eca3d3..5d6d26b 100644 --- a/Source/Library/Common/WChar.class.h +++ b/Source/Library/Common/WChar.class.h @@ -83,7 +83,7 @@ struct WChar { return v; } - inline operator u32int () { return value; } + inline operator u32int () const { return value; } }; #endif diff --git a/Source/Library/Interface/FSNode.iface.h b/Source/Library/Interface/FSNode.iface.h index 482ebd2..fd99bab 100644 --- a/Source/Library/Interface/FSNode.iface.h +++ b/Source/Library/Interface/FSNode.iface.h @@ -1,6 +1,13 @@ #ifndef DEF_FSNODE_IFACE_H #define DEF_FSNODE_IFACE_H +enum { + NT_FILE = 1, + NT_DIRECTORY = 2, + NT_SYMLINK = 3, + NT_MOUNTPOINT = 4 +}; + #define FNIF_OBJTYPE 0x14 //S : static, GET : get, R : root, FN : fsnode @@ -10,5 +17,9 @@ #define FNIF_TYPE 0x11 #define FNIF_GETPARENT 0x12 #define FNIF_GETLENGTH 0x13 +#define FNIF_GETUID 0x14 +#define FNIF_GETGID 0x15 +#define FNIF_GETPERM 0x16 +#define FNIF_GETPATH 0x17 #endif diff --git a/Source/Library/Interface/Sys.iface.h b/Source/Library/Interface/Sys.iface.h new file mode 100644 index 0000000..c734f52 --- /dev/null +++ b/Source/Library/Interface/Sys.iface.h @@ -0,0 +1,9 @@ +#ifndef SYS_IFACE_H +#define SYS_IFACE_H + +#define SYIF_IFID 0xFF + +#define SYIF_HALT 0x1 +#define SYIF_REBOOT 0x2 + +#endif diff --git a/Source/Library/Makefile b/Source/Library/Makefile index a4b9b6a..7091116 100644 --- a/Source/Library/Makefile +++ b/Source/Library/Makefile @@ -16,6 +16,7 @@ Objects = Common/WChar.class.uo \ Common/Heap.class.uo \ Common/Heap-index.class.uo \ Common/String.class.uo \ + Userland/Binding/Sys.ns.uo \ Userland/Syscall/Syscall.wtf.uo \ Userland/Syscall/RessourceCaller.class.uo \ Userland/Start.uo diff --git a/Source/Library/Userland/Binding/FSNode.class.h b/Source/Library/Userland/Binding/FSNode.class.h index eb25782..95802a4 100644 --- a/Source/Library/Userland/Binding/FSNode.class.h +++ b/Source/Library/Userland/Binding/FSNode.class.h @@ -20,4 +20,16 @@ class FSNode : public RessourceCaller { u64int getLength() { return *((u64int*)doCall(FNIF_GETLENGTH)); } + u32int getUid() { + return doCall(FNIF_GETUID); + } + u32int getGid() { + return doCall(FNIF_GETGID); + } + u32int getPerm() { + return doCall(FNIF_GETPERM); + } + String path() { + return String::unserialize(doCall(FNIF_GETPATH)); + } }; diff --git a/Source/Library/Userland/Binding/Sys.ns.cpp b/Source/Library/Userland/Binding/Sys.ns.cpp new file mode 100644 index 0000000..7083e56 --- /dev/null +++ b/Source/Library/Userland/Binding/Sys.ns.cpp @@ -0,0 +1,15 @@ +#include <Sys.iface.h> +#include "Sys.ns.h" +#include <Syscall/RessourceCaller.class.h> + +namespace Sys { + +void halt() { + RessourceCaller::sCall(SYIF_IFID, SYIF_HALT); +} + +void reboot() { + RessourceCaller::sCall(SYIF_IFID, SYIF_REBOOT); +} + +} diff --git a/Source/Library/Userland/Binding/Sys.ns.h b/Source/Library/Userland/Binding/Sys.ns.h new file mode 100644 index 0000000..3a8426b --- /dev/null +++ b/Source/Library/Userland/Binding/Sys.ns.h @@ -0,0 +1,9 @@ +#ifndef DEF_SYS_NS_H +#define DEF_SYS_NS_H + +namespace Sys { + void halt(); + void reboot(); +} + +#endif diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.h b/Source/Library/Userland/Syscall/RessourceCaller.class.h index 85beacf..f26216d 100644 --- a/Source/Library/Userland/Syscall/RessourceCaller.class.h +++ b/Source/Library/Userland/Syscall/RessourceCaller.class.h @@ -23,11 +23,11 @@ class RessourceCaller { RessourceCaller(u32int id, u32int type); //Static call -- a call specific to a class and not an object - static u32int sCall(u32int type, u8int wat, u32int a = 0, u32int b = 0, u32int c = 0, u32int d = 0); u32int doCall(u8int call, u32int a = 0, u32int b = 0, u32int c = 0, u32int d = 0, u32int e = 0); 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; } bool valid() { return m_type != 0; } |