From 79bc676f49a531b52534ea2917ec2b902cf106e5 Mon Sep 17 00:00:00 2001 From: wullie Date: Fri, 11 Sep 2026 03:50:43 +0100 Subject: [PATCH] feture match with master --- include/stdWullie.h | 6 +- include/stdWullie/definitions/int.h | 3 +- include/stdWullie/definitions/umodetypes.h | 4 +- include/stdWullie/filehandle/mkdir.h | 6 + include/stdWullie/namespaces/convert.h | 7 +- include/stdWullie/namespaces/random.h | 18 +++ src/fileHandling/closeOpen.c | 4 +- src/fileHandling/mkdir.c | 19 +++ src/fileHandling/readWrite.c | 6 +- src/main.c | 34 +++++- src/namespace/ConversionNamespace.c | 13 ++ src/namespace/RandomNamespace.c | 16 +++ src/random/randcoice.c | 10 ++ src/random/xorshift.c | 24 ++++ src/string/printing.c | 2 +- src/string/typeConvert.c | 132 +++++++++++++++++++++ 16 files changed, 293 insertions(+), 11 deletions(-) create mode 100644 include/stdWullie/filehandle/mkdir.h create mode 100644 include/stdWullie/namespaces/random.h create mode 100644 src/fileHandling/mkdir.c create mode 100644 src/namespace/RandomNamespace.c create mode 100644 src/random/randcoice.c create mode 100644 src/random/xorshift.c diff --git a/include/stdWullie.h b/include/stdWullie.h index 966322e..e3d7906 100644 --- a/include/stdWullie.h +++ b/include/stdWullie.h @@ -15,6 +15,7 @@ // namespaces #include "stdWullie/namespaces/print.h" #include "stdWullie/namespaces/convert.h" +#include "stdWullie/namespaces/random.h" // errors & exits #include "stdWullie/exit.h" @@ -23,11 +24,14 @@ #include "stdWullie/time.h" // file handling +#include "stdWullie/definitions/umodetypes.h" #include "stdWullie/filehandle/closeOpen.h" #include "stdWullie/filehandle/readWrite.h" +#include "stdWullie/filehandle/mkdir.h" -// string extras +// string #include "stdWullie/String/colours.h" +// congtates youse have made it to the end #endif diff --git a/include/stdWullie/definitions/int.h b/include/stdWullie/definitions/int.h index 6777e42..fb8635a 100644 --- a/include/stdWullie/definitions/int.h +++ b/include/stdWullie/definitions/int.h @@ -3,7 +3,6 @@ // please see attached licence for full usage and rights //defined like stdint to avoid confilict -#ifdef _WrathINT #ifndef _STDINT_H #define _STDINT_H 1 @@ -52,4 +51,4 @@ typedef unsigned long size_t; #define INT32_MIN ((int32_t)(-INT32_MAX - 1)) #define INT64_MIN ((int64_t)(-INT64_MAX - 1)) #endif -#endif + diff --git a/include/stdWullie/definitions/umodetypes.h b/include/stdWullie/definitions/umodetypes.h index b97e559..15ecc51 100644 --- a/include/stdWullie/definitions/umodetypes.h +++ b/include/stdWullie/definitions/umodetypes.h @@ -6,9 +6,9 @@ #define UMODETYPES_H #ifdef __linux__ - +#define DefaultMode 255 #elif __FreeBSD__ - +#define DefaultMode 255 #endif #endif diff --git a/include/stdWullie/filehandle/mkdir.h b/include/stdWullie/filehandle/mkdir.h new file mode 100644 index 0000000..5c3decd --- /dev/null +++ b/include/stdWullie/filehandle/mkdir.h @@ -0,0 +1,6 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +// why i continue to do this i have no fucking clue +long mkdir(const char *filePath, int mode); diff --git a/include/stdWullie/namespaces/convert.h b/include/stdWullie/namespaces/convert.h index 8d8072d..0c92de7 100644 --- a/include/stdWullie/namespaces/convert.h +++ b/include/stdWullie/namespaces/convert.h @@ -5,6 +5,8 @@ #ifndef TYPECONVERSION_H #define TYPECONVERSION_H +#include "stdWullie/definitions/int.h" + typedef struct{ // string manipulation @@ -12,7 +14,10 @@ typedef struct{ void (*toLower)(char string[]); // the numbers mason, what do they mean - const char *(*ItoStr)(int number); + const char *(*I32toStr)(int number); + const char *(*I64toStr)(int64_t number); + const char *(*U32toStr)(uint32_t number); + const char *(*U64toStr)(uint64_t number); const char *(*FtoStr)(float number); int (*toInt)(char *rawInt); diff --git a/include/stdWullie/namespaces/random.h b/include/stdWullie/namespaces/random.h new file mode 100644 index 0000000..8990380 --- /dev/null +++ b/include/stdWullie/namespaces/random.h @@ -0,0 +1,18 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef WRATHRANDOM_H +#define WRATHRANDOM_H + +#include "stdWullie/definitions/int.h" + +typedef struct{ + uint32_t (*xor32)(void); + uint64_t (*xor64)(void); + int (*choice)(int min, int max) +}RandomNameSpace; + +extern const RandomNameSpace random; + +#endif diff --git a/src/fileHandling/closeOpen.c b/src/fileHandling/closeOpen.c index d943996..09be448 100644 --- a/src/fileHandling/closeOpen.c +++ b/src/fileHandling/closeOpen.c @@ -10,7 +10,7 @@ // hanles operations for opening and closeing files // it should be set to W for wumbo -long wopen(const char *pathname, int flag, int mode){ +long wopen(const char *pathname, int flags, int mode){ if(pathname || flags || mode == NULL){ safeError("A Null value was passed into this function, for proper prems nothing should be NULL"); } @@ -18,7 +18,7 @@ long wopen(const char *pathname, int flag, int mode){ } -long closeFile(long fd){ +long closeFile(int fd){ if(fd == NULL){ safeError("A null file descriptor was passed"); diff --git a/src/fileHandling/mkdir.c b/src/fileHandling/mkdir.c new file mode 100644 index 0000000..004d5c9 --- /dev/null +++ b/src/fileHandling/mkdir.c @@ -0,0 +1,19 @@ +// 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/definitions/umodetypes.h" +#include "stdWullie/exit.h" + +// does what is says on the tin +long mkdir(const char *filePath, int mode){ + + if(mode == NULL){ + + riskyError(); + return NULL; + } + syscall2(SYS_mkdir, (long)filePath, mode); +} diff --git a/src/fileHandling/readWrite.c b/src/fileHandling/readWrite.c index be06a33..89f4a83 100644 --- a/src/fileHandling/readWrite.c +++ b/src/fileHandling/readWrite.c @@ -4,8 +4,12 @@ #include "LocalHeader.h" #include "stdWullie/definitions/typeNull.h" +#include "stdWullie/definitions/int.h" #include "stdWullie/exit.h" #include "stdWullie/filehandle/readWrite.h" + +#define WrathINT + long reader(long fd, char *string, size_t buflen){ if(buflen <= 0){ safeError("can not parse 0 characters"); @@ -15,7 +19,7 @@ long reader(long fd, char *string, size_t buflen){ } long writer(long fd, const char *string, size_t buflen){ - if(bufflen <=0){ + if(buflen <=0){ safeError("can not write 0 characters to a file"); } syscall3(SYS_write, fd, (long)string, (long)buflen); diff --git a/src/main.c b/src/main.c index ca197b0..549850f 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,10 @@ #include "LocalHeader.h" #include "stdWullie.h" + +// decleration for random +int randomTest(); + int main(int argc, char *argv[]){ if(argc != 2){ @@ -40,7 +44,20 @@ int main(int argc, char *argv[]){ break; case 5: - print.nl("makes a test directory with user permissions"); + print.nl("makes a test directory with user permissions"); + mkdir("test", DefaultMode); + break; + + case 6: + print.nl("numbers into string i fucking give up"); + int cunt = 68; + char *output = convert.I32toStr(cunt); + print.nl(output); + break; + + case 7: + print.nl("tests for random number generation: xor shift32 64 and choice"); + randomTest(); break; default: @@ -50,6 +67,21 @@ int main(int argc, char *argv[]){ return 0; } +int randomTest(){ + uint32_t x = random.xor32(); + char *output32 = convert.U32toStr(x); + print.nl(output32); + + uint64_t y = random.xor64(); + char *output64 = convert.U64toStr(y); + print.nl(output64); + + int z = random.choice(1, 10); + char *outputChoice = convert.I32toStr(z); + print.nl(outputChoice); + 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(){ diff --git a/src/namespace/ConversionNamespace.c b/src/namespace/ConversionNamespace.c index c93a872..98ec7f7 100644 --- a/src/namespace/ConversionNamespace.c +++ b/src/namespace/ConversionNamespace.c @@ -4,12 +4,25 @@ #include "stdWullie/namespaces/convert.h" +// to number int intParser(char *rawInt); + +// string stuff void upper(char string[]); void lower(char string[]); +// to string defines +const char *IntCon(int number); +const char *I64Con(int64_t number); +const char *U32Con(uint32_t number); +const char *U64Con(uint64_t number); + const ConversionNameSpace convert = { .toInt = intParser, .toLower = lower, .toUpper = upper, + .I32toStr = IntCon, + .I64toStr = I64Con, + .U32toStr = U32Con, + .U64toStr = U64Con, }; diff --git a/src/namespace/RandomNamespace.c b/src/namespace/RandomNamespace.c new file mode 100644 index 0000000..af5a600 --- /dev/null +++ b/src/namespace/RandomNamespace.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 + +#include "stdWullie/definitions/int.h" +#include "stdWullie/namespaces/random.h" + +uint32_t xshift32(); +uint64_t xshift64(); +int randomChoice(int min, int max); + +const RandomNameSpace random = { + .xor32 = xshift32, + .xor64 = xshift64, + .choice = randomChoice, +}; diff --git a/src/random/randcoice.c b/src/random/randcoice.c new file mode 100644 index 0000000..18bd397 --- /dev/null +++ b/src/random/randcoice.c @@ -0,0 +1,10 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie/namespaces/random.h" + +int randomChoice(int min, int max){ + int ranged = min + (random.xor32() % (max - min + 1)); + return ranged; +} diff --git a/src/random/xorshift.c b/src/random/xorshift.c new file mode 100644 index 0000000..e4fd4e1 --- /dev/null +++ b/src/random/xorshift.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/definitions/int.h" +#include "stdWullie/time.h" + +uint32_t xshift32(){ + uint32_t x = unixTime(); + x ^= x << 13; + x ^= x >> 17; + x ^= x << 5; + return x; +} + +uint64_t xshift64(){ + uint32_t x = unixTime(); + uint32_t y = unixTime(); + uint64_t z = x + y; + z ^= z << 13; + z ^= z >> 7; + z ^= z << 15; + return z; +} diff --git a/src/string/printing.c b/src/string/printing.c index 0606945..b64fb5a 100644 --- a/src/string/printing.c +++ b/src/string/printing.c @@ -27,7 +27,7 @@ void printText(char *string){ void printReturn(char *string){ syscall3(SYS_write, 1, (long)string, lengthStr(string)); - syscall3(SYS_write, 1, (long)"\n", 8); + syscall3(SYS_write, 1, (long)"\n", 6); } // it can do everything that print can but better diff --git a/src/string/typeConvert.c b/src/string/typeConvert.c index fd4f901..48bc2e1 100644 --- a/src/string/typeConvert.c +++ b/src/string/typeConvert.c @@ -2,6 +2,9 @@ // © 2026 wullie wulliestudio.com // please see attached licence for full usage and rights +#include "stdWullie/definitions/int.h" +#include "stdWullie/definitions/typeNull.h" + // turns strings into numbers int intParser(char *rawInt){ int result = 0; char *cursor = rawInt; @@ -14,3 +17,132 @@ int intParser(char *rawInt){ return result; } +// reverser +void reverseString(char string[], int index){ + int start = 0, end = index -1; + + while(start < end){ + char tempStr = string[start]; + string[start] = string[end]; + string[end] = tempStr; + start ++; + end --; + } +} + +// turns 32bit numebrs into strings +const char *IntCon(int number){ + int index = 0, isNegative = 0; + static char string[12]; + + // handles a value of 0 + if(number == 0){ + string[index] = '0'; + return string; + } + + if(number < 0){ + isNegative = 1; + number = -number; + } + + while(number){ + string[index++] = (number % 10)+ '0'; + number /= 10; + } + if(isNegative){ + string[index++] = '-'; + } + + string[index] = '\0'; + reverseString(string, index); + return string; +} + +// same but 64 bit +const char *I64Con(int64_t number){ + int index = 0, isNegative = 0; + static char string[21]; + + // handles a value of 0 + if(number == 0){ + string[index] = '0'; + return string; + } + + if(number < 0){ + isNegative = 1; + number = -number; + } + + while(number){ + string[index++] = (number % 10)+ '0'; + number /= 10; + } + if(isNegative){ + string[index++] = '-'; + } + + string[index] = '\0'; + reverseString(string, index); + return string; +} + +// handle for unsigned 32 +const char *U32Con(uint32_t number){ + int index = 0, isNegative = 0; + static char string[12]; + + // handles a value of 0 + if(number == 0){ + string[index] = '0'; + return string; + } + + if(number < 0){ + isNegative = 1; + number = -number; + } + + while(number){ + string[index++] = (number % 10)+ '0'; + number /= 10; + } + if(isNegative){ + string[index++] = '-'; + } + + string[index] = '\0'; + reverseString(string, index); + return string; +} + +// handle for unsigned 64 +const char *U64Con(uint64_t number){ + int index = 0, isNegative = 0; + static char string[21]; + + // handles a value of 0 + if(number == 0){ + string[index] = '0'; + return string; + } + + if(number < 0){ + isNegative = 1; + number = -number; + } + + while(number){ + string[index++] = (number % 10)+ '0'; + number /= 10; + } + if(isNegative){ + string[index++] = '-'; + } + + string[index] = '\0'; + reverseString(string, index); + return string; +} +