summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compose-all-in-dir.c56
-rw-r--r--test/source/1.bvr1
-rw-r--r--test/source/1.html2
-rw-r--r--test/source/12.bvr1
-rw-r--r--test/source/12.html2
-rw-r--r--test/source1.html0
6 files changed, 62 insertions, 0 deletions
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 <bvr.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <tape.c>
+#include <dirent.h>
+#include <string.h>
+#include <limits.h>
+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
--- /dev/null
+++ b/test/source1.html