commit 9bdac4207a1c3e1caffc1f7d12356fe0282429fa
parent 70aaa5e01b2895d11b6d0dee8d600e822a199cfe
Author: Armaan Bhojwani <me@armaanb.net>
Date: Mon, 8 Mar 2021 14:04:37 -0500
Write index to index.html instead of stdout
Diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/stagit-index.c b/src/stagit-index.c
@@ -63,8 +63,9 @@ printtimeshort(FILE *fp, const git_time *intime)
}
void
-writeheader(FILE *fp)
+writeheader(char *path)
{
+ FILE *fp = fopen(path, "w");
fputs("<!DOCTYPE html>\n"
"<html>\n<head>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
@@ -82,17 +83,21 @@ writeheader(FILE *fp)
"<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Owner</b></td>"
"<td><b>Last commit</b></td></tr>"
"</thead><tbody>\n", fp);
+ fclose(fp);
}
void
-writefooter(FILE *fp)
+writefooter(char *path)
{
+ FILE *fp = fopen(path, "a");
fputs("</tbody>\n</table>\n</div>\n</body>\n</html>\n", fp);
+ fclose(fp);
}
int
-writelog(FILE *fp)
+writelog(char *path)
{
+ FILE *fp = fopen(path, "a");
git_commit *commit = NULL;
const git_signature *author;
git_revwalk *w = NULL;
@@ -136,6 +141,7 @@ writelog(FILE *fp)
err:
git_revwalk_free(w);
free(stripped_name);
+ fclose(fp);
return ret;
}
@@ -164,7 +170,7 @@ main(int argc, char *argv[])
err(1, "pledge");
#endif
- writeheader(stdout);
+ writeheader("index.html");
for (i = 1; i < argc; i++) {
repodir = argv[i];
@@ -210,9 +216,9 @@ main(int argc, char *argv[])
owner[strcspn(owner, "\n")] = '\0';
fclose(fp);
}
- writelog(stdout);
+ writelog("index.html");
}
- writefooter(stdout);
+ writefooter("index.html");
/* copy css */
char cwd[PATH_MAX];