summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2021-05-26 09:39:57 +0200
committerLinus Groh <mail@linusgroh.de>2021-05-30 14:56:50 +0100
commitcd970928a0779219655d5bdaf46cf32f8c865b23 (patch)
tree2257bd65c9e8a721b64a525e67da3f00006e123a /Userland/Libraries
parenta3b4e43dd86de12c1e2ca403f0535eaa3ef21497 (diff)
downloadserenity-cd970928a0779219655d5bdaf46cf32f8c865b23.zip
LibC: Implement getprogname and setprogname
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibC/stdlib.cpp19
-rw-r--r--Userland/Libraries/LibC/stdlib.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp
index 5449b9814d..8c2e5545d5 100644
--- a/Userland/Libraries/LibC/stdlib.cpp
+++ b/Userland/Libraries/LibC/stdlib.cpp
@@ -373,6 +373,25 @@ int putenv(char* new_var)
return 0;
}
+static const char* __progname = NULL;
+
+const char* getprogname()
+{
+ return __progname;
+}
+
+void setprogname(const char* progname)
+{
+ for (int i = strlen(progname) - 1; i >= 0; i--) {
+ if (progname[i] == '/') {
+ __progname = progname + i + 1;
+ return;
+ }
+ }
+
+ __progname = progname;
+}
+
double strtod(const char* str, char** endptr)
{
// Parse spaces, sign, and base
diff --git a/Userland/Libraries/LibC/stdlib.h b/Userland/Libraries/LibC/stdlib.h
index c63e7eebc5..c9eae34db1 100644
--- a/Userland/Libraries/LibC/stdlib.h
+++ b/Userland/Libraries/LibC/stdlib.h
@@ -31,6 +31,8 @@ int putenv(char*);
int unsetenv(const char*);
int clearenv(void);
int setenv(const char* name, const char* value, int overwrite);
+const char* getprogname();
+void setprogname(const char*);
int atoi(const char*);
long atol(const char*);
long long atoll(const char*);