diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luma/app_t/app_t.cc | 79 | ||||
-rw-r--r-- | src/luma/app_t/archstr.cc | 22 | ||||
-rw-r--r-- | src/luma/app_t/arghandl.cc | 12 | ||||
-rw-r--r-- | src/luma/app_t/dbgmsgf.cc | 6 | ||||
-rw-r--r-- | src/luma/app_t/exit.cc | 5 | ||||
-rw-r--r-- | src/luma/app_t/getenv.cc | 13 | ||||
-rw-r--r-- | src/luma/app_t/kernelstr.cc | 34 | ||||
-rw-r--r-- | src/luma/app_t/msgf.cc | 7 | ||||
-rw-r--r-- | src/luma/app_t/msgferr.cc | 4 | ||||
-rw-r--r-- | src/luma/app_t/msgfout.cc | 4 | ||||
-rw-r--r-- | src/luma/app_t/strcmp.cc | 11 | ||||
-rw-r--r-- | src/luma/app_t/strcut.cc | 25 | ||||
-rw-r--r-- | src/luma/app_t/strlen.cc | 8 | ||||
-rw-r--r-- | src/main.cc | 6 |
14 files changed, 236 insertions, 0 deletions
diff --git a/src/luma/app_t/app_t.cc b/src/luma/app_t/app_t.cc new file mode 100644 index 0000000..0c311d6 --- /dev/null +++ b/src/luma/app_t/app_t.cc @@ -0,0 +1,79 @@ +# include <fcntl.h> +# include <luma/main.hh> +# include <unistd.h> +luma::app_t::app_t(int const argc,char const * * argv) { + this->stderr = ::open("/dev/stderr",O_WRONLY); + this->stdout = ::open("/dev/stdout",O_WRONLY); + if(argc < 0x2) { + this->msgferr("Missing argument \"file\".\n"); + this->msgferr("Use \"--help\" for help.\n"); + this->exit(); + } + //else { + // for(int i = 0x0;i < argc;++i) { + // this->arghandl(argv[i]); + // } + //} + this->msgfout(this->archstr(this->arch)); + this->msgfout(this->kernelstr(this->kernel)); + if(!::access(argv[0x1],R_OK)) { + int lumafile = ::open(argv[0x1],O_RDONLY); +//char8_t const * validtoks = "\t 2abcdefghijklmnopqrstuvwxyz0123456789#()*+<=>×÷↊↋−≠⋜⋝\n"; + char const * toks[] = { + "\u0009", // Horizontal Tabulation + "\u000A", // New Line (Nl) + "\u0020", // Space + "\u0023", // Number Sign + "\u0028", // Left Parenthesis + "\u0029", // Right Parenthesis + "\u002B", // Plus Sign + "\u003C", // Less-Than Sign + "\u003D", // Equals Sign + "\u003E", // Greater-Than Sign + "\u0061", // Latin Small Letter a + "\u0062", // Latin Small Letter b + "\u0063", // Latin Small Letter c + "\u0064", // Latin Small Letter d + "\u0065", // Latin Small Letter e + "\u0066", // Latin Small Letter f + "\u0067", // Latin Small Letter g + "\u0068", // Latin Small Letter h + "\u0069", // Latin Small Letter i + "\u006a", // Latin Small Letter j + "\u006B", // Latin Small Letter k + "\u006C", // Latin Small Letter l + "\u006D", // Latin Small Letter m + "\u006E", // Latin Small Letter n + "\u006F", // Latin Small Letter o + "\u0070", // Latin Small Letter p + "\u0071", // Latin Small Letter q + "\u0072", // Latin Small Letter r + "\u0073", // Latin Small Letter s + "\u0074", // Latin Small Letter t + "\u0075", // Latin Small Letter u + "\u0076", // Latin Small Letter v + "\u0077", // Latin Small Letter w + "\u0078", // Latin Small Letter x + "\u0079", // Latin Small Letter y + "\u007A", // Latin Small Letter z + "\u00D7", // Multiplication Sign + "\u00F7", // Division Sign + "\u201C", // Left Double Quotation Mark + "\u201D", // Right Double Quotation Mark + "\u218A", // Turned Digit Two + "\u218B", // Turned Digit Three + "\u2212", // Minus Sign + "\u2217", // Asterisk Operator + "\u2260", // Not Equal To + "\u2264", // Less-Than or Equal To + "\u2265", // Greater-Than or Equal To + }; + } + else { + this->msgferr("The file doesn\'t exist.\n"); + this->exit(); + } +} +luma::app_t::~app_t() { + this->exit(); +} diff --git a/src/luma/app_t/archstr.cc b/src/luma/app_t/archstr.cc new file mode 100644 index 0000000..57b32dc --- /dev/null +++ b/src/luma/app_t/archstr.cc @@ -0,0 +1,22 @@ +# include <luma/main.hh> +char const * luma::app_t::archstr(luma::arch_t arch) noexcept { + char const * str = ""; + switch(arch) { + default: + str = "Unknown"; + break; + case luma::arch_t::aarch64: + str = "ARM64/AArch64"; + break; + case luma::arch_t::amd64: + str = "AMD64/x86-64"; + break; + case luma::arch_t::ia64: + str = "IA-64"; + break; + case luma::arch_t::ppc64: + str = "PPC64"; + break; + } + return str; +} diff --git a/src/luma/app_t/arghandl.cc b/src/luma/app_t/arghandl.cc new file mode 100644 index 0000000..74a63ed --- /dev/null +++ b/src/luma/app_t/arghandl.cc @@ -0,0 +1,12 @@ +# include <luma/main.hh> +void luma::app_t::arghandl(char const * arg) { + char const * appinf = "Luma ()"; + if(this->strcmp(arg,"--help")) { + this->msgfout("\n"); + this->exit(); + } + else if(this->strcmp(arg,"--version")) { + this->msgfout("\n"); + this->exit(); + } +} diff --git a/src/luma/app_t/dbgmsgf.cc b/src/luma/app_t/dbgmsgf.cc new file mode 100644 index 0000000..fe0631c --- /dev/null +++ b/src/luma/app_t/dbgmsgf.cc @@ -0,0 +1,6 @@ +# include <luma/main.hh> +void luma::app_t::dbgmsgf(char const * msg) { + if constexpr(debug) { + this->msgferr(msg); + } +} diff --git a/src/luma/app_t/exit.cc b/src/luma/app_t/exit.cc new file mode 100644 index 0000000..8a975e6 --- /dev/null +++ b/src/luma/app_t/exit.cc @@ -0,0 +1,5 @@ +# include <luma/main.hh> +# include <unistd.h> +[[noreturn]] void luma::app_t::exit() noexcept { + ::_exit(0x0); +} diff --git a/src/luma/app_t/getenv.cc b/src/luma/app_t/getenv.cc new file mode 100644 index 0000000..2c1b3f4 --- /dev/null +++ b/src/luma/app_t/getenv.cc @@ -0,0 +1,13 @@ +# include <luma/main.hh> +# include <unistd.h> +char const * luma::app_t::getenv(char const * envvar) { + /* + strlen = this->strlen(envvar); + for(char const * var : ::environ) { + if(this->strcmp(this->strcut(envvar,0x0,this->strlen(envvar),envvar) == 0x0) { + + } + } + */ + return "wayland"; +} diff --git a/src/luma/app_t/kernelstr.cc b/src/luma/app_t/kernelstr.cc new file mode 100644 index 0000000..9b326bd --- /dev/null +++ b/src/luma/app_t/kernelstr.cc @@ -0,0 +1,34 @@ +# include <luma/main.hh> +char const * luma::app_t::kernelstr(luma::kernel_t kernel) noexcept { + char const * str = ""; + switch(kernel) { + default: + str = "Unknown"; + break; + case luma::kernel_t::darwinos: + str = "Dawin OS"; + break; + case luma::kernel_t::dragonflybsd: + str = "DragonFly BSD"; + break; + case luma::kernel_t::freebsd: + str = "FreeBSD"; + break; + case luma::kernel_t::hurd: + str = "Hurd"; + break; + case luma::kernel_t::linux: + str = "Linux"; + break; + case luma::kernel_t::minix: + str = "MINIX"; + break; + case luma::kernel_t::netbsd: + str = "NetBSD"; + break; + case luma::kernel_t::openbsd: + str = "OpenBSD"; + break; + } + return str; +} diff --git a/src/luma/app_t/msgf.cc b/src/luma/app_t/msgf.cc new file mode 100644 index 0000000..5cb6828 --- /dev/null +++ b/src/luma/app_t/msgf.cc @@ -0,0 +1,7 @@ +# include <luma/main.hh> +# include <unistd.h> +void luma::app_t::msgf(int pipe,char const * msg) { + if(::write(pipe,msg,this->strlen(msg)) < 0x0) { + // ??? + } +} diff --git a/src/luma/app_t/msgferr.cc b/src/luma/app_t/msgferr.cc new file mode 100644 index 0000000..4feb608 --- /dev/null +++ b/src/luma/app_t/msgferr.cc @@ -0,0 +1,4 @@ +# include <luma/main.hh> +void luma::app_t::msgferr(char const * msg) { + this->msgf(this->stderr,msg); +} diff --git a/src/luma/app_t/msgfout.cc b/src/luma/app_t/msgfout.cc new file mode 100644 index 0000000..92556ce --- /dev/null +++ b/src/luma/app_t/msgfout.cc @@ -0,0 +1,4 @@ +# include <luma/main.hh> +void luma::app_t::msgfout(char const * msg) { + this->msgf(this->stdout,msg); +} diff --git a/src/luma/app_t/strcmp.cc b/src/luma/app_t/strcmp.cc new file mode 100644 index 0000000..ce8e082 --- /dev/null +++ b/src/luma/app_t/strcmp.cc @@ -0,0 +1,11 @@ +# include <luma/main.hh> +int luma::app_t::strcmp(char const * lstr,char const * rstr) noexcept { + for(int i = 0x0;;++i) { + if(lstr[i] != rstr[i]) { + return lstr[i] < rstr[i] ? -0x1 : 0x1; + } + if(lstr[i] == '\0') { + return 0x0; + } + } +} diff --git a/src/luma/app_t/strcut.cc b/src/luma/app_t/strcut.cc new file mode 100644 index 0000000..233c47f --- /dev/null +++ b/src/luma/app_t/strcut.cc @@ -0,0 +1,25 @@ +# include <luma/main.hh> +char const * luma::app_t::strcut(char const * str,int pos,int len) { + /* + if((this->strlen(str) - pos - len - 0x1) < 0x0) { // 0x1 counts null as well + // string too short + this->msgerr("String too short!\n"); + return nullptr; + } + else { + char * outstr = nullptr; + int outstrpos = 0x0; + this->msg("boys"); + for(int pos = 0x0;(pos < len);++pos) { + this->msg("diers"); + char chr = str[pos]; + this->msg("hallo"); + outstr[outstrpos] = chr; + ++outstrpos; + } + outstr[++outstrpos] = '\0'; + return outstr; + } + */ + return nullptr; +} diff --git a/src/luma/app_t/strlen.cc b/src/luma/app_t/strlen.cc new file mode 100644 index 0000000..a4c9ba6 --- /dev/null +++ b/src/luma/app_t/strlen.cc @@ -0,0 +1,8 @@ +# include <luma/main.hh> +int luma::app_t::strlen(char const * str) noexcept { + int len = 0x0; + while(str[len] != '\0') { + ++len; + } + return len; +} diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..7bca331 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,6 @@ +# include <fcntl.h> +# include <luma/main.hh> +# include <unistd.h> +int main(int const argc,char const * * argv) { + luma::app_t app(argc,argv); +} |