diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..dd72655 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "*.h": "c" + } +} \ No newline at end of file diff --git a/DtsodC/GPATH b/DtsodC/GPATH deleted file mode 100644 index 8d52cf2..0000000 Binary files a/DtsodC/GPATH and /dev/null differ diff --git a/DtsodC/GRTAGS b/DtsodC/GRTAGS deleted file mode 100644 index db5b126..0000000 Binary files a/DtsodC/GRTAGS and /dev/null differ diff --git a/DtsodC/GTAGS b/DtsodC/GTAGS deleted file mode 100644 index d642280..0000000 Binary files a/DtsodC/GTAGS and /dev/null differ diff --git a/DtsodC/Makefile b/DtsodC/Makefile index c078581..3d10752 100644 --- a/DtsodC/Makefile +++ b/DtsodC/Makefile @@ -31,7 +31,7 @@ std_test: std_build_test # using cosmopolitan COSMARGS_PRE=-g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -D COSMOPOLITAN COSMARGS_POST=-Wl,--oformat=binary -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd -Wl,-T,cosmopolitan/ape.lds \ - -include cosmopolitan/cosmopolitan.h cosmopolitan/crt.o ./cosmopolitan/ape-no-modify-self.o cosmopolitan/cosmopolitan.a + -include cosmopolitan/cosmopolitan.h cosmopolitan/crt.o ./cosmopolitan/ape.o cosmopolitan/cosmopolitan.a build: build_test diff --git a/DtsodC/README.md b/DtsodC/README.md new file mode 100644 index 0000000..89d8dca --- /dev/null +++ b/DtsodC/README.md @@ -0,0 +1,24 @@ +# DtsodC + +DtsodV23 parser in C# works too slow, so i wrote V24 parser in C + +
+ + +## Compiling on Linux +**Required packages:** gcc + +Compile with glibc: +```bash +make std_build +```` + +Compile with cosmopolitan (crossplatform libc implementation): +```bash +make build +``` + +If you see the `run-detectors: unable to find an interpreter` error, just execute this command: +```bash +sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register" +``` \ No newline at end of file diff --git a/DtsodC/src/!headers.h b/DtsodC/src/!headers.h new file mode 100644 index 0000000..7701200 --- /dev/null +++ b/DtsodC/src/!headers.h @@ -0,0 +1,14 @@ +#if COSMOPOLITAN + #include "../cosmopolitan/cosmopolitan.h" +#else + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif diff --git a/DtsodC/src/DtsodV24.c b/DtsodC/src/DtsodV24.c index 1d8dfdc..139597f 100644 --- a/DtsodC/src/DtsodV24.c +++ b/DtsodC/src/DtsodV24.c @@ -1,6 +1,2 @@ -#if COSMOPOLITAN - #include "../cosmopolitan/cosmopolitan.h" -#else - #include "stdio.h" -#endif + diff --git a/DtsodC/src/DtsodV24.h b/DtsodC/src/DtsodV24.h index 1d8dfdc..139597f 100644 --- a/DtsodC/src/DtsodV24.h +++ b/DtsodC/src/DtsodV24.h @@ -1,6 +1,2 @@ -#if COSMOPOLITAN - #include "../cosmopolitan/cosmopolitan.h" -#else - #include "stdio.h" -#endif + diff --git a/DtsodC/src/autosize_array/Autoarr.h b/DtsodC/src/autosize_array/Autoarr.h index b34fc13..772c270 100644 --- a/DtsodC/src/autosize_array/Autoarr.h +++ b/DtsodC/src/autosize_array/Autoarr.h @@ -1,10 +1,6 @@ -#ifndef STDLIB - #include "../../cosmopolitan/cosmopolitan.h" -#else - #include -#endif +#include "../!headers.h" #include "../strict_types.h" -#include "../err_t.h" +#include "../errors.h" typedef struct Autoarr{ void** values; diff --git a/DtsodC/src/err_t.h b/DtsodC/src/errors.h similarity index 100% rename from DtsodC/src/err_t.h rename to DtsodC/src/errors.h diff --git a/DtsodC/src/nsleep.h b/DtsodC/src/nsleep.h new file mode 100644 index 0000000..2f4be78 --- /dev/null +++ b/DtsodC/src/nsleep.h @@ -0,0 +1,12 @@ +#include "!headers.h" +#include "strict_types.h" + +#ifndef __NSLEEP_DEFINED +#define __NSLEEP_DEFINED +void nsleep(uint8 sec, uint8 milisec){ + if (sec>0) + sleep(sec); + if (milisec>0) + usleep(milisec*1000); +} +#endif \ No newline at end of file diff --git a/DtsodC/src/slimak.h b/DtsodC/src/slimak.h new file mode 100644 index 0000000..1c20dc9 --- /dev/null +++ b/DtsodC/src/slimak.h @@ -0,0 +1,53 @@ +#include "!headers.h" + +const wchar_t* slimak = +U" ▄▄▄ \n" +"▄▀░▄░▀▄ \n" +"█░█▄▀░█ \n" +"█░▀▄▄▀█▄█▄▀ \n" +"▄▄█▄▄▄▄███▀ \n" +" ▄▄▄ \n" +" █▀▄▄░▀█ \n" +"█░█░▄▀░░█ \n" +"█░▀▄▄▄▀░█▄█▄▄▀ \n" +"▄▄█▄▄▄▄███▀▀ \n" +" ▄▄▄ \n" +" █▀▄▄░▀█ \n" +"█░█░▄▀░░█ \n" +"█░▀▄▄▄▀░█▄█▄▄▀ \n" +"▄▄█▄▄▄▄████▀▀ \n" +" ▄▄▄ \n" +" ▄▀░▄░▀▄ \n" +" █░█▄▀░█ \n" +" █░▀▄▄▀█▄█▄▀ \n" +" ▄▄█▄▄▄▄███▀ \n" +" ▄▄▄ \n" +" █▀▄▄░▀█ \n" +" █░█░▄▀░░█ \n" +" █░▀▄▄▄▀░█▄█▄▄▀ \n" +" ▄▄█▄▄▄▄███▀▀ \n" +" ▄▄▄ \n" +" █▀▄▄░▀█ \n" +" █░█░▄▀░░█ \n" +" █░▀▄▄▄▀░█▄█▄▄▀ \n" +" ▄▄█▄▄▄▄████▀▀ \n" +" ▄▄▄ \n" +" ▄▀░▄░▀▄ \n" +" █░█▄▀░█ \n" +" █░▀▄▄▀█▄█▄▀ \n" +" ▄▄█▄▄▄▄███▀ \n" +" ▄▄▄ \n" +" █▀▄▄░▀█ \n" +" █░█░▄▀░░█ \n" +" █░▀▄▄▄▀░█▄█▄▄▀\n" +" ▄▄█▄▄▄▄███▀▀ \n" +" ▄▄▄ \n" +" █▀▄▄░▀█ \n" +" █░█░▄▀░░█ \n" +" █░▀▄▄▄▀░█▄█▄▄▀\n" +" ▄▄█▄▄▄▄████▀▀ \n" +" ▄▄▄ \n" +" ▄▀░▄░▀▄ \n" +" █░█▄▀░█ \n" +" █░▀▄▄▀█▄█▄▀\n" +" ▄▄█▄▄▄▄███▀ \n"; \ No newline at end of file diff --git a/DtsodC/src/strict_types.c b/DtsodC/src/strict_types.c index a540ad7..f818a1f 100644 --- a/DtsodC/src/strict_types.c +++ b/DtsodC/src/strict_types.c @@ -1,10 +1,6 @@ -#ifndef STDLIB - #include "../cosmopolitan/cosmopolitan.h" -#else - #include "stdint.h" -#endif +#include "!headers.h" #include "strict_types.h" -#include "err_t.h" +#include "errors.h" int8 GetTypeSize(strict_type type){ int8 type_size=0; diff --git a/DtsodC/src/strict_types.h b/DtsodC/src/strict_types.h index 960c12f..4bdaf38 100644 --- a/DtsodC/src/strict_types.h +++ b/DtsodC/src/strict_types.h @@ -1,9 +1,5 @@ -#ifndef STDLIB - #include "../cosmopolitan/cosmopolitan.h" -#else - #include "stdint.h" -#endif -#include "err_t.h" +#include "!headers.h" +#include "errors.h" typedef int8_t int8; typedef uint8_t uint8; diff --git a/DtsodC/src/test.c b/DtsodC/src/test.c index 725d0a9..195ea75 100644 --- a/DtsodC/src/test.c +++ b/DtsodC/src/test.c @@ -1,45 +1,34 @@ -#ifndef STDLIB - #include "../cosmopolitan/cosmopolitan.h" -#else - #include - #include - #include - #include - #include - #include - #include - #include -#endif +#include "!headers.h" #include "strict_types.h" +#include "errors.h" #include "autosize_array/Autoarr.h" -void nsleep(long miliseconds) { - struct timespec ts = {10, miliseconds * 1000000L}; - nanosleep(&ts, NULL); -} -int8 main(){ +#include "nsleep.h" +#include "slimak.h" + +#define clrscr() printf("\e[1;1H\e[2J") +int main(){ printf("\e[32mdtsod parser in c language!\n"); - dsleep(0.5); //Autoarr* ar=Autoarr_create(100,10,Int8); //Autoarr_add_int8(&ar,-1); //printf("ar[0]==%d",Autoarr_get_int8(&ar,0)); //free(ar); - //setlocale(LC_ALL, "en-US.Unicode"); - /*struct stat st; - FILE* f1 = fopen("1.gui","r"); - FILE* f2 = fopen("2.gui","r"); - fstat(fileno(f1), &st); - size_t size = st.st_size; - char page1[size]; - fread(page1, 8, size, f1); - char page2[size]; - fread(page2, 8, size, f2); - printf("\e[31m\n"); - for (int64 i = 0; i<100000; i++){ - nsleep(10000L); - if(i%2==0) printf("%s", page1); - else printf("%s", page2); - }*/ - printf("\e[32m\n"); - //getc(stdin); + setlocale(LC_ALL, "en-US.Unicode"); + uint8 n = 0; + clrscr(); + for (uint16 i = 0; i<40; i++){ + nsleep(0,70); + printf("\e[1;1H%.*ls", 105,slimak+n*105); + if (n>=10) n=0; + else n++; + } + for (uint16 i = 0; i<120; i++){ + nsleep(0,20); + printf("\e[1;1H%.*ls", 105,slimak+n*105); + if (n>=10) n=0; + else n++; + } + clrscr(); + printf("\e[32m\npress any key to exit...\n"); + getc(stdin); return 0; } \ No newline at end of file diff --git a/DtsodC/src/throw.c b/DtsodC/src/throw.c index 055c49f..bfb7ccd 100644 --- a/DtsodC/src/throw.c +++ b/DtsodC/src/throw.c @@ -1,10 +1,5 @@ -#ifndef STDLIB - #include "../cosmopolitan/cosmopolitan.h" -#else - #include - #include -#endif -#include "err_t.h" +#include "!headers.h" +#include "errors.h" void throwstr(const char* errmesg){ printf("\e[31mthrowed error: %s\e[0m\n",errmesg);