From 0ee6d9274e221a6ad709f35b6808b696ea4157a8 Mon Sep 17 00:00:00 2001 From: Vasco Costa Date: Sat, 23 Mar 2024 09:20:13 +0000 Subject: [PATCH] Add tail --- README.md | 8 +++ tail/.gitignore | 6 ++ tail/README.md | 7 +++ tail/bin/tail.bin | Bin 0 -> 13760 bytes tail/bin/tail.map | 157 ++++++++++++++++++++++++++++++++++++++++++++++ tail/makefile | 17 +++++ tail/src/tail.c | 93 +++++++++++++++++++++++++++ 7 files changed, 288 insertions(+) create mode 100644 tail/.gitignore create mode 100644 tail/README.md create mode 100644 tail/bin/tail.bin create mode 100644 tail/bin/tail.map create mode 100644 tail/makefile create mode 100644 tail/src/tail.c diff --git a/README.md b/README.md index a736e78..378da1d 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,14 @@ Usage: %s [-hn min-len] filename -n strings at least min-len long (default: 4) ``` +### tail + +``` +Usage: %s [-hn] filename +-h show this help message +-n print the last n lines (default: 10) +``` + ### wc ``` diff --git a/tail/.gitignore b/tail/.gitignore new file mode 100644 index 0000000..75ceac6 --- /dev/null +++ b/tail/.gitignore @@ -0,0 +1,6 @@ +obj/ +src/gfx/*.c +src/gfx/*.h +src/gfx/*.8xv +.DS_Store +convimg.out diff --git a/tail/README.md b/tail/README.md new file mode 100644 index 0000000..03ab638 --- /dev/null +++ b/tail/README.md @@ -0,0 +1,7 @@ +# The tail utility for MOS on the Agon Light computer + +``` +Usage: %s [-hn] filename +-h show this help message +-n print the last n lines (default: 10) +``` diff --git a/tail/bin/tail.bin b/tail/bin/tail.bin new file mode 100644 index 0000000000000000000000000000000000000000..e3dd722f3f3364ad3fc0c592742e705e1664c191 GIT binary patch literal 13760 zcmbVz4Rll2mF|^oB+J*fEE~`jKlYUsA{mb@3zxtAD2bau+9Z%NKz;}i+&JJsY=WTz z94mC(@E&W@#BZ8aX3|-0GwqO0$g30jT;+wS8zB^8>#0PUr#D02I+IZ|H>*^=%(82T zqRExtx6i$jMR3-vd5V$lJwN;Gv-duG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-vkcq+hLAia7@_?mKNcu zU=E0L6;{qs$ktf{RdbXFs&6QyI~NvasR-C^sM1Z^Q5mS2qbg84S7F@^g$~fS2Ik*T zuCUeCzycKO=igW+3+V;wB)bSWwq5LPE4kUkOEw0iZ5IQkHq-ERLbMQR1n|J3Z5Q=J z{#jcn)GeN?j)x2Mg#wn`z?sDyaNbY|SwJgG3*~`&JSuc0Wp+$xsG-onP-j5?dYnIH$=Tvzf)3@`); z2S{u7@-vNwI~)k$93gWgMWJ-^k8L_AY?#6c4X}{!s=kv%v+_2$gfi^B*(P{*%LLAD zah*rtN3K^zDFuK&ks`*%$mc5ia0T&giRtzGXAQFY3T7 z6SNz06&M3-zYE|4B*+b5F^(=%beG0AMgOA(KnL#G0|HGoOCND@n8_>L zb8Cc_(32(&OiE_qpgUdTpRAx8et6IGV+Guv!i|F4R?^+8l4irU#wXCwLlxK+NZIe; zwO^uI{XX4lgW+PSS|L?jT}0mQznX-8i*}K~ZT4-7T8w5{!{}yA(HAxPMn?v8EuRo(N{2ww{nE%<& z0b!RA6b=M;3CBu|&zGeEun$sAD+m+-dZQ_o-e++ zKrCG#E?pqrQ}p)_3&f^{;#U`nw=EQJc8cvz@nNTUfd8Qcf1Q%J4ZS3Bl_YN9e<;D< zl0{<60`as{{H0U;g#VcqQQ?NWHVErBd_~x_aiiefu;u>yn}iBsOW&^DUAM@~`s8gb zdwRCZPj>I?>e=;lS5<|utWRj!Bee7goA-3dJ%^s|>^dO#J}K|(?&<22pFY%gQ10xK z_xJX7AME}{mvBJ1=fHtpwAkO()7`V16GDHvZ%=PfKDej5Pu|nDZ@>I>S09a71-kP7 i1Km9bQP(B!+XZSp25IjTT~F>hwC~_8vcIjVO89^DlwwH$ literal 0 HcmV?d00001 diff --git a/tail/bin/tail.map b/tail/bin/tail.map new file mode 100644 index 0000000..10b5791 --- /dev/null +++ b/tail/bin/tail.map @@ -0,0 +1,157 @@ +Section Base Top High Length +----------- ------ ------ ------ ------- +.libs 0B0045 0B0045 0h +.init 0B0045 0B0079 34h +.fini 0B0079 0B00BF 46h +.init.args 0B00BF 0B00D5 16h +.init.bss 0B00D5 0B00E1 Ch +.text 0B00E1 0B336E 328Dh +.data 0B336E 0B33B3 45h +.rodata 0B33B3 0B35C0 20Dh +.init_array 000000 000000 0h +.ctors 000000 000000 0h +.dtors 000000 000000 0h +.fini_array 000000 000000 0h +.bss 080000 080031 09FFFF 31h +.header 0B0000 0B0045 45h + +Label Value +---------------------- ------ +___low_bss = 080000 +___len_bss = 000031 +___heaptop = 09FFFF +___heapbot = 080031 +___init_array_count = 000000 +___ctors_count = 000000 +___dtors_count = 000000 +___fini_array_count = 000000 +__stack = 0AFFFF +__fcmp = 0B00E1 +_inchar = 0B00FE +__setflag = 0B0105 +___arg_processing = 0B0114 +___parse_args = 0B0135 +___check_redirect = 0B0218 +___close_redir_files = 0B0409 +_.str = 0B33B3 +_.str.1 = 0B33B5 +_.str.2 = 0B33B7 +__frameset = 0B0452 +__frameset0 = 0B0460 +__iand = 0B046B +__idivu = 0B0484 +__idvrms = 0B048C +__idvrmu = 0B04BA +__imulu = 0B04D2 +__indcallhl = 0B0502 +__ineg = 0B0503 +__ior = 0B050C +__irems = 0B0525 +__ishl = 0B052D +__ishrs = 0B0558 +__ishru = 0B0553 +__ixor = 0B0594 +__ladd = 0B05AD +__land = 0B05B3 +__lcmps = 0B05CE +__lcmpu = 0B05DB +__lcmpzero = 0B05E3 +__lladd = 0B05EB +__lland = 0B060F +__llcmpu = 0B064C +__llcmpzero = 0B0676 +__llctlz = 0B068B +__lldivs = 0B06A3 +__lldivu = 0B06F3 +__lldvrmu = 0B0707 +__lldvrmu.hijack = 0B070E +__llmulu = 0B0765 +__llneg = 0B07BA +__llshl = 0B07D3 +__llshrs.hijack_llshru = 0B0801 +__llshrs.finish = 0B0820 +__llshru = 0B0824 +__llsub = 0B083E +__lmulu = 0B0860 +__lneg = 0B08BC +__lshrs.hijack_lshru = 0B08D5 +__lshru = 0B08E4 +_atoi = 0B08F4 +_fclose = 0B0907 +_fgetc = 0B094B +_fgets = 0B0A2A +__stdio_init = 0B0ABD +_stdin = 0B336E +_stdout = 0B3373 +_stderr = 0B3378 +__file_streams = 080000 +_fopen = 0B0B0F +___fmodeflags = 0B0BD0 +_.str = 0B33B9 +_fputc = 0B0C37 +_fput_char = 0B0CC7 +_free = 0B0CEE +_fseek = 0B0DAB +_fwrite = 0B0E54 +_malloc = 0B0F28 +__alloc_base = 080028 +___maptab = 0B33BD +_npf_vpprintf = 0B0FC7 +JTI0_0 = 0B343D +JTI0_1 = 0B345B +JTI0_2 = 0B34A0 +JTI0_3 = 0B34C1 +JTI0_4 = 0B34D9 +JTI0_5 = 0B34F1 +_npf_utoa_rev = 0B2731 +_printf = 0B27F9 +_vprintf = 0B2818 +_npf_putc_std = 0B2838 +_.str = 0B3509 +_.str.1 = 0B350D +_.str.2 = 0B3511 +_strtol = 0B2848 +_isspace = 0B2A41 +_outchar = 0B2A58 +_putchar = 0B2A5F +_puts = 0B2A8E +___null_literal_str = 0B3515 +___end_of_line_str = 0B351C +_sbrk = 0B2ABA +__sbrkbase = 0B337D +_toupper = 0B2AD8 +_strchr = 0B2AE5 +_strcmp = 0B2B02 +_strlen = 0B2B1F +_strncmp = 0B2B34 +_errno = 08002E +_mos_fopen = 0B2DC7 +_mos_fclose = 0B2DDF +_mos_fgetc = 0B2DF4 +_mos_fputc = 0B2E09 +_mos_fwrite = 0B2F0D +_mos_flseek = 0B2F29 +_mos_getfil = 0B2F48 +_freopen = 0B2FDE +_ungetc = 0B3028 +__start = 0B0045 +_exit = 0B007B +skip._abort = 0B00B3 +_exit.sp = 0B00B4 +_clear_bss = 0B00D5 +_parse_params = 0B00BF +argv_ptrs = 0B3380 +_atexit = 0B3065 +exit_functions = 0B33B0 +_show_usage = 0B3091 +_show_lines = 0B30BB +___main_argc_argv = 0B321A +_.str = 0B351E +_.str.3 = 0B3539 +_.str.4 = 0B353C +_.str.5 = 0B353F +_.str.6 = 0B3542 +_.str.7 = 0B3567 +_.str.8 = 0B3569 +_str = 0B357C +_str.9 = 0B3597 diff --git a/tail/makefile b/tail/makefile new file mode 100644 index 0000000..1902d7e --- /dev/null +++ b/tail/makefile @@ -0,0 +1,17 @@ +# ---------------------------- +# Makefile Options +# ---------------------------- + +NAME = tail +DESCRIPTION = "The tail utility for Agon" +COMPRESSED = NO +INIT_LOC = 0B0000 +LDHAS_EXIT_HANDLER:=0 +LDHAS_ARG_PROCESSING = 1 + +CFLAGS = -Wall -Wextra -Oz +CXXFLAGS = -Wall -Wextra -Oz + +# ---------------------------- + +include $(shell cedev-config --makefile) diff --git a/tail/src/tail.c b/tail/src/tail.c new file mode 100644 index 0000000..1ef800d --- /dev/null +++ b/tail/src/tail.c @@ -0,0 +1,93 @@ +#include +#include +#include + +void show_usage(char *prog_name) +{ + printf("Usage: %s [-hn] filename\r\n", prog_name); + printf("-h show this help message\r\n"); + printf("-n print the last n lines (default: 10)\r\n"); +} + +void show_lines(FILE *file, int lines) +{ + char **buf = malloc(sizeof(char *) * lines); + + for (int i = 0; i < lines; i++) + buf[i] = malloc(sizeof(char) * 1024); + + int lc = 0; + + while (fgets(buf[lc % lines], 1024, file) != NULL) + { + lc++; + } + + int start = lc > lines ? lc % lines : 0; + int count = lc > lines ? lines : lc; + + for (int i = 0; i < count; i++) + { + printf("%s", buf[(start + i) % lines]); + } + + for (int i = 0; i < lines; i++) + free(buf[i]); + + free(buf); +} + +int main(int argc, char *argv[]) +{ + FILE *file = NULL; + char *filename = NULL; + int parsed_lines = 0; + size_t lines = 10; + + for (int i = 1; i != argc; i++) + { + if (strcmp(argv[i], "-h") == 0) + { + show_usage(argv[0]); + return 0; + } + else if (strncmp(argv[i], "-n", 2) == 0) + { + parsed_lines = atoi(argv[++i]); + + if (parsed_lines <= 0) + { + fprintf(stderr, "The number of lines must be positive"); + return 1; + } + + lines = parsed_lines; + } + else if (!filename) + { + filename = argv[i]; + } + else + { + show_usage(argv[0]); + return 0; + } + } + + if (filename == NULL) + { + show_usage(argv[0]); + return 0; + } + + if (!(file = fopen(filename, "r"))) + { + fprintf(stderr, "Error opening file"); + return 1; + } + + show_lines(file, lines); + fclose(file); + + return 0; +} \ No newline at end of file