From 2b8ef629c516c5920bc110d8050256e8baaf5073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20L=2E=20=C5=A0ijanec?= Date: Thu, 14 May 2020 18:22:34 +0200 Subject: // => /**/ for CSS --- a.out | Bin 22400 -> 0 bytes src/bvr.h | 2 ++ src/bvrcommands.c | 3 +++ src/jsbundle.c | 2 +- test/compose-all-in-dir.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ test/source/1.bvr | 1 + test/source/1.html | 2 ++ test/source/12.bvr | 1 + test/source/12.html | 2 ++ test/source1.html | 0 tmp/1.html | 2 ++ tmp/12.html | 2 ++ 12 files changed, 72 insertions(+), 1 deletion(-) delete mode 100755 a.out create mode 100644 test/compose-all-in-dir.c create mode 100644 test/source/1.bvr create mode 100644 test/source/1.html create mode 100644 test/source/12.bvr create mode 100644 test/source/12.html create mode 100644 test/source1.html create mode 100644 tmp/1.html create mode 100644 tmp/12.html diff --git a/a.out b/a.out deleted file mode 100755 index 5f5d85b..0000000 Binary files a/a.out and /dev/null differ diff --git a/src/bvr.h b/src/bvr.h index dd26653..413fe99 100644 --- a/src/bvr.h +++ b/src/bvr.h @@ -1,5 +1,7 @@ #pragma once #include +#include +#include #define SUCCESS 0 #define FAILURE -1 #define COPY_BUFFER_SIZE 128 diff --git a/src/bvrcommands.c b/src/bvrcommands.c index f08c0ab..5f58457 100644 --- a/src/bvrcommands.c +++ b/src/bvrcommands.c @@ -97,6 +97,9 @@ int bvr_handle_include(FILE * input, FILE * output) { if(stream == NULL) { strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT); stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery + if(stream != NULL) { + break; + } } *singlepath = '\0'; } diff --git a/src/jsbundle.c b/src/jsbundle.c index a2f9b61..f7bf8d2 100644 --- a/src/jsbundle.c +++ b/src/jsbundle.c @@ -38,7 +38,7 @@ int bundle_js(char* bundle_filename, char* js_source_folder_name, char* file_ext strcat(source_filename, ent->d_name); source_file = fopen(source_filename, "r"); // printf("[jsbundle.c] source_filename: %s\n", source_filename); - fprintf(bundle_file, "\n// %s\n", source_filename); + fprintf(bundle_file, "\n/* %s */\n", source_filename); copy_buffer = fgetc(source_file); while (copy_buffer != EOF) { fputc(copy_buffer, bundle_file); diff --git a/test/compose-all-in-dir.c b/test/compose-all-in-dir.c new file mode 100644 index 0000000..489891b --- /dev/null +++ b/test/compose-all-in-dir.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include +#include +extern int main(int argc, char* argv[]) { + if(argc != 3) { + printf("usage: %s source-dir/ destination-dir/ (trailing slash mandatory)\n", argv[0]); + return 1; + } + char* source_folder_name = argv[1]; + char* destination_folder_name = argv[2]; + char* file_extension = ".bvr"; + char* destination_extension = ".html"; + char* file_extension2 = ".bverbose"; // unofficial + char source_filename[NAME_MAX]; + char destination_filename[NAME_MAX]; + int response_from_composer; + char copy_buffer; + DIR *dir; + struct dirent *ent; + if ((dir = opendir (source_folder_name)) != NULL) { + while ((ent = readdir (dir)) != NULL) { + if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0) { + char *dot = strrchr(ent->d_name, '.'); + if(dot && ( !strcmp(dot, file_extension) || !strcmp(dot, file_extension2) ) ) { + strcpy(source_filename, source_folder_name); + strcat(source_filename, ent->d_name); + strcpy(destination_filename, destination_folder_name); + strcat(destination_filename, ent->d_name); + char* temp_pointer = strrchr(destination_filename, '.'); + if (!temp_pointer) { + } else { + *temp_pointer = '\0'; + } + strcat(destination_filename, destination_extension); + fprintf(stderr, "[compose-all-in-dir.c] %s -> %s ", source_filename, destination_filename); + fflush(stderr); + if(bvr_compose_page(source_filename, 0, destination_filename) == SUCCESS) { + fprintf(stderr, "SUCCESS!\n"); + } else { + fprintf(stderr, "FAILURE!!!\n"); + } + } + } + } + closedir (dir); + } else { + /* could not open directory */ + return 1; + } + return 0; +} + diff --git a/test/source/1.bvr b/test/source/1.bvr new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/source/1.bvr @@ -0,0 +1 @@ +1 diff --git a/test/source/1.html b/test/source/1.html new file mode 100644 index 0000000..a464d9d --- /dev/null +++ b/test/source/1.html @@ -0,0 +1,2 @@ + +1 diff --git a/test/source/12.bvr b/test/source/12.bvr new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/test/source/12.bvr @@ -0,0 +1 @@ +12 diff --git a/test/source/12.html b/test/source/12.html new file mode 100644 index 0000000..b70b26b --- /dev/null +++ b/test/source/12.html @@ -0,0 +1,2 @@ + +12 diff --git a/test/source1.html b/test/source1.html new file mode 100644 index 0000000..e69de29 diff --git a/tmp/1.html b/tmp/1.html new file mode 100644 index 0000000..a464d9d --- /dev/null +++ b/tmp/1.html @@ -0,0 +1,2 @@ + +1 diff --git a/tmp/12.html b/tmp/12.html new file mode 100644 index 0000000..b70b26b --- /dev/null +++ b/tmp/12.html @@ -0,0 +1,2 @@ + +12 -- cgit v1.2.3