summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--LICENSE21
-rw-r--r--Makefile22
-rw-r--r--README1
-rw-r--r--TODO0
-rw-r--r--test/Makefile0
-rw-r--r--trashsys.c107
7 files changed, 154 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e551279
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+trashsys.txt
+tsr
+tsr-TESTING
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f66c023
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 734j
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..91fdebd
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,22 @@
+CC=gcc
+CFLAGS_TESTBIN=-O3 -Wfatal-errors -Wall -Werror -Wextra -g -fsanitize=address -Wpedantic -std=gnu99
+CFLAGS=-O3 -flto -march=native -DNDEBUG -fomit-frame-pointer -s -static -std=gnu99
+TARGET=tsr
+TESTTARGET=tsr-TESTING
+INSTALL_DIRECTORY=/usr/local/bin
+MAKEFLAGS +=
+SRCS=trashsys.c
+
+all: release
+clean:
+ rm -f $(TARGET)
+ rm -f test/$(TESTTARGET)
+
+tests:
+ $(CC) $(CFLAGS_TESTBIN) $(SRCS) -o test/$(TESTTARGET)
+
+install:
+ cp $(TARGET) $(INSTALL_DIRECTORY)
+
+release:
+ $(CC) $(CFLAGS) $(SRCS) -o $(TARGET)
diff --git a/README b/README
new file mode 100644
index 0000000..4e0750d
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+Simple trashing system \ No newline at end of file
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TODO
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Makefile
diff --git a/trashsys.c b/trashsys.c
new file mode 100644
index 0000000..7b6da79
--- /dev/null
+++ b/trashsys.c
@@ -0,0 +1,107 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+#define USAGE "to be decided"
+
+struct trashsys_log_info {
+ uint64_t ts_log_id;
+ char ts_log_filename[255];
+ size_t ts_log_filesize;
+ time_t ts_log_trashtime;
+ char ts_log_originalpath[4096];
+ bool ts_log_tmp;
+};
+
+int main (int argc, char *argv[]) {
+
+ if (argc == 1) {
+ fprintf(stderr, "%s: please specify a filename\n%s\n", argv[0], USAGE);
+ return EXIT_FAILURE;
+ }
+
+ bool y_used = false;
+ bool n_used = false;
+ bool v_used = false;
+ bool f_used = false;
+ bool a_used = false;
+ bool t_used = false;
+ bool l_used = false;
+ bool L_used = false;
+ bool c_used = false;
+ bool C_used = false;
+ bool R_used = false;
+
+ int opt;
+ int returnval;
+ char *optarg_copy = NULL; // We will copy optarg to this
+ while ((opt = getopt(argc, argv, "ynvfatlLcCR:")) != -1) {
+ switch (opt) {
+ case 'y':
+
+ y_used = true;
+
+ break;
+ case 'n':
+
+ n_used = true;
+
+ break;
+ case 'v':
+
+ v_used = true;
+
+ break;
+ case 'f':
+
+ f_used = true;
+
+ break;
+ case 'a':
+
+ a_used = true;
+
+ break;
+ case 't':
+
+ t_used = true;
+
+ break;
+ case 'l':
+
+ l_used = true;
+
+ break;
+ case 'L':
+
+ L_used = true;
+
+ break;
+ case 'c':
+
+ c_used = true;
+
+ break;
+ case 'C':
+
+ C_used = true;
+
+ break;
+ case 'R':
+
+ R_used = true;
+
+ break;
+ }
+ }
+
+
+ if (n_used == true && y_used == true) { // If both YES and NO are used print usage and exit
+ fprintf(stderr, "%s", USAGE);
+ return EXIT_FAILURE;
+ }
+ return 0;
+}