diff --git a/hmml_to_html/hmml_to_html.c b/hmml_to_html/hmml_to_html.c
index 4015c16..d520cfe 100644
--- a/hmml_to_html/hmml_to_html.c
+++ b/hmml_to_html/hmml_to_html.c
@@ -118,7 +118,7 @@ TimecodeToSeconds(char *Timecode)
while(*Timecode)
{
//if((*Timecode < '0' || *Timecode > '9') && *Timecode != ':') { return FALSE; }
-
+
if(*Timecode == ':')
{
++Colons;
@@ -133,12 +133,12 @@ TimecodeToSeconds(char *Timecode)
{
HMS[0] = HMS[0] * 10 + *Timecode - '0';
}
-
+
++Timecode;
}
-
+
//if(HMS[0] > 59 || HMS[1] > 59 || Timecode[-1] == ':') { return FALSE; }
-
+
return HMS[2] * 60 * 60 + HMS[1] * 60 + HMS[0];
}
@@ -154,7 +154,6 @@ CopyBuffer(buffer *Dest, buffer *Src)
{
fprintf(stderr, "CopyBuffer: %s cannot accommodate %s\n", Dest->ID, Src->ID);
__asm__("int3");
-
}
}
*Dest->Ptr++ = *Src->Ptr++;
@@ -338,7 +337,6 @@ hsl_colour
CharToColour(char Char)
{
hsl_colour Colour;
-
if(Char >= 'a' && Char <= 'z')
{
Colour.Hue = (((float)Char - 'a') / ('z' - 'a') * 360);
@@ -359,7 +357,7 @@ CharToColour(char Char)
Colour.Hue = 180;
Colour.Saturation = 50;
}
-
+
return Colour;
}
@@ -369,14 +367,14 @@ StringToColourHash(hsl_colour *Colour, char *String)
Colour->Hue = 0;
Colour->Saturation = 0;
Colour->Lightness = 26;
-
+
int i;
for(i = 0; String[i]; ++i)
{
Colour->Hue += CharToColour(String[i]).Hue;
Colour->Saturation += CharToColour(String[i]).Saturation;
}
-
+
Colour->Hue = Colour->Hue % 360;
Colour->Saturation = Colour->Saturation % 26 + 74;
return(Colour);
@@ -409,7 +407,7 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
// TODO(matt): Handle co-hosts and guests
bool FoundHost = FALSE;
bool FoundAnnotator = FALSE;
-
+
for(int CredentialIndex = 0; CredentialIndex < ArrayCount(Credentials); ++CredentialIndex)
{
if(!StringsDiffer(Host, Credentials[CredentialIndex][0]))
@@ -436,7 +434,7 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
" \n",
Credentials[CredentialIndex][1]);
}
-
+
if(*Credentials[CredentialIndex][4] && *Credentials[CredentialIndex][3])
{
CopyStringToBuffer(HostInfo,
@@ -445,11 +443,11 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
ImagesDir,
Credentials[CredentialIndex][3]);
}
-
+
CopyStringToBuffer(HostInfo,
" \n");
}
-
+
if(!StringsDiffer(Annotator, Credentials[CredentialIndex][0]))
{
FoundAnnotator = TRUE; // TODO(matt): Check if this is actually necessary...
@@ -474,7 +472,7 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
" \n",
Credentials[CredentialIndex][1]);
}
-
+
if(*Credentials[CredentialIndex][4] && *Credentials[CredentialIndex][3])
{
CopyStringToBuffer(AnnotatorInfo,
@@ -483,12 +481,12 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
ImagesDir,
Credentials[CredentialIndex][3]);
}
-
+
CopyStringToBuffer(AnnotatorInfo,
" \n");
}
}
-
+
if(FoundHost || FoundAnnotator)
{
CopyStringToBuffer(CreditsMenu,
@@ -496,7 +494,7 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
"
\n"
" Credits\n"
" \n");
-
+
if(FoundHost)
{
CopyBuffer(CreditsMenu, HostInfo);
@@ -513,7 +511,7 @@ BuildCredits(buffer *CreditsMenu, buffer *HostInfo, buffer *AnnotatorInfo, bool
{
return 1;
}
-
+
*HasCreditsMenu = TRUE;
return 0;
}
@@ -587,7 +585,7 @@ BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMM
{
return 1;
}
-
+
CopyString(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode, Anno.time);
ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Identifier = RefIdentifier;
return 0;
@@ -611,7 +609,7 @@ void
BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaArray, int *UniqueMedia, char *Marker)
{
bool IsMedium = FALSE;
-
+
int i = 0;
for(i = 0; i < ArrayCount(CategoryMedium); ++i)
{
@@ -621,7 +619,7 @@ BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaA
break;
}
}
-
+
int Offset;
if(IsMedium)
{
@@ -640,19 +638,19 @@ BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaA
CopyString(MediaArray[k].Marker, MediaArray[k-1].Marker);
CopyString(MediaArray[k].WrittenText, MediaArray[k-1].WrittenText);
}
-
+
CopyString(MediaArray[k].Marker, CategoryMedium[i][0]);
CopyString(MediaArray[k].WrittenText, CategoryMedium[i][2]);
break;
}
}
-
+
if(j == *UniqueMedia)
{
CopyString(MediaArray[j].Marker, CategoryMedium[i][0]);
CopyString(MediaArray[j].WrittenText, CategoryMedium[i][2]);
}
-
+
++*UniqueMedia;
return;
}
@@ -672,17 +670,17 @@ BuildFilter(category_info *TopicsArray, int *UniqueTopics, category_info *MediaA
{
CopyString(TopicsArray[j].Marker, TopicsArray[j-1].Marker);
}
-
+
CopyString(TopicsArray[j].Marker, Marker);
break;
}
}
-
+
if(i == *UniqueTopics)
{
CopyString(TopicsArray[i].Marker, Marker);
}
-
+
++*UniqueTopics;
return;
}
@@ -710,7 +708,7 @@ BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, boo
CopyStringToBuffer(Category, "
");
*HasCategory = TRUE;
}
-
+
// NOTE(matt): Iterate through the Category->Location looking for "Marker", and bail if we find it
char *Ptr = Category->Location;
bool Found = FALSE;
@@ -734,17 +732,17 @@ BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, boo
}
++Ptr;
}
-
+
if(Found == FALSE)
{
CopyStringToBuffer(Category, "",
SanitisePunctuation(Marker),
SanitisePunctuation(Marker));
-
+
CopyStringToBuffer(AnnotationClass, " cat_%s",
SanitisePunctuation(Marker));
}
-
+
++*MarkerIndex;
return;
}
@@ -772,7 +770,7 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, char *QuoteDir)
perror(Path);
return 1;
}
-
+
fseek(File, 0, SEEK_END);
int Length = ftell(File);
fseek(File, 0, SEEK_SET);
@@ -783,10 +781,10 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, char *QuoteDir)
}
fread(Buffer, Length, 1, File);
fclose(File);
-
+
// TODO(matt): Search the quote store in reverse
char *InPtr = Buffer;
-
+
while(InPtr - Buffer < Length)
{
char InID[4] = { 0 };
@@ -796,7 +794,7 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, char *QuoteDir)
*OutPtr++ = *InPtr++;
}
*OutPtr = '\0';
-
+
if(StringToInt(InID) == ID)
{
InPtr += 2;
@@ -806,7 +804,7 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, char *QuoteDir)
*OutPtr++ = *InPtr++;
}
*OutPtr = '\0';
-
+
InPtr += 3;
OutPtr = Info->Text;
while(*InPtr != '\n')
@@ -818,7 +816,7 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, char *QuoteDir)
*OutPtr++ = *InPtr++;
}
*--OutPtr = '\0';
-
+
free(Buffer);
return 0;
}
@@ -831,7 +829,7 @@ BuildQuote(quote_info *Info, char *Speaker, int ID, char *QuoteDir)
++InPtr;
}
}
-
+
free(Buffer);
return 1;
}
@@ -846,7 +844,7 @@ GenerateTopicColours(buffer *Colour, char *Topic, char *TopicsDir)
return;
}
}
-
+
FILE *TopicsFile;
char *TopicsBuffer;
// TODO(matt): Consider (optionally) pulling this path from the config
@@ -857,18 +855,18 @@ GenerateTopicColours(buffer *Colour, char *Topic, char *TopicsDir)
fseek(TopicsFile, 0, SEEK_END);
int TopicsLength = ftell(TopicsFile);
fseek(TopicsFile, 0, SEEK_SET);
-
+
// TODO(matt): May this not just ClaimBuffer (if I can figure out how)?
if(!(TopicsBuffer = malloc(TopicsLength)))
{
perror("GenerateTopicColours");
return;
}
-
+
fread(TopicsBuffer, TopicsLength, 1, TopicsFile);
-
+
char *TopicsPtr = TopicsBuffer;
-
+
while(TopicsPtr - TopicsBuffer < TopicsLength)
{
TopicsPtr += StringLength(".category.");
@@ -884,12 +882,12 @@ GenerateTopicColours(buffer *Colour, char *Topic, char *TopicsDir)
}
++TopicsPtr;
}
-
+
hsl_colour Colour;
StringToColourHash(&Colour, Topic);
fprintf(TopicsFile, ".category.%s { border: 1px solid hsl(%d, %d%%, %d%%); background: hsl(%d, %d%%, %d%%); }\n",
SanitisePunctuation(Topic), Colour.Hue, Colour.Saturation, Colour.Lightness, Colour.Hue, Colour.Saturation, Colour.Lightness);
-
+
fclose(TopicsFile);
free(TopicsBuffer);
}
@@ -925,7 +923,7 @@ ParseConfig(buffer *Buffer, char *Username)
Essentially, I want to pass a Username to this, and have it write the credentials into the Config buffer
Let's start by just grabbing the stuff and printing it out
*/
-
+
// TODO(matt): Actually figure out the "standard" config location
char Config_Location[255];
if(getenv("XDG_CONFIG_HOME"))
@@ -941,32 +939,32 @@ ParseConfig(buffer *Buffer, char *Username)
fprintf(stderr, "Config file location not set");
return 1;
}
-
+
FILE *InFile;
if(!(InFile = fopen(Config_Location, "r")))
{
perror(Config_Location);
return 2;
}
-
+
printf("Reading: %s\n", Config_Location);
-
+
fseek(InFile, 0, SEEK_END);
int InSize = ftell(InFile);
fseek(InFile, 0, SEEK_SET);
-
+
char *InBuffer;
//config Config = { 0 };
-
+
if(!(InBuffer = malloc(InSize)))
{
perror("ParseConfig");
return 3;
}
-
+
fread(InBuffer, InSize, 1, InFile);
fclose(InFile);
-
+
char *InPtr = InBuffer;
char OutBuffer[256];
//char *OutPtr = Config.Credentials.Display_Name;
@@ -974,7 +972,7 @@ ParseConfig(buffer *Buffer, char *Username)
bool Quoted = FALSE;
bool FoundCredentials, ParsingUsername = FALSE;
unsigned int ScopeDepth = 0;
-
+
while(InPtr - InBuffer < InSize)
{
switch(*InPtr)
@@ -1041,7 +1039,7 @@ ParseConfig(buffer *Buffer, char *Username)
*OutPtr = '\0';
OutPtr = OutBuffer;
printf("%s\n", OutBuffer);
-
+
// TODO(matt): Switch on the OutBuffer? I have a feeling that isn't actually possible, though
if(!StringsDiffer("credentials", OutBuffer))
{
@@ -1129,7 +1127,7 @@ ParseConfig(buffer *Buffer, char *Username)
{
*OutPtr++ = *InPtr++;
}
-
+
if(InPtr - InBuffer == InSize)
{
printf(" We have reached the EOF\n");
@@ -1143,8 +1141,8 @@ ParseConfig(buffer *Buffer, char *Username)
}
}
}
-
-
+
+
#if 0
while(InPtr - InBuffer < InSize)
{
@@ -1156,11 +1154,11 @@ ParseConfig(buffer *Buffer, char *Username)
printf("%s\n", Config.Credentials.Display_Name);
}
#endif
-
+
free(InBuffer);
-
+
// Reading from the config file, parsing it inline (on the stack) and writing into the buffer *Config
-
+
return 0;
}
@@ -1223,10 +1221,10 @@ main(int ArgC, char **Args)
char *QuoteDir = DefaultQuoteDir;
char *CINERA_MODE = getenv("CINERA_MODE");
-
+
if(ArgC < 2)
{
- PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultQuoteDir, DefaultTemplateLocation, DefaultOutLocation);
+ PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation);
return 1;
}
@@ -1258,7 +1256,7 @@ main(int ArgC, char **Args)
// Override config path, once we even have a default!
case 'h':
default:
- PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultQuoteDir, DefaultTemplateLocation, DefaultOutLocation);
+ PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation);
return 1;
}
}
@@ -1266,7 +1264,7 @@ main(int ArgC, char **Args)
if(optind == ArgC)
{
fprintf(stderr, "%s: requires at least one input .hmml file\n", Args[0]);
- PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultQuoteDir, DefaultTemplateLocation, DefaultOutLocation);
+ PrintUsage(Args[0], DefaultCSSDir, DefaultImagesDir, DefaultJSDir, DefaultQuoteDir, DefaultOutLocation, DefaultTemplateLocation);
return 1;
}
@@ -1296,14 +1294,14 @@ main(int ArgC, char **Args)
return 1;
}
int ClaimedMemory = 0;
-
+
// NOTE(matt): Setup buffers and ptrs
char *InPtr;
-
+
#if CONFIG
buffer Config;
#endif
-
+
// NOTE(matt): Tree structure of buffer dependencies
// Master
// Includes
@@ -1323,10 +1321,10 @@ main(int ArgC, char **Args)
// Category
// Script
// FilterState
-
+
buffer Master;
buffer Includes;
-
+
buffer Menus;
buffer QuoteMenu;
buffer ReferenceMenu;
@@ -1336,7 +1334,7 @@ main(int ArgC, char **Args)
buffer CreditsMenu;
buffer HostInfo;
buffer AnnotatorInfo;
-
+
buffer Player;
buffer Colour;
buffer Annotation;
@@ -1345,10 +1343,10 @@ main(int ArgC, char **Args)
buffer AnnotationData;
buffer Text;
buffer Category;
-
+
buffer Script;
buffer FilterState;
-
+
for(int FileIndex = optind; FileIndex < ArgC; ++FileIndex)
{
FILE *InFile;
@@ -1358,14 +1356,14 @@ main(int ArgC, char **Args)
free(MemoryArena);
return 1;
}
-
+
#if CONFIG
ClaimBuffer(MemoryArena, &ClaimedMemory, &Config, "Config", Kilobytes(1));
#endif
-
+
HMML_Output HMML = hmml_parse_file(InFile);
fclose(InFile);
-
+
if(HMML.well_formed)
{
#if DEBUG
@@ -1390,10 +1388,10 @@ main(int ArgC, char **Args)
// Annotation
// Script
// FilterState
-
+
ClaimBuffer(MemoryArena, &ClaimedMemory, &Master, "Master", Kilobytes(512));
ClaimBuffer(MemoryArena, &ClaimedMemory, &Includes, "Includes", Kilobytes(1));
-
+
ClaimBuffer(MemoryArena, &ClaimedMemory, &Menus, "Menus", Kilobytes(24));
ClaimBuffer(MemoryArena, &ClaimedMemory, &QuoteMenu, "QuoteMenu", Kilobytes(16));
ClaimBuffer(MemoryArena, &ClaimedMemory, &ReferenceMenu, "ReferenceMenu", Kilobytes(16));
@@ -1403,41 +1401,41 @@ main(int ArgC, char **Args)
ClaimBuffer(MemoryArena, &ClaimedMemory, &CreditsMenu, "CreditsMenu", Kilobytes(8));
ClaimBuffer(MemoryArena, &ClaimedMemory, &HostInfo, "HostInfo", Kilobytes(1));
ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotatorInfo, "AnnotatorInfo", Kilobytes(1));
-
+
ClaimBuffer(MemoryArena, &ClaimedMemory, &Player, "Player", Kilobytes(256));
ClaimBuffer(MemoryArena, &ClaimedMemory, &Colour, "Colour", 32);
ClaimBuffer(MemoryArena, &ClaimedMemory, &Annotation, "Annotation", Kilobytes(8));
-
+
ClaimBuffer(MemoryArena, &ClaimedMemory, &Script, "Script", Kilobytes(8));
ClaimBuffer(MemoryArena, &ClaimedMemory, &FilterState, "FilterState", Kilobytes(4));
-
+
ref_info ReferencesArray[200] = { 0 };
category_info TopicsArray[56] = { 0 };
category_info MediaArray[8] = { 0 };
-
+
bool HasQuoteMenu = FALSE;
bool HasReferenceMenu = FALSE;
bool HasFilterMenu = FALSE;
bool HasCreditsMenu = FALSE;
-
+
int QuoteIdentifier = 0x3b1;
int RefIdentifier = 1;
int UniqueRefs = 0;
int UniqueTopics = 0;
int UniqueMedia = 0;
-
+
CopyStringToBuffer(&Menus,
" \n"
"
", HMML.metadata.project);
CopyStringToBufferHTMLSafe(&Menus, HMML.metadata.title);
CopyStringToBuffer(&Menus, "\n"
"
⚠ Click here to regain focus ⚠\n");
-
+
CopyStringToBuffer(&Player,
"
\n"
"
\n"
"
\n", HMML.metadata.id, HMML.metadata.project);
-
+
// TODO(matt): Handle multiple annotators
if(HMML.metadata.annotator_count > 0)
{
@@ -1450,11 +1448,11 @@ main(int ArgC, char **Args)
free(MemoryArena);
return 1;
}
-
+
#if DEBUG
printf(" --- Entering Annotations Loop ---\n");
#endif
-
+
for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex)
{
#if DEBUG
@@ -1465,29 +1463,29 @@ main(int ArgC, char **Args)
bool HasMedium = FALSE;
bool HasQuote = FALSE;
bool HasReference = FALSE;
-
+
quote_info QuoteInfo = { 0 };
-
+
// NOTE(matt): Tree structure of "annotation local" buffer dependencies
// AnnotationHeader
// AnnotationClass
// AnnotationData
// Text
// Category
-
+
ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationHeader, "AnnotationHeader", 512);
ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationClass, "AnnotationClass", 256);
ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationData, "AnnotationData", 256);
ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, "Text", Kilobytes(4));
ClaimBuffer(MemoryArena, &ClaimedMemory, &Category, "Category", 512);
-
+
CopyStringToBuffer(&AnnotationHeader,
"
time));
-
+
CopyStringToBuffer(&AnnotationClass,
" class=\"marker");
-
+
if(Anno->author)
{
if(!HasFilterMenu)
@@ -1517,15 +1515,15 @@ main(int ArgC, char **Args)
AuthorColour.Hue, AuthorColour.Saturation,
Anno->author);
}
-
+
if(!HasMedium)
{
HasMedium = TRUE;
}
}
-
+
InPtr = Anno->text;
-
+
int MarkerIndex = 0, RefIndex = 0;
while(*InPtr || RefIndex < Anno->reference_count)
{
@@ -1558,7 +1556,7 @@ main(int ArgC, char **Args)
MemberColour.Hue, MemberColour.Saturation,
StringLength(Readable), InPtr);
}
-
+
InPtr += StringLength(Readable);
++MarkerIndex;
}
@@ -1600,7 +1598,7 @@ main(int ArgC, char **Args)
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, &HasMedium, Anno->markers[MarkerIndex].marker);
}
}
-
+
if(RefIndex < Anno->reference_count &&
InPtr - Anno->text == Anno->references[RefIndex].offset)
{
@@ -1612,7 +1610,7 @@ main(int ArgC, char **Args)
"
References ▼\n"
"
\n"
"
\n");
-
+
if(BuildReference(ReferencesArray, RefIdentifier, UniqueRefs, *CurrentRef, *Anno) == 1)
{
fprintf(stderr, "%s:%d: Cannot process new combination of reference info\n", Args[FileIndex], Anno->line);
@@ -1622,7 +1620,7 @@ main(int ArgC, char **Args)
}
++ReferencesArray[RefIdentifier - 1].IdentifierCount;
++UniqueRefs;
-
+
HasReferenceMenu = TRUE;
}
else
@@ -1657,7 +1655,7 @@ main(int ArgC, char **Args)
return 1;
}
}
-
+
if(BuildReference(ReferencesArray, RefIdentifier, UniqueRefs, *CurrentRef, *Anno) == 1)
{
fprintf(stderr, "%s:%d: Cannot process new combination of reference info\n", Args[FileIndex], Anno->line);
@@ -1686,7 +1684,7 @@ main(int ArgC, char **Args)
free(MemoryArena);
return 1;
}
-
+
HasReference = TRUE;
}
else
@@ -1707,7 +1705,7 @@ main(int ArgC, char **Args)
return 1;
}
}
-
+
if(RefIndex > 1 && Anno->references[RefIndex].offset == Anno->references[RefIndex-1].offset)
{
CopyStringToBuffer(&Text, "
,%d", RefIdentifier);
@@ -1716,11 +1714,11 @@ main(int ArgC, char **Args)
{
CopyStringToBuffer(&Text, "
%d", RefIdentifier);
}
-
+
++RefIndex;
++RefIdentifier;
}
-
+
if(*InPtr)
{
switch(*InPtr)
@@ -1751,7 +1749,7 @@ main(int ArgC, char **Args)
}
}
}
-
+
if(Anno->is_quote)
{
if(!HasQuoteMenu)
@@ -1761,10 +1759,10 @@ main(int ArgC, char **Args)
"
Quotes ▼\n"
"
\n"
"
\n");
-
+
HasQuoteMenu = TRUE;
}
-
+
if(!HasReference)
{
CopyStringToBuffer(&AnnotationData, " data-ref=\"%d;", QuoteIdentifier);
@@ -1773,10 +1771,10 @@ main(int ArgC, char **Args)
{
CopyStringToBuffer(&AnnotationData, ",%d;", QuoteIdentifier);
}
-
+
HasQuote = TRUE;
-
-
+
+
if(BuildQuote(&QuoteInfo, HMML.metadata.stream_username ? HMML.metadata.stream_username : HMML.metadata.member, Anno->quote.id, QuoteDir) == 1)
{
fprintf(stderr, "%s:%d: Quote #%s %d not found! Consider pulling the latest quotes\n",
@@ -1788,7 +1786,7 @@ main(int ArgC, char **Args)
free(MemoryArena);
return 1;
}
-
+
CopyStringToBuffer(&QuoteMenu,
"
\n"
" \n"
@@ -1796,9 +1794,9 @@ main(int ArgC, char **Args)
" ",
QuoteIdentifier,
Anno->quote.id);
-
+
CopyStringToBufferCSVSafe(&QuoteMenu, QuoteInfo.Text);
-
+
CopyStringToBuffer(&QuoteMenu, "
\n"
" —%s, %s
\n"
" \n"
@@ -1820,7 +1818,7 @@ main(int ArgC, char **Args)
CopyStringToBuffer(&Text, "%d;", QuoteIdentifier);
++QuoteIdentifier;
}
-
+
while(MarkerIndex < Anno->marker_count)
{
GenerateTopicColours(&Colour, Anno->markers[MarkerIndex].marker, CSSDir);
@@ -1835,29 +1833,29 @@ main(int ArgC, char **Args)
}
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, &HasMedium, Anno->markers[MarkerIndex].marker);
}
-
+
if(!HasMedium)
{
BuildFilter(TopicsArray, &UniqueTopics, MediaArray, &UniqueMedia, "default");
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, &HasMedium, "default");
}
-
+
CopyStringToBuffer(&AnnotationClass, "\"");
CopyBuffer(&AnnotationHeader, &AnnotationClass);
-
+
if(HasQuote || HasReference)
{
CopyStringToBuffer(&AnnotationData, "\"");
CopyBuffer(&AnnotationHeader, &AnnotationData);
}
CopyStringToBuffer(&AnnotationHeader, ">\n");
-
+
CopyBuffer(&Annotation, &AnnotationHeader);
CopyStringToBuffer(&Annotation,
" %s",
Anno->time);
-
-
+
+
if(HasCategory)
{
CopyStringToBuffer(&Category, "");
@@ -1865,37 +1863,37 @@ main(int ArgC, char **Args)
}
// NOTE(matt): This feels a bit janky...
*Text.Ptr = '\0';
-
+
CopyBuffer(&Annotation, &Text);
-
+
CopyStringToBuffer(&Annotation, "
\n"
" \n"
"
%s",
Anno->time);
-
+
CopyBuffer(&Annotation, &Text);
-
+
CopyStringToBuffer(&Annotation, "
\n"
"
\n"
" \n"
"
%s",
Anno->time);
-
+
CopyBuffer(&Annotation, &Text);
-
+
CopyStringToBuffer(&Annotation, "
\n"
"
\n"
" \n");
-
+
CopyBuffer(&Player, &Annotation);
-
+
// NOTE(matt): Tree structure of "annotation local" buffer dependencies
// Category
// Text
// AnnotationData
// AnnotationClass
// AnnotationHeader
-
+
DeclaimBuffer(&Category, &ClaimedMemory);
DeclaimBuffer(&Text, &ClaimedMemory);
DeclaimBuffer(&AnnotationData, &ClaimedMemory);
@@ -1903,7 +1901,7 @@ main(int ArgC, char **Args)
DeclaimBuffer(&AnnotationHeader, &ClaimedMemory);
Annotation.Ptr = Annotation.Location;
}
-
+
#if DEBUG
printf(" --- End of Annotations Loop ---\n\n");
#endif
@@ -1914,7 +1912,7 @@ main(int ArgC, char **Args)
"
\n");
CopyBuffer(&Menus, &QuoteMenu);
}
-
+
if(HasReferenceMenu)
{
for(int i = 0; i < UniqueRefs; ++i)
@@ -1924,7 +1922,7 @@ main(int ArgC, char **Args)
"
\n",
ReferencesArray[i].ID,
ReferencesArray[i].URL);
-
+
if(*ReferencesArray[i].Source)
{
CopyStringToBuffer(&ReferenceMenu,
@@ -1944,7 +1942,7 @@ main(int ArgC, char **Args)
}
CopyStringToBuffer(&ReferenceMenu,
" \n");
-
+
for(int j = 0; j < ReferencesArray[i].IdentifierCount;)
{
CopyStringToBuffer(&ReferenceMenu,
@@ -1960,17 +1958,17 @@ main(int ArgC, char **Args)
CopyStringToBuffer(&ReferenceMenu, "\n"
"
\n");
}
-
+
CopyStringToBuffer(&ReferenceMenu,
" \n");
}
-
+
CopyStringToBuffer(&ReferenceMenu,
"
\n"
"
\n");
CopyBuffer(&Menus, &ReferenceMenu);
}
-
+
if(HasFilterMenu)
{
CopyStringToBuffer(&FilterState,
@@ -1987,18 +1985,18 @@ main(int ArgC, char **Args)
}
CopyStringToBuffer(&FilterState,
" };\n");
-
+
CopyStringToBuffer(&FilterMenu,
" \n"
"
\n"
-
+
" ");
-
+
CopyStringToBuffer(&Player,
" \n"
" ");
-
+
// TODO(matt): Maybe do something about indentation levels
CopyStringToBuffer(&Includes,
"\n"
@@ -2318,14 +2316,14 @@ main(int ArgC, char **Args)
CSSDir,
HMML.metadata.project,
CSSDir);
-
+
CopyStringToBuffer(&Script,
" ");
-
+
#if DEBUG
printf("Buffer Collation\n\n");
#endif
-
+
if(CINERA_MODE && !StringsDiffer(CINERA_MODE, "INTEGRATE"))
{
FILE *TemplateFile;
@@ -2519,7 +2517,7 @@ main(int ArgC, char **Args)
{
perror(Args[0]); hmml_free(&HMML); free(MemoryArena); return 1;
}
-
+
fseek(TemplateFile, 0, SEEK_END);
buffer Template;
Template.ID = "Template";
@@ -2532,7 +2530,7 @@ main(int ArgC, char **Args)
Template.Ptr = Template.Location;
fread(Template.Location, Template.Size, 1, TemplateFile);
fclose(TemplateFile);
-
+
buffer Output;
Output.Size = Template.Size + Master.Size;
Output.ID = "Output";
@@ -2541,18 +2539,18 @@ main(int ArgC, char **Args)
perror(Args[0]); free(Template.Location); hmml_free(&HMML); free(MemoryArena); return 1;
}
Output.Ptr = Output.Location;
-
+
char *IncludesTag = "__CINERA_INCLUDES__";
char *TitleTag = "__CINERA_TITLE__";
char *MenusTag = "__CINERA_MENUS__";
char *PlayerTag = "__CINERA_PLAYER__";
char *ScriptTag = "__CINERA_SCRIPT__";
-
+
bool FoundIncludes = FALSE;
bool FoundMenus = FALSE;
bool FoundPlayer = FALSE;
bool FoundScript = FALSE;
-
+
while(Template.Ptr - Template.Location < Template.Size)
{
if(*Template.Ptr == '!' && (Template.Ptr > Template.Location && !StringsDifferT("\n"); }
free(Template.Location); free(Output.Location); hmml_free(&HMML); free(MemoryArena); return 1;
}
-
+
free(Template.Location);
free(Output.Location);
}
@@ -2707,7 +2705,7 @@ main(int ArgC, char **Args)
CopyStringToBuffer(&Master,
"\n"
" \n");
-
+
//NOTE(matt): Here is where we do all our CopyBuffer() calls
CopyBuffer(&Master, &Includes);
CopyStringToBuffer(&Master,
@@ -2721,11 +2719,11 @@ main(int ArgC, char **Args)
CopyBuffer(&Master, &Script);
CopyStringToBuffer(&Master, "\n");
//
-
+
CopyStringToBuffer(&Master,
" \n"
"\n");
-
+
FILE *OutFile;
if(!(OutFile = fopen(OutLocation, "w")))
{
@@ -2734,7 +2732,7 @@ main(int ArgC, char **Args)
fwrite(Master.Location, Master.Ptr - Master.Location, 1, OutFile);
fclose(OutFile);
}
-
+
// NOTE(matt): Tree structure of "global" buffer dependencies
// FilterState
// Script
@@ -2752,13 +2750,13 @@ main(int ArgC, char **Args)
// Menus
// Includes
// Master
-
+
DeclaimBuffer(&FilterState, &ClaimedMemory);
DeclaimBuffer(&Script, &ClaimedMemory);
DeclaimBuffer(&Annotation, &ClaimedMemory);
DeclaimBuffer(&Colour, &ClaimedMemory);
DeclaimBuffer(&Player, &ClaimedMemory);
-
+
DeclaimBuffer(&AnnotatorInfo, &ClaimedMemory);
DeclaimBuffer(&HostInfo, &ClaimedMemory);
DeclaimBuffer(&CreditsMenu, &ClaimedMemory);
@@ -2768,7 +2766,7 @@ main(int ArgC, char **Args)
DeclaimBuffer(&ReferenceMenu, &ClaimedMemory);
DeclaimBuffer(&QuoteMenu, &ClaimedMemory);
DeclaimBuffer(&Menus, &ClaimedMemory);
-
+
DeclaimBuffer(&Includes, &ClaimedMemory);
DeclaimBuffer(&Master, &ClaimedMemory);
}