Initial commit

This commit is contained in:
2026-08-19 00:38:08 +01:00
commit ee00f3ee3d
21 changed files with 603 additions and 0 deletions
+38
View File
@@ -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;
}
+29
View File
@@ -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);
}
}
+15
View File
@@ -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);
}
+65
View File
@@ -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"
);
}
+15
View File
@@ -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,
};
+18
View File
@@ -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,
};
+66
View File
@@ -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++;
}
}
+16
View File
@@ -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;
}
+56
View File
@@ -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;
}
+24
View File
@@ -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;
}