From 3a0cb7078cb1e9d46c0a49c8a28e97a34c243d65 Mon Sep 17 00:00:00 2001 From: netbenix Date: Sat, 8 May 2021 20:01:49 +0200 Subject: [PATCH] Update 0.2.6 --- README.md | 2 +- etc/{math.c => math_ext.c} | 10 ++++++- etc/{math.h => math_ext.h} | 7 +++-- etc/your-reality.c | 41 ---------------------------- etc/your-reality.h | 8 ------ main.c | 8 ++++-- makefile | 12 +++++---- math.o | Bin 0 -> 2328 bytes utils/calc.c | 54 +++++++++++++++++++++++++++++++++++++ utils/calc.h | 12 +++++++++ utils/update_check.c | 2 +- 11 files changed, 95 insertions(+), 61 deletions(-) rename etc/{math.c => math_ext.c} (66%) rename etc/{math.h => math_ext.h} (54%) create mode 100644 math.o create mode 100644 utils/calc.c create mode 100644 utils/calc.h diff --git a/README.md b/README.md index b698f62..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.2.4* +Version: *0.2.6* ## Features: 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 9d79011..ce8a05f 100644 --- a/etc/math.c +++ b/etc/math_ext.c @@ -3,7 +3,7 @@ #include #include "../utils/logger.h" -#include "math.h" +#include "math_ext.h" double Add(double x, double y){ return(x + y); @@ -21,4 +21,12 @@ double Div(double x, double y){ 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 aa3f520..74a06e5 100644 --- a/etc/math.h +++ b/etc/math_ext.h @@ -1,9 +1,12 @@ -#ifndef _MATH_H_ -#define _MATH_H_ +#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/etc/your-reality.c b/etc/your-reality.c index 270ff87..e64d55f 100644 --- a/etc/your-reality.c +++ b/etc/your-reality.c @@ -1,4 +1,3 @@ -<<<<<<< HEAD #include #include @@ -37,43 +36,3 @@ void yourReality(){ 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 4151b24..06363f3 100644 --- a/etc/your-reality.h +++ b/etc/your-reality.h @@ -1,14 +1,6 @@ -<<<<<<< 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/main.c b/main.c index d46aab7..6c07f2f 100644 --- a/main.c +++ b/main.c @@ -15,14 +15,15 @@ #include "utils/sql_test.h" #include "etc/logo.h" #include "etc/man.h" -#include "etc/math.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" -#define VERSION "0.2.5" +#define VERSION "0.2.6" bool VER_CHECK_ON_START = true; bool DEV_MODE = false; @@ -88,6 +89,9 @@ int commandHandler(char *cmd){ } 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#####"); diff --git a/makefile b/makefile index 101083c..3b2d376 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,8 @@ 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.o +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 netbenixCMD: $(OBJ) $(CC) $(CFLAGS) $(ARGS) -o netbenixCMD $(OBJ) $(LDLIBS) main.o: main.c @@ -27,7 +27,9 @@ 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.c - $(CC) $(CFLAGS) -c etc/math.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 \ No newline at end of file + $(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/math.o b/math.o new file mode 100644 index 0000000000000000000000000000000000000000..217e530046d31d5665f552a415c44aa69f3c83ee GIT binary patch literal 2328 zcmb_c&1=+95T9*pyRB`r6%WOVLA zghb#B)IEU$JlRpVbtH%4aqgsDo-1Xe} zVFoax30Djk?Q`VZ6f^)-32VefvfEb>SsI5(B^K#vZ;3ABK=&d}i=>wxMrZ6nL!zTO zjREKqcZzV7t@s(A-jct~{19nT|5m;JQ|6Bc`9ht4#e5>jFZn!En-tyECiwn)6M;Zu z=uIX(aG5!gdax@H@AUw&cE*J-G|hnG&!Z+0IQ5_KiiZMty+FI0adAek2Z$ZSMYUu( zfj}638gZ(>&Iw+x$j+NiPMd{+xjC3{GcfAT!_c(_NVpm6LUG>BTaX?}jSUW@(qqHJ z6UJnEa$qoJq@h&22@|E9Ws5Ms@O!S0_shFmzkd7jk#V|nZMXy;<)4NezlU)-{(uxu zJc;T(f$p`p*acm}MZd2|xR}R12^aHtCgEZpRS6gU1+Bc8cgzfG$M$tjShh89YK~QL zK$|li6SPdZ44Pf^o!MeOZxxU$6dg;$Z?&)Nn6o$7zglp$l3grWwzG&iRLRPvv$lzY z`X8cV5o&R>R7_|8824Y$k_$aZ&`fj@z`C0UCHlD&amtMfp7kNd8`&3XL4FYvGJFJa zs`;<^am=NfbdQ2k;TOr@me{|DrSFeI`vt)IA?MTig2J$uL--&rfd%7Ugn=QkC1D o=>JM3#rs7*)s$zC5UenGmYjfaxf;@iR#?8uzka6{=^JwXAL6DVfdBvi literal 0 HcmV?d00001 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 6c77891..51a66c0 100644 --- a/utils/update_check.c +++ b/utils/update_check.c @@ -5,7 +5,7 @@ #include "update_check.h" #include "logger.h" -#define DEFAULT_IP "192.168.0.32" +#define DEFAULT_IP "127.0.0.1" int checkForUpdate(char ver[10]){ int sock;