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/luma/arghandl.cc | 14 | ||||
-rw-r--r-- | src/luma/luma.cc | 36 | ||||
-rw-r--r-- | src/main.cc | 6 |
16 files changed, 52 insertions, 234 deletions
diff --git a/src/luma/app_t/app_t.cc b/src/luma/app_t/app_t.cc deleted file mode 100644 index 0c311d6..0000000 --- a/src/luma/app_t/app_t.cc +++ /dev/null @@ -1,79 +0,0 @@ -# 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 deleted file mode 100644 index 57b32dc..0000000 --- a/src/luma/app_t/archstr.cc +++ /dev/null @@ -1,22 +0,0 @@ -# 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 deleted file mode 100644 index 74a63ed..0000000 --- a/src/luma/app_t/arghandl.cc +++ /dev/null @@ -1,12 +0,0 @@ -# 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 deleted file mode 100644 index fe0631c..0000000 --- a/src/luma/app_t/dbgmsgf.cc +++ /dev/null @@ -1,6 +0,0 @@ -# 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 deleted file mode 100644 index 8a975e6..0000000 --- a/src/luma/app_t/exit.cc +++ /dev/null @@ -1,5 +0,0 @@ -# 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 deleted file mode 100644 index 2c1b3f4..0000000 --- a/src/luma/app_t/getenv.cc +++ /dev/null @@ -1,13 +0,0 @@ -# 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 deleted file mode 100644 index 9b326bd..0000000 --- a/src/luma/app_t/kernelstr.cc +++ /dev/null @@ -1,34 +0,0 @@ -# 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 deleted file mode 100644 index 5cb6828..0000000 --- a/src/luma/app_t/msgf.cc +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100644 index 4feb608..0000000 --- a/src/luma/app_t/msgferr.cc +++ /dev/null @@ -1,4 +0,0 @@ -# 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 deleted file mode 100644 index 92556ce..0000000 --- a/src/luma/app_t/msgfout.cc +++ /dev/null @@ -1,4 +0,0 @@ -# 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 deleted file mode 100644 index ce8e082..0000000 --- a/src/luma/app_t/strcmp.cc +++ /dev/null @@ -1,11 +0,0 @@ -# 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 deleted file mode 100644 index 233c47f..0000000 --- a/src/luma/app_t/strcut.cc +++ /dev/null @@ -1,25 +0,0 @@ -# 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 deleted file mode 100644 index a4c9ba6..0000000 --- a/src/luma/app_t/strlen.cc +++ /dev/null @@ -1,8 +0,0 @@ -# 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/luma/arghandl.cc b/src/luma/arghandl.cc new file mode 100644 index 0000000..70b9ae6 --- /dev/null +++ b/src/luma/arghandl.cc @@ -0,0 +1,14 @@ +# include <cstdio> +# include <luma.hh> +# include <string> +# include <vector> +using namespace std::literals::string_literals; +void luma::arghandl(int const argc,char const * * argv) { + std::vector<std::basic_string<char>> args; + for(int pos = 0x1;pos < argc; ++pos) { + args.push_back(argv[pos]); + } + for(std::basic_string<char> arg : args) { + std::printf("Got argument \"%s\".\u000A",arg.c_str()); + } +} diff --git a/src/luma/luma.cc b/src/luma/luma.cc new file mode 100644 index 0000000..18fcdb7 --- /dev/null +++ b/src/luma/luma.cc @@ -0,0 +1,36 @@ +# include <cstdio> +# include <cstdlib> +# include <luma.hh> +# include <fcntl.h> +# include <sys/stat.h> +# include <unistd.h> +[[noreturn]] luma::luma(int const argc,char const * * argv) { + this->arghandl(argc,argv); + int file = ::open("test.luma",O_RDONLY); + char tok = '\0'; + char word[0x1000]; + int wordpos = 0x0; + struct ::stat fst; + ::fstat(file,&fst); + printf("Size of file is %ld characters.\u000A",fst.st_size); + ::sleep(0x1); + for(int filepos = 0x0;filepos < fst.st_size;++filepos) { + if(::read(file,&tok,0x1) < 0x0) { + std::printf("Error reading file.\u000A"); + ::_exit(EXIT_FAILURE); + } + if(tok == '\u000A' || tok == '\u0020') { + if(wordpos == 0x0) continue; + word[wordpos] = '\0'; + std::printf("The word is \"%s\".\u000A",word); + word[0x0] = '\0'; + wordpos = 0x0; + } + else { + word[wordpos] = tok; + std::printf("Got character '%c' and set word[%d] to it.\u000A",tok,wordpos); + ++wordpos; + } + } + ::_exit(EXIT_SUCCESS); +} diff --git a/src/main.cc b/src/main.cc index 7bca331..5de90c4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,4 @@ -# include <fcntl.h> -# include <luma/main.hh> -# include <unistd.h> +# include <luma.hh> int main(int const argc,char const * * argv) { - luma::app_t app(argc,argv); + ::luma luma(argc,argv); } |