|
|
26e14f |
#ifndef NTUX_DRIVER_IMPL_H
|
|
|
26e14f |
#define NTUX_DRIVER_IMPL_H
|
|
|
26e14f |
|
|
|
471bb0 |
#include <psxabi/sys_abitypes.h>
|
|
|
471bb0 |
#include <psxabi/sys_fcntl.h>
|
|
|
26e14f |
#include <psxscl/psxscl.h>
|
|
|
471bb0 |
|
|
|
26e14f |
#include <stdint.h>
|
|
|
26e14f |
#include <stdio.h>
|
|
|
26e14f |
|
|
|
26e14f |
#include <ntux/ntux.h>
|
|
|
fed26a |
#include "ntux_dprintf_impl.h"
|
|
|
26e14f |
#include "argv/argv.h"
|
|
|
26e14f |
|
|
|
2404cd |
#define NTUX_OPTV_ELEMENTS 64
|
|
|
2404cd |
|
|
|
7deda5 |
extern const struct argv_option ntux_default_options[];
|
|
|
7deda5 |
extern const struct argv_option ntux_spawn_options[];
|
|
|
7deda5 |
extern const struct argv_option ntux_strace_options[];
|
|
|
80f43a |
extern const struct argv_option ntux_chmod_options[];
|
|
|
dcb685 |
extern const struct argv_option ntux_aceit_options[];
|
|
|
8ec5ce |
extern const struct argv_option ntux_fspath_options[];
|
|
|
b824c9 |
extern const struct argv_option ntux_bridge_options[];
|
|
|
b824c9 |
|
|
|
b824c9 |
/* bridge functionality */
|
|
|
b824c9 |
#define NTUX_EXE_SUFFIX ".exe"
|
|
|
b824c9 |
#define NTUX_EXE_SUFFIX_LEN (4)
|
|
|
b824c9 |
#define NTUX_MAX_PATH_UTF8 (32768 / 2 * 3)
|
|
|
b824c9 |
#define NTUX_MAX_PATH NTUX_MAX_PATH_UTF8
|
|
|
b824c9 |
|
|
|
26e14f |
|
|
|
26e14f |
enum app_tags {
|
|
|
26e14f |
TAG_HELP,
|
|
|
26e14f |
TAG_VERSION,
|
|
|
6a7c02 |
TAG_CMD,
|
|
|
9682ca |
TAG_LOADER,
|
|
|
9682ca |
TAG_LOGFILE,
|
|
|
80f43a |
TAG_VERBOSE,
|
|
|
80f43a |
TAG_SILENT,
|
|
|
80f43a |
TAG_RECURSIVE,
|
|
|
80f43a |
TAG_STRMODE,
|
|
|
d7daca |
TAG_REFOBJ,
|
|
|
80f43a |
TAG_CHANGES,
|
|
|
de8f1c |
TAG_OWNER,
|
|
|
de8f1c |
TAG_GROUP,
|
|
|
80f43a |
TAG_ROOTED,
|
|
|
80f43a |
TAG_ROOTLESS,
|
|
|
dcb685 |
TAG_DUMP,
|
|
|
8ec5ce |
TAG_SYNTAX,
|
|
|
8ec5ce |
TAG_RPATH,
|
|
|
8ec5ce |
TAG_APATH,
|
|
|
8ec5ce |
TAG_NPATH,
|
|
|
8ec5ce |
TAG_DPATH,
|
|
|
b824c9 |
TAG_INTERP,
|
|
|
b824c9 |
TAG_SCRIPT,
|
|
|
b824c9 |
TAG_OPTARG,
|
|
|
b824c9 |
TAG_CWDPATH,
|
|
|
b824c9 |
TAG_ABSPATH,
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
26e14f |
struct ntux_driver_ctx_impl {
|
|
|
26e14f |
struct ntux_common_ctx cctx;
|
|
|
26e14f |
struct ntux_driver_ctx ctx;
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
26e14f |
struct __psx_context xctx;
|
|
|
da20d8 |
const struct ntux_unit_ctx *euctx;
|
|
|
26e14f |
const char * eunit;
|
|
|
b824c9 |
char * interp;
|
|
|
26e14f |
struct ntux_error_info ** errinfp;
|
|
|
26e14f |
struct ntux_error_info ** erricap;
|
|
|
26e14f |
struct ntux_error_info * erriptr[64];
|
|
|
26e14f |
struct ntux_error_info erribuf[64];
|
|
|
da20d8 |
char errsbuf[28];
|
|
|
da20d8 |
int errcode;
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
da20d8 |
|
|
|
da20d8 |
static inline struct ntux_driver_ctx_impl * ntux_get_driver_ictx(const struct ntux_driver_ctx * dctx)
|
|
|
da20d8 |
{
|
|
|
da20d8 |
uintptr_t addr;
|
|
|
da20d8 |
|
|
|
da20d8 |
if (dctx) {
|
|
|
da20d8 |
addr = (uintptr_t)dctx - offsetof(struct ntux_driver_ctx_impl,ctx);
|
|
|
da20d8 |
return (struct ntux_driver_ctx_impl *)addr;
|
|
|
da20d8 |
}
|
|
|
da20d8 |
|
|
|
da20d8 |
return 0;
|
|
|
da20d8 |
}
|
|
|
da20d8 |
|
|
|
da20d8 |
static inline void ntux_driver_set_ectx(
|
|
|
da20d8 |
const struct ntux_driver_ctx * dctx,
|
|
|
da20d8 |
const struct ntux_unit_ctx * uctx,
|
|
|
da20d8 |
const char * unit)
|
|
|
da20d8 |
{
|
|
|
da20d8 |
struct ntux_driver_ctx_impl * ictx;
|
|
|
da20d8 |
|
|
|
da20d8 |
ictx = ntux_get_driver_ictx(dctx);
|
|
|
da20d8 |
ictx->euctx = uctx;
|
|
|
da20d8 |
ictx->eunit = unit;
|
|
|
da20d8 |
}
|
|
|
da20d8 |
|
|
|
ec0005 |
static inline int ntux_driver_fdin(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdin;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fdout(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdout;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fderr(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fderr;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fdlog(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdlog;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fdcwd(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fdcwd;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
ec0005 |
static inline int ntux_driver_fddst(const struct ntux_driver_ctx * dctx)
|
|
|
ec0005 |
{
|
|
|
ec0005 |
struct ntux_fd_ctx fdctx;
|
|
|
ec0005 |
ntux_get_driver_fdctx(dctx,&fdctx);
|
|
|
ec0005 |
return fdctx.fddst;
|
|
|
ec0005 |
}
|
|
|
ec0005 |
|
|
|
26e14f |
#endif
|