diff --git a/.gitignore b/.gitignore index 9baf9aa..65dfd61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,18 @@ -.vscode -glade/test_window.glade~ -netbenixCMD -output.log -main.o -logger.o -help.o -logo.o -sql_test.o -gtk_test.o -sys_info.o -show_dir.o -change_dir.o -update_check.o -man.o -calc.o -math_ext.o -your-reality.o -clear_screen.o \ No newline at end of file +.vscode +glade/test_window.glade~ +netbenixCMD +output.log +main.o +logger.o +help.o +logo.o +sql_test.o +gtk_test.o +sys_info.o +show_dir.o +change_dir.o +update_check.o +man.o +calc.o +math_ext.o +your-reality.o \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 1c2fda5..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index be0f224..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 9661ac7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index a881d12..42b34bb 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Tested on: *Ubuntu, Debian, Arch* Used libs for Linux: *gtk+3.0, libmysqlclient* -Version: *0.3.1* +Version: *0.2.6* ## Features: diff --git a/clear_screen.o b/clear_screen.o new file mode 100644 index 0000000..28f1ac5 Binary files /dev/null and b/clear_screen.o differ diff --git a/etc/man.c b/etc/man.c index d5d28e8..65516e9 100644 --- a/etc/man.c +++ b/etc/man.c @@ -1,78 +1,98 @@ -#include -#include -#include - -#include "man.h" - -// Color Codes: -// Reset: \033[0m -// Red: \033[0;31m -// Green: \033[0;32m -// Yellow: \033[0;33m -// Blue: \033[0;34m -// Magenta: \033[0;35m -// Cyan: \033[0;36m -// BoldRed: \033[1;31m -// BoldGreen: \033[1;32m -// BoldYellow: \033[1;33m -// BoldBlue: \033[1;34m -// BoldMagenta: \033[1;35m -// BoldCyan: \033[1;36m - -//Main function to start man is at the bottom - -//MAN ENTRIES - -//LS -void manEntry_ls(){ - printf("\033[0;33m##################\033[0m\n"); - printf("\033[0;33m# Manual of \033[0;36m'ls' \033[0;33m#\033[0m\n"); - printf("\033[0;33m##################\033[0m\n\n"); - printf("\033[0;33mNAME\033[0m\n"); - printf("\t\033[0;36mls - list directory contents\033[0m\n\n"); - printf("\033[0;33mUSAGE\033[0m\n"); - printf("\t\033[0;36mls \033[0;35m[DIRECTORY]\033[0m\n\n"); - printf("\033[0;33mDESCRIPTION\033[0m\n"); - printf("\t\033[0;36mList files and directorys in the given directory. Sorts entries alphabetically.\033[0m\n\n"); -} - -//CD -void manEntry_cd(){ - printf("\033[0;33m##################\033[0m\n"); - printf("\033[0;33m# Manual of \033[0;36m'cd' \033[0;33m#\033[0m\n"); - printf("\033[0;33m##################\033[0m\n"); - printf("\033[0;33mNAME\033[0m\n"); - printf("\t\033[0;36mcd - change directory\033[0m\n\n"); - printf("\033[0;33mUSAGE\033[0m\n"); - printf("\t\033[0;36mcd \033[0;35m[DIRECTORY]\033[0m\n\n"); - printf("\033[0;33mDESCRIPTION\033[0m\n"); - printf("\t\033[0;36mChanged the currently selected directory.\033[0m\n\n"); -} - -//MAN -void manEntry_man(){ - printf("\033[0;33m###################\033[0m\n"); - printf("\033[0;33m# Manual of \033[0;36m'man' \033[0;33m#\033[0m\n"); - printf("\033[0;33m###################\033[0m\n\n"); - printf("\033[0;33mNAME\033[0m\n"); - printf("\t\033[0;36mman - manual\033[0m\n\n"); - printf("\033[0;33mUSAGE\033[0m\n"); - printf("\t\033[0;36mman \033[0;35m[COMMAND]\033[0m\n\n"); - printf("\033[0;33mDESCRIPTION\033[0m\n"); - printf("\t\033[0;36mShows the manual of given command.\033[0m\n\n"); -} - - - -//MAIN FUNCTION -void showManEntry(char *arg[]){ - if(!strcmp(arg[1], "man")){ - manEntry_man(); - } else if(!strcmp(arg[1], "ls")){ - manEntry_ls(); - } else if(!strcmp(arg[1], "cd")){ - manEntry_cd(); - } else { - printf("Entry not found.\n"); - } +<<<<<<< HEAD +#include +#include +#include + +#include "man.h" + +// Color Codes: +// Reset: \033[0m +// Red: \033[0;31m +// Green: \033[0;32m +// Yellow: \033[0;33m +// Blue: \033[0;34m +// Magenta: \033[0;35m +// Cyan: \033[0;36m +// BoldRed: \033[1;31m +// BoldGreen: \033[1;32m +// BoldYellow: \033[1;33m +// BoldBlue: \033[1;34m +// BoldMagenta: \033[1;35m +// BoldCyan: \033[1;36m + +//Main function to start man is at the bottom + +//MAN ENTRIES +//LS +void manEntry_ls(){ + printf("\033[0;33m##################\033[0m\n"); + printf("\033[0;33m# Manual of \033[0;36m'ls' \033[0;33m#\033[0m\n"); + printf("\033[0;33m##################\033[0m\n\n"); + printf("\033[0;33mNAME\033[0m\n"); + printf("\t\033[0;36mls - list directory contents\033[0m\n\n"); + printf("\033[0;33mUSAGE\033[0m\n"); + printf("\t\033[0;36mls \033[0;35m[DIRECTORY]\033[0m\n\n"); + printf("\033[0;33mDESCRIPTION\033[0m\n"); + printf("\t\033[0;36mList files and directorys in the given directory. Sorts entries alphabetically.\033[0m\n\n"); +} + + + +//MAIN FUNCTION +void showManEntry(char *arg[]){ + if(!strcmp(arg[1], "man")){ + printf("Coming soon.\n"); + } else if(!strcmp(arg[1], "ls")){ + manEntry_ls(); + } else { + printf("Entry not found.\n"); + } +======= +#include +#include +#include + +// Color Codes: +// Reset: \033[0m +// Red: \033[0;31m +// Green: \033[0;32m +// Yellow: \033[0;33m +// Blue: \033[0;34m +// Magenta: \033[0;35m +// Cyan: \033[0;36m +// BoldRed: \033[1;31m +// BoldGreen: \033[1;32m +// BoldYellow: \033[1;33m +// BoldBlue: \033[1;34m +// BoldMagenta: \033[1;35m +// BoldCyan: \033[1;36m + +//Main function to start man is at the bottom + +//MAN ENTRIES +//LS +void manEntry_ls(){ + printf("\033[0;33m##################\033[0m\n"); + printf("\033[0;33m# Manual of \033[0;36m'ls' \033[0;33m#\033[0m\n"); + printf("\033[0;33m##################\033[0m\n\n"); + printf("\033[0;33mNAME\033[0m\n"); + printf("\t\033[0;36mls - list directory contents\033[0m\n\n"); + printf("\033[0;33mUSAGE\033[0m\n"); + printf("\t\033[0;36mls \033[0;35m[DIRECTORY]\033[0m\n\n"); + printf("\033[0;33mDESCRIPTION\033[0m\n"); + printf("\t\033[0;36mList files and directorys in the given directory. Sorts entries alphabetically.\033[0m\n\n"); +} + + + +//MAIN FUNCTION +void showManEntry(char *arg[]){ + if(!strcmp(arg[1], "man")){ + printf("Coming soon.\n"); + } else if(!strcmp(arg[1], "ls")){ + manEntry_ls(); + } else { + printf("Entry not found.\n"); + } +>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80 } \ No newline at end of file diff --git a/etc/man.h b/etc/man.h index f6a756b..08bcf7c 100644 --- a/etc/man.h +++ b/etc/man.h @@ -2,8 +2,6 @@ #define _MAN_H_ void manEntry_ls(); -void manEntry_cd(); -void manEntry_man(); void showManEntry(char *arg[]); #endif \ No newline at end of file diff --git a/etc/your-reality.c b/etc/your-reality.c index 127046f..270ff87 100644 --- a/etc/your-reality.c +++ b/etc/your-reality.c @@ -1,38 +1,79 @@ -#include -#include - -#include "your-reality.h" - -//Lyrics from "Your Reality" by Dan Salvato - -//fs -> flush & sleep -void fs(int milliseconds){ - fflush(stdout); - usleep(milliseconds*1000); -} - -//p -> printf -void p(char* txt){ - printf(txt); -} - -void yourReality(){ - - printf("\e[?25l"); - p("Loading "); - for(int i = 0; i < 2; i++){ - //\033[XC => X columns right - //\033[XD => X columns left - printf("\033[3D "); printf("\033[3D"); - fs(500); printf("."); fs(500); printf("."); fs(500); printf("."); fs(500); - - } - printf("\n"); - printf("\033[0;33mEvery "); fs(350); printf("day, "); - fs(700); - p("I "); fs(450); p("imagine "); fs(350); p("a "); fs(350); p("future "); fs(350); p("where "); fs(750); - p("i "); fs(300); p("can "); fs(300); p("be "); fs(300); p("with "); fs(300); p("you."); - - p("\033[0m"); - printf("\e[?25h"); -} +<<<<<<< HEAD +#include +#include + +#include "your-reality.h" + +//Lyrics from "Your Reality" by Dan Salvato + +//fs -> flush & sleep +void fs(int milliseconds){ + fflush(stdout); + usleep(milliseconds*1000); +} + +//p -> printf +void p(char* txt){ + printf(txt); +} + +void yourReality(){ + + printf("\e[?25l"); + p("Loading "); + for(int i = 0; i < 2; i++){ + //\033[XC => X columns right + //\033[XD => X columns left + printf("\033[3D "); printf("\033[3D"); + fs(500); printf("."); fs(500); printf("."); fs(500); printf("."); fs(500); + + } + printf("\n"); + printf("\033[0;33mEvery "); fs(350); printf("day, "); + fs(700); + p("I "); fs(450); p("imagine "); fs(350); p("a "); fs(350); p("future "); fs(350); p("where "); fs(750); + p("i "); fs(300); p("can "); fs(300); p("be "); fs(300); p("with "); fs(300); p("you."); + + p("\033[0m"); + printf("\e[?25h"); +} +======= +#include +#include + +#include "your-reality.h" + +//Lyrics from "Your Reality" by Dan Salvato + +//fs -> flush & sleep +void fs(int milliseconds){ + fflush(stdout); + usleep(milliseconds*1000); +} + +//p -> printf +void p(char* txt){ + printf(txt); +} + +void yourReality(){ + + printf("\e[?25l"); + p("Loading "); + for(int i = 0; i < 2; i++){ + //\033[XC => X columns right + //\033[XD => X columns left + printf("\033[3D "); printf("\033[3D"); + fs(500); printf("."); fs(500); printf("."); fs(500); printf("."); fs(500); + + } + printf("\n"); + printf("\033[0;33mEvery "); fs(350); printf("day, "); + fs(700); + p("I "); fs(450); p("imagine "); fs(350); p("a "); fs(350); p("future "); fs(350); p("where "); fs(750); + p("i "); fs(300); p("can "); fs(300); p("be "); fs(300); p("with "); fs(300); p("you."); + + p("\033[0m"); + printf("\e[?25h"); +} +>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80 diff --git a/etc/your-reality.h b/etc/your-reality.h index 7dae4ca..4151b24 100644 --- a/etc/your-reality.h +++ b/etc/your-reality.h @@ -1,6 +1,14 @@ -#ifndef _YOUR_REALITY_H -#define _YOUR_REALITY_H - -void yourReality(); - +<<<<<<< HEAD +#ifndef _YOUR_REALITY_H +#define _YOUR_REALITY_H + +void yourReality(); + +======= +#ifndef _YOUR_REALITY_H +#define _YOUR_REALITY_H + +void yourReality(); + +>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80 #endif \ No newline at end of file diff --git a/glade/test_window.glade b/glade/test_window.glade index 6ff1c8d..b536e3c 100644 --- a/glade/test_window.glade +++ b/glade/test_window.glade @@ -1,101 +1,104 @@ - - - - - - 300 - 230 - False - False - center - 300 - 230 - ../logo.png - center - - - - - True - False - - - Ok - 100 - 31 - True - True - True - Pink Fluffy Unicorns - - - - 135 - 183 - - - - - 369 - 20 - True - False - center - center - center - 50 - - - - - - - 57 - - - - - Toggle - 107 - 24 - True - True - False - True - - - - 140 - 153 - - - - - 40 - 40 - True - False - True - - - 324 - 179 - - - - - 100 - 20 - True - False - 100 - - - 8 - 201 - - - - - - + + + + + + 300 + 230 + False + False + center + 300 + 230 + ../logo.png + center + + + + + True + False + + + Ok + 100 + 31 + True + True + True + Pink Fluffy Unicorns + + + + 135 + 183 + + + + + 369 + 20 + True + False + center + center + center + 50 + + + + + + + 57 + + + + + Toggle + 107 + 24 + True + True + False + True + + + + 140 + 153 + + + + + 40 + 40 + True + False + True + + + 324 + 179 + + + + + 100 + 20 + True + False + 100 + + + 8 + 201 + + + + + + + + + diff --git a/main.c b/main.c index c47fb25..5c5cc7c 100644 --- a/main.c +++ b/main.c @@ -1,185 +1,181 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "commands/help.h" -#include "commands/show_dir.h" -#include "commands/change_dir.h" -#include "utils/gtk_test.h" -#include "utils/sql_test.h" -#include "etc/logo.h" -#include "etc/man.h" -#include "etc/math_ext.h" -#include "etc/your-reality.h" -#include "utils/logger.h" -#include "utils/sys_info.h" -#include "utils/update_check.h" -#include "utils/calc.h" -#include "utils/clear_screen.h" - - -#define VERSION "0.3.1" - -bool VER_CHECK_ON_START = true; -bool DEV_MODE = false; -bool FUN_CONTENT = false; - -// Color Codes: -// Reset: \033[0m -// Red: \033[0;31m -// Green: \033[0;32m -// Yellow: \033[0;33m -// Blue: \033[0;34m -// Magenta: \033[0;35m -// Cyan: \033[0;36m -// BoldRed: \033[1;31m -// BoldGreen: \033[1;32m -// BoldYellow: \033[1;33m -// BoldBlue: \033[1;34m -// BoldMagenta: \033[1;35m -// BoldCyan: \033[1;36m - - -//Handles the commands -int commandHandler(char *cmd){ - char *token = strtok(cmd, " "); - int argc = 1; - char *arg[10]; - int i = 0; - while( token != NULL ){ - arg[i] = token; - token = strtok(NULL, " "); - if(token != NULL){ - i++; - argc++; - } - } - char *p = arg[i]; - p[strlen(p)-1] = 0; - arg[i] = p; - - //Start to compare the command - if(!strcmp(arg[0], "help")){ - printf("\033[1;34mcd \033[0;35m[dir]\033[0m : change directory\n"); - printf("\033[1;34mls \033[0;35m[dir]\033[0m : show contents of directory\n"); - printf("\033[1;34mhelp\033[0m : this help list\n"); - printf("\033[1;34mman \033[0;35m[cmd]\033[0m : manual for the commands\n"); - printf("\033[1;34mversion\033[0m : shows the version\n"); - printf("\033[1;34mexit\033[0m : exit the program\n"); - return 0; - } else if(!strcmp(arg[0], "version")){ - printf("netbenixCMD (Version: \033[1;34m%s\033[0m)\n", VERSION); - printf("Author: \033[1;34m%s\033[0m\n", "netbenix"); - printf("Github: \033[1;34mhttps://github.com/netbenix/netbenixCMD\033[0m\n"); - logger("Showing program version."); - return 0; - } else if(!strcmp(arg[0], "exit")){ - return 1; - } else if(!strcmp(arg[0], "ls")){ - showDirectory(arg); - return 0; - } else if(!strcmp(arg[0], "cd")){ - changeCurrentWorkDir(arg); - return 0; - } else if(!strcmp(arg[0], "man")){ - showManEntry(arg); - return 0; - } else if(!strcmp(arg[0], "calc")){ - startCalc(); - return 0; - } else if(!strcmp(arg[0], "rainbow") && FUN_CONTENT){ - while(1){ - printf("\033[0;31m#####"); - printf("\033[0;32m#####"); - printf("\033[0;33m#####"); - printf("\033[0;34m#####"); - printf("\033[0;35m#####"); - } - } else if(!strcmp(arg[0], "your-reality") && FUN_CONTENT){ - yourReality(); - } else { - printf("Unknown command. Please use 'help' for more information.\n"); - logger("User entered unknown command."); - return 0; - } -} - -//Action starts here -int main(int argc, char *argv[]){ - char buffer[1024]; - extern char loggerDirPath[PATH_MAX]; - realpath("." , loggerDirPath); - logger("================================================"); - snprintf(buffer, sizeof(buffer), "Starting netbenixCMD (Version: %s)", VERSION); - logger(buffer); - log_Specs(); //Log system specs - clearScreen(); //Clear the screen - showLogo(); //Show the logo - logger("Logo Displayed."); - if(argc > 2){ - printf("Too many arguments. Please use --help for more information.\n"); - snprintf(buffer, sizeof(buffer), "[ERROR] Too many arguments. Argument count: %i", argc-1); - logger(buffer); - } - - //Check the startup args - if(argc == 2){ - if(!strcmp(argv[1], "--help")){ - logger("Showing help."); - outputHelp(); - exit(0); - } else if (!strcmp(argv[1], "--gtk-test")){ - logger("Stating GTK test."); - createGTKTestWindow(); - exit(0); - } else if (!strcmp(argv[1], "--sys-info")){ - logger("Showing system information."); - print_Specs(); - exit(0); - } else if (!strcmp(argv[1], "--sql-test")){ - logger("Starting SQL test."); - testSQLConnection(); - exit(0); - } else if (!strcmp(argv[1], "--no-version-check")){ - VER_CHECK_ON_START = false; - logger("[INFO] Argument 'no-version-check' used."); - } else if (!strcmp(argv[1], "--dev-mode")){ - VER_CHECK_ON_START = false; - DEV_MODE = true; - logger("[INFO] Starting in developer mode."); - } else if (!strcmp(argv[1], "--time-for-fun")){ - FUN_CONTENT = true; - logger("[WARNING] It's time... TO PARTYY."); - } else { - printf("Argument unknown. Please use --help for more information.\n"); - snprintf(buffer, sizeof(buffer), "[ERROR] Argument unknown. Given argument: %s", argv[1]); - logger(buffer); - exit(0); - } - } - - if(VER_CHECK_ON_START){checkForUpdate(VERSION);} //Check for newer version of client - - //If no startup arg is given, start command handler - int exit = 0; - char cmd[128]; - logger("Starting Command Handler."); - while (!exit){ - char cwp[255]; - printf("\033[0;32m%s> \033[0m", getcwd(cwp, 255)); - fgets(cmd, 128, stdin); - exit = commandHandler(cmd); - } - logger("Exiting Command Handler."); - printf("\n"); - logger("Exiting."); - return 0; -} - - +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "commands/help.h" +#include "commands/show_dir.h" +#include "commands/change_dir.h" +#include "utils/gtk_test.h" +#include "utils/sql_test.h" +#include "etc/logo.h" +#include "etc/man.h" +#include "etc/math.h" +#include "etc/your-reality.h" +#include "utils/logger.h" +#include "utils/sys_info.h" +#include "utils/update_check.h" + + +#define VERSION "0.2.5" + +bool VER_CHECK_ON_START = true; +bool DEV_MODE = false; +bool FUN_CONTENT = false; + +// Color Codes: +// Reset: \033[0m +// Red: \033[0;31m +// Green: \033[0;32m +// Yellow: \033[0;33m +// Blue: \033[0;34m +// Magenta: \033[0;35m +// Cyan: \033[0;36m +// BoldRed: \033[1;31m +// BoldGreen: \033[1;32m +// BoldYellow: \033[1;33m +// BoldBlue: \033[1;34m +// BoldMagenta: \033[1;35m +// BoldCyan: \033[1;36m + + +//Handles the commands +int commandHandler(char *cmd){ + + char *token = strtok(cmd, " "); + int argc = 1; + char *arg[10]; + int i = 0; + while( token != NULL ){ + arg[i] = token; + token = strtok(NULL, " "); + if(token != NULL){ + i++; + argc++; + } + } + char *p = arg[i]; + p[strlen(p)-1] = 0; + arg[i] = p; + + //Start to compare the command + if(!strcmp(arg[0], "help")){ + printf("\033[1;34mcd \033[0;35m[dir]\033[0m : change directory\n"); + printf("\033[1;34mls \033[0;35m[dir]\033[0m : show contents of directory\n"); + printf("\033[1;34mhelp\033[0m : this help list\n"); + printf("\033[1;34mman \033[0;35m[cmd]\033[0m : manual for the commands\n"); + printf("\033[1;34mversion\033[0m : shows the version\n"); + printf("\033[1;34mexit\033[0m : exit the program\n"); + return 0; + } else if(!strcmp(arg[0], "version")){ + + printf("netbenixCMD (Version: \033[1;34m%s\033[0m)\n", VERSION); + printf("Author: \033[1;34m%s\033[0m\n", "netbenix"); + printf("Github: \033[1;34mhttps://github.com/netbenix/netbenixCMD\033[0m\n"); + logger("Showing program version."); + return 0; + } else if(!strcmp(arg[0], "exit")){ + return 1; + } else if(!strcmp(arg[0], "ls")){ + showDirectory(arg); + return 0; + } else if(!strcmp(arg[0], "cd")){ + changeCurrentWorkDir(arg); + return 0; + } else if(!strcmp(arg[0], "man")){ + showManEntry(arg); + return 0; + } else if(!strcmp(arg[0], "rainbow") && FUN_CONTENT){ + while(1){ + printf("\033[0;31m#####"); + printf("\033[0;32m#####"); + printf("\033[0;33m#####"); + printf("\033[0;34m#####"); + printf("\033[0;35m#####"); + } + } else if(!strcmp(arg[0], "your-reality") && FUN_CONTENT){ + yourReality(); + } else { + printf("Unknown command. Please use 'help' for more information.\n"); + logger("User entered unknown command."); + return 0; + } +} + +//Action starts here +int main(int argc, char *argv[]){ + char buffer[1024]; + extern char loggerDirPath[PATH_MAX]; + realpath("." , loggerDirPath); + logger("================================================"); + snprintf(buffer, sizeof(buffer), "Starting netbenixCMD (Version: %s)", VERSION); + logger(buffer); + log_Specs(); //Log system specs + showLogo(); //Show the logo + logger("Logo Displayed."); + if(argc > 2){ + printf("Too many arguments. Please use --help for more information.\n"); + snprintf(buffer, sizeof(buffer), "[ERROR] Too many arguments. Argument count: %i", argc-1); + logger(buffer); + } + + //Check the startup args + if(argc == 2){ + if(!strcmp(argv[1], "--help")){ + logger("Showing Help."); + outputHelp(); + exit(0); + } else if (!strcmp(argv[1], "--gtk-test")){ + logger("Stating GTK Test."); + createGTKTestWindow(); + exit(0); + } else if (!strcmp(argv[1], "--sys-info")){ + logger("Showing System Information."); + print_Specs(); + exit(0); + } else if (!strcmp(argv[1], "--sql-test")){ + logger("Starting SQL Test."); + testSQLConnection(); + exit(0); + } else if (!strcmp(argv[1], "--no-version-check")){ + VER_CHECK_ON_START = false; + logger("[INFO] Argument 'no-version-check' used."); + } else if (!strcmp(argv[1], "--dev-mode")){ + VER_CHECK_ON_START = false; + DEV_MODE = true; + logger("[INFO] Starting in developer mode."); + } else if (!strcmp(argv[1], "--time-for-fun")){ + FUN_CONTENT = true; + logger("[WARNING] It's time... TO PARTYY."); + } else { + printf("Argument unknown. Please use --help for more information.\n"); + snprintf(buffer, sizeof(buffer), "[ERROR] Argument unknown. Given argument: %s", argv[1]); + logger(buffer); + exit(0); + } + } + + if(VER_CHECK_ON_START){checkForUpdate(VERSION);} //Check for newer version of client + + //If no startup arg is given, start command handler + int exit = 0; + char cmd[128]; + logger("Starting Command Handler."); + while (!exit){ + char cwp[255]; + printf("\033[0;32m%s> \033[0m", getcwd(cwp, 255)); + fgets(cmd, 128, stdin); + exit = commandHandler(cmd); + } + logger("Exiting Command Handler."); + printf("\n"); + logger("Exiting."); + return 0; +} + + diff --git a/makefile b/makefile index 84498fc..28d38d9 100644 --- a/makefile +++ b/makefile @@ -1,37 +1,36 @@ -CC= gcc -ARGS= -export-dynamic -ansi -std=gnu99 -CFLAGS= $(shell pkg-config --cflags gtk+-3.0) -I/usr/include/mysql -LDLIBS= $(shell pkg-config --libs gtk+-3.0) -L/usr/lib/mysql -lmysqlclient -lm -OBJ= main.o logo.o logger.o help.o sys_info.o gtk_test.o sql_test.o show_dir.o change_dir.o update_check.o man.o your-reality.o math_ext.o calc.o clear_screen.o -netbenixCMD: $(OBJ) - $(CC) $(CFLAGS) $(ARGS) -o netbenixCMD $(OBJ) $(LDLIBS) -main.o: main.c - $(CC) $(CFLAGS) -c main.c -logo.o: etc/logo.c - $(CC) $(CFLAGS) -c etc/logo.c -logger.o: utils/logger.c - $(CC) $(CFLAGS) -c utils/logger.c -help.o: commands/help.c - $(CC) $(CFLAGS) -c commands/help.c -sys_info.o: utils/sys_info.c - $(CC) $(CFLAGS) $(ARGS) -c utils/sys_info.c -gtk_test.o: utils/gtk_test.c - $(CC) $(CFLAGS) -c utils/gtk_test.c -sql_test.o: utils/sql_test.c - $(CC) $(CFLAGS) -c utils/sql_test.c -show_dir.o: commands/show_dir.c - $(CC) $(CFLAGS) -c commands/show_dir.c -change_dir.o: commands/change_dir.c - $(CC) $(CFLAGS) -c commands/change_dir.c -update_check.o: utils/update_check.c - $(CC) $(CFLAGS) -c utils/update_check.c -man.o: etc/man.c - $(CC) $(CFLAGS) -c etc/man.c -math_ext.o: etc/math_ext.c - $(CC) $(CFLAGS) -c etc/math_ext.c -your-reality.o: etc/your-reality.c - $(CC) $(CFLAGS) -c etc/your-reality.c -calc.o: utils/calc.c - $(CC) $(CFLAGS) -c utils/calc.c -clear_screen.o: utils/clear_screen.c - $(CC) $(CFLAGS) -c utils/clear_screen.c \ No newline at end of file +CC= gcc +ARGS= -export-dynamic -ansi -std=gnu99 +CFLAGS= $(shell pkg-config --cflags gtk+-3.0) -I/usr/include/mysql +LDLIBS= $(shell pkg-config --libs gtk+-3.0) -L/usr/lib/mysql -lmysqlclient +OBJ= main.o logo.o logger.o help.o sys_info.o gtk_test.o sql_test.o show_dir.o change_dir.o update_check.o man.o your-reality.o math_ext.o calc.o + +netbenixCMD: $(OBJ) + $(CC) $(CFLAGS) $(ARGS) -o netbenixCMD $(OBJ) $(LDLIBS) +main.o: main.c + $(CC) $(CFLAGS) -c main.c +logo.o: etc/logo.c + $(CC) $(CFLAGS) -c etc/logo.c +logger.o: utils/logger.c + $(CC) $(CFLAGS) -c utils/logger.c +help.o: commands/help.c + $(CC) $(CFLAGS) -c commands/help.c +sys_info.o: utils/sys_info.c + $(CC) $(CFLAGS) $(ARGS) -c utils/sys_info.c +gtk_test.o: utils/gtk_test.c + $(CC) $(CFLAGS) -c utils/gtk_test.c +sql_test.o: utils/sql_test.c + $(CC) $(CFLAGS) -c utils/sql_test.c +show_dir.o: commands/show_dir.c + $(CC) $(CFLAGS) -c commands/show_dir.c +change_dir.o: commands/change_dir.c + $(CC) $(CFLAGS) -c commands/change_dir.c +update_check.o: utils/update_check.c + $(CC) $(CFLAGS) -c utils/update_check.c +man.o: etc/man.c + $(CC) $(CFLAGS) -c etc/man.c +math.o: etc/math_ext.c + $(CC) $(CFLAGS) -c etc/math_ext.c +your-reality.o: etc/your-reality.c + $(CC) $(CFLAGS) -c etc/your-reality.c +calc.o: utils/calc.c + $(CC) $(CFLAGS) -c utils/calc.c \ No newline at end of file diff --git a/utils/clear_screen.c b/utils/clear_screen.c deleted file mode 100644 index 4a315dc..0000000 --- a/utils/clear_screen.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#if defined(_WIN32) -#include -#elif defined(__linux__) -#include -#include -#endif - -#include "clear_screen.h" - - -void clearScreen(){ - #if defined(_WIN32) - CONSOLE_SCREEN_BUFFER_INFO csbi; - int rows; - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); - rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; - for(int i = 0; i < rows; i++){ - printf("\n"); - } - #elif defined(__linux__) - struct winsize w; - ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); - for(int i = 0; i < w.ws_row; i++){ - printf("\n"); - } - #endif -} \ No newline at end of file diff --git a/utils/clear_screen.h b/utils/clear_screen.h deleted file mode 100644 index 41c86c9..0000000 --- a/utils/clear_screen.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _CLEAR_SCREEN_H_ -#define _CLEAR_SCREEN_H_ - -void clearScreen(); - -#endif \ No newline at end of file