summary refs log tree commit diff
diff options
context:
space:
mode:
authorSingustromo <singustromo@disroot.org>2024-05-18 20:08:36 +0200
committerSingustromo <singustromo@disroot.org>2024-05-18 20:08:36 +0200
commit5cd0bbde6fbe6325d00bb5e1b2b7331757f0dcf3 (patch)
tree8bfbd20fa10ca34437fff675b65ee46d20af52a2
parent66c0ffd70e623ef63453d5c769e35cef381fcca1 (diff)
downloadoperating-systems_3_clash-5cd0bbde6fbe6325d00bb5e1b2b7331757f0dcf3.tar.gz
operating-systems_3_clash-5cd0bbde6fbe6325d00bb5e1b2b7331757f0dcf3.zip
Implemented main function & walkList(..)
-rw-r--r--.gitignore2
-rw-r--r--Makefile19
-rw-r--r--src/clash.c8
-rw-r--r--src/clash.h0
-rw-r--r--src/plist.c5
5 files changed, 16 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 8306ee3..aac1e73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-build/**
+bin/**
 clash
 
 MD5SUM
diff --git a/Makefile b/Makefile
index b65e010..59ba575 100644
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,9 @@ CC = gcc
 CFLAGS = -Wall -Werror -std=c11 -pedantic -D_XOPEN_SOURCE=700
 VPATH=src # search for a prerequisite in those directories (delimiter is :)
 
-BUILD_TARGET=wsort
-BUILD_DIR=build
-OBJS = $(patsubst %.o, $(BUILD_DIR)/%.o, strictmem.o dynamic_array.o $(BUILD_TARGET).o)
+BUILD_TARGET=clash
+BUILD_DIR=bin
+OBJS = $(patsubst %.o, $(BUILD_DIR)/%.o, plist.o $(BUILD_TARGET).o)
 
 $(BUILD_TARGET): $(OBJS)
 	$(CC) -o $@ $(CFLAGS) $(OBJS)
@@ -16,19 +16,6 @@ $(BUILD_TARGET): $(OBJS)
 clean:
 	rm -r $(BUILD_TARGET) $(BUILD_DIR)
 
-TESTFILES=$(wildcard data/wlist*)
-
-test:
-	@time (for f in $(TESTFILES); do file="$${f##*/}"; ./$(BUILD_TARGET) < data/"$$file" > "$$file"; done)
-	@md5sum --quiet -c MD5SUM
-	@rm -f wlist*
-
-test-spec:
-	@time (for f in data/wlist*; do file="$${f##*/}"; ./$(BUILD_TARGET).bsteam < data/"$$file" > "$$file"; done)
-	@md5sum wlist* > MD5SUM
-	@rm -f wlist*
-
-
 $(BUILD_DIR)/%.o:%.c
 	@[ -d $(BUILD_DIR) ] || mkdir $(BUILD_DIR)
 	$(CC) -c -o $@ $(CFLAGS) $<
diff --git a/src/clash.c b/src/clash.c
new file mode 100644
index 0000000..e41edc3
--- /dev/null
+++ b/src/clash.c
@@ -0,0 +1,8 @@
+#include <stdlib.h>
+
+#include "clash.h"
+#include "plist.h"
+
+int main(int argc, char* argv[]) {
+        exit(EXIT_SUCCESS);
+}
diff --git a/src/clash.h b/src/clash.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/clash.h
diff --git a/src/plist.c b/src/plist.c
index 2a4ecb7..2767e34 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -18,7 +18,10 @@ struct queue_element {
 static struct queue_element *head;
 
 void walkList(bool (*callback) (pid_t, const char *)) {
-	// TODO: implement me
+        struct queue_element* current = head;
+
+        while (current && (callback(current->pid, current->cmdLine) != 0))
+                ;
 }
 
 int insertElement(pid_t pid, const char *cmdLine) {