From fc462e3f81528258cff1c043f75a2f2f1de8615f Mon Sep 17 00:00:00 2001 From: netbenix Date: Thu, 19 Nov 2020 12:31:31 +0100 Subject: [PATCH] Added math module --- etc/math.c | 24 ++++++++++++++++++++++++ etc/math.h | 9 +++++++++ main.c | 1 + makefile | 4 +++- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 etc/math.c create mode 100644 etc/math.h diff --git a/etc/math.c b/etc/math.c new file mode 100644 index 0000000..5409e07 --- /dev/null +++ b/etc/math.c @@ -0,0 +1,24 @@ +#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); +} \ No newline at end of file diff --git a/etc/math.h b/etc/math.h new file mode 100644 index 0000000..b52fd57 --- /dev/null +++ b/etc/math.h @@ -0,0 +1,9 @@ +#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); + +#endif \ No newline at end of file diff --git a/main.c b/main.c index 1c94ad1..2ed8f5a 100644 --- a/main.c +++ b/main.c @@ -15,6 +15,7 @@ #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" diff --git a/makefile b/makefile index 407fe6f..8457c14 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ 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 +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 netbenixCMD: $(OBJ) $(CC) $(CFLAGS) $(ARGS) -o netbenixCMD $(OBJ) $(LDLIBS) @@ -28,5 +28,7 @@ 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 your-reality.o: etc/your-reality.c $(CC) $(CFLAGS) -c etc/your-reality.c \ No newline at end of file