Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 284bc1b70e | |||
| d90f046561 | |||
| 1984fb9269 | |||
| c3b39135f6 | |||
| 06ec88f374 | |||
| eead1718c0 | |||
| 365c7c5a02 | |||
| e56b2da0a6 | |||
| eb17c19a60 | |||
| 7443de7152 | |||
| 26e1056597 | |||
| 2f0f7c8bec | |||
| 310657aed5 | |||
| ae50272003 | |||
| a0ce78ca80 | |||
| 8928e19461 |
@@ -1,11 +1,12 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
|
||||
#ifndef LOCALHEADER_H
|
||||
#define LOCALHEADER_H
|
||||
|
||||
// syscall macros
|
||||
// syscall macros, replaces the number based on system
|
||||
#ifdef __linux__
|
||||
#define SYS_read 0
|
||||
#define SYS_write 1
|
||||
@@ -14,7 +15,7 @@
|
||||
#define SYS_sleep 35
|
||||
#define SYS_exit 60
|
||||
#define SYS_mkdir 83
|
||||
|
||||
#define SYS_getTime 228
|
||||
|
||||
#elif __FreeBSD__
|
||||
#define SYS_read 3
|
||||
@@ -24,20 +25,16 @@
|
||||
#define SYS_sleep 244
|
||||
#define SYS_exit 1
|
||||
#define SYS_mkdir 136
|
||||
#define SYS_getTime 232
|
||||
#endif
|
||||
|
||||
// local functions
|
||||
// functions that SHOULD NOT be exposed to a dev using the library
|
||||
void exit(int code);
|
||||
|
||||
// time spec for sleep
|
||||
typedef struct timespec {
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
} timespec;
|
||||
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);
|
||||
|
||||
// syscalls go here i dont want them exposed to the user
|
||||
long syscall1(long number, long arg1);
|
||||
long syscall2(long number, long arg1, long arg2);
|
||||
long syscall3(long number, long arg1, long arg2, long arg3);
|
||||
long syscall4(long number, long arg1, long arg2, long arg3, long arg4);
|
||||
#endif
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#ifndef FILES_h
|
||||
#define FILES_h
|
||||
|
||||
// file handling
|
||||
long Wopen(const char *pathname, int flags, int mode);
|
||||
long closeFile(long fd);
|
||||
long reader(long fd, char *string);
|
||||
long mkdir(const char *filePath, int mode);
|
||||
|
||||
|
||||
#endif
|
||||
Binary file not shown.
+22
-34
@@ -1,41 +1,29 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#ifndef MAIN_h
|
||||
#define MAIN_h
|
||||
#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"
|
||||
|
||||
|
||||
// gay ass glibc shit why in the fuck does this exist like that
|
||||
#undef NULL
|
||||
#define NULL 0
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
// import tree
|
||||
#include "string.h"
|
||||
#include "files.h"
|
||||
|
||||
// memory
|
||||
void Wmalloc();
|
||||
|
||||
// error handling
|
||||
void safeError(char *error);
|
||||
void riskyError();
|
||||
|
||||
|
||||
|
||||
// math
|
||||
int intParser(char *rawInt);
|
||||
float invSqrt(float x);
|
||||
float floatPow(float base, int exponant);
|
||||
int intPow(int base, int exponant0);
|
||||
|
||||
|
||||
// misc
|
||||
void sleeper(long seconds);
|
||||
// string extras
|
||||
#include "stdWullie/String/colours.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#ifndef STRING_h
|
||||
#define STRING_h
|
||||
#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"
|
||||
|
||||
|
||||
// ANSI colors
|
||||
// foreground
|
||||
#define BLACK "\x1b[30m"
|
||||
#define RED "\x1b[31m"
|
||||
@@ -15,7 +20,6 @@
|
||||
#define MAGENTA "\x1b[35m"
|
||||
#define CYAN "\x1b[36m"
|
||||
#define WHITE "\x1b[37m"
|
||||
#define NORMAL "\x1b[m"
|
||||
|
||||
// background
|
||||
#define BBLACK "\x1b[40m"
|
||||
@@ -26,21 +30,4 @@
|
||||
#define BMAGENTA "\x1b[45m"
|
||||
#define BCYAN "\x1b[46m"
|
||||
#define BWHITE "\x1b[47m"
|
||||
|
||||
// printing
|
||||
void ColorPrint(char *string, char *color);
|
||||
void BackgroundPrint(char *string, char *Bcolor);
|
||||
void print(char *string);
|
||||
|
||||
long unsigned lengthStr(char *string);
|
||||
|
||||
// conversion
|
||||
void upper(char string[]);
|
||||
void lower(char string[]);
|
||||
const char *intCon(int num);
|
||||
|
||||
|
||||
void input();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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
|
||||
#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;
|
||||
|
||||
// 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)0xFFFFFFF)
|
||||
#define INT64_MAX ((int64_t)0xFFFFFFFFFFFFFFFLL)
|
||||
|
||||
// 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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "stdWullie.h"
|
||||
#include "localheader.h"
|
||||
|
||||
// it should be set to W for wumbo
|
||||
// opens files
|
||||
long Wopen(const char *pathname, int flags, int mode){
|
||||
if(pathname == NULL || flags == NULL || mode == NULL){
|
||||
safeError(NULL);
|
||||
}
|
||||
syscall3(SYS_open, (long)pathname, flags, mode);
|
||||
}
|
||||
|
||||
// named like this to not cause compat issues with glibc
|
||||
long closeFile(long fd){
|
||||
if(fd == NULL){
|
||||
safeError(NULL);
|
||||
}
|
||||
syscall2(SYS_close, fd, 0);
|
||||
}
|
||||
|
||||
// read whats in the file descripter and move it into a buffer
|
||||
long reader(long fd, char *string){
|
||||
syscall3(SYS_read, fd, (long)string, sizeof(string)-1);
|
||||
|
||||
}
|
||||
// does that it say on the tin
|
||||
long mkdir(const char *filePath, int mode){
|
||||
syscall2(SYS_mkdir, (long)filePath, mode);
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "stdWullie.h"
|
||||
#include "localheader.h"
|
||||
|
||||
// generic functions that dont need a file of there own
|
||||
|
||||
// our own exit LINUX ONLY
|
||||
void exit(int code){
|
||||
syscall1(SYS_exit, code);
|
||||
for(;;) {}
|
||||
}
|
||||
|
||||
// safty last
|
||||
void safeError(char *error){
|
||||
if(error != NULL){
|
||||
print(error);
|
||||
ColorPrint("exiting with code -1\n", RED);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
print("something went wrong ");
|
||||
ColorPrint("exiting with code -1\n", RED);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// only use this when something will work but not as intended
|
||||
void riskyError(){
|
||||
print("not critical error was found\n");
|
||||
}
|
||||
|
||||
|
||||
// #Schlaf mein Kindlein, schlaf doch ein, der Rabe hat nach dir gerufen.#
|
||||
void sleeper(long seconds){
|
||||
timespec duration = {0};
|
||||
duration.tv_sec = seconds;
|
||||
|
||||
syscall2(SYS_sleep, (long)(&duration), 0);
|
||||
|
||||
|
||||
}
|
||||
+22
-38
@@ -1,70 +1,55 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "LocalHeader.h"
|
||||
#include "stdWullie.h"
|
||||
#include "localheader.h"
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
||||
if(argc != 2){
|
||||
print("test functions for stdWullie use agruments 1 - 3 to test features\n");
|
||||
print.nl("to many or to few arguments were provided");
|
||||
print.nl("the test functions for StdWullie use 1 - 7");
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *rawArg = argv[1];
|
||||
long argNum = intParser(rawArg);
|
||||
|
||||
switch(argNum){
|
||||
long argNumb = convert.toInt(argv[1]);
|
||||
|
||||
switch(argNumb){
|
||||
case 1:
|
||||
print("look Ma no stdlib\n");
|
||||
ColorPrint("NOW WITH COLORS\n", RED);
|
||||
BackgroundPrint("and backgrounds\n", BBLUE);
|
||||
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("test for safe exit\n");
|
||||
print.nl("test for safe exit, should close the program");
|
||||
safeError(NULL);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
print("sleep for 2 seconds before exit\n");
|
||||
print.nl("sleeps for 2 seconds: program will terminate like other test cases");
|
||||
sleeper(2);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
char string[] = "contvers to upper then to lower\n";
|
||||
upper(string);
|
||||
print(string);
|
||||
lower(string);
|
||||
print(string);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
print("making a test dir with the name test\n");
|
||||
mkdir("test", 0);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
print("turning a int to string: ");
|
||||
int num = 8001;
|
||||
char *str = intCon(num);
|
||||
print(str);
|
||||
print("\n");
|
||||
char string[] = "converts to upper then to lower\n";
|
||||
convert.toUpper(string);
|
||||
print.text(string);
|
||||
convert.toLower(string);
|
||||
print.text(string);
|
||||
break;
|
||||
|
||||
default:
|
||||
print("no args given or arg is out of range\n");
|
||||
print.nl("args is out or range or is NAN please check avaible args with ./stdwullie");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// #I say softly to myself "FUCK YOUR STDLIB"#
|
||||
// handles the main loop
|
||||
// #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__(
|
||||
__asm__ __volatile(
|
||||
"xor %ebp, %ebp\n"
|
||||
"mov (%rsp), %rdi\n"
|
||||
"lea 8(%rsp), %rsi\n"
|
||||
@@ -72,6 +57,5 @@ __attribute__((naked)) void _start(){
|
||||
"call main\n"
|
||||
"mov %rax, %rdi\n"
|
||||
"call exit\n"
|
||||
);
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "stdWullie.h"
|
||||
|
||||
// int parser basicly atol
|
||||
int intParser(char *rawInt){
|
||||
int result = 0;
|
||||
char *cursor = rawInt;
|
||||
|
||||
while(*cursor >= '0' && *cursor <= '9'){
|
||||
result = result * 10 + (*cursor - '0');
|
||||
cursor++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// fast inverse square root why: bc this is my lib
|
||||
float invSqrt(float x){
|
||||
float xhalf = 0.5f * x;
|
||||
int i = *(int*)&x;
|
||||
i = 0x5f3759df - (i >> 1); // bit fuck magic
|
||||
x = *(float*)&i;
|
||||
x = x*(1.5f - xhalf*x*x);
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
// power of for floats
|
||||
float floatPow(float base, int exponant){
|
||||
float result;
|
||||
|
||||
if(base == 0.0f || exponant == 0){
|
||||
result = 0.0f;
|
||||
return result;
|
||||
|
||||
}
|
||||
while(exponant > 0){
|
||||
result = base * base;
|
||||
exponant --;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// power of for int
|
||||
int intPow(int base, int exponant){
|
||||
int result;
|
||||
|
||||
if(base == 0 || exponant == 0){
|
||||
result = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
result = base ^ exponant;
|
||||
return result;
|
||||
}
|
||||
|
||||
float Sqrt(){
|
||||
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "string.h"
|
||||
#include "localheader.h"
|
||||
|
||||
void input(){
|
||||
|
||||
}
|
||||
+36
-33
@@ -1,15 +1,17 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "stdWullie.h"
|
||||
#include "localheader.h"
|
||||
|
||||
// handles the length of a string for print
|
||||
#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("error: a string was passed with a null value terminating program");
|
||||
}
|
||||
safeError("a string was passed with a lenght of 0");
|
||||
}
|
||||
|
||||
char *cursor = string;
|
||||
while(*cursor){
|
||||
cursor++;
|
||||
@@ -18,46 +20,47 @@ long unsigned lengthStr(char *string){
|
||||
return result;
|
||||
}
|
||||
|
||||
// its print what do you expect? for it to read?
|
||||
void print(char *string){
|
||||
// its print what did you expect? for it to read?
|
||||
void printText(char *string){
|
||||
syscall3(SYS_write, 1, (long)string, lengthStr(string));
|
||||
}
|
||||
|
||||
// it can do everythig print can but better
|
||||
void ColorPrint(char *string, char *color){
|
||||
syscall3(SYS_write, 1, (long)color, lengthStr(color));
|
||||
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);
|
||||
}
|
||||
|
||||
// instead of changing the foreground it changes the background
|
||||
void BackgroundPrint(char *string, char *Bcolor){
|
||||
syscall3(SYS_write, 1, (long)Bcolor, lengthStr(Bcolor));
|
||||
// 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);
|
||||
}
|
||||
|
||||
// converts a sting to uppercase
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
|
||||
// does the same but to lower case instead
|
||||
void lower(char string[]){
|
||||
int cursor = 0;
|
||||
while(string[cursor] != '\0'){
|
||||
if(string[cursor] >= 'A' && string[cursor] <= 'Z'){
|
||||
string[cursor] = string[cursor] + 32;
|
||||
while(string[i] != '\0'){
|
||||
if(string[i] >= 'a' && string[i] <= 'z'){
|
||||
string[i] = string[i] - 32;
|
||||
}
|
||||
cursor++;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-39
@@ -1,45 +1,16 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "string.h"
|
||||
// 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++;
|
||||
}
|
||||
|
||||
|
||||
// converts int to string
|
||||
const char *intCon(int number){
|
||||
int i = 0, isNegative = 0;
|
||||
static char string[34];
|
||||
|
||||
if(number < 0){
|
||||
isNegative = 1;
|
||||
number = -number;
|
||||
}
|
||||
while(number){
|
||||
string[i++] = (number % 10) + '0';
|
||||
number /= 10;
|
||||
}
|
||||
|
||||
if(isNegative){
|
||||
string[i++] = '-';
|
||||
}
|
||||
|
||||
string[i] = '\0';
|
||||
|
||||
int start = 0, end = i -1;
|
||||
while(start < end){
|
||||
char tempStr = string[start];
|
||||
string[start] = string[end];
|
||||
string[end] = tempStr;
|
||||
start ++;
|
||||
end --;
|
||||
}
|
||||
|
||||
return string;
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *floatCon(float number){
|
||||
int i = 0, isNegative = 0;
|
||||
static char string[32];
|
||||
|
||||
|
||||
}
|
||||
|
||||
+12
-24
@@ -1,68 +1,56 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "localheader.h"
|
||||
|
||||
|
||||
#include "LocalHeader.h"
|
||||
// look at me I am the handler now
|
||||
|
||||
// syscall1
|
||||
|
||||
// each numbered syscall take that amount of arguments eg syscall1 takes one arg
|
||||
|
||||
long syscall1(long number, long arg1){
|
||||
long result;
|
||||
|
||||
// asm for a system call with one arg
|
||||
__asm__ __volatile(
|
||||
"syscall"
|
||||
: "=a"(result)
|
||||
: "a"(number), "D"(arg1)
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// syscall2
|
||||
long syscall2(long number, long arg1, long arg2){
|
||||
long result;
|
||||
|
||||
// asm for system call with 2 args
|
||||
__asm__ __volatile(
|
||||
"syscall"
|
||||
: "=a"(result)
|
||||
: "a"(number), "D"(arg1), "S"(arg2)
|
||||
: "rcx", "r11","memory"
|
||||
"syscall"
|
||||
: "=a"(result)
|
||||
: "a"(number), "D"(arg1), "S"(arg2)
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// syscall3
|
||||
long syscall3(long number, long arg1, long arg2, long arg3){
|
||||
long result;
|
||||
|
||||
// asm for a system call with 3 args
|
||||
__asm__ __volatile(
|
||||
"syscall"
|
||||
: "=a"(result)
|
||||
: "a"(number), "D"(arg1), "S"(arg2), "d"(arg3)
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// syscall4
|
||||
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), "b"(arg4)
|
||||
: "a"(number), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10)
|
||||
: "rcx", "r11", "memory"
|
||||
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+24
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user