From e70b7c569ba13a68aba1c2b127811e61ac88a902 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Wed, 21 Oct 2009 19:11:53 +0200 Subject: Started working on user managment --- Source/Library/Common/BasicString.class.cpp | 34 ++++++++++++------------- Source/Library/Common/String.class.cpp | 1 + Source/Library/Interface/Process.iface.h | 3 +++ Source/Library/Userland/Binding/Process.class.h | 10 ++++++++ 4 files changed, 31 insertions(+), 17 deletions(-) (limited to 'Source/Library') diff --git a/Source/Library/Common/BasicString.class.cpp b/Source/Library/Common/BasicString.class.cpp index ceab60b..b8f7eea 100644 --- a/Source/Library/Common/BasicString.class.cpp +++ b/Source/Library/Common/BasicString.class.cpp @@ -1,8 +1,8 @@ #include -#define FREE if (m_string != 0) delete m_string; -#define ALLOC m_string = new T[m_length]; -#define VRFY if (m_length == 0) { m_string = NULL; return; } +#define BS_FREE if (m_string != 0) delete m_string; +#define BS_ALLOC m_string = new T[m_length]; +#define BS_VRFY if (m_length == 0) { m_string = NULL; return; } using namespace CMem; @@ -32,33 +32,33 @@ BasicString::BasicString(const T value, u32int count) { template BasicString::~BasicString() { - FREE; + BS_FREE; } template void BasicString::affect(const BasicString &other) { - FREE; + BS_FREE; m_length = other.m_length; - VRFY; - ALLOC; + BS_VRFY; + BS_ALLOC; memcpy((u8int*)m_string, (u8int*)(other.m_string), m_length * sizeof(T)); } template void BasicString::affect(const T* string, u32int length) { - FREE; + BS_FREE; m_length = length; - VRFY; - ALLOC; + BS_VRFY; + BS_ALLOC; memcpy((u8int*)string, (u8int*)string, m_length * sizeof(T)); } template void BasicString::affect(const T value, u32int count) { - FREE; + BS_FREE; m_length = count; - VRFY; - ALLOC; + BS_VRFY; + BS_ALLOC; for (u32int i = 0; i < count; i++) { m_string[i] = value; } @@ -91,7 +91,7 @@ BasicString &BasicString::append(const BasicString &other) { for (u32int i = 0; i < other.m_length; i++) { newdata[i + m_length] = other.m_string[i]; } - FREE; + BS_FREE; m_string = newdata; m_length += other.m_length; return *this; @@ -106,7 +106,7 @@ BasicString &BasicString::append(const T* string, u32int length) { for (u32int i = 0; i < length; i++) { newdata[i + m_length] = string[i]; } - FREE; + BS_FREE; m_string = newdata; m_length += length; return *this; @@ -118,7 +118,7 @@ BasicString &BasicString::append(const T other) { for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } - FREE; + BS_FREE; m_string = newdata; m_string[m_length] = other; m_length++; @@ -145,7 +145,7 @@ BasicString BasicString::concat(const T other) const { template void BasicString::clear() { - FREE; + BS_FREE; m_string = 0; m_length = 0; } diff --git a/Source/Library/Common/String.class.cpp b/Source/Library/Common/String.class.cpp index ac0eba0..63ff837 100644 --- a/Source/Library/Common/String.class.cpp +++ b/Source/Library/Common/String.class.cpp @@ -50,6 +50,7 @@ String String::number(s32int number) { } String String::unserialize(u32int w) { + if (w == (u32int) - 1) return String(); u32int* a = (u32int*)w; String ret; ret.m_length = a[0]; diff --git a/Source/Library/Interface/Process.iface.h b/Source/Library/Interface/Process.iface.h index 2126dc6..b79639d 100644 --- a/Source/Library/Interface/Process.iface.h +++ b/Source/Library/Interface/Process.iface.h @@ -9,5 +9,8 @@ #define PRIF_EXIT 0x01 #define PRIF_ALLOCPAGE 0x02 #define PRIF_FREEPAGE 0x03 +#define PRIF_GETPID 0x04 +#define PRIF_GETPPID 0x05 +#define PRIF_GETCMDLINE 0x06 #endif diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h index 00afe27..935bb39 100644 --- a/Source/Library/Userland/Binding/Process.class.h +++ b/Source/Library/Userland/Binding/Process.class.h @@ -1,6 +1,7 @@ #include #include +#include class Process : public RessourceCaller { public: @@ -19,4 +20,13 @@ class Process : public RessourceCaller { void freePage(u32int pos) { doCall(PRIF_FREEPAGE, pos); } + u32int getPid() { + return doCall(PRIF_GETPID); + } + u32int getPpid() { + return doCall(PRIF_GETPPID); + } + String getCmdline() { + return String::unserialize(doCall(PRIF_GETCMDLINE)); + } }; -- cgit v1.2.3