This commit is contained in:
Timerix22 2022-01-19 23:53:51 +03:00
parent 5e75552199
commit cf8aa8bff0
17 changed files with 144 additions and 72 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"files.associations": {
"*.h": "c"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -31,7 +31,7 @@ std_test: std_build_test
# using cosmopolitan # using cosmopolitan
COSMARGS_PRE=-g -O -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -D 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 \ 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 build: build_test

24
DtsodC/README.md Normal file
View File

@ -0,0 +1,24 @@
# DtsodC
DtsodV23 parser in C# works too slow, so i wrote V24 parser in C
<br>
## Compiling on Linux
**Required packages:** gcc
Compile with glibc:
```bash
make std_build
````
Compile with <a href="https://github.com/jart/cosmopolitan">cosmopolitan<a> (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"
```

14
DtsodC/src/!headers.h Normal file
View File

@ -0,0 +1,14 @@
#if COSMOPOLITAN
#include "../cosmopolitan/cosmopolitan.h"
#else
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <locale.h>
#include <uchar.h>
#include <wchar.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#endif

View File

@ -1,6 +1,2 @@
#if COSMOPOLITAN
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdio.h"
#endif

View File

@ -1,6 +1,2 @@
#if COSMOPOLITAN
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdio.h"
#endif

View File

@ -1,10 +1,6 @@
#ifndef STDLIB #include "../!headers.h"
#include "../../cosmopolitan/cosmopolitan.h"
#else
#include <stdint.h>
#endif
#include "../strict_types.h" #include "../strict_types.h"
#include "../err_t.h" #include "../errors.h"
typedef struct Autoarr{ typedef struct Autoarr{
void** values; void** values;

12
DtsodC/src/nsleep.h Normal file
View File

@ -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

53
DtsodC/src/slimak.h Normal file
View File

@ -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";

View File

@ -1,10 +1,6 @@
#ifndef STDLIB #include "!headers.h"
#include "../cosmopolitan/cosmopolitan.h"
#else
#include "stdint.h"
#endif
#include "strict_types.h" #include "strict_types.h"
#include "err_t.h" #include "errors.h"
int8 GetTypeSize(strict_type type){ int8 GetTypeSize(strict_type type){
int8 type_size=0; int8 type_size=0;

View File

@ -1,9 +1,5 @@
#ifndef STDLIB #include "!headers.h"
#include "../cosmopolitan/cosmopolitan.h" #include "errors.h"
#else
#include "stdint.h"
#endif
#include "err_t.h"
typedef int8_t int8; typedef int8_t int8;
typedef uint8_t uint8; typedef uint8_t uint8;

View File

@ -1,45 +1,34 @@
#ifndef STDLIB #include "!headers.h"
#include "../cosmopolitan/cosmopolitan.h"
#else
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <locale.h>
#include <uchar.h>
#include <wchar.h>
#include <sys/stat.h>
#include <time.h>
#endif
#include "strict_types.h" #include "strict_types.h"
#include "errors.h"
#include "autosize_array/Autoarr.h" #include "autosize_array/Autoarr.h"
void nsleep(long miliseconds) { #include "nsleep.h"
struct timespec ts = {10, miliseconds * 1000000L}; #include "slimak.h"
nanosleep(&ts, NULL);
} #define clrscr() printf("\e[1;1H\e[2J")
int8 main(){ int main(){
printf("\e[32mdtsod parser in c language!\n"); printf("\e[32mdtsod parser in c language!\n");
dsleep(0.5);
//Autoarr* ar=Autoarr_create(100,10,Int8); //Autoarr* ar=Autoarr_create(100,10,Int8);
//Autoarr_add_int8(&ar,-1); //Autoarr_add_int8(&ar,-1);
//printf("ar[0]==%d",Autoarr_get_int8(&ar,0)); //printf("ar[0]==%d",Autoarr_get_int8(&ar,0));
//free(ar); //free(ar);
//setlocale(LC_ALL, "en-US.Unicode"); setlocale(LC_ALL, "en-US.Unicode");
/*struct stat st; uint8 n = 0;
FILE* f1 = fopen("1.gui","r"); clrscr();
FILE* f2 = fopen("2.gui","r"); for (uint16 i = 0; i<40; i++){
fstat(fileno(f1), &st); nsleep(0,70);
size_t size = st.st_size; printf("\e[1;1H%.*ls", 105,slimak+n*105);
char page1[size]; if (n>=10) n=0;
fread(page1, 8, size, f1); else n++;
char page2[size]; }
fread(page2, 8, size, f2); for (uint16 i = 0; i<120; i++){
printf("\e[31m\n"); nsleep(0,20);
for (int64 i = 0; i<100000; i++){ printf("\e[1;1H%.*ls", 105,slimak+n*105);
nsleep(10000L); if (n>=10) n=0;
if(i%2==0) printf("%s", page1); else n++;
else printf("%s", page2); }
}*/ clrscr();
printf("\e[32m\n"); printf("\e[32m\npress any key to exit...\n");
//getc(stdin); getc(stdin);
return 0; return 0;
} }

View File

@ -1,10 +1,5 @@
#ifndef STDLIB #include "!headers.h"
#include "../cosmopolitan/cosmopolitan.h" #include "errors.h"
#else
#include <stdio.h>
#include <stdlib.h>
#endif
#include "err_t.h"
void throwstr(const char* errmesg){ void throwstr(const char* errmesg){
printf("\e[31mthrowed error: %s\e[0m\n",errmesg); printf("\e[31mthrowed error: %s\e[0m\n",errmesg);