Update 0.2.6

This commit is contained in:
netbenix 2021-05-08 20:06:22 +02:00
commit 88f11da06f
13 changed files with 177 additions and 88 deletions

3
.gitignore vendored
View file

@ -13,8 +13,5 @@ show_dir.o
change_dir.o change_dir.o
update_check.o update_check.o
man.o man.o
<<<<<<< HEAD
math.o math.o
=======
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
your-reality.o your-reality.o

View file

@ -1,4 +1,4 @@
# **netbenixCMD** # netbenixCMD
A little project of mine to learn C. A little project of mine to learn C.
@ -8,40 +8,59 @@ Tested on: *Ubuntu, Debian, Arch*
Used libs for Linux: *gtk+3.0, libmysqlclient* Used libs for Linux: *gtk+3.0, libmysqlclient*
Version: *0.2.4* Version: *0.2.6*
## Features: ## Features:
- A help page (OMG!!!) - A help page (OMG!!!)
- A little GTK Test - A little GTK Test
- Can detect if you're using linux or not and tell the Architecture you're running on
- 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) - Can give you a bit of information about your CPU (but just a little bit)
- Checks your client version on start with the server - Checks your client version on start with the server
## Building: ## Building:
Install packages: Install packages:
- Ubuntu: ```sudo apt-get install make gcc git libgtk-3-dev libmysqlclient-dev``` - 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``` - Debian: `sudo apt-get install make gcc git libgtk-3-dev libmariadbclient-dev
libmariadb-dev-compat`
Go into the cloned directory: ```cd netbenixCMD``` - Arch: `sudo pacman -S make gcc git gtk3 mariadb-libs pkgconf`
Build program: ```make``` Clone repository: `git clone https://github.com/netbenix/netbenixCMD.git`
Go into the cloned directory: `cd netbenixCMD`
Build program: `make`
## Usage ## Usage
After building use ```./netbenixCMD``` to start the program
If you want to use the testing arguments use ```./netbenixCMD <argument>``` After building use `./netbenixCMD` to start the program
If you want to use the testing arguments use `./netbenixCMD <argument>`
## Arguments ## Arguments
- ```--help``` => Displays all arguments
- ```--gtk-test``` => Opens the GTK Test Window - `--help` =\> Displays all arguments
- ```--sql-test``` => Makes a test connection to a mysql server
- ```--sys-info``` => Gives you information about your system - `--gtk-test` =\> Opens the GTK Test Window
- ```--no-version-check``` => Skips the client version check
- ```--dev-mode``` => Starts the program in developer mode (right now it just skips version check) - `--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 ## Known Bugs
- ```sql-test``` sha-256 passwords not working on Debian
- `sql-test` sha-256 passwords not working on Debian

BIN
calc.o Normal file

Binary file not shown.

View file

@ -26,7 +26,7 @@ void showDirectory(char *arg[]){
DIR *d; DIR *d;
struct dirent *dir; struct dirent *dir;
char path[PATH_MAX]; char path[PATH_MAX];
;
d = opendir(arg[1]); //Try to open directory d = opendir(arg[1]); //Try to open directory
if(d == NULL){ //Check if directory exists if(d == NULL){ //Check if directory exists
printf("Folder not found.\n"); printf("Folder not found.\n");

View file

@ -3,7 +3,7 @@
#include <math.h> #include <math.h>
#include "../utils/logger.h" #include "../utils/logger.h"
#include "math.h" #include "math_ext.h"
double Add(double x, double y){ double Add(double x, double y){
return(x + y); return(x + y);
@ -22,3 +22,11 @@ double Div(double x, double y){
else else
return(x / y); return(x / y);
} }
double CubeVolume(double a){
return pow(a, 3);
}
double SphereVolume(double r){
return (4/3*M_PI*pow(r, 3));
}

View file

@ -1,9 +1,12 @@
#ifndef _MATH_H_ #ifndef _MATH_EXT_H_
#define _MATH_H_ #define _MATH_EXT_H_
double Add(double x, double y); double Add(double x, double y);
double Sub(double x, double y); double Sub(double x, double y);
double Mul(double x, double y); double Mul(double x, double y);
double Div(double x, double y); double Div(double x, double y);
double CubeVolume(double a);
double SphereVolume(double r);
#endif #endif

3
main.c
View file

@ -15,10 +15,7 @@
#include "utils/sql_test.h" #include "utils/sql_test.h"
#include "etc/logo.h" #include "etc/logo.h"
#include "etc/man.h" #include "etc/man.h"
<<<<<<< HEAD
#include "etc/math.h" #include "etc/math.h"
=======
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
#include "etc/your-reality.h" #include "etc/your-reality.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "utils/sys_info.h" #include "utils/sys_info.h"

BIN
math.o Normal file

Binary file not shown.

BIN
math_ext.o Normal file

Binary file not shown.

54
utils/calc.c Normal file
View file

@ -0,0 +1,54 @@
#include <stdio.h>
#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;
}

12
utils/calc.h Normal file
View file

@ -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

View file

@ -5,7 +5,7 @@
#include "update_check.h" #include "update_check.h"
#include "logger.h" #include "logger.h"
#define SERVER_IP "127.0.0.1" #define DEFAULT_IP "127.0.0.1"
int checkForUpdate(char ver[10]){ int checkForUpdate(char ver[10]){
int sock; int sock;
@ -19,7 +19,7 @@ int checkForUpdate(char ver[10]){
logger("Error while creating socket"); 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_family = AF_INET;
server.sin_port = htons( 34000 ); //Set the server port server.sin_port = htons( 34000 ); //Set the server port

View file

@ -2,5 +2,4 @@
#define _UPDATE_CHECK_H_ #define _UPDATE_CHECK_H_
int checkForUpdate(char ver[10]); int checkForUpdate(char ver[10]);
#endif #endif