From cf8dbf4bb4e632c77b27d1b7f0c8ff0b1a85e9bd Mon Sep 17 00:00:00 2001 From: radhitya Date: Fri, 17 Jan 2025 20:57:24 +0700 Subject: [PATCH] Something In Your Eyes --- main.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 6067955..ca0a1ad 100644 --- a/main.c +++ b/main.c @@ -35,7 +35,8 @@ Markdown mdt = { .code = 0 }; -FILE *fptr, *fpto; +FILE *fptr, *fpto, + *fcss, *fcss_target; char txt[MAX_LENGTH], of[MAX_LENGTH]; @@ -68,6 +69,32 @@ void add_css(void) { } } +void copy_css(void) { + const char *css = "./media/style.css"; + const char *css_target = "./target/style.css"; + int x; + + FILE *fcss = fopen(css, "r"); + if (fcss == NULL) { + perror("Tidak bisa membuka file masukan CSS"); + return; + } + + FILE *fcss_target = fopen(css_target, "w"); + if (fcss_target == NULL) { + perror("Tidak bisa membuka file keluaran CSS"); + fclose(fcss); + return; + } + + while ((x = fgetc(fcss)) != EOF) { + fputc(x, fcss_target); + } + + fclose(fcss); + fclose(fcss_target); +} + void newsetup(void) { struct stat st; if (stat("./source", &st) == -1) mkdir("./source", 0700); @@ -247,11 +274,15 @@ dohyperlink(void) { fprintf(fpto, "["); } +} +void build(void) { } void generate(void) { - fprintf(fpto, "\n\n\n\ndaisy homepage\n"); - fprintf(fpto, "\n\n"); - + fprintf(fpto, "\n\n"); + fprintf(fpto, "\n"); + fprintf(fpto, "daisy homepage\n"); + fprintf(fpto, "\n"); + fprintf(fpto, "\n\n"); while (fgets(txt, MAX_LENGTH, fptr) != NULL) { len = strlen(txt); @@ -352,7 +383,6 @@ int main(int argc, char *argv[]) { char *new_name = gantihuruf(ent->d_name); snprintf(of, sizeof(of), "./target/%s", new_name); - fpto = fopen(of, "w"); if (fpto == NULL) { perror("galat membuat berkas keluaran"); @@ -360,7 +390,8 @@ int main(int argc, char *argv[]) { continue; } - generate(); + generate(); + copy_css(); fclose(fptr); fclose(fpto);