1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:17:34 +00:00

Add getpwent() family of functions to LibC.

Also add a little /etc/passwd database. There's just me in there.
This commit is contained in:
Andreas Kling 2018-10-31 19:49:22 +01:00
parent 819ce91395
commit 9886b27d9c
17 changed files with 175 additions and 25 deletions

View file

@ -2,6 +2,7 @@
#define PACKED __attribute__ ((packed))
#define NORETURN __attribute__ ((noreturn))
#undef ALWAYS_INLINE
#define ALWAYS_INLINE __attribute__ ((always_inline))
#define NEVER_INLINE __attribute__ ((noinline))
#define MALLOC_ATTR __attribute__ ((malloc))

View file

@ -75,4 +75,19 @@ ByteBuffer String::toByteBuffer() const
return ByteBuffer::copy(reinterpret_cast<const byte*>(characters()), length());
}
unsigned String::toUInt(bool& ok) const
{
unsigned value = 0;
for (size_t i = 0; i < length(); ++i) {
if (characters()[i] < '0' || characters()[i] > '9') {
ok = false;
return 0;
}
value = value * 10;
value += characters()[i] - '0';
}
ok = true;
return value;
}
}

View file

@ -44,6 +44,8 @@ public:
{
}
unsigned toUInt(bool& ok) const;
String toLowercase() const
{
if (!m_impl)