/*
 * 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/>.
 */

#ifndef BIN_MOD_H
#define BIN_MOD_H

#include <bin/types.h>
#include <nanowasm/nw.h>
#include <stddef.h>

const struct bin_mod *bin_mod(const char *path);
int bin_mod_lock(struct bin_mod *m);
int bin_mod_unlock(struct bin_mod *m);
int bin_mod_move(struct bin_mod *m, struct bin *from, struct bin *to);
void bin_mod_free(struct bin_mod *m);
int bin_mod_read(void *buf, size_t n, void *user);
int bin_mod_eof(void *user);
enum nw_state bin_mod_pc(long offset, struct nw_next *next, void *user);
enum nw_state bin_mod_seek(long offset, void *user);
enum nw_state bin_mod_tell(long *offset, void *user);

extern const struct nw_mod_cfg bin_mod_cfg;

#endif
