diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-12 00:37:26 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-16 22:57:45 +0100 |
| commit | 2ce58c995946f85666e793c4f06efff683e76ae4 (patch) | |
| tree | fbf2658bb0b0f61dadcf4ca27f997eaded78aae5 /src/drv/stderr/src | |
| parent | 5ce25ae3b5d8666d373f7d7e336546ce8508c213 (diff) | |
fixesHEADhelloworldmaster
Diffstat (limited to 'src/drv/stderr/src')
| -rw-r--r-- | src/drv/stderr/src/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | src/drv/stderr/src/free.c | 32 | ||||
| -rw-r--r-- | src/drv/stderr/src/init.c | 35 | ||||
| -rw-r--r-- | src/drv/stderr/src/update.c | 47 | ||||
| -rw-r--r-- | src/drv/stderr/src/write.c | 29 |
5 files changed, 165 insertions, 0 deletions
diff --git a/src/drv/stderr/src/CMakeLists.txt b/src/drv/stderr/src/CMakeLists.txt new file mode 100644 index 0000000..fd685c8 --- /dev/null +++ b/src/drv/stderr/src/CMakeLists.txt @@ -0,0 +1,22 @@ +# wnix, a Unix-like operating system for WebAssembly applications. +# Copyright (C) 2025 Xavier Del Campo Romero +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +target_sources(drv_stderr PRIVATE + free.c + init.c + update.c + write.c +) diff --git a/src/drv/stderr/src/free.c b/src/drv/stderr/src/free.c new file mode 100644 index 0000000..1793540 --- /dev/null +++ b/src/drv/stderr/src/free.c @@ -0,0 +1,32 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <drv/event.h> +#include <drv/stderr.h> +#include <drv/stderr/ops.h> +#include <drv/stderr/types.h> +#include <stddef.h> +#include <stdlib.h> + +void drv_stderr_free(struct drv_port *const p) +{ + if (!p) + return; + + free(p); +} diff --git a/src/drv/stderr/src/init.c b/src/drv/stderr/src/init.c new file mode 100644 index 0000000..95797d7 --- /dev/null +++ b/src/drv/stderr/src/init.c @@ -0,0 +1,35 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <drv/event.h> +#include <drv/stderr.h> +#include <drv/stderr/ops.h> +#include <drv/stderr/types.h> +#include <stddef.h> +#include <stdlib.h> + +struct drv_port *drv_stderr_init(const struct drv_event *const ev) +{ + struct drv_port *ret = NULL; + + if (!(ret = malloc(sizeof *ret))) + return NULL; + + *ret = (const struct drv_port){.ev = *ev}; + return ret; +} diff --git a/src/drv/stderr/src/update.c b/src/drv/stderr/src/update.c new file mode 100644 index 0000000..24e0cf4 --- /dev/null +++ b/src/drv/stderr/src/update.c @@ -0,0 +1,47 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <drv/event.h> +#include <drv/stderr.h> +#include <drv/stderr/ops.h> +#include <drv/stderr/types.h> +#include <stdbool.h> + +static int init(struct drv_port *const p) +{ + if (p->init) + return 0; + + const struct drv_event *const ev = &p->ev; + const struct drv_event_ops ops = + { + .write = drv_stderr_write, + .p = p + }; + + if (ev->status("stderr", &ops, true, 0666, ev->args)) + return -1; + + p->init = true; + return 0; +} + +int drv_stderr_update(struct drv_port *const p) +{ + return init(p); +} diff --git a/src/drv/stderr/src/write.c b/src/drv/stderr/src/write.c new file mode 100644 index 0000000..2f5ccf8 --- /dev/null +++ b/src/drv/stderr/src/write.c @@ -0,0 +1,29 @@ +/* + * wnix, a Unix-like operating system for WebAssembly applications. + * Copyright (C) 2025 Xavier Del Campo Romero + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include <drv/event.h> +#include <drv/stderr.h> +#include <drv/stderr/types.h> +#include <drv/stderr/ops.h> +#include <stddef.h> + +int drv_stderr_write(struct drv_port *const p, const void *const buf, + const size_t n, const struct drv_event_done *const d) +{ + return n; +} |
