Update
This commit is contained in:
parent
9caca5a4fb
commit
f55aa94d84
10 changed files with 330 additions and 374 deletions
38
.gitignore
vendored
38
.gitignore
vendored
|
|
@ -1,20 +1,20 @@
|
||||||
.vscode
|
.vscode
|
||||||
glade/test_window.glade~
|
glade/test_window.glade~
|
||||||
netbenixCMD
|
netbenixCMD
|
||||||
output.log
|
output.log
|
||||||
main.o
|
main.o
|
||||||
logger.o
|
logger.o
|
||||||
help.o
|
help.o
|
||||||
logo.o
|
logo.o
|
||||||
sql_test.o
|
sql_test.o
|
||||||
gtk_test.o
|
gtk_test.o
|
||||||
sys_info.o
|
sys_info.o
|
||||||
show_dir.o
|
show_dir.o
|
||||||
change_dir.o
|
change_dir.o
|
||||||
update_check.o
|
update_check.o
|
||||||
man.o
|
man.o
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
math.o
|
math.o
|
||||||
=======
|
=======
|
||||||
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
|
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
|
||||||
your-reality.o
|
your-reality.o
|
||||||
113
README.md
113
README.md
|
|
@ -1,47 +1,66 @@
|
||||||
# **netbenixCMD**
|
# netbenixCMD
|
||||||
|
|
||||||
A little project of mine to learn C.
|
A little project of mine to learn C.
|
||||||
|
|
||||||
Available for: *Linux*
|
Available for: *Linux*
|
||||||
|
|
||||||
Tested on: *Ubuntu, Debian, Arch*
|
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.4*
|
||||||
|
|
||||||
## Features:
|
## Features:
|
||||||
- A help page (OMG!!!)
|
|
||||||
- A little GTK Test
|
- A help page (OMG!!!)
|
||||||
- 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)
|
- A little GTK Test
|
||||||
- Checks your client version on start with the server
|
|
||||||
|
- Can detect if you're using linux or not and tell the Architecture you're
|
||||||
## Building:
|
running on
|
||||||
Install packages:
|
|
||||||
|
- Can give you a bit of information about your CPU (but just a little bit)
|
||||||
- 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```
|
- Checks your client version on start with the server
|
||||||
- Arch: ```sudo pacman -S make gcc git gtk3 mariadb-libs pkgconf```
|
|
||||||
|
## Building:
|
||||||
Clone repository: ```git clone https://github.com/netbenix/netbenixCMD.git```
|
|
||||||
|
Install packages:
|
||||||
Go into the cloned directory: ```cd netbenixCMD```
|
|
||||||
|
- Ubuntu: `sudo apt-get install make gcc git libgtk-3-dev libmysqlclient-dev`
|
||||||
Build program: ```make```
|
|
||||||
|
- Debian: `sudo apt-get install make gcc git libgtk-3-dev libmariadbclient-dev
|
||||||
## Usage
|
libmariadb-dev-compat`
|
||||||
After building use ```./netbenixCMD``` to start the program
|
|
||||||
|
- Arch: `sudo pacman -S make gcc git gtk3 mariadb-libs pkgconf`
|
||||||
If you want to use the testing arguments use ```./netbenixCMD <argument>```
|
|
||||||
|
Clone repository: `git clone https://github.com/netbenix/netbenixCMD.git`
|
||||||
## Arguments
|
|
||||||
- ```--help``` => Displays all arguments
|
Go into the cloned directory: `cd netbenixCMD`
|
||||||
- ```--gtk-test``` => Opens the GTK Test Window
|
|
||||||
- ```--sql-test``` => Makes a test connection to a mysql server
|
Build program: `make`
|
||||||
- ```--sys-info``` => Gives you information about your system
|
|
||||||
- ```--no-version-check``` => Skips the client version check
|
## Usage
|
||||||
- ```--dev-mode``` => Starts the program in developer mode (right now it just skips version check)
|
|
||||||
|
After building use `./netbenixCMD` to start the program
|
||||||
## Known Bugs
|
|
||||||
- ```sql-test``` sha-256 passwords not working on Debian
|
If you want to use the testing arguments use `./netbenixCMD <argument>`
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
|
||||||
|
|
@ -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");
|
||||||
|
|
|
||||||
49
etc/man.c
49
etc/man.c
|
|
@ -1,4 +1,3 @@
|
||||||
<<<<<<< HEAD
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -47,52 +46,4 @@ void showManEntry(char *arg[]){
|
||||||
} else {
|
} else {
|
||||||
printf("Entry not found.\n");
|
printf("Entry not found.\n");
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.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");
|
|
||||||
}
|
|
||||||
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
|
|
||||||
}
|
}
|
||||||
46
etc/math.c
46
etc/math.c
|
|
@ -1,24 +1,24 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../utils/logger.h"
|
#include "../utils/logger.h"
|
||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
double Add(double x, double y){
|
double Add(double x, double y){
|
||||||
return(x + y);
|
return(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Sub(double x, double y){
|
double Sub(double x, double y){
|
||||||
return(x - y);
|
return(x - y);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Mul(double x, double y){
|
double Mul(double x, double y){
|
||||||
return(x * y);
|
return(x * y);
|
||||||
}
|
}
|
||||||
double Div(double x, double y){
|
double Div(double x, double y){
|
||||||
if (y == 0.0)
|
if (y == 0.0)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
else
|
else
|
||||||
return(x / y);
|
return(x / y);
|
||||||
}
|
}
|
||||||
16
etc/math.h
16
etc/math.h
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef _MATH_H_
|
#ifndef _MATH_H_
|
||||||
#define _MATH_H_
|
#define _MATH_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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
363
main.c
363
main.c
|
|
@ -1,184 +1,179 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <gdk/gdkconfig.h>
|
#include <gdk/gdkconfig.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
|
||||||
#include "commands/help.h"
|
#include "commands/help.h"
|
||||||
#include "commands/show_dir.h"
|
#include "commands/show_dir.h"
|
||||||
#include "commands/change_dir.h"
|
#include "commands/change_dir.h"
|
||||||
#include "utils/gtk_test.h"
|
#include "utils/gtk_test.h"
|
||||||
#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"
|
#include "etc/your-reality.h"
|
||||||
=======
|
#include "utils/logger.h"
|
||||||
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
|
#include "utils/sys_info.h"
|
||||||
#include "etc/your-reality.h"
|
#include "utils/update_check.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;
|
||||||
#define VERSION "0.2.5"
|
bool DEV_MODE = false;
|
||||||
|
bool FUN_CONTENT = false;
|
||||||
bool VER_CHECK_ON_START = true;
|
|
||||||
bool DEV_MODE = false;
|
// Color Codes:
|
||||||
bool FUN_CONTENT = false;
|
// Reset: \033[0m
|
||||||
|
// Red: \033[0;31m
|
||||||
// Color Codes:
|
// Green: \033[0;32m
|
||||||
// Reset: \033[0m
|
// Yellow: \033[0;33m
|
||||||
// Red: \033[0;31m
|
// Blue: \033[0;34m
|
||||||
// Green: \033[0;32m
|
// Magenta: \033[0;35m
|
||||||
// Yellow: \033[0;33m
|
// Cyan: \033[0;36m
|
||||||
// Blue: \033[0;34m
|
// BoldRed: \033[1;31m
|
||||||
// Magenta: \033[0;35m
|
// BoldGreen: \033[1;32m
|
||||||
// Cyan: \033[0;36m
|
// BoldYellow: \033[1;33m
|
||||||
// BoldRed: \033[1;31m
|
// BoldBlue: \033[1;34m
|
||||||
// BoldGreen: \033[1;32m
|
// BoldMagenta: \033[1;35m
|
||||||
// BoldYellow: \033[1;33m
|
// BoldCyan: \033[1;36m
|
||||||
// BoldBlue: \033[1;34m
|
|
||||||
// BoldMagenta: \033[1;35m
|
|
||||||
// BoldCyan: \033[1;36m
|
//Handles the commands
|
||||||
|
int commandHandler(char *cmd){
|
||||||
|
char *token = strtok(cmd, " ");
|
||||||
//Handles the commands
|
int argc = 1;
|
||||||
int commandHandler(char *cmd){
|
char *arg[10];
|
||||||
|
int i = 0;
|
||||||
char *token = strtok(cmd, " ");
|
while( token != NULL ){
|
||||||
int argc = 1;
|
arg[i] = token;
|
||||||
char *arg[10];
|
token = strtok(NULL, " ");
|
||||||
int i = 0;
|
if(token != NULL){
|
||||||
while( token != NULL ){
|
i++;
|
||||||
arg[i] = token;
|
argc++;
|
||||||
token = strtok(NULL, " ");
|
}
|
||||||
if(token != NULL){
|
}
|
||||||
i++;
|
char *p = arg[i];
|
||||||
argc++;
|
p[strlen(p)-1] = 0;
|
||||||
}
|
arg[i] = p;
|
||||||
}
|
|
||||||
char *p = arg[i];
|
//Start to compare the command
|
||||||
p[strlen(p)-1] = 0;
|
if(!strcmp(arg[0], "help")){
|
||||||
arg[i] = p;
|
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");
|
||||||
//Start to compare the command
|
printf("\033[1;34mhelp\033[0m : this help list\n");
|
||||||
if(!strcmp(arg[0], "help")){
|
printf("\033[1;34mman \033[0;35m[cmd]\033[0m : manual for the commands\n");
|
||||||
printf("\033[1;34mcd \033[0;35m[dir]\033[0m : change directory\n");
|
printf("\033[1;34mversion\033[0m : shows the version\n");
|
||||||
printf("\033[1;34mls \033[0;35m[dir]\033[0m : show contents of directory\n");
|
printf("\033[1;34mexit\033[0m : exit the program\n");
|
||||||
printf("\033[1;34mhelp\033[0m : this help list\n");
|
return 0;
|
||||||
printf("\033[1;34mman \033[0;35m[cmd]\033[0m : manual for the commands\n");
|
} else if(!strcmp(arg[0], "version")){
|
||||||
printf("\033[1;34mversion\033[0m : shows the version\n");
|
printf("netbenixCMD (Version: \033[1;34m%s\033[0m)\n", VERSION);
|
||||||
printf("\033[1;34mexit\033[0m : exit the program\n");
|
printf("Author: \033[1;34m%s\033[0m\n", "netbenix");
|
||||||
return 0;
|
printf("Github: \033[1;34mhttps://github.com/netbenix/netbenixCMD\033[0m\n");
|
||||||
} else if(!strcmp(arg[0], "version")){
|
logger("Showing program version.");
|
||||||
|
return 0;
|
||||||
printf("netbenixCMD (Version: \033[1;34m%s\033[0m)\n", VERSION);
|
} else if(!strcmp(arg[0], "exit")){
|
||||||
printf("Author: \033[1;34m%s\033[0m\n", "netbenix");
|
return 1;
|
||||||
printf("Github: \033[1;34mhttps://github.com/netbenix/netbenixCMD\033[0m\n");
|
} else if(!strcmp(arg[0], "ls")){
|
||||||
logger("Showing program version.");
|
showDirectory(arg);
|
||||||
return 0;
|
return 0;
|
||||||
} else if(!strcmp(arg[0], "exit")){
|
} else if(!strcmp(arg[0], "cd")){
|
||||||
return 1;
|
changeCurrentWorkDir(arg);
|
||||||
} else if(!strcmp(arg[0], "ls")){
|
return 0;
|
||||||
showDirectory(arg);
|
} else if(!strcmp(arg[0], "man")){
|
||||||
return 0;
|
showManEntry(arg);
|
||||||
} else if(!strcmp(arg[0], "cd")){
|
return 0;
|
||||||
changeCurrentWorkDir(arg);
|
} else if(!strcmp(arg[0], "rainbow") && FUN_CONTENT){
|
||||||
return 0;
|
while(1){
|
||||||
} else if(!strcmp(arg[0], "man")){
|
printf("\033[0;31m#####");
|
||||||
showManEntry(arg);
|
printf("\033[0;32m#####");
|
||||||
return 0;
|
printf("\033[0;33m#####");
|
||||||
} else if(!strcmp(arg[0], "rainbow") && FUN_CONTENT){
|
printf("\033[0;34m#####");
|
||||||
while(1){
|
printf("\033[0;35m#####");
|
||||||
printf("\033[0;31m#####");
|
}
|
||||||
printf("\033[0;32m#####");
|
} else if(!strcmp(arg[0], "your-reality") && FUN_CONTENT){
|
||||||
printf("\033[0;33m#####");
|
yourReality();
|
||||||
printf("\033[0;34m#####");
|
} else {
|
||||||
printf("\033[0;35m#####");
|
printf("Unknown command. Please use 'help' for more information.\n");
|
||||||
}
|
logger("User entered unknown command.");
|
||||||
} else if(!strcmp(arg[0], "your-reality") && FUN_CONTENT){
|
return 0;
|
||||||
yourReality();
|
}
|
||||||
} else {
|
}
|
||||||
printf("Unknown command. Please use 'help' for more information.\n");
|
|
||||||
logger("User entered unknown command.");
|
//Action starts here
|
||||||
return 0;
|
int main(int argc, char *argv[]){
|
||||||
}
|
char buffer[1024];
|
||||||
}
|
extern char loggerDirPath[PATH_MAX];
|
||||||
|
realpath("." , loggerDirPath);
|
||||||
//Action starts here
|
logger("================================================");
|
||||||
int main(int argc, char *argv[]){
|
snprintf(buffer, sizeof(buffer), "Starting netbenixCMD (Version: %s)", VERSION);
|
||||||
char buffer[1024];
|
logger(buffer);
|
||||||
extern char loggerDirPath[PATH_MAX];
|
log_Specs(); //Log system specs
|
||||||
realpath("." , loggerDirPath);
|
showLogo(); //Show the logo
|
||||||
logger("================================================");
|
logger("Logo Displayed.");
|
||||||
snprintf(buffer, sizeof(buffer), "Starting netbenixCMD (Version: %s)", VERSION);
|
if(argc > 2){
|
||||||
logger(buffer);
|
printf("Too many arguments. Please use --help for more information.\n");
|
||||||
log_Specs(); //Log system specs
|
snprintf(buffer, sizeof(buffer), "[ERROR] Too many arguments. Argument count: %i", argc-1);
|
||||||
showLogo(); //Show the logo
|
logger(buffer);
|
||||||
logger("Logo Displayed.");
|
}
|
||||||
if(argc > 2){
|
|
||||||
printf("Too many arguments. Please use --help for more information.\n");
|
//Check the startup args
|
||||||
snprintf(buffer, sizeof(buffer), "[ERROR] Too many arguments. Argument count: %i", argc-1);
|
if(argc == 2){
|
||||||
logger(buffer);
|
if(!strcmp(argv[1], "--help")){
|
||||||
}
|
logger("Showing Help.");
|
||||||
|
outputHelp();
|
||||||
//Check the startup args
|
exit(0);
|
||||||
if(argc == 2){
|
} else if (!strcmp(argv[1], "--gtk-test")){
|
||||||
if(!strcmp(argv[1], "--help")){
|
logger("Stating GTK Test.");
|
||||||
logger("Showing Help.");
|
createGTKTestWindow();
|
||||||
outputHelp();
|
exit(0);
|
||||||
exit(0);
|
} else if (!strcmp(argv[1], "--sys-info")){
|
||||||
} else if (!strcmp(argv[1], "--gtk-test")){
|
logger("Showing System Information.");
|
||||||
logger("Stating GTK Test.");
|
print_Specs();
|
||||||
createGTKTestWindow();
|
exit(0);
|
||||||
exit(0);
|
} else if (!strcmp(argv[1], "--sql-test")){
|
||||||
} else if (!strcmp(argv[1], "--sys-info")){
|
logger("Starting SQL Test.");
|
||||||
logger("Showing System Information.");
|
testSQLConnection();
|
||||||
print_Specs();
|
exit(0);
|
||||||
exit(0);
|
} else if (!strcmp(argv[1], "--no-version-check")){
|
||||||
} else if (!strcmp(argv[1], "--sql-test")){
|
VER_CHECK_ON_START = false;
|
||||||
logger("Starting SQL Test.");
|
logger("[INFO] Argument 'no-version-check' used.");
|
||||||
testSQLConnection();
|
} else if (!strcmp(argv[1], "--dev-mode")){
|
||||||
exit(0);
|
VER_CHECK_ON_START = false;
|
||||||
} else if (!strcmp(argv[1], "--no-version-check")){
|
DEV_MODE = true;
|
||||||
VER_CHECK_ON_START = false;
|
logger("[INFO] Starting in developer mode.");
|
||||||
logger("[INFO] Argument 'no-version-check' used.");
|
} else if (!strcmp(argv[1], "--time-for-fun")){
|
||||||
} else if (!strcmp(argv[1], "--dev-mode")){
|
FUN_CONTENT = true;
|
||||||
VER_CHECK_ON_START = false;
|
logger("[WARNING] It's time... TO PARTYY.");
|
||||||
DEV_MODE = true;
|
} else {
|
||||||
logger("[INFO] Starting in developer mode.");
|
printf("Argument unknown. Please use --help for more information.\n");
|
||||||
} else if (!strcmp(argv[1], "--time-for-fun")){
|
snprintf(buffer, sizeof(buffer), "[ERROR] Argument unknown. Given argument: %s", argv[1]);
|
||||||
FUN_CONTENT = true;
|
logger(buffer);
|
||||||
logger("[WARNING] It's time... TO PARTYY.");
|
exit(0);
|
||||||
} 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);
|
if(VER_CHECK_ON_START){checkForUpdate(VERSION);} //Check for newer version of client
|
||||||
exit(0);
|
|
||||||
}
|
//If no startup arg is given, start command handler
|
||||||
}
|
int exit = 0;
|
||||||
|
char cmd[128];
|
||||||
if(VER_CHECK_ON_START){checkForUpdate(VERSION);} //Check for newer version of client
|
logger("Starting Command Handler.");
|
||||||
|
while (!exit){
|
||||||
//If no startup arg is given, start command handler
|
char cwp[255];
|
||||||
int exit = 0;
|
printf("\033[0;32m%s> \033[0m", getcwd(cwp, 255));
|
||||||
char cmd[128];
|
fgets(cmd, 128, stdin);
|
||||||
logger("Starting Command Handler.");
|
exit = commandHandler(cmd);
|
||||||
while (!exit){
|
}
|
||||||
char cwp[255];
|
logger("Exiting Command Handler.");
|
||||||
printf("\033[0;32m%s> \033[0m", getcwd(cwp, 255));
|
printf("\n");
|
||||||
fgets(cmd, 128, stdin);
|
logger("Exiting.");
|
||||||
exit = commandHandler(cmd);
|
return 0;
|
||||||
}
|
}
|
||||||
logger("Exiting Command Handler.");
|
|
||||||
printf("\n");
|
|
||||||
logger("Exiting.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
72
makefile
72
makefile
|
|
@ -1,41 +1,33 @@
|
||||||
CC= gcc
|
CC= gcc
|
||||||
ARGS= -export-dynamic -ansi -std=gnu99
|
ARGS= -export-dynamic -ansi -std=gnu99
|
||||||
CFLAGS= $(shell pkg-config --cflags gtk+-3.0) -I/usr/include/mysql
|
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
|
LDLIBS= $(shell pkg-config --libs gtk+-3.0) -L/usr/lib/mysql -lmysqlclient
|
||||||
<<<<<<< HEAD
|
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
|
||||||
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)
|
||||||
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
|
main.o: main.c
|
||||||
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
|
$(CC) $(CFLAGS) -c main.c
|
||||||
|
logo.o: etc/logo.c
|
||||||
netbenixCMD: $(OBJ)
|
$(CC) $(CFLAGS) -c etc/logo.c
|
||||||
$(CC) $(CFLAGS) $(ARGS) -o netbenixCMD $(OBJ) $(LDLIBS)
|
logger.o: utils/logger.c
|
||||||
main.o: main.c
|
$(CC) $(CFLAGS) -c utils/logger.c
|
||||||
$(CC) $(CFLAGS) -c main.c
|
help.o: commands/help.c
|
||||||
logo.o: etc/logo.c
|
$(CC) $(CFLAGS) -c commands/help.c
|
||||||
$(CC) $(CFLAGS) -c etc/logo.c
|
sys_info.o: utils/sys_info.c
|
||||||
logger.o: utils/logger.c
|
$(CC) $(CFLAGS) $(ARGS) -c utils/sys_info.c
|
||||||
$(CC) $(CFLAGS) -c utils/logger.c
|
gtk_test.o: utils/gtk_test.c
|
||||||
help.o: commands/help.c
|
$(CC) $(CFLAGS) -c utils/gtk_test.c
|
||||||
$(CC) $(CFLAGS) -c commands/help.c
|
sql_test.o: utils/sql_test.c
|
||||||
sys_info.o: utils/sys_info.c
|
$(CC) $(CFLAGS) -c utils/sql_test.c
|
||||||
$(CC) $(CFLAGS) $(ARGS) -c utils/sys_info.c
|
show_dir.o: commands/show_dir.c
|
||||||
gtk_test.o: utils/gtk_test.c
|
$(CC) $(CFLAGS) -c commands/show_dir.c
|
||||||
$(CC) $(CFLAGS) -c utils/gtk_test.c
|
change_dir.o: commands/change_dir.c
|
||||||
sql_test.o: utils/sql_test.c
|
$(CC) $(CFLAGS) -c commands/change_dir.c
|
||||||
$(CC) $(CFLAGS) -c utils/sql_test.c
|
update_check.o: utils/update_check.c
|
||||||
show_dir.o: commands/show_dir.c
|
$(CC) $(CFLAGS) -c utils/update_check.c
|
||||||
$(CC) $(CFLAGS) -c commands/show_dir.c
|
man.o: etc/man.c
|
||||||
change_dir.o: commands/change_dir.c
|
$(CC) $(CFLAGS) -c etc/man.c
|
||||||
$(CC) $(CFLAGS) -c commands/change_dir.c
|
math.o: etc/math.c
|
||||||
update_check.o: utils/update_check.c
|
$(CC) $(CFLAGS) -c etc/math.c
|
||||||
$(CC) $(CFLAGS) -c utils/update_check.c
|
your-reality.o: etc/your-reality.c
|
||||||
man.o: etc/man.c
|
|
||||||
$(CC) $(CFLAGS) -c etc/man.c
|
|
||||||
<<<<<<< HEAD
|
|
||||||
math.o: etc/math.c
|
|
||||||
$(CC) $(CFLAGS) -c etc/math.c
|
|
||||||
=======
|
|
||||||
>>>>>>> f1cf6269f94065bfb8498dd7ef06bfbb61442b80
|
|
||||||
your-reality.o: etc/your-reality.c
|
|
||||||
$(CC) $(CFLAGS) -c etc/your-reality.c
|
$(CC) $(CFLAGS) -c etc/your-reality.c
|
||||||
|
|
@ -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 "192.168.0.32"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,4 @@
|
||||||
#define _UPDATE_CHECK_H_
|
#define _UPDATE_CHECK_H_
|
||||||
|
|
||||||
int checkForUpdate(char ver[10]);
|
int checkForUpdate(char ver[10]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in a new issue