diff --git a/.gitignore b/.gitignore index 8c657d5..9532f51 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,5 @@ show_dir.o change_dir.o update_check.o man.o -<<<<<<< HEAD math.o -======= ->>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80 your-reality.o \ No newline at end of file diff --git a/README.md b/README.md index 60668ba..42b34bb 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,66 @@ -# **netbenixCMD** - -A little project of mine to learn C. - -Available for: *Linux* - -Tested on: *Ubuntu, Debian, Arch* - -Used libs for Linux: *gtk+3.0, libmysqlclient* - -Version: *0.2.4* - -## Features: -- A help page (OMG!!!) -- A little GTK Test -- Can detect if you're using linux or not and tell the Architecture you're running on -- Can give you a bit of information about your CPU (but just a little bit) -- Checks your client version on start with the server - -## Building: -Install packages: - -- Ubuntu: ```sudo apt-get install make gcc git libgtk-3-dev libmysqlclient-dev``` -- Debian: ```sudo apt-get install make gcc git libgtk-3-dev libmariadbclient-dev libmariadb-dev-compat``` -- Arch: ```sudo pacman -S make gcc git gtk3 mariadb-libs pkgconf``` - -Clone repository: ```git clone https://github.com/netbenix/netbenixCMD.git``` - -Go into the cloned directory: ```cd netbenixCMD``` - -Build program: ```make``` - -## Usage -After building use ```./netbenixCMD``` to start the program - -If you want to use the testing arguments use ```./netbenixCMD ``` - -## Arguments -- ```--help``` => Displays all arguments -- ```--gtk-test``` => Opens the GTK Test Window -- ```--sql-test``` => Makes a test connection to a mysql server -- ```--sys-info``` => Gives you information about your system -- ```--no-version-check``` => Skips the client version check -- ```--dev-mode``` => Starts the program in developer mode (right now it just skips version check) - -## Known Bugs -- ```sql-test``` sha-256 passwords not working on Debian \ No newline at end of file +# netbenixCMD + +A little project of mine to learn C. + +Available for: *Linux* + +Tested on: *Ubuntu, Debian, Arch* + +Used libs for Linux: *gtk+3.0, libmysqlclient* + +Version: *0.2.6* + +## Features: + +- A help page (OMG!!!) + +- A little GTK Test + +- Can detect if you're using linux or not and tell the Architecture you're + running on + +- Can give you a bit of information about your CPU (but just a little bit) + +- Checks your client version on start with the server + +## Building: + +Install packages: + +- Ubuntu: `sudo apt-get install make gcc git libgtk-3-dev libmysqlclient-dev` + +- Debian: `sudo apt-get install make gcc git libgtk-3-dev libmariadbclient-dev + libmariadb-dev-compat` + +- Arch: `sudo pacman -S make gcc git gtk3 mariadb-libs pkgconf` + +Clone repository: `git clone https://github.com/netbenix/netbenixCMD.git` + +Go into the cloned directory: `cd netbenixCMD` + +Build program: `make` + +## Usage + +After building use `./netbenixCMD` to start the program + +If you want to use the testing arguments use `./netbenixCMD ` + +## Arguments + +- `--help` =\> Displays all arguments + +- `--gtk-test` =\> Opens the GTK Test Window + +- `--sql-test` =\> Makes a test connection to a mysql server + +- `--sys-info` =\> Gives you information about your system + +- `--no-version-check` =\> Skips the client version check + +- `--dev-mode` =\> Starts the program in developer mode (right now it just + skips version check) + +## Known Bugs + +- `sql-test` sha-256 passwords not working on Debian diff --git a/calc.o b/calc.o new file mode 100644 index 0000000..488b657 Binary files /dev/null and b/calc.o differ diff --git a/commands/show_dir.c b/commands/show_dir.c index 4664644..1074880 100644 --- a/commands/show_dir.c +++ b/commands/show_dir.c @@ -26,7 +26,7 @@ void showDirectory(char *arg[]){ DIR *d; struct dirent *dir; char path[PATH_MAX]; - +; d = opendir(arg[1]); //Try to open directory if(d == NULL){ //Check if directory exists printf("Folder not found.\n"); diff --git a/etc/math.c b/etc/math_ext.c similarity index 66% rename from etc/math.c rename to etc/math_ext.c index 5409e07..ce8a05f 100644 --- a/etc/math.c +++ b/etc/math_ext.c @@ -1,24 +1,32 @@ -#include -#include -#include -#include "../utils/logger.h" - -#include "math.h" - -double Add(double x, double y){ - return(x + y); -} - -double Sub(double x, double y){ - return(x - y); -} - -double Mul(double x, double y){ - return(x * y); -} -double Div(double x, double y){ - if (y == 0.0) - return 0.0; - else - return(x / y); +#include +#include +#include +#include "../utils/logger.h" + +#include "math_ext.h" + +double Add(double x, double y){ + return(x + y); +} + +double Sub(double x, double y){ + return(x - y); +} + +double Mul(double x, double y){ + return(x * y); +} +double Div(double x, double y){ + if (y == 0.0) + return 0.0; + else + return(x / y); +} + +double CubeVolume(double a){ + return pow(a, 3); +} + +double SphereVolume(double r){ + return (4/3*M_PI*pow(r, 3)); } \ No newline at end of file diff --git a/etc/math.h b/etc/math_ext.h similarity index 54% rename from etc/math.h rename to etc/math_ext.h index b52fd57..74a06e5 100644 --- a/etc/math.h +++ b/etc/math_ext.h @@ -1,9 +1,12 @@ -#ifndef _MATH_H_ -#define _MATH_H_ - -double Add(double x, double y); -double Sub(double x, double y); -double Mul(double x, double y); -double Div(double x, double y); - +#ifndef _MATH_EXT_H_ +#define _MATH_EXT_H_ + +double Add(double x, double y); +double Sub(double x, double y); +double Mul(double x, double y); +double Div(double x, double y); + +double CubeVolume(double a); +double SphereVolume(double r); + #endif \ No newline at end of file diff --git a/main.c b/main.c index c66417a..5c5cc7c 100644 --- a/main.c +++ b/main.c @@ -15,10 +15,7 @@ #include "utils/sql_test.h" #include "etc/logo.h" #include "etc/man.h" -<<<<<<< HEAD #include "etc/math.h" -======= ->>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80 #include "etc/your-reality.h" #include "utils/logger.h" #include "utils/sys_info.h" diff --git a/math.o b/math.o new file mode 100644 index 0000000..217e530 Binary files /dev/null and b/math.o differ diff --git a/math_ext.o b/math_ext.o new file mode 100644 index 0000000..62828c7 Binary files /dev/null and b/math_ext.o differ diff --git a/utils/calc.c b/utils/calc.c new file mode 100644 index 0000000..2d7dcca --- /dev/null +++ b/utils/calc.c @@ -0,0 +1,54 @@ +#include + +#include "calc.h" +#include "../etc/math_ext.h" +#include "logger.h" + +void startCalc(){ + logger("Started calculator."); + char op; + printf("Calculator - Version 0.1\n\n"); + + do{ + printf("\nOperation (h for help): "); + scanf("%c", &op); + chooseOperation(op); + }while(op != 'q'); + + +} + +void chooseOperation(char op){ + logger("Operation choosen: " + op); + + switch(op){ + case '1': { OP_1(); break;}; + case 'h': { listOperations(); break;}; + case 'q': {/*do nothing bcause auto break*/ break;} + default: { /*do none*/ break;}; + } +} + +void listOperations(){ + printf("Operations List: \n\n"); + printf("1 - Addition\n"); + printf("2 - Subtraction\n"); + printf("3 - Multiply\n"); + printf("4 - Divide\n"); +} + +void OP_1(){ + double x, y; + printf("1. Number: \n"); + scanf("%lf", &x); + printf("2. Number: \n"); + scanf("%lf", &y); + printf("\n Result: %lf\n", Add(x,y)); +} + +int getNumber(){ + int no; + scanf("%d", &no); + + return no; +} \ No newline at end of file diff --git a/utils/calc.h b/utils/calc.h new file mode 100644 index 0000000..63543e4 --- /dev/null +++ b/utils/calc.h @@ -0,0 +1,12 @@ +#ifndef _CALC_H_ +#define _CALC_H_ + +void startCalc(); +void chooseOperation(char op); +void listOperations(); +int getNumber(); + +//Operations +void OP_1(); + +#endif \ No newline at end of file diff --git a/utils/update_check.c b/utils/update_check.c index 8ca0442..51a66c0 100644 --- a/utils/update_check.c +++ b/utils/update_check.c @@ -5,7 +5,7 @@ #include "update_check.h" #include "logger.h" -#define SERVER_IP "127.0.0.1" +#define DEFAULT_IP "127.0.0.1" int checkForUpdate(char ver[10]){ int sock; @@ -19,7 +19,7 @@ int checkForUpdate(char ver[10]){ logger("Error while creating socket"); } - server.sin_addr.s_addr = inet_addr(SERVER_IP); //Set the IP address of the server + server.sin_addr.s_addr = inet_addr(DEFAULT_IP); //Set the IP address of the server server.sin_family = AF_INET; server.sin_port = htons( 34000 ); //Set the server port diff --git a/utils/update_check.h b/utils/update_check.h index 2b4a08d..3984e95 100644 --- a/utils/update_check.h +++ b/utils/update_check.h @@ -2,5 +2,4 @@ #define _UPDATE_CHECK_H_ int checkForUpdate(char ver[10]); - #endif \ No newline at end of file