XenevaOS
Loading...
Searching...
No Matches
xe_script.h
Go to the documentation of this file.
1
34#ifndef XE_SCRIPT_H
35#define XE_SCRIPT_H
36
37#include <stdbool.h>
38#include <stdint.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/* Run a script file. argv[0] is the script name, argv[1..] are $1.. / %1..
45 * Returns the script's exit status (127 if the file can't be opened). */
46int XsRunFile(const char* path, int argc, char** argv);
47
48/* Run script text that is already in memory. */
49int XsRunText(const char* text, int len, bool bat, int argc, char** argv);
50
51/* true if the name ends in .sh (*isBat=false) or .bat/.cmd (*isBat=true) */
52bool XsScriptKind(const char* name, bool* isBat);
53
54/* Bumped by xesh's SIGINT handler, polled by every loop. */
55extern volatile int g_interrupted;
56
57/* ------------------------------------------------------------------ */
58/* Host hooks, implemented by xesh */
59/* ------------------------------------------------------------------ */
60
61/* Run a shell builtin or external program. fd < 0 means "inherit the
62 * shell's own stdin/stdout/stderr". Returns the exit status (127 = not found). */
63int XsHostRun(int argc, char** argv, int fdIn, int fdOut, int fdErr);
64
65const char* XsHostCwd(void);
66
67/* mode: 0 = read, 1 = write (create + TRUNCATE), 2 = append. Returns fd or -1. */
68int XsHostOpen(const char* path, int mode);
69void XsHostClose(int fd);
70int XsHostRead(int fd, void* buf, int n);
71int XsHostWrite(int fd, const void* buf, int n);
72
73/* 1 if the path exists; *isDir set when non-NULL */
74int XsHostExists(const char* path, int* isDir);
75void XsHostRemove(const char* path); /* may be a no-op */
76
77/* Console input. ReadLine echoes and returns the length (-1 on EOF).
78 * ReadKey returns ONE raw byte with no echo and no line buffering (-1 on EOF). */
79int XsHostReadLine(char* buf, int max);
80int XsHostReadKey(void);
81
82void XsHostSetEnv(const char* name, const char* value);
83void XsHostSleepMs(int ms);
84void XsHostWinSize(int* cols, int* rows); /* leave untouched when unknown */
85
86#ifdef __cplusplus
87}
88#endif
89#endif
struct drm_crtc struct drm_plane struct drm_plane const struct drm_crtc_funcs const char * name
Definition drm_crtc.h:1242
size_t len
Definition initial.c:23
#define max(a, b)
Definition minmax.h:28
Definition file.h:140
Definition path.h:8
#define mode(x)
__virtio16 rows
Definition virtio_console.h:3
__virtio16 cols
Definition virtio_console.h:1
int XsHostExists(const char *path, int *isDir)
Definition main.cpp:934
void XsHostClose(int fd)
Definition main.cpp:912
void XsHostSetEnv(const char *name, const char *value)
Definition main.cpp:879
int XsHostRun(int argc, char **argv, int fdIn, int fdOut, int fdErr)
Definition main.cpp:1051
void XsHostRemove(const char *path)
Definition main.cpp:947
int XsHostReadLine(char *buf, int max)
Definition main.cpp:969
int XsRunText(const char *text, int len, bool bat, int argc, char **argv)
Definition xe_script.cpp:4359
void XsHostWinSize(int *cols, int *rows)
Definition main.cpp:893
int XsRunFile(const char *path, int argc, char **argv)
Definition xe_script.cpp:4426
int XsHostWrite(int fd, const void *buf, int n)
Definition main.cpp:927
int XsHostOpen(const char *path, int mode)
Definition main.cpp:900
bool XsScriptKind(const char *name, bool *isBat)
Definition xe_script.cpp:4253
const char * XsHostCwd(void)
Definition main.cpp:872
int XsHostReadKey(void)
Definition main.cpp:954
int XsHostRead(int fd, void *buf, int n)
Definition main.cpp:920
void XsHostSleepMs(int ms)
Definition main.cpp:886
volatile int g_interrupted
Definition main.cpp:74