aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c_implementation/Makefile.am9
-rw-r--r--c_implementation/include/libaklog.h21
-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
5 files changed, 70 insertions, 29 deletions
diff --git a/c_implementation/Makefile.am b/c_implementation/Makefile.am
index 1c83779..57fd80a 100644
--- a/c_implementation/Makefile.am
+++ b/c_implementation/Makefile.am
@@ -8,7 +8,7 @@ libaklog_la_SOURCES = $(top_srcdir)/src/aklog.c
libaksettings_la_SOURCES = $(top_srcdir)/src/aksettings.c
libakfs_LDADD = libaksettings.la
-libakfs_la_SOURCES = $(top_srcdir)/src/akfs.c $(top_srcdir)/src/aksettings.c $(top_srcdir)/src/akfs_sha512sum.c $(top_srcdir)/src/akfs_map_v3.c $(top_srcdir)/src/akfs_map_v4.c
+libakfs_la_SOURCES = $(top_srcdir)/src/akfs.c $(top_srcdir)/src/aksettings.c $(top_srcdir)/src/akfs_sha512sum.c $(top_srcdir)/src/akfs_map_v3.c $(top_srcdir)/src/akfs_map_v4.c $(top_srcdir)/src/akfs_main.c
libakutils_la_SOURCES = $(top_srcdir)/src/akutils.c
@@ -16,7 +16,10 @@ libakdatetime_la_SOURCES = $(top_srcdir)/src/akdatetime.c
include_HEADERS = include/libaklog.h include/libaksettings.h include/libakfs.h
-bin_PROGRAMS = akt akdefuse aklog
+bin_PROGRAMS = akt akdefuse aklog akfs
+akfs_LDADD = libaklog.la libakfs.la libaksettings.la
+akfs_SOURCES = src/akfs_main.c
+akt_SOURCES = src/ak.c
akt_LDADD = libaklog.la libakfs.la libaksettings.la
akt_SOURCES = src/ak.c
akdefuse_CFLAGS = -I/usr/include/fuse3 -lfuse3 -lpthread
@@ -48,4 +51,4 @@ TESTS = $(check_PROGRAMS)
CLEANFILES = $(TESTS)
cppcheck:
- cppcheck --std=c99 --enable=all --check-library -I /usr/include -I $(top_srcdir)/include/*.h $(top_srcdir)/include/*.h $(top_srcdir)/src/*.c $(top_srcdir)/tests/test*.c
+ cppcheck --std=c99 --force --enable=all --check-library -I $(top_srcdir)/include/*.h $(top_srcdir)/include/*.h $(top_srcdir)/src/*.c $(top_srcdir)/tests/test*.c
diff --git a/c_implementation/include/libaklog.h b/c_implementation/include/libaklog.h
index 0a91505..fa441a4 100644
--- a/c_implementation/include/libaklog.h
+++ b/c_implementation/include/libaklog.h
@@ -10,17 +10,18 @@ typedef enum {
DEBUG,
} LogMessageType;
-void ak_log_print_log_line(char* line);
+void ak_log_print_log_line(const char*);
void ak_log_follow();
-void ak_log_grep(char* string);
+void ak_log_grep(char*);
void ak_log_rotate();
-int ak_log_write_to_file(char* message);
-void ak_log_message(const char* program, LogMessageType lmtype, char* message);
-void ak_log_exit(const char* program, char* message);
-void ak_log_warning(const char* program, char* message);
-void ak_log_debug(const char* program, char* message);
-void ak_log_error(const char* program, char* message);
-void ak_log_info(const char* program, char* message);
-void ak_log_test(const char* program, char* message);
+int ak_log_write_to_file(const char*);
+void ak_log_message(const char*, LogMessageType, char*);
+void ak_log_exit(const char*, char*);
+void ak_log_warning(const char*, char*);
+void ak_log_debug(const char*, char*);
+void ak_log_error(const char*, char*);
+void ak_log_info(const char*, char*);
+void ak_log_test(const char*, char*);
+int ak_log_main(int, char**);
#endif // AKLOG
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++;
}
}