feture match with master
This commit is contained in:
+5
-1
@@ -15,6 +15,7 @@
|
|||||||
// namespaces
|
// namespaces
|
||||||
#include "stdWullie/namespaces/print.h"
|
#include "stdWullie/namespaces/print.h"
|
||||||
#include "stdWullie/namespaces/convert.h"
|
#include "stdWullie/namespaces/convert.h"
|
||||||
|
#include "stdWullie/namespaces/random.h"
|
||||||
|
|
||||||
// errors & exits
|
// errors & exits
|
||||||
#include "stdWullie/exit.h"
|
#include "stdWullie/exit.h"
|
||||||
@@ -23,11 +24,14 @@
|
|||||||
#include "stdWullie/time.h"
|
#include "stdWullie/time.h"
|
||||||
|
|
||||||
// file handling
|
// file handling
|
||||||
|
#include "stdWullie/definitions/umodetypes.h"
|
||||||
#include "stdWullie/filehandle/closeOpen.h"
|
#include "stdWullie/filehandle/closeOpen.h"
|
||||||
#include "stdWullie/filehandle/readWrite.h"
|
#include "stdWullie/filehandle/readWrite.h"
|
||||||
|
#include "stdWullie/filehandle/mkdir.h"
|
||||||
|
|
||||||
|
|
||||||
// string extras
|
// string
|
||||||
#include "stdWullie/String/colours.h"
|
#include "stdWullie/String/colours.h"
|
||||||
|
|
||||||
|
// congtates youse have made it to the end
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
// please see attached licence for full usage and rights
|
// please see attached licence for full usage and rights
|
||||||
|
|
||||||
//defined like stdint to avoid confilict
|
//defined like stdint to avoid confilict
|
||||||
#ifdef _WrathINT
|
|
||||||
|
|
||||||
#ifndef _STDINT_H
|
#ifndef _STDINT_H
|
||||||
#define _STDINT_H 1
|
#define _STDINT_H 1
|
||||||
@@ -52,4 +51,4 @@ typedef unsigned long size_t;
|
|||||||
#define INT32_MIN ((int32_t)(-INT32_MAX - 1))
|
#define INT32_MIN ((int32_t)(-INT32_MAX - 1))
|
||||||
#define INT64_MIN ((int64_t)(-INT64_MAX - 1))
|
#define INT64_MIN ((int64_t)(-INT64_MAX - 1))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#define UMODETYPES_H
|
#define UMODETYPES_H
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
#define DefaultMode 255
|
||||||
#elif __FreeBSD__
|
#elif __FreeBSD__
|
||||||
|
#define DefaultMode 255
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
#ifndef TYPECONVERSION_H
|
#ifndef TYPECONVERSION_H
|
||||||
#define TYPECONVERSION_H
|
#define TYPECONVERSION_H
|
||||||
|
|
||||||
|
#include "stdWullie/definitions/int.h"
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
|
|
||||||
// string manipulation
|
// string manipulation
|
||||||
@@ -12,7 +14,10 @@ typedef struct{
|
|||||||
void (*toLower)(char string[]);
|
void (*toLower)(char string[]);
|
||||||
|
|
||||||
// the numbers mason, what do they mean
|
// 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);
|
const char *(*FtoStr)(float number);
|
||||||
int (*toInt)(char *rawInt);
|
int (*toInt)(char *rawInt);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
// hanles operations for opening and closeing files
|
// hanles operations for opening and closeing files
|
||||||
|
|
||||||
// it should be set to W for wumbo
|
// 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){
|
if(pathname || flags || mode == NULL){
|
||||||
safeError("A Null value was passed into this function, for proper prems nothing should be 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){
|
if(fd == NULL){
|
||||||
safeError("A null file descriptor was passed");
|
safeError("A null file descriptor was passed");
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -4,8 +4,12 @@
|
|||||||
|
|
||||||
#include "LocalHeader.h"
|
#include "LocalHeader.h"
|
||||||
#include "stdWullie/definitions/typeNull.h"
|
#include "stdWullie/definitions/typeNull.h"
|
||||||
|
#include "stdWullie/definitions/int.h"
|
||||||
#include "stdWullie/exit.h"
|
#include "stdWullie/exit.h"
|
||||||
#include "stdWullie/filehandle/readWrite.h"
|
#include "stdWullie/filehandle/readWrite.h"
|
||||||
|
|
||||||
|
#define WrathINT
|
||||||
|
|
||||||
long reader(long fd, char *string, size_t buflen){
|
long reader(long fd, char *string, size_t buflen){
|
||||||
if(buflen <= 0){
|
if(buflen <= 0){
|
||||||
safeError("can not parse 0 characters");
|
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){
|
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");
|
safeError("can not write 0 characters to a file");
|
||||||
}
|
}
|
||||||
syscall3(SYS_write, fd, (long)string, (long)buflen);
|
syscall3(SYS_write, fd, (long)string, (long)buflen);
|
||||||
|
|||||||
+32
@@ -4,6 +4,10 @@
|
|||||||
#include "LocalHeader.h"
|
#include "LocalHeader.h"
|
||||||
#include "stdWullie.h"
|
#include "stdWullie.h"
|
||||||
|
|
||||||
|
|
||||||
|
// decleration for random
|
||||||
|
int randomTest();
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
if(argc != 2){
|
if(argc != 2){
|
||||||
@@ -41,6 +45,19 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
case 5:
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -50,6 +67,21 @@ int main(int argc, char *argv[]){
|
|||||||
return 0;
|
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"#
|
// #I say softly to my self "FUCK your STDLIB"#
|
||||||
// hadles the entry point of code and calls main when registary is set
|
// hadles the entry point of code and calls main when registary is set
|
||||||
__attribute__((naked)) void _start(){
|
__attribute__((naked)) void _start(){
|
||||||
|
|||||||
@@ -4,12 +4,25 @@
|
|||||||
|
|
||||||
#include "stdWullie/namespaces/convert.h"
|
#include "stdWullie/namespaces/convert.h"
|
||||||
|
|
||||||
|
// to number
|
||||||
int intParser(char *rawInt);
|
int intParser(char *rawInt);
|
||||||
|
|
||||||
|
// string stuff
|
||||||
void upper(char string[]);
|
void upper(char string[]);
|
||||||
void lower(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 = {
|
const ConversionNameSpace convert = {
|
||||||
.toInt = intParser,
|
.toInt = intParser,
|
||||||
.toLower = lower,
|
.toLower = lower,
|
||||||
.toUpper = upper,
|
.toUpper = upper,
|
||||||
|
.I32toStr = IntCon,
|
||||||
|
.I64toStr = I64Con,
|
||||||
|
.U32toStr = U32Con,
|
||||||
|
.U64toStr = U64Con,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,
|
||||||
|
};
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ void printText(char *string){
|
|||||||
|
|
||||||
void printReturn(char *string){
|
void printReturn(char *string){
|
||||||
syscall3(SYS_write, 1, (long)string, lengthStr(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
|
// it can do everything that print can but better
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
// © 2026 wullie wulliestudio.com
|
// © 2026 wullie wulliestudio.com
|
||||||
// please see attached licence for full usage and rights
|
// please see attached licence for full usage and rights
|
||||||
|
|
||||||
|
#include "stdWullie/definitions/int.h"
|
||||||
|
#include "stdWullie/definitions/typeNull.h"
|
||||||
|
|
||||||
// turns strings into numbers
|
// turns strings into numbers
|
||||||
int intParser(char *rawInt){
|
int intParser(char *rawInt){
|
||||||
int result = 0; char *cursor = rawInt;
|
int result = 0; char *cursor = rawInt;
|
||||||
@@ -14,3 +17,132 @@ int intParser(char *rawInt){
|
|||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user