Browse Source

include finnally works to a usable extent.

master
Anton Luka Šijanec 2 years ago
parent
commit
e7d1afd46b
  1. BIN
      a.out
  2. 20
      assets/content/global.bvr
  3. 1
      assets/layout/html/krneki.bvr
  4. 3
      src/bvr.h
  5. 28
      src/bvrcommands.c
  6. 22
      test/tape-test.bvr
  7. 39
      tmp/output.htm

BIN
a.out

Binary file not shown.

20
assets/content/global.bvr

@ -1,21 +1,21 @@
# max 128 characters
<@?s site_name=Anton Luka Šijanec@>
<@?s site_name Anton Luka Šijanec@>
# max 2 characters
<@?s site_language=sl@>
<@?s site_language sl@>
# max 128 characters
<@?s site_description=Moj osebni blog.@>
<@?s site_description Moj osebni blog.@>
# max 32, max 64 characters per entry
<@?s featured_links=posts/about,posts/contact,posts/sample-post@>
<@?s featured_links posts/about posts/contact posts/sample-post@>
# max 64 characters or latest-posts
<@?s index_page=pages/about@>
<@?s index_page pages/about@>
# centered paragraph width. Can be 1, 2, 3, 4; 5 means text is left centered.
<@?s content_width=8@>
<@?s content_width 8@>
# hour offset to format dates with. NOTE: 11 is subtracted to this value. GMT is then 11, Ljubljana is then 13
<@?s timezone=13@>
<@?s timezone 13@>
# what folders to copy from layout to dist (such as fonts)
<@?s copy_folders=fonts,media@>
# path, where bvr files will be searched for
<@?s bvr_include_path assets/content/;assets/content/posts/;assets/layout/;assets/content/html/@>
<@?s copy_folders fonts,media@>
# path, where bvr files will be searched for. split with spaces.
<@?s bvr_include_path assets/content/ assets/content/posts/ assets/layout/ assets/layout/html/ test/@>
# post-specific variables --- you should set them now. unset variables may cause problems --- they return BVR_UNDEFINED
<@?s post_description Unset description.@>
<@?s post_author anonymous@>

1
assets/layout/html/krneki.bvr

@ -0,0 +1 @@
krneki123

3
src/bvr.h

@ -26,7 +26,8 @@ int bvr_bvrvar_first_time_set = 1;
#define BVR_VER_MINOR 1
#define BVR_VER_PATCH 0
#define BVR_PATH_SEPARATOR ';'
#define BVR_PATH_SEPARATOR ' '
#define BVR_INCLUDE_PATH_VAR_NAME "bvr_include_path"
#define BVR_COMMAND_FILE_EXT ".bvr"
int bvr_compose_stream(FILE *, FILE *);

28
src/bvrcommands.c

@ -60,24 +60,34 @@ int bvr_handle_include(FILE * input, FILE * output) {
FILE * stream = fopen(item, "r");
char notgoodatnamingvariables[PATH_MAX];
char * path = bvr_var_get(BVR_INCLUDE_PATH_VAR_NAME);
if(strcmp(path, BVR_UNDEFINED) == 0 && stream == NULL) {
fprintf(output, "\nbVerbose include error. File %s not found. Path is undefined.\n", item);
fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File %s not found. Path is undefined.\n", item);
return FAILURE;
if(stream == NULL) {
strcpy(notgoodatnamingvariables, item);
strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
stream = fopen(notgoodatnamingvariables, "r");
if(strcmp(path, BVR_UNDEFINED) == 0 && stream == NULL) {
fprintf(output, "\nbVerbose include error. File %s not found. Path is undefined.\n", item);
fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File %s not found. Path is undefined.\n", item);
return FAILURE;
}
}
char * singlepath;
while(stream == NULL) {
singlepath = strrchr(path, BVR_PATH_SEPARATOR);
strcpy(notgoodatnamingvariables, singlepath);
strcat(notgoodatnamingvariables, item);
stream = fopen(notgoodatnamingvariables, "r");
if(strrchr(path, BVR_PATH_SEPARATOR) == NULL) {
stream = fopen(notgoodatnamingvariables, "r");
if(singlepath == NULL) {
stream = fopen(path, "r"); // ob1 fuckery
if(stream == NULL) {
fprintf(output, "\nbVerbose include error. File %s not found.\n", item);
fprintf(stderr, "[bvrcommands.c] bvr_handle_include: File %s not found.\n", item);
return FAILURE;
}
break;
}
strcpy(notgoodatnamingvariables, singlepath);
strcat(notgoodatnamingvariables, item);
stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery
if(stream == NULL) {
strcat(notgoodatnamingvariables, BVR_COMMAND_FILE_EXT);
stream = fopen(notgoodatnamingvariables+1, "r"); // ob1 fuckery
}
*singlepath = '\0';
}

22
test/tape-test.bvr

@ -1,11 +1,15 @@
<@?i test/tape-test-to-include.bvr @>
<@?g included_variable @>
<@?s abc 1232@>
<@?g abc@>
<@?m abc bbc@>
<@?g abc@>
<@?g bbc@>
hello?
<@?i assets/content/global.bvr @>
<@?i krneki@>
# <@?g post_slug @>
# <@?g bvr_include_path @>
# <@?i tape-test-to-includes @>
# <@?g included_variable @>
# <@?s abc 1232@>
# <@?g abc@>
# <@?m abc bbc@>
# <@?g abc@>
# <@?g bbc@>
# hello?
# <@?g abc@>
# <@?s abc 123@>
# <@?g abc@>
@ -23,4 +27,4 @@ hello?
# <@?5 image@>
# <@?6 image@>
# <@?7 image@>
in tako so srečno živeli do konca svojih dni!
# in tako so srečno živeli do konca svojih dni!

39
tmp/output.htm

@ -1,20 +1,23 @@
including worked!
included file:
|
| included variable set and read from included file
|
|
|
|
|
included variable set and read
1232
BVR_UNDEFINED
1232
hello?
in tako so srečno živeli do konca svojih dni!
krneki123

Loading…
Cancel
Save

Med zimskimi počitnicami so pričakovani občasni izpadi podomrežja O, ker bodo izvajana testiranja varnosti komunikacijsko-informacijske opreme.