2020-01-27 23:54:57 +01:00
|
|
|
/*
|
2020-02-19 02:08:03 +01:00
|
|
|
umka_shell: User-Mode KolibriOS developer tools, the shell
|
2020-01-27 23:54:57 +01:00
|
|
|
Copyright (C) 2018--2020 Ivan Baravy <dunkaist@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-05-14 09:54:05 +02:00
|
|
|
#include <inttypes.h>
|
2019-10-30 22:54:12 +01:00
|
|
|
#include <limits.h>
|
2020-05-10 06:21:49 +02:00
|
|
|
#include <stdio.h>
|
2018-04-23 12:09:46 +02:00
|
|
|
#include <stdlib.h>
|
2017-11-02 21:41:11 +01:00
|
|
|
#include <string.h>
|
2022-05-29 17:17:00 +02:00
|
|
|
#include "optparse.h"
|
2020-05-10 06:21:49 +02:00
|
|
|
#include "shell.h"
|
2020-05-07 03:57:01 +02:00
|
|
|
#include "umka.h"
|
2019-10-09 01:35:47 +02:00
|
|
|
#include "trace.h"
|
2020-02-21 00:18:40 +01:00
|
|
|
|
2021-11-02 10:46:36 +01:00
|
|
|
#define UMKA_DEFAULT_DISPLAY_WIDTH 400
|
|
|
|
#define UMKA_DEFAULT_DISPLAY_HEIGHT 300
|
|
|
|
|
2020-10-17 04:13:18 +02:00
|
|
|
int
|
|
|
|
main(int argc, char **argv) {
|
2022-05-29 17:17:00 +02:00
|
|
|
(void)argc;
|
2020-05-11 05:38:44 +02:00
|
|
|
umka_tool = UMKA_SHELL;
|
2020-03-07 23:09:36 +01:00
|
|
|
const char *usage = \
|
2022-05-29 17:17:00 +02:00
|
|
|
"usage: umka_shell [-i infile] [-o outfile] [-r] [-c] [-h]\n"
|
|
|
|
" -i infile file with commands\n"
|
|
|
|
" -o outfile file for logs\n"
|
|
|
|
" -r reproducible logs (without pointers and datetime)\n"
|
2020-05-10 06:21:49 +02:00
|
|
|
" -c collect coverage";
|
2022-05-29 17:17:00 +02:00
|
|
|
const char *infile = NULL, *outfile = NULL;
|
|
|
|
struct shell_ctx ctx = {.fin = stdin, .fout = stdout, .reproducible = 0};
|
2020-02-18 03:30:16 +01:00
|
|
|
|
2021-11-02 10:46:36 +01:00
|
|
|
kos_boot.bpp = 32;
|
|
|
|
kos_boot.x_res = UMKA_DEFAULT_DISPLAY_WIDTH;
|
|
|
|
kos_boot.y_res = UMKA_DEFAULT_DISPLAY_HEIGHT;
|
|
|
|
kos_boot.pitch = UMKA_DEFAULT_DISPLAY_WIDTH*4; // 32bpp
|
2018-04-26 11:17:55 +02:00
|
|
|
|
2022-05-29 17:17:00 +02:00
|
|
|
struct optparse options;
|
|
|
|
int opt;
|
|
|
|
optparse_init(&options, argv);
|
2020-05-10 06:21:49 +02:00
|
|
|
|
2022-05-29 17:17:00 +02:00
|
|
|
while ((opt = optparse(&options, "i:o:rc")) != -1) {
|
|
|
|
switch (opt) {
|
|
|
|
case 'i':
|
|
|
|
infile = options.optarg;
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
outfile = options.optarg;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
ctx.reproducible = 1;
|
|
|
|
break;
|
|
|
|
case 'c':
|
2020-03-09 22:03:57 +01:00
|
|
|
coverage = 1;
|
2022-05-29 17:17:00 +02:00
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
fputs(usage, stderr);
|
|
|
|
exit(0);
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "bad option: %c\n", opt);
|
|
|
|
fputs(usage, stderr);
|
2021-11-02 10:46:36 +01:00
|
|
|
exit(1);
|
2020-03-08 03:02:53 +01:00
|
|
|
}
|
|
|
|
}
|
2022-05-29 17:17:00 +02:00
|
|
|
if (infile && !(ctx.fin = fopen(infile, "r"))) {
|
|
|
|
fprintf(stderr, "[!] can't open file for reading: %s", infile);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (outfile && !(ctx.fout = fopen(outfile, "w"))) {
|
|
|
|
fprintf(stderr, "[!] can't open file for writing: %s", outfile);
|
|
|
|
exit(1);
|
|
|
|
}
|
2020-03-08 03:02:53 +01:00
|
|
|
|
2020-03-09 22:03:57 +01:00
|
|
|
if (coverage)
|
2019-10-30 22:54:12 +01:00
|
|
|
trace_begin();
|
2020-03-09 22:03:57 +01:00
|
|
|
|
2022-05-29 17:17:00 +02:00
|
|
|
run_test(&ctx);
|
2019-10-30 22:54:12 +01:00
|
|
|
|
2020-03-09 22:03:57 +01:00
|
|
|
if (coverage)
|
2019-10-30 22:54:12 +01:00
|
|
|
trace_end();
|
|
|
|
|
2017-10-18 22:19:53 +02:00
|
|
|
return 0;
|
|
|
|
}
|