shithub: fsgen

Download patch

ref: 67090e5d7dcfd71b9f41e40bb9fcc8c3c7846b2e
parent: 8c1650529794e4aaee6a217c85bff0b402de8c29
author: sirjofri <sirjofri@sirjofri.de>
date: Mon Dec 15 05:15:42 EST 2025

variable support in function header

--- a/code.c
+++ b/code.c
@@ -3,16 +3,39 @@
 #include "dat.h"
 #include "fns.h"
 
+static void
+printvars(VFile *file)
+{
+	char **a;
+	char buf[64];
+	int n;
+	
+	for (a = file->parts; *a; a++) {
+		if (!(*a)[0])
+			continue;
+		n = strlen(*a) - 1;
+		if (!((*a)[0] == '{' && (*a)[n] == '}'))
+			continue;
+		strcpy(buf, *a);
+		buf[n] = 0;
+		print(", char *%s", buf+1);
+	}
+}
+
 void
 printread(VFile *file)
 {
-	print("static void\nfsread_%s(Req *r)\n", file->path);
+	print("static void\nfsread_%s(Req *r", file->path);
+	printvars(file);
+	print(")\n");
 }
 
 void
 printwrite(VFile *file)
 {
-	print("static void\nfswrite_%s(Req *r)\n", file->path);
+	print("static void\nfswrite_%s(Req *r", file->path);
+	printvars(file);
+	print(")\n");
 }
 
 void
--