aboutsummaryrefslogtreecommitdiff
path: root/c_implementation/src
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-04-25 06:55:43 +0300
committerkaotisk <kaotisk@arching-kaos.org>2025-04-25 06:55:43 +0300
commit0190c66a1032abc482bf5ef068e2164feaef432c (patch)
tree7e9639f9c63765c87ef1aaa883c4cc450280dd97 /c_implementation/src
parent5d0152e151c7731b99af51744fc5dab03cad6cd4 (diff)
downloadarching-kaos-tools-0190c66a1032abc482bf5ef068e2164feaef432c.tar.gz
arching-kaos-tools-0190c66a1032abc482bf5ef068e2164feaef432c.tar.bz2
arching-kaos-tools-0190c66a1032abc482bf5ef068e2164feaef432c.zip
[libaklog] updates
Diffstat (limited to 'c_implementation/src')
-rw-r--r--c_implementation/src/aklog.c62
-rw-r--r--c_implementation/src/aklog_main.c6
-rw-r--r--c_implementation/src/aklogcatter.c1
3 files changed, 53 insertions, 16 deletions
diff --git a/c_implementation/src/aklog.c b/c_implementation/src/aklog.c
index b545365..260621c 100644
--- a/c_implementation/src/aklog.c
+++ b/c_implementation/src/aklog.c
@@ -2,6 +2,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <time.h>
#include "libaklog.h"
@@ -10,7 +11,7 @@
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-int ak_log_write_to_file(char* message)
+int ak_log_write_to_file(const char* message)
{
FILE *fp;
char *fullpath_to_log_file={0};
@@ -29,13 +30,13 @@ int ak_log_write_to_file(char* message)
return 0;
}
-void ak_log_print_log_line(char* line)
+void ak_log_print_log_line(const char* line)
{
int spaces_found = 0;
int sa[] = { -1, -1, -1, -1 };
long int l = 1000000000;
long int ts = 0;
- struct tm *timeInfo;
+ const struct tm *timeInfo;
char ts_string[16]; // %Y%Y%Y%Y%m%m%d%d_%H%H%M%M%S%S
for (size_t i = 0; i < strlen(line); ++i)
{
@@ -114,20 +115,21 @@ void ak_log_follow()
void ak_log_grep(char* message)
{
+ (void)message;
printf("ak_log_grep: not implemented\n");
return;
- exit(2);
- if ( message )
- {
- if ( strcmp(message, "-h") || strcmp(message, "--help") )
- {
- // description();
- printf("Launch with no arguments and select from the menu that will appear\n");
- exit(1);
- }
- }
- printf("The following scripts have entries in the log file.\n");
- printf("Select one of those by entering the number of it below and hit enter:\n");
+ // exit(2);
+ // if ( message )
+ // {
+ // if ( strcmp(message, "-h") || strcmp(message, "--help") )
+ // {
+ // // description();
+ // printf("Launch with no arguments and select from the menu that will appear\n");
+ // exit(1);
+ // }
+ // }
+ // printf("The following scripts have entries in the log file.\n");
+ // printf("Select one of those by entering the number of it below and hit enter:\n");
// select x in $(cat $AK_LOGSFILE | cut -d ' ' -f 2 | sort | uniq)
// do
// grep $x $AK_LOGSFILE | while read line
@@ -152,7 +154,7 @@ void ak_log_rotate()
// fi
printf("ak_log_rotate: not implemented\n");
return;
- exit(2);
+ // exit(2);
}
void ak_log_message(const char* program, LogMessageType lmtype, char* message)
@@ -236,3 +238,31 @@ void ak_log_test(const char* program, char* message)
{
ak_log_message(program, TEST, message);
}
+
+static int ak_log_usage()
+{
+ ak_log_info(__func__, "Available commands:");
+ ak_log_info(__func__, " ak_log");
+ return 1;
+}
+
+int ak_log_main(int argc, char **argv)
+{
+ int option;
+ while ( (option = getopt(argc, argv, ":h|:help")) != -1 )
+ {
+ printf("%d\n", option);
+ switch(option)
+ {
+ case 'h':
+ return ak_log_usage();
+ case ':':
+ printf("kek\n");
+ return 1;
+ case '?':
+ printf("lol\n");
+ return 2;
+ }
+ }
+ return 0;
+}
diff --git a/c_implementation/src/aklog_main.c b/c_implementation/src/aklog_main.c
new file mode 100644
index 0000000..582c28e
--- /dev/null
+++ b/c_implementation/src/aklog_main.c
@@ -0,0 +1,6 @@
+#include <libaklog.h>
+
+int main(int argc, char** argv)
+{
+ return ak_log_main(argc, argv);
+}
diff --git a/c_implementation/src/aklogcatter.c b/c_implementation/src/aklogcatter.c
index 54b1f8c..c002eda 100644
--- a/c_implementation/src/aklogcatter.c
+++ b/c_implementation/src/aklogcatter.c
@@ -27,6 +27,7 @@ int ak_logcatter()
else
{
line[i] = buffer[0];
+ line[i+1] = '\0';
i++;
}
}