/*
 * 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/drv.h>
#include <drv/tree.h>
#include <drv/null.h>
#include <drv/stderr.h>
#include <drv/stdin.h>
#include <drv/stdout.h>
#include <drv/tty.h>
#include <drv/port.h>
#include <stddef.h>

struct drv_port *(*const drv_tree_init[])(const struct drv_event *) =
{
#if DRV_PS1
    drv_ps1_init,
#endif
    drv_tty_init,
    drv_null_init,
    drv_stderr_init,
    drv_stdin_init,
    drv_stdout_init
};

enum {N = sizeof drv_tree_init / sizeof *drv_tree_init};

int (*const drv_tree_update[N])(struct drv_port *) =
{
#if DRV_PS1
    drv_ps1_update,
#endif
    drv_tty_update,
    drv_null_update,
    drv_stderr_update,
    drv_stdin_update,
    drv_stdout_update
};

void (*const drv_tree_free[N])(struct drv_port *) =
{
#if DRV_PS1
    drv_ps1_free,
#endif
    drv_tty_free,
    drv_null_free,
    drv_stderr_free,
    drv_stdin_free,
    drv_stdout_free
};

const size_t drv_tree_n = N;
