commit 755a6df5675a40a81c66bdacc43d029fd349247f
parent 1338dcdb67113c73ec12c0e7cdce8ba093d2e7f5
Author: Mario Rosell R. Martinez <mario@mariorosell.es>
Date: Fri, 3 Apr 2026 16:11:55 +0200
stat: new stat_t struct for stat, and fix messages
This new struct should make it easier to work with, and also put ttmxm: for
messages instead of slash:, ttmxm is another project I am working on, so yeah,
my fault, I messed up :(.
Diffstat:
4 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/cli.c b/cli.c
@@ -43,19 +43,24 @@ cli(int argc, char** argv)
case 'o':
if (i + 1 >= argc) {
- fprintf(stderr,
- "ttmxm: missing argument for -o\n");
+ fprintf(stderr, "slash: missing argument for -o\n");
+ help(argv[0]);
exit(2);
}
- snprintf(s_file, sizeof(s_file), "%s", argv[++i]);
+ snprintf(stat.s_outf, sizeof(stat.s_outf), "%s", argv[++i]);
break;
case 's':
+ if (i + 1 >= argc) {
+ fprintf(stderr, "slash: missing argument for -s\n");
+ help(argv[0]);
+ exit(2);
+ }
+ snprintf(stat.s_asmf, sizeof(stat.s_asmf), "%s", argv[++i]);
break;
default:
- fprintf(stderr,
- "ttmxm: unknown flag: -%c\n", arg[ii]);
+ fprintf(stderr, "slash: unknown flag: -%c\n", arg[ii]);
help(argv[0]);
exit(2);
}
@@ -65,8 +70,7 @@ cli(int argc, char** argv)
in_opts = false;
if (src != NULL) {
- fprintf(stderr,
- "ttmxm: too many input files\n");
+ fprintf(stderr, "slash: too many input files\n");
exit(2);
}
@@ -75,7 +79,7 @@ cli(int argc, char** argv)
}
if (src == NULL) {
- fprintf(stderr, "ttmxm: missing input file\n");
+ fprintf(stderr, "slash: missing input file\n");
help(argv[0]);
exit(2);
}
diff --git a/slash.c b/slash.c
@@ -11,6 +11,7 @@
int
main(int argc, char** argv)
{
+ initstat();
cli(argc, argv);
return EXIT_SUCCESS;
diff --git a/stat.c b/stat.c
@@ -1,6 +1,16 @@
/*
- * stat.c -- fuck c
+ * stat.c -- status implementation
*/
-char s_file[512];
+#include "stat.h"
+
+#include <string.h>
+
+stat_t stat;
+
+void
+initstat(void)
+{
+ memset(&stat, 0, sizeof(stat));
+}
diff --git a/stat.h b/stat.h
@@ -2,6 +2,18 @@
* stat.h -- status
*/
-/* current file */
-extern char s_file[512];
+#include <stdbool.h>
+
+struct stat {
+ char s_outf[512]; /* output file */
+ char s_asmf[512]; /* ASM output file */
+ bool mod_pipe; /* if using pipes for communication over tempfiles */
+};
+
+typedef struct stat stat_t;
+
+/* current stat */
+extern stat_t stat;
+
+void initstat(void);