commit ee00f3ee3d472c439c09e00837c09add6cf833bb Author: wullie Date: Wed Aug 19 00:38:08 2026 +0100 Initial commit diff --git a/include/LocalHeader.h b/include/LocalHeader.h new file mode 100644 index 0000000..190ec58 --- /dev/null +++ b/include/LocalHeader.h @@ -0,0 +1,40 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + + +#ifndef LOCALHEADER_H +#define LOCALHEADER_H + +// syscall macros, replaces the number based on system +#ifdef __linux__ +#define SYS_read 0 +#define SYS_write 1 +#define SYS_open 2 +#define SYS_close 3 +#define SYS_sleep 35 +#define SYS_exit 60 +#define SYS_mkdir 83 +#define SYS_getTime 228 + +#elif __FreeBSD__ +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_sleep 244 +#define SYS_exit 1 +#define SYS_mkdir 136 +#define SYS_getTime 232 +#endif + +// functions that SHOULD NOT be exposed to a dev using the library +void exit(int code); + +long syscall1(long number, long args1); +long syscall2(long number, long args1, long args2); +long syscall3(long number, long args1, long args2, long args3); +long syscall4(long number, long args1, long args2, long args3, long args4); + +#endif + diff --git a/include/stdWullie.h b/include/stdWullie.h new file mode 100644 index 0000000..a3092ec --- /dev/null +++ b/include/stdWullie.h @@ -0,0 +1,29 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef STDWULLIE_H +#define STDWULLIE_H + +// import everything + +//types +#include "stdWullie/definitions/int.h" +#include "stdWullie/definitions/typeNull.h" +#include "stdWullie/definitions/typeBool.h" + +// namespaces +#include "stdWullie/namespaces/print.h" +#include "stdWullie/namespaces/convert.h" + +// errors & exits +#include "stdWullie/exit.h" + +// time +#include "stdWullie/time.h" + + +// string extras +#include "stdWullie/String/colours.h" + +#endif diff --git a/include/stdWullie/String/colours.h b/include/stdWullie/String/colours.h new file mode 100644 index 0000000..3ad971b --- /dev/null +++ b/include/stdWullie/String/colours.h @@ -0,0 +1,33 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef STRCOLOUR_h +#define STRCOLOUR_h + +// ANSI colours + +// Normal value not white as normal could be something else on other systems +#define NORMAL "\x1b[m" + + +// foreground +#define BLACK "\x1b[30m" +#define RED "\x1b[31m" +#define GREEN "\x1b[32m" +#define YELLOW "\x1b[33m" +#define BLUE "\x1b[34m" +#define MAGENTA "\x1b[35m" +#define CYAN "\x1b[36m" +#define WHITE "\x1b[37m" + +// background +#define BBLACK "\x1b[40m" +#define BRED "\x1b[41m" +#define BGREEN "\x1b[42m" +#define BYELLOW "\x1b[43m" +#define BBLUE "\x1b[44m" +#define BMAGENTA "\x1b[45m" +#define BCYAN "\x1b[46m" +#define BWHITE "\x1b[47m" +#endif diff --git a/include/stdWullie/definitions/int.h b/include/stdWullie/definitions/int.h new file mode 100644 index 0000000..6777e42 --- /dev/null +++ b/include/stdWullie/definitions/int.h @@ -0,0 +1,55 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +//defined like stdint to avoid confilict +#ifdef _WrathINT + +#ifndef _STDINT_H +#define _STDINT_H 1 + +// create the types for signed ints using base structures +typedef signed char int8_t; +typedef signed short int int16_t; +typedef signed int int32_t; +typedef signed long long int int64_t; + +// same as above but unsigned +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long int uint64_t; + +// misc int types +typedef unsigned long size_t; + +// macros for long long, unsigned and unsigned long long +#define U unsigned +#define LL long long +#define ULL unsigned long long + +// int max values +#define INT8_MAX ((int8_t)0x7F) +#define INT16_MAX ((int16_t)0x7FFF) +#define INT32_MAX ((int32_t)0xFFFFFFFF) +#define INT64_MAX ((int64_t)0xFFFFFFFFFFFFFFFFLL) + +// max values for uint's +#define UINT8_MAX ((uint8_t)0xFF) +#define UINT16_MAX ((uint16_t)0xFFFF) +#define UINT32_MAX ((uint32_t)0xFFFFFFFFU) +#define UINT64_MAX ((uint64_t)0xFFFFFFFFFFFFFFFFULL) + +// min values for uint +#define UINT8_MIN ((uint8_t)0) +#define UINT16_MIN ((uint16_t)0) +#define UINT32_MIN ((uint32_t)0) +#define UINT64_MIN ((uint64_t)0) + +//min values for int +#define INT8_MIN ((int8_t)(-INT8_MAX - 1)) +#define INT16_MIN ((int16_t)(-INT16_MAX - 1)) +#define INT32_MIN ((int32_t)(-INT32_MAX - 1)) +#define INT64_MIN ((int64_t)(-INT64_MAX - 1)) +#endif +#endif diff --git a/include/stdWullie/definitions/timespec.h b/include/stdWullie/definitions/timespec.h new file mode 100644 index 0000000..2df93c4 --- /dev/null +++ b/include/stdWullie/definitions/timespec.h @@ -0,0 +1,14 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef TIMESPEC_H +#define TIMESPEC_H + +// storage for seconds and nano seconds +typedef struct timespec{ + long tv_sec; + long tv_nsec; +}timespec; + +#endif diff --git a/include/stdWullie/definitions/typeBool.h b/include/stdWullie/definitions/typeBool.h new file mode 100644 index 0000000..35f765b --- /dev/null +++ b/include/stdWullie/definitions/typeBool.h @@ -0,0 +1,13 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef TYPEBOOL_h +#define TYPEBOOL_h + +// just 3 lines but its cleaner here +#define bool _Bool +#define false 0 +#define true 1 + +#endif diff --git a/include/stdWullie/definitions/typeNull.h b/include/stdWullie/definitions/typeNull.h new file mode 100644 index 0000000..efddbba --- /dev/null +++ b/include/stdWullie/definitions/typeNull.h @@ -0,0 +1,12 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef TYPENULL_h +#define TYPENULL_h + +// 2 line of gay shit maybe more if i do pointers +#undef NULL +#define NULL 0 + +#endif diff --git a/include/stdWullie/exit.h b/include/stdWullie/exit.h new file mode 100644 index 0000000..1300d22 --- /dev/null +++ b/include/stdWullie/exit.h @@ -0,0 +1,11 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef ERROR_H +#define ERROR_H + +void safeError(char *error); +void riskyError(); + +#endif diff --git a/include/stdWullie/namespaces/convert.h b/include/stdWullie/namespaces/convert.h new file mode 100644 index 0000000..8d8072d --- /dev/null +++ b/include/stdWullie/namespaces/convert.h @@ -0,0 +1,22 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef TYPECONVERSION_H +#define TYPECONVERSION_H + +typedef struct{ + + // string manipulation + void (*toUpper)(char string[]); + void (*toLower)(char string[]); + + // the numbers mason, what do they mean + const char *(*ItoStr)(int number); + const char *(*FtoStr)(float number); + int (*toInt)(char *rawInt); + +}ConversionNameSpace; + +extern const ConversionNameSpace convert; +#endif diff --git a/include/stdWullie/namespaces/print.h b/include/stdWullie/namespaces/print.h new file mode 100644 index 0000000..de3fc58 --- /dev/null +++ b/include/stdWullie/namespaces/print.h @@ -0,0 +1,17 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef PRINT_H +#define PRINT_H + +typedef struct{ + void (*text)(char *string); + void (*nl)(char *string); + void (*colour)(char *string, char *colour); + void (*background)(char *string, char *Bcolour); +}PrintNameSpace; + +extern const PrintNameSpace print; + +#endif diff --git a/include/stdWullie/time.h b/include/stdWullie/time.h new file mode 100644 index 0000000..549e388 --- /dev/null +++ b/include/stdWullie/time.h @@ -0,0 +1,15 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +// deals with time shit like sleeping and getting the unix epoch + +#ifndef TIME_H +#define TIME_H + +#include "stdWullie/definitions/timespec.h" + +void sleeper(long seconds); +int unixTime(); + +#endif diff --git a/src/exithandle.c b/src/exithandle.c new file mode 100644 index 0000000..261a770 --- /dev/null +++ b/src/exithandle.c @@ -0,0 +1,38 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "LocalHeader.h" +#include "stdWullie/exit.h" + +#include "stdWullie/definitions/typeNull.h" +#include "stdWullie/namespaces/print.h" +#include "stdWullie/String/colours.h" +// exit not ment to be used in other programs +void exit(int code){ + syscall1(SYS_exit, code); + for(;;){} +} + +// safty last +// errors out with either an error message or generic, and exits +void safeError(char *error){ + + // if the user does provide an error message + if(error == NULL){ + print.text(error); + print.colour("exiting program with code -1\n", RED); + exit(-1); + } + // if no error was provided + print.text("something went wrong: "); + print.colour("exiting with code -1\n", RED); + exit(-1); +} + +// safty?? +void riskyError(){ + print.text("there was an error\n"); + return; +} + diff --git a/src/fileHandling/closeOpen.c b/src/fileHandling/closeOpen.c new file mode 100644 index 0000000..d4e6526 --- /dev/null +++ b/src/fileHandling/closeOpen.c @@ -0,0 +1,29 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "LocalHeader.h" +#include "stdWullie/definitions/typeNull.h" +#include "stdWullie/exit.h" + +// hanles operations for opening and closeing files + +// it should be set to W for wumbo +long wopen(const char *pathname, int flag, int mode){ + if(pathname || flags || mode == NULL){ + safeError("A Null value was passed into this function, for proper prems nothing should be NULL"); + } + syscall3(SYS_open, (long)pathname, flags, mode); + +} + +long closeFile(long fd){ + if(fd == NULL){ + safeError("A null file descriptor was passed"); + + syscall2(SYS_close, fd, 0); + } + +} + + diff --git a/src/fileHandling/readWrite.c b/src/fileHandling/readWrite.c new file mode 100644 index 0000000..938889e --- /dev/null +++ b/src/fileHandling/readWrite.c @@ -0,0 +1,15 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "LocalHeader.h" +#include "stdWullie/definitions/typeNull.h" +#include "stdWullie/exit.h" + +long reader(long fd, char *string, size_t count){ + if(count <= 0){ + safeError("can not parse 0 characters"); + } + syscall3(SYS_read, fd, (long)string, (long)count); + +} diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..ca197b0 --- /dev/null +++ b/src/main.c @@ -0,0 +1,65 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights +#include "LocalHeader.h" +#include "stdWullie.h" + +int main(int argc, char *argv[]){ + + if(argc != 2){ + print.nl("to many or to few arguments were provided"); + print.nl("the test functions for StdWullie use 1 - 7"); + return 0; + } + + long argNumb = convert.toInt(argv[1]); + + switch(argNumb){ + case 1: + print.text("look Ma no stdlib\n"); + print.colour("NOW WITH COLOURS\n", RED); + print.background("and with backgrounds\n", BBLUE); + break; + + case 2: + print.nl("test for safe exit, should close the program"); + safeError(NULL); + break; + + case 3: + print.nl("sleeps for 2 seconds: program will terminate like other test cases"); + sleeper(2); + break; + + case 4: + char string[] = "converts to upper then to lower\n"; + convert.toUpper(string); + print.text(string); + convert.toLower(string); + print.text(string); + break; + + case 5: + print.nl("makes a test directory with user permissions"); + break; + + default: + print.nl("args is out or range or is NAN please check avaible args with ./stdwullie"); + break; + } + return 0; +} + +// #I say softly to my self "FUCK your STDLIB"# +// hadles the entry point of code and calls main when registary is set +__attribute__((naked)) void _start(){ + __asm__ __volatile( + "xor %ebp, %ebp\n" + "mov (%rsp), %rdi\n" + "lea 8(%rsp), %rsi\n" + "and $-16, %rsp\n" + "call main\n" + "mov %rax, %rdi\n" + "call exit\n" + ); +} diff --git a/src/namespace/ConversionNamespace.c b/src/namespace/ConversionNamespace.c new file mode 100644 index 0000000..c93a872 --- /dev/null +++ b/src/namespace/ConversionNamespace.c @@ -0,0 +1,15 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie/namespaces/convert.h" + +int intParser(char *rawInt); +void upper(char string[]); +void lower(char string[]); + +const ConversionNameSpace convert = { + .toInt = intParser, + .toLower = lower, + .toUpper = upper, +}; diff --git a/src/namespace/printingNamespace.c b/src/namespace/printingNamespace.c new file mode 100644 index 0000000..4a360ba --- /dev/null +++ b/src/namespace/printingNamespace.c @@ -0,0 +1,18 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie/namespaces/print.h" + +void printText(char *string); +void printReturn(char *string); +void ColourPrint(char *string, char *colour); +void BackgroundPrint(char *string, char *Bcolour); + +const PrintNameSpace print = { + .text = printText, + .nl = printReturn, + .colour = ColourPrint, + .background = BackgroundPrint, +}; + diff --git a/src/string/printing.c b/src/string/printing.c new file mode 100644 index 0000000..0606945 --- /dev/null +++ b/src/string/printing.c @@ -0,0 +1,66 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "LocalHeader.h" +#include "stdWullie/definitions/typeNull.h" +#include "stdWullie/String/colours.h" +#include "stdWullie/exit.h" +long unsigned lengthStr(char *string){ + + if(string == NULL){ + safeError("a string was passed with a lenght of 0"); + } + + char *cursor = string; + while(*cursor){ + cursor++; + } + long unsigned result = cursor - string; + return result; +} + +// its print what did you expect? for it to read? +void printText(char *string){ + syscall3(SYS_write, 1, (long)string, lengthStr(string)); +} + +void printReturn(char *string){ + syscall3(SYS_write, 1, (long)string, lengthStr(string)); + syscall3(SYS_write, 1, (long)"\n", 8); +} + +// it can do everything that print can but better +void ColourPrint(char *string, char *colour){ + syscall3(SYS_write, 1, (long)colour, lengthStr(colour)); + syscall3(SYS_write, 1, (long)string, lengthStr(string)); + syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1); +} + +// changes background instead of foreground +void BackgroundPrint(char *string, char *Bcolour){ + syscall3(SYS_write, 1, (long)Bcolour, lengthStr(Bcolour)); + syscall3(SYS_write, 1, (long)string, lengthStr(string)); + syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1); +} + +// changes all letters to upper or lower depending on whats called +void upper(char string[]){ + int i = 0; + while(string[i] != '\0'){ + if(string[i] >= 'a' && string[i] <= 'z'){ + string[i] = string[i] - 32; + } + i++; + } +} + +void lower(char string[]){ + int i = 0; + while(string[i] != '\0'){ + if(string[i] >= 'A' && string[i] <= 'Z'){ + string[i] = string[i] + 32; + } + i++; + } +} diff --git a/src/string/typeConvert.c b/src/string/typeConvert.c new file mode 100644 index 0000000..fd4f901 --- /dev/null +++ b/src/string/typeConvert.c @@ -0,0 +1,16 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +// turns strings into numbers +int intParser(char *rawInt){ + int result = 0; char *cursor = rawInt; + + while(*cursor >= '0' && *cursor <= '9'){ + result = result * 10 + (*cursor - '0'); + cursor++; + } + + return result; +} + diff --git a/src/syscall.c b/src/syscall.c new file mode 100644 index 0000000..31aa439 --- /dev/null +++ b/src/syscall.c @@ -0,0 +1,56 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "LocalHeader.h" +// look at me I am the handler now + + +// each numbered syscall take that amount of arguments eg syscall1 takes one arg + +long syscall1(long number, long arg1){ + long result; + __asm__ __volatile( + "syscall" + : "=a"(result) + : "a"(number), "D"(arg1) + : "rcx", "r11", "memory" + ); + return result; +} + +long syscall2(long number, long arg1, long arg2){ + long result; + __asm__ __volatile( + "syscall" + : "=a"(result) + : "a"(number), "D"(arg1), "S"(arg2) + : "rcx", "r11", "memory" + ); + return result; +} + +long syscall3(long number, long arg1, long arg2, long arg3){ + long result; + __asm__ __volatile( + "syscall" + : "=a"(result) + : "a"(number), "D"(arg1), "S"(arg2), "d"(arg3) + : "rcx", "r11", "memory" + ); + return result; +} + +long syscall4(long number, long arg1, long arg2, long arg3, long arg4){ + long result; + + register long r10 __asm__("r10") = arg4; + + __asm__ __volatile( + "syscall" + : "=a"(result) + : "a"(number), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10) + : "rcx", "r11", "memory" + ); + return result; +} diff --git a/src/time.c b/src/time.c new file mode 100644 index 0000000..a571d1c --- /dev/null +++ b/src/time.c @@ -0,0 +1,24 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie/time.h" +#include "LocalHeader.h" +// #you out of touch, im out of time when youre not a round# + +// # Schlaft mine Kindlein, schlaft doch ein, der Rabe hat nach der gerufen # +void sleeper(long seconds){ + timespec duration = {0}; + duration.tv_sec = seconds; + + syscall2(SYS_sleep, (long)(&duration), 0); +} + + +int unixTime(){ + timespec seconds = {0}; + syscall2(SYS_getTime, 0, (long)(&seconds)); + + return seconds.tv_sec; +} +