summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-09-04 09:48:35 +0200
committerdefault <nobody@localhost>2024-09-04 09:48:35 +0200
commit6778350211aeae076be80393cbef637e0218ad49 (patch)
treeaf2edb5302be580629b62a1a454463e142b90842 /utils.c
parentd8e77aca76c120ab5a55f97aa591501080c24ee2 (diff)
If style.css does not exist, it's created with the default one.
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/utils.c b/utils.c
index d5c2ee4..09a201b 100644
--- a/utils.c
+++ b/utils.c
@@ -107,6 +107,22 @@ static const char *greeting_html =
"<p>This site is powered by <abbr title=\"Social Networks Are Crap\">snac</abbr>.</p>\n"
"</body></html>\n";
+
+int write_default_css(void)
+{
+ FILE *f;
+
+ xs *sfn = xs_fmt("%s/style.css", srv_basedir);
+ if ((f = fopen(sfn, "w")) == NULL)
+ return 1;
+
+ fwrite(default_css, strlen(default_css), 1, f);
+ fclose(f);
+
+ return 0;
+}
+
+
int snac_init(const char *basedir)
{
FILE *f;
@@ -217,15 +233,11 @@ int snac_init(const char *basedir)
fwrite(gh, strlen(gh), 1, f);
fclose(f);
- xs *sfn = xs_fmt("%s/style.css", srv_basedir);
- if ((f = fopen(sfn, "w")) == NULL) {
- printf("ERROR: cannot create '%s'\n", sfn);
+ if (write_default_css()) {
+ printf("ERROR: cannot create style.css\n");
return 1;
}
- fwrite(default_css, strlen(default_css), 1, f);
- fclose(f);
-
xs *cfn = xs_fmt("%s/server.json", srv_basedir);
if ((f = fopen(cfn, "w")) == NULL) {
printf("ERROR: cannot create '%s'\n", cfn);