aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjustanothercatgirl <sotov@twistea.su>2025-04-01 08:27:33 +0300
committerjustanothercatgirl <sotov@twistea.su>2025-04-01 21:52:34 +0300
commit588976a9a16eaa0f1b694587b459b2b264e5fe49 (patch)
tree83a4fe728384fc3a003cda9c17064831c84708ec
parenta5f1cb5ce34f31b9c46de94e55b5f85d571b792f (diff)
added -o flag to STEHEADmaster
-rw-r--r--README.md14
-rw-r--r--ste/example/Makefile2
-rw-r--r--ste/ste.c19
3 files changed, 21 insertions, 14 deletions
diff --git a/README.md b/README.md
index 93d6a75..2886e38 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ This is just a collection of (usually single-purpose) header files that I use re
* For now i only support GCC-based compilers. I will consider removing this dependency in future (e.g. getting rid of
all `typeof` uses)
# Descriptions for heders:
-## [`container.h`](include/container.h)
+## [`container.h`](tree/include/container.h)
* Summary: originally was several headers, but since `hash_map.h` used `dynarray.h`, which itself used `utility.h`, it
was too complex to work with. So i combined everything in a single header.
* How to use: Define `CONTAINER_IMPLEMENTATION` macro before including `container.h`. It's probably better to `#undef`
@@ -27,7 +27,7 @@ This is just a collection of (usually single-purpose) header files that I use re
`CONTAINER_DISABLE_ARRAY` will disable array implementation (and hmap and hset as a consequence).
`CONTAINER_DISABLE_UTILITY` will disable utilities, which will in turn disable everything else.
`CONTAINER_DISABLE_ALL` will not disable anything else but will leave you with unuseable header. Not useful, huh?
-## [`rstypes.h`](include/rstypes.h)
+## [`rstypes.h`](tree/include/rstypes.h)
* Summary: rust type aliases (like `u32`, `f128` e.t.c.)
* How to use: if you don't need `i128` or `u128`, then just include the header. If you do need them, define macro
`RS_TYPES_USE_128`.
@@ -35,12 +35,12 @@ This is just a collection of (usually single-purpose) header files that I use re
* Notes: Not many compilers support 128-bit wide integers, and ones which DO support them tend to warn you that these
are non ISO-C. That's why I've put them behind a macro. If they are not supported, their usage will fail with
compilation error.
-## [`embed.h`](include/embed.h) \[\[NOT IN DEVELOPMENT\]\]
+## [`embed.h`](tree/include/embed.h) \[\[NOT IN DEVELOPMENT\]\]
* Summary: Code generator for embedding resources directly into an executable.
* How to use: It exposes C interface, so in order to use it, you will need to have a C program that builds resources for
you. It has it's own repo, but i will be adding CLI to there soon.
* Examples: see [this repo](https://github.com/justanothercatgirl/embed_test.c/)
-## [`jacson.h`](include/jacson.h)
+## [`jacson.h`](tree/include/jacson.h)
* Summary: Spec-compliant json serializer and parser
* How to use: define `JACSON_IMPLEMENTATION` macro. `CONTAINER_IMPLEMENTATION` MUST be defined as well; either somewhere
earlier in the code before including `container.h` or just before `jacson.h`. this JSON implementation uses `array`
@@ -48,7 +48,7 @@ This is just a collection of (usually single-purpose) header files that I use re
* Macros: `JACSON_EXPORT_RSNPRINTF` will make symbols `__jacson_rsnprintf` and `__jacson_rsnputc` visible. These 2
functions allow for appending a string to a buffer obtained from malloc and resizing it (realloc) if needed. They're
not visible by default because they do not have obvious friendly signature.
-## [`stringbuilder.h`](include/stringbuilder.h)
+## [`stringbuilder.h`](tree/include/stringbuilder.h)
* Summary: string builder. Quite simple.
* How to use: include the header, define `STRINGBUILDER_IMPLEMENTATION`. Done.
* Notes: Pretty small at the moment, but I plan on expanding it on-demand. The interfaces are called `jac_sb` despite
@@ -64,6 +64,6 @@ This is just a collection of (usually single-purpose) header files that I use re
as possible, so you can use the code after a careful review. # License The [Unlicense license](https://unlicense.org).
Also known as [fuck google employees](https://opensource.google/documentation/reference/patching#forbidden) license
(nothing personal), equivalent to BSD0, CC0 or Public Domain.
-## `ste/`
-Please refer to [README](ste/READNE.md) in ste subdirectory.
+## [`ste/`](tree/ste/)
+Please refer to [README](tree/ste/READNE.md) in ste subdirectory.
<!--vim:tw=120-->
diff --git a/ste/example/Makefile b/ste/example/Makefile
index f8a6ef4..f9053d7 100644
--- a/ste/example/Makefile
+++ b/ste/example/Makefile
@@ -12,3 +12,5 @@ ste: ../ste.c
main: main.c tmpl.c
$(CC) -o $@ $<
+clean:
+ $(RM) ste main tmpl.c
diff --git a/ste/ste.c b/ste/ste.c
index 43252b9..7ec1fe4 100644
--- a/ste/ste.c
+++ b/ste/ste.c
@@ -21,29 +21,34 @@ void process_files(FILE* in, FILE* out, const char *macro) {
int main(int argc, char **argv) {
const char *macro = "OUT";
- char *filename = NULL;
+ char *filename = NULL, *outname = NULL;
FILE *in, *out;
if (argc < 2) {
usage:
- fprintf(stderr, "Usage: %s [-m name] <file.ste>\n", *argv);
+ fprintf(stderr, "Usage: %s [-m name] [-o out] <file.ste>\n", *argv);
return 1;
}
for (int i = 0; i < argc; ++i) {
if (!strcmp("-m", argv[i])) macro = argv[++i];
+ else if (!strcmp("-o", argv[i])) outname = argv[++i];
else filename = argv[i];
}
if (!filename || strlen(filename) <= 4) goto usage;
in = fopen(filename, "r");
- for (char *fn = filename; fn[3]; ++fn) {
- if (!strncmp(".ste", fn, 4)) {
- *fn = '\0';
- break;
+ if (!outname) {
+ for (char *fn = filename; fn[3]; ++fn) {
+ if (!strncmp(".ste", fn, 4)) {
+ *fn = '\0';
+ break;
+ }
}
+ out = fopen(filename, "w");
+ } else {
+ out = fopen(outname, "w");
}
- out = fopen(filename, "w");
if (!in || !out) {
perror("fopen");
goto usage;