aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aklogcatter.c35
-rwxr-xr-xsrc/build_tree/ak_logcatter_build.sh2
-rw-r--r--src/include/aklogcatter.h6
-rw-r--r--src/tests/test_aklogcatter.c7
4 files changed, 50 insertions, 0 deletions
diff --git a/src/aklogcatter.c b/src/aklogcatter.c
new file mode 100644
index 0000000..add6c30
--- /dev/null
+++ b/src/aklogcatter.c
@@ -0,0 +1,35 @@
+#include <aklogcatter.h>
+#include <stdio.h>
+#include <aklog.h>
+#include <stdlib.h>
+
+int ak_logcatter()
+{
+ printf("Testing: %s\n", __func__);
+ FILE *fp;
+ fp = fopen("/home/kaotisk/.arching-kaos/logs", "r");
+ if (!fp)
+ {
+ perror("fopen");
+ return EXIT_FAILURE;
+ }
+ char buffer[1] = {0};
+ char line[1024] = {0};
+ unsigned int i = 0;
+ while ( fread(buffer, sizeof(char), sizeof(char), fp) )
+ {
+ if ( buffer[0] == '\n' )
+ {
+ line[i] = '\0';
+ ak_log_print_log_line(line);
+ i = 0;
+ }
+ else
+ {
+ line[i] = buffer[0];
+ i++;
+ }
+ }
+ fclose(fp);
+ return 0;
+}
diff --git a/src/build_tree/ak_logcatter_build.sh b/src/build_tree/ak_logcatter_build.sh
new file mode 100755
index 0000000..91a1805
--- /dev/null
+++ b/src/build_tree/ak_logcatter_build.sh
@@ -0,0 +1,2 @@
+echo "Building lib/aklogcatter.so" && gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include aklogcatter.c -o lib/aklogcatter.so && echo "Building tests/test_aklogcatter" && gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_aklogcatter.c lib/aklog.so lib/aklogcatter.so -o tests/test_aklogcatter && echo "Running test_aklogcatter" && time ./tests/test_aklogcatter
+rm ./tests/test_aklogcatter
diff --git a/src/include/aklogcatter.h b/src/include/aklogcatter.h
new file mode 100644
index 0000000..650ef7c
--- /dev/null
+++ b/src/include/aklogcatter.h
@@ -0,0 +1,6 @@
+#ifndef AK_LOGCATTER_H
+#define AK_LOGCATTER_H
+
+int ak_logcatter();
+
+#endif // AK_LOGCATTER_H
diff --git a/src/tests/test_aklogcatter.c b/src/tests/test_aklogcatter.c
new file mode 100644
index 0000000..bc45063
--- /dev/null
+++ b/src/tests/test_aklogcatter.c
@@ -0,0 +1,7 @@
+#include <aklogcatter.h>
+
+int main()
+{
+ ak_logcatter();
+ return 0;
+}