Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patterns: put author and description inside each pattern #155

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,277 changes: 1,140 additions & 1,137 deletions patterns/3ds.hexpat

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions patterns/7z.hexpat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma description 7z File Format

#include <std/io.pat>
#include <std/mem.pat>
#include <std/math.pat>
Expand Down
2 changes: 2 additions & 0 deletions patterns/Crashlvl.hexpat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma description Crash Bandicoot - Back in Time (fan game) User created flashback tapes level format

#include <type/magic.pat>
#include <std/string.pat>
#include <std/array.pat>
Expand Down
3 changes: 3 additions & 0 deletions patterns/afe2.hexpat
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#pragma author WerWolv
#pragma description Nintendo Switch Atmosphère CFW Fatal Error log

#pragma endian little

#include <std/io.pat>
Expand Down
3 changes: 3 additions & 0 deletions patterns/ar.hexpat
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#pragma author WerWolv
#pragma description Static library archive files

#pragma MIME application/x-archive

#include <std/string.pat>
Expand Down
3 changes: 3 additions & 0 deletions patterns/arm_cm_vtor.hexpat
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#pragma author WerWolv
#pragma description ARM Cortex M Vector Table Layout

#pragma endian little

#include <std/io.pat>
Expand Down
149 changes: 76 additions & 73 deletions patterns/bencode.hexpat
Original file line number Diff line number Diff line change
@@ -1,73 +1,76 @@
#pragma MIME application/x-bittorrent

#include <std/ctype.pat>
#include <std/mem.pat>
#include <std/string.pat>

namespace bencode {

struct ASCIIDecimal {
char value[while(std::ctype::isdigit(std::mem::read_unsigned($, 1)))];
} [[sealed, format("bencode::format_ascii_decimal"), transform("bencode::format_ascii_decimal")]];

fn format_ascii_decimal(ASCIIDecimal adsasd) {
return std::string::parse_int(adsasd.value, 10);
};

enum Type : u8 {
Integer = 'i',
Dictionary = 'd',
List = 'l',

String0 = '0',
String1 = '1',
String2 = '2',
String3 = '3',
String4 = '4',
String5 = '5',
String6 = '6',
String7 = '7',
String8 = '8',
String9 = '9'
};

struct String {
ASCIIDecimal length;
char separator [[hidden]];
char value[length];
} [[sealed, format("bencode::format_string"), transform("bencode::format_string")]];

fn format_string(String string) {
return string.value;
};

using Bencode;
using Value;

struct DictionaryEntry {
String key;
Value value;
};

struct Value {
Type type;

if (type == Type::Dictionary) {
DictionaryEntry entry[while(std::mem::read_unsigned($, 1) != 'e')];
} else if (type == Type::Integer) {
ASCIIDecimal value;
char end;
} else {
$ -= 1;
String value;
}
};

struct Bencode {
Value value[while(!std::mem::eof())] [[inline]];
char end;
};

}

bencode::Bencode bencode @ 0x00;
#pragma author WerWolv
#pragma description Bencode encoding, used by Torrent files

#pragma MIME application/x-bittorrent

#include <std/ctype.pat>
#include <std/mem.pat>
#include <std/string.pat>

namespace bencode {

struct ASCIIDecimal {
char value[while(std::ctype::isdigit(std::mem::read_unsigned($, 1)))];
} [[sealed, format("bencode::format_ascii_decimal"), transform("bencode::format_ascii_decimal")]];

fn format_ascii_decimal(ASCIIDecimal adsasd) {
return std::string::parse_int(adsasd.value, 10);
};

enum Type : u8 {
Integer = 'i',
Dictionary = 'd',
List = 'l',

String0 = '0',
String1 = '1',
String2 = '2',
String3 = '3',
String4 = '4',
String5 = '5',
String6 = '6',
String7 = '7',
String8 = '8',
String9 = '9'
};

struct String {
ASCIIDecimal length;
char separator [[hidden]];
char value[length];
} [[sealed, format("bencode::format_string"), transform("bencode::format_string")]];

fn format_string(String string) {
return string.value;
};

using Bencode;
using Value;

struct DictionaryEntry {
String key;
Value value;
};

struct Value {
Type type;

if (type == Type::Dictionary) {
DictionaryEntry entry[while(std::mem::read_unsigned($, 1) != 'e')];
} else if (type == Type::Integer) {
ASCIIDecimal value;
char end;
} else {
$ -= 1;
String value;
}
};

struct Bencode {
Value value[while(!std::mem::eof())] [[inline]];
char end;
};

}

bencode::Bencode bencode @ 0x00;
2 changes: 2 additions & 0 deletions patterns/bmp.hexpat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma description OS2/Windows Bitmap files

#pragma MIME image/bmp
#pragma endian little
#include <std/mem.pat>
Expand Down
Loading
Loading