2022-06-27 19:36:56 +02:00
|
|
|
/*
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
UMKa - User-Mode KolibriOS developer tools
|
|
|
|
umka_shell - the shell
|
|
|
|
|
2023-01-17 01:49:11 +01:00
|
|
|
Copyright (C) 2020-2023 Ivan Baravy <dunkaist@gmail.com>
|
2022-06-27 19:36:56 +02:00
|
|
|
*/
|
|
|
|
|
2020-05-10 06:21:49 +02:00
|
|
|
#ifndef SHELL_H_INCLUDED
|
|
|
|
#define SHELL_H_INCLUDED
|
|
|
|
|
2023-02-03 05:39:32 +01:00
|
|
|
#include <stdatomic.h>
|
2020-05-10 06:21:49 +02:00
|
|
|
#include <stdio.h>
|
2023-02-01 19:30:44 +01:00
|
|
|
#include <pthread.h>
|
2023-01-17 01:49:11 +01:00
|
|
|
#include "umka.h"
|
2023-02-01 19:30:44 +01:00
|
|
|
#include "umkaio.h"
|
2023-02-05 00:41:26 +01:00
|
|
|
#include "optparse/optparse.h"
|
2020-05-10 06:21:49 +02:00
|
|
|
|
2022-05-31 15:43:41 +02:00
|
|
|
enum shell_var_type {
|
|
|
|
SHELL_VAR_SINT,
|
|
|
|
SHELL_VAR_UINT,
|
|
|
|
SHELL_VAR_POINTER,
|
|
|
|
};
|
|
|
|
|
2023-01-17 01:49:11 +01:00
|
|
|
#define SHELL_LOG_NONREPRODUCIBLE 0
|
|
|
|
#define SHELL_LOG_REPRODUCIBLE 1
|
|
|
|
|
2022-05-31 15:43:41 +02:00
|
|
|
#define SHELL_VAR_NAME_LEN 16
|
|
|
|
|
|
|
|
struct shell_var {
|
|
|
|
struct shell_var *next;
|
|
|
|
enum shell_var_type type;
|
|
|
|
char name[SHELL_VAR_NAME_LEN];
|
|
|
|
union {ssize_t sint; size_t uint; uint64_t uint64; void *ptr;} value;
|
|
|
|
};
|
|
|
|
|
2022-05-29 17:17:00 +02:00
|
|
|
struct shell_ctx {
|
2023-01-18 09:29:08 +01:00
|
|
|
const struct umka_ctx *umka;
|
2023-02-06 17:01:37 +01:00
|
|
|
const struct umka_io *io;
|
2022-05-29 17:17:00 +02:00
|
|
|
int reproducible;
|
2022-05-30 00:08:15 +02:00
|
|
|
const char *hist_file;
|
2022-05-31 15:43:41 +02:00
|
|
|
struct shell_var *var;
|
2023-01-30 07:24:23 +01:00
|
|
|
FILE *fin;
|
|
|
|
FILE *fout;
|
2023-02-03 05:39:32 +01:00
|
|
|
const atomic_int *running;
|
2023-02-01 19:30:44 +01:00
|
|
|
pthread_cond_t cmd_done;
|
|
|
|
pthread_mutex_t cmd_mutex;
|
2023-02-02 17:25:20 +01:00
|
|
|
struct optparse opts;
|
2022-05-29 17:17:00 +02:00
|
|
|
};
|
|
|
|
|
2023-01-17 01:49:11 +01:00
|
|
|
struct shell_ctx *
|
2023-02-06 17:01:37 +01:00
|
|
|
shell_init(const int reproducible, const char *hist_file,
|
|
|
|
const struct umka_ctx *umka, const struct umka_io *io, FILE *fin);
|
2023-01-17 01:49:11 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
shell_close(struct shell_ctx *shell);
|
|
|
|
|
|
|
|
void *
|
|
|
|
run_test(struct shell_ctx *ctx);
|
2020-05-10 06:21:49 +02:00
|
|
|
|
2023-01-31 03:38:48 +01:00
|
|
|
void
|
|
|
|
umka_run_cmd_sync(struct shell_ctx *ctx);
|
|
|
|
|
2020-05-10 06:21:49 +02:00
|
|
|
#endif // SHELL_H_INCLUDED
|