Random extra stuff

This commit is contained in:
TriantaTV 2023-03-31 00:07:46 -05:00
parent e59bffdd68
commit a3017fd80f
4 changed files with 27 additions and 16 deletions

View File

@ -1,12 +1,24 @@
INC := -I include
CFLAGS := -Wall
CFLAGS += -Wextra
CFLAGS += -Wpointer-arith
CFLAGS += -Wcast-align
CFLAGS += -Wwrite-strings
CFLAGS += -Wswitch-default
CFLAGS += -Wunreachable-code
CFLAGS += -Winit-self
CFLAGS += -Wmissing-field-initializers
CFLAGS += -Wno-unknown-pragmas
CFLAGS += -Wundef
CFLAGS += -Wold-style-definition
all: compile link
compile:
gcc $(INC) -c -o build/main.o src/main.c
gcc $(INC) -c -o build/Common.o src/Common.c
gcc $(INC) -c -o build/Integrated.o src/Integrated.c
gcc $(INC) -c -o build/Pish.o src/Pish.c
gcc $(CFLAGS) $(INC) -c -o build/main.o src/main.c
gcc $(CFLAGS) $(INC) -c -o build/Common.o src/Common.c
gcc $(CFLAGS) $(INC) -c -o build/Integrated.o src/Integrated.c
gcc $(CFLAGS) $(INC) -c -o build/Pish.o src/Pish.c
link:
gcc -o bin/pish.out build/*.o
@ -17,10 +29,10 @@ exec: compile link
debug: clean debugCompile debugLink
debugCompile:
gcc $(INC) -g -c -o build/main.o src/main.c
gcc $(INC) -g -c -o build/Integrated.o src/Integrated.c
gcc $(INC) -g -c -o build/Common.o src/Common.c
gcc $(INC) -g -c -o build/Pish.o src/Pish.c
gcc $(CFLAGS) $(INC) -g -c -o build/main.o src/main.c
gcc $(CFLAGS) $(INC) -g -c -o build/Integrated.o src/Integrated.c
gcc $(CFLAGS) $(INC) -g -c -o build/Common.o src/Common.c
gcc $(CFLAGS) $(INC) -g -c -o build/Pish.o src/Pish.c
debugLink:
gcc -g -o bin/pish.out build/*.o

View File

@ -121,7 +121,7 @@ int CountSymbol(CommandStruct* command, char symbol)
void ioRedirection(CommandStruct* command)
{
for (int i = 0; i <sizeof(command); i++)
for (int i = 0; i < (int)sizeof(command); i++)
{
if (strpbrk(command->argv[i], ">>")!= NULL)//append
{
@ -146,7 +146,7 @@ void ioRedirection(CommandStruct* command)
void output(char *command){
int newfd;
if (newfd = open(command, O_CREAT | O_CREAT, 0666) < 0)
if ((newfd = open(command, O_CREAT | O_CREAT, 0666)) < 0)
{
perror(command);
exit(1);
@ -157,7 +157,7 @@ void output(char *command){
void input(char *command)
{
int newfd;
if (newfd = open(command, O_RDONLY | O_CREAT) < 0)
if ((newfd = open(command, O_RDONLY | O_CREAT)) < 0)
{
perror(command);
exit(1);
@ -207,7 +207,7 @@ int ExecPipe(CommandStruct* commandParent, CommandStruct* commandChild, int* pip
void append(char* input, char* fileName)
{
char buffer[4];
int fd = open(fileName, O_APPEND | O_CREAT);
// int fd = open(fileName, O_APPEND | O_CREAT);
// fp = fopen(file, "a+");
// fputs(input, fp);

View File

@ -13,8 +13,8 @@
// Main function for Pish program
void Pish(void)
{
CommandStruct commandParentObject = {"", 0};
CommandStruct commandChildObject = {"", 0};
CommandStruct commandParentObject = {{""}, 0, {""}};
CommandStruct commandChildObject = {{""}, 0, {""}};
CommandStruct* commandParent = &commandParentObject;
CommandStruct* commandChild = &commandChildObject;
char inputString[1000]; // Max 1000 characters
@ -52,7 +52,6 @@ void ReadPishrc(CommandStruct *commandParent, CommandStruct *commandChild, char
char buffer[1];
int pipefd[2];
int forkPID;
int *argc = &(commandParent->argc);
char* pishLocation = GetHomeDir();
strcat(pishLocation, "/.pishrc");
int fd = open(pishLocation, O_RDONLY | O_CREAT, 0644);

View File

@ -1,6 +1,6 @@
#include "Pish.h"
int main()
int main(void)
{
Pish();
}