stacinhtml

Static C in HTML - simple static site generator
git clone git://git.kocotian.pl/stacinhtml.git
Log | Files | Refs | README

commit 57c303b89d176bf340f96f9e215439536aeb3346
parent 61029f691be4c49fd25361877d24a25d1c9a4546
Author: kocotian <kocotian@kocotian.pl>
Date:   Sun, 21 Mar 2021 14:33:26 +0100

Variables at output, fixed permissions, gitignore

Diffstat:
A.gitignore | 5+++++
Mgenerate.c | 16++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,5 @@ +generate +in +meta +out +*.o diff --git a/generate.c b/generate.c @@ -100,7 +100,7 @@ main(int argc, char *argv[]) /* Variables: */ /* File names and file descriptors */ char *inputfn = NULL, *outputfn = NULL, *templatefn = NULL; - int inputfd, outputfd, templatefd; + int inputfd, outputfd, templatefd, viter; /* Read bytes (from nextline()/write()) */ ssize_t rb; @@ -184,21 +184,21 @@ main(int argc, char *argv[]) readinput.len -= parseinput.len; } - int i; - for (i = 0; i < vss; ++i) - printf(" * [%d]: %.*s = \"%.*s\"\n", i, - vs[i].name.len, vs[i].name.data, - vs[i].value.len, vs[i].value.data); - /* Closing an input */ close(inputfd); /* Here will be some templates replacing */ /* Opening an output */ - if ((outputfd = open(outputfn, O_WRONLY | O_CREAT)) < 0) + if ((outputfd = open(outputfn, O_WRONLY | O_CREAT, 0644)) < 0) die("open (output):"); + /* Declaring variables */ + for (viter = 0; viter < vss; ++viter) + dprintf(outputfd, "DECLVAR(%.*s, \"%.*s\"); ", + vs[viter].name.len, vs[viter].name.data, + vs[viter].value.len, vs[viter].value.data); + /* And finally, generating C code to output */ generateC(outputfd, input);